93 $(this).addClass('nu_' + this.value)
94 })
95
96 for (var i = 0; i < 7; i++) { 97 $('#nuTab' + i).removeClass('nuRelatedTab')
98 }
99
242 $(this).addClass('nu_' + this.value)
243 })
244
245 for (var i = 0; i < 7; i++) {246 $('#nuTab' + i).removeClass('nuRelatedTab')
247 }
248
363 nuSetBrowseColumnSize(0, 0)
364 } // Hide Preview
365
366 var _nuSelectBrowse = window.nuSelectBrowse367 const nuSelectBrowse = function (e, t) {
368 nuSelectBrowseNew(e, t)
369 }
114 nuSetFK()
115}
116
117var tableExists = false118
119function nuSetFFTable () {
120 tableExists = nuFORM.getTables().indexOf(nuGetValue('fastform_table')) !== -1
461
462 calc (field) {
463 if (field.split('.').length == 2) {
464 var subform_name = field.split('.')[0]465 var field_name = field.split('.')[1]
466 } else {
467 const o = $('#' + field)
462 calc (field) {
463 if (field.split('.').length == 2) {
464 var subform_name = field.split('.')[0]
465 var field_name = field.split('.')[1]466 } else {
467 const o = $('#' + field)
468 var f = o.attr('data-nu-format')
465 var field_name = field.split('.')[1]
466 } else {
467 const o = $('#' + field)
468 var f = o.attr('data-nu-format')469 var v = o.val()
470
471 return nuFORM.removeFormatting(v, f)
466 } else {
467 const o = $('#' + field)
468 var f = o.attr('data-nu-format')
469 var v = o.val()470
471 return nuFORM.removeFormatting(v, f)
472 }
472 }
473
474 const d = this.data() // -- an array of all data as subforms (the mainform is the first element)
475 var v = 0476 let u = 0
477
478 for (let i = 0; i < d.length; i++) {
479 const SF = d[i]
480 if (SF.id == subform_name) { // -- i've got the right subform
481 // var fmt = $("[id$='" + field_name + "']input[id^='" + subform_name + "']").attr('data-nu-format')
482 var f = SF.fields.indexOf(field_name) // -- check for valid field(column)483 if (f == -1) { return 0 }
484 for (let c = 0; c < SF.rows.length; c++) {
485 if (SF.deleted[c] == 0) { // -- add up only stuff not being deleted
573 pk = $('#nuRECORD').attr('data-nu-primary-key-name')
574 table = $('#nuRECORD').attr('data-nu-table')
575 sel = '#nuRECORD'
576 var sf = 'nuRECORD'577
578 if (table === undefined) {
579 oi = parent.nuFORM === undefined ? undefined : parent.nuFORM.getCurrent().form_id
652 o.columns.push(c)
653 }
654
655 for (var i = 0; i < o.rows.length; i++) {656 var row = JSON.parse(JSON.stringify(o.rows[i]))
657
658 row.shift()
653 }
654
655 for (var i = 0; i < o.rows.length; i++) {
656 var row = JSON.parse(JSON.stringify(o.rows[i]))657
658 row.shift()
659 row.pop()
672 titles.shift()
673 o.chartData.splice(0, 0, titles)
674
675 for (var i = 0; i < o.chartData[0].length; i++) {676 row = []
677
678 for (let p = 0; p < o.chartData.length; p++) {
683 }
684
685 if (nd == 0) { // -- no deleting allowed
686 for (var i = 0; i < o.rows.length; i++) {687 o.deleted[i] = 0
688 }
689
782 const FMT = this.setFormats()
783
784 if (v.includes('-')) {
785 var d = String(v.split(' ')[0]).split('-')786 var t = String(v.split(' ')[1]).split(':')
787 } else {
788 var d = [0, 0, 0]
783
784 if (v.includes('-')) {
785 var d = String(v.split(' ')[0]).split('-')
786 var t = String(v.split(' ')[1]).split(':')787 } else {
788 var d = [0, 0, 0]
789 var t = String(v.split(' ')[0]).split(':')
785 var d = String(v.split(' ')[0]).split('-')
786 var t = String(v.split(' ')[1]).split(':')
787 } else {
788 var d = [0, 0, 0]789 var t = String(v.split(' ')[0]).split(':')
790 }
791
786 var t = String(v.split(' ')[1]).split(':')
787 } else {
788 var d = [0, 0, 0]
789 var t = String(v.split(' ')[0]).split(':')790 }
791
792 if (t[0] == 'undefined') {
790 }
791
792 if (t[0] == 'undefined') {
793 var t = [0, 0, 0]794 }
795
796 const o = new Date(d[0], d[1] - 1, d[2], t[0], t[1], t[2], 0) // -- (year, month, day, hours, minutes, seconds, milliseconds)
880 .nuReplaceAll(',', ' ')
881 .split(' ')
882
883 var o = Date().toString().split(' ', 6) // -- Tue Sep 07 2004 11:11:12 GMT+0930 (Cen. Australia Standard Time)884 const time = String(o[4]).split(':')
885
886 const d = { y: o[3], m: FMT[nuTranslateToEnglish(o[1])].jsmonth, d: o[2], h: time[0], n: time[1], s: time[2] } // -- today's date time[2]}; //-- today's date
905 if (l == 's') { d.s = v[i] }
906 }
907
908 var o = new Date(d.y, Number(d.m) - 1, d.d, Number(d.h), Number(d.n), Number(d.s), 0)909 const y = String(o.getFullYear()) + '-'
910 const m = nuPad2(o.getMonth() + 1) + '-'
911 const a = nuPad2(o.getDate()) + ' '
149
150 const s = this.buildSelect(c, b)
151 const f = this.buildFrom()
152 var c = this.buildClauses()153
154 parent.$('#sse_sql')
155 .val(s + f + c + '\n')
179 const s = []
180
181 for (let i = 0; i < this.boxes.length; i++) {
182 var b = this.boxes[i]183
184 if ($('#' + b).length == 1) {
185 const t = $('#tablename' + b).html()
185 const t = $('#tablename' + b).html()
186 const a = $('#alias' + b).val()
187
188 var T = this.justAlias(t, a)189
190 if ($('#checkall' + b).is(':checked')) {
191 s.push(T + '.*')
It is recommended to use let
or const
over var
.
This will help prevent re-declaration of variables that are in the global scope when using var
.
ES6 allows programmers to create variables with block scope instead of function scope using the let
and const
keywords.
Block scope is common in many other programming languages and helps programmers avoid mistakes such as this one:
var count = people.length;
var enoughFood = count > sandwiches.length;
if (enoughFood) {
var count = sandwiches.length; // accidentally overriding the count variable
console.log("We have " + count + " sandwiches for everyone. Plenty for all!");
}
// our count variable is no longer accurate
console.log("We have " + count + " people and " + sandwiches.length + " sandwiches!");
Block scoped variables shadow outer declarations instead of writing to them.
NOTE: There are certain edge cases where users might want to consider var. Consider this example:
var lib = lib || { run: () => {} }
Here, lib
might be a library that is exposed to an HTML file using a <script>
tag.
The var
keyword helps avoid re-writing lib
if it has already been declared via an injected script that was executed before this one.
Ideally, you should let bundlers worry about cases like this.
But if you want to use var
anyway, consider using a skipcq comment, or disabling the issue altogether.
Bad Practice
var x = "y";
var CONFIG = {};
Recommended
let x = "y";
const CONFIG = {};