/* * Main scripts. */ (function (win, doc, undef) { "use strict"; win.sax = win.sax || {}; //-------------------------------------------------------------- // Utilities. sax.isDef = function (obj) { return obj === null || typeof obj == "undefined" ? false : true; } sax.isFn = function (fn) { return fn != null && typeof fn == typeof Function; } sax.isNumeric = function (n) { return !isNaN(parseFloat(n)) && isFinite(n); } sax.getTime = function () { return (new Date()).getTime(); } sax.zeroPad = function (num, count) { var val = num + ''; while (val.length < count) val = "0" + val; return val; } sax.toInt = function (value, defaultValue) { return sax.isNumeric(value) ? parseInt(value, 10) : defaultValue || 0; } if ("function" != typeof "".format) String.prototype.format = (function () { var rx1 = /\{(\d|\d\d)\}/g, rx2 = /\d+/; return function () { var args = arguments; return this.replace(rx1, function ($0) { var idx = 1 * $0.match(rx2)[0]; return args[idx] !== undefined ? args[idx] : (args[idx] === "" ? "" : $0); }); } }()); sax.getFileType = function (file) { if (!file) return ""; if (file.type) return file.type; if (file.filename) return filename.split('.').pop(); return ""; } sax.formatFileSize = function (size) { if (size / 10 ** 9 > 1) return Math.floor(size / 10 ** 9) + 'Gb'; if (size / 10 ** 6 > 1) return Math.floor(size / 10 ** 6) + 'Mb'; if (size / 10 ** 3 > 1) return Math.floor(size / 10 ** 3) + 'Kb'; return size + 'bytes'; } sax.escapeRegExp = function (val) { return (val || '').replace(/[[{}()*+?^$|\]\.\\]/g, "\\$&"); } sax.haltEvent = function (evt) { evt.preventDefault(); evt.stopPropagation(); } sax.debug = sax.debugMode ? win.console.log.bind(win.console) : function () { }; //-------------------------------------------------------------- sax.compareCI = function (a, b) { var comparison = a.toLowerCase().localeCompare(b.toLowerCase()); if (comparison === 0) return a.localeCompare(b); return comparison; } sax.arraySortCI = function () { if (!this) return this; this.sort(function (a, b) { return sax.compareCI(a, b); }); return this; }; //-------------------------------------------------------------- sax.setOddDataRowClass = function (rowSel, cName) { $(rowSel).addClass(function (index, currentClasses) { return index % 2 == 1 ? (cName || "other") : ""; }); } sax.populateSelectCodeDesc = function ($sel, values) { $sel = $($sel).empty(); for (const value of values) $sel.append($('