diff --git a/assets/js/bootstrap/bootstrap.autocomplete.js b/assets/js/bootstrap/bootstrap.autocomplete.js index 6c8114f..60fb6e4 100644 --- a/assets/js/bootstrap/bootstrap.autocomplete.js +++ b/assets/js/bootstrap/bootstrap.autocomplete.js @@ -1,40 +1,8 @@ -var __extends = (undefined && undefined.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - if (typeof b !== "function" && b !== null) - throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -var BaseResolver = (function () { - function BaseResolver(options) { +var AjaxResolver = class { + constructor(options) { this._settings = $.extend(true, {}, this.getDefaults(), options); } - BaseResolver.prototype.getDefaults = function () { - return {}; - }; - BaseResolver.prototype.getResults = function (limit, start, end) { - return this.results; - }; - BaseResolver.prototype.search = function (q, cbk) { - cbk(this.getResults()); - }; - return BaseResolver; -}()); - -var AjaxResolver = (function (_super) { - __extends(AjaxResolver, _super); - function AjaxResolver(options) { - return _super.call(this, options) || this; - } - AjaxResolver.prototype.getDefaults = function () { + getDefaults() { return { url: '', method: 'post', @@ -43,42 +11,42 @@ var AjaxResolver = (function (_super) { timeout: 0, requestThrottling: 500 }; - }; - AjaxResolver.prototype.search = function (q, cbk) { - var _this = this; - if (this.jqXHR != null) { - this.jqXHR.abort(); - } + } + search(q, cbk) { + if (this.jqXHR != null) this.jqXHR.abort(); + var data = {}; data[this._settings.queryKey] = q; - if (this._settings.param.length > 0) $.extend(data, FoniaJS.RequestParam(this._settings.param)); - if (this.requestTID) { - window.clearTimeout(this.requestTID); + if (this._settings.param.length > 0) { + $.extend(data, FoniaJS.RequestParam(this._settings.param)); } - this.requestTID = window.setTimeout(function () { - _this.jqXHR = $.ajax(_this._settings.url, { - method: _this._settings.method, + + if (this.requestTID) window.clearTimeout(this.requestTID); + + this.requestTID = window.setTimeout(() => { + this.jqXHR = $.ajax(this._settings.url, { + method: this._settings.method, data: data, - timeout: _this._settings.timeout + timeout: this._settings.timeout }); - _this.jqXHR.done(function (result) { - //gnips: result in object - cbk((undefined !== result.autodata) ? result.autodata : result); + + this.jqXHR.done(result => { + cbk(result.autodata !== undefined ? result.autodata : result); }); - _this.jqXHR.fail(function (err) { - var _a; - (_a = _this._settings) === null || _a === void 0 ? void 0 : _a.fail(err); + + this.jqXHR.fail(err => { + this._settings.fail?.(err); }); - _this.jqXHR.always(function () { - _this.jqXHR = null; + + this.jqXHR.always(() => { + this.jqXHR = null; }); }, this._settings.requestThrottling); - }; - return AjaxResolver; -}(BaseResolver)); + } +}; -var DropdownV5 = (function () { - function DropdownV5(e, formatItemCbk, autoSelect, noResultsText) { +var DropdownV5 = class { + constructor(e, formatItemCbk, autoSelect, noResultsText) { this.initialized = false; this.shown = false; this.items = []; @@ -88,195 +56,160 @@ var DropdownV5 = (function () { this.autoSelect = autoSelect; this.noResultsText = noResultsText; } - DropdownV5.prototype.getElPos = function () { - var pos = $.extend({}, this._$el.position(), { - height: this._$el[0].offsetHeight - }); - return pos; - }; - DropdownV5.prototype.init = function () { - var _this = this; + + getElPos() { + return $.extend({}, this._$el.position(), { height: this._$el[0].offsetHeight }); + } + + init() { var pos = this.getElPos(); - var fontsize = _this._$el.css('font-size'); - this._dd = $('
'); - this._dd.addClass('bootstrap-autocomplete dropdown-menu'); - this._dd.insertAfter(this._$el); - this._dd.css({ top: pos.top + this._$el.outerHeight(), left: pos.left, width: this._$el.outerWidth(), 'font-size': fontsize }); - this._dd.on('click', '.dropdown-item', function (evt) { + var fontsize = this._$el.css('font-size'); + + this._dd = $('') + .addClass('bootstrap-autocomplete dropdown-menu') + .insertAfter(this._$el) + .css({ + top: pos.top + this._$el.outerHeight(), + left: pos.left, + width: this._$el.outerWidth(), + 'font-size': fontsize + }); + + this._dd.on('click', '.dropdown-item', evt => { var item = $(evt.currentTarget).data('item'); - _this.itemSelectedLaunchEvent(item); + this.itemSelectedLaunchEvent(item); evt.preventDefault(); }); - this._dd.on('keyup', function (evt) { - if (_this.shown) { - switch (evt.which) { - case 27: - _this.hide(); - _this._$el.focus(); - break; - } + + this._dd.on('keyup', evt => { + if (this.shown && evt.which === 27) { + this.hide(); + this._$el.focus(); return false; } }); - this._dd.on('mouseenter', function (evt) { - _this.ddMouseover = true; - }); - this._dd.on('mouseleave', function (evt) { - _this.ddMouseover = false; - }); - this._dd.on('mouseenter', '.dropdown-item', function (evt) { - if (_this.haveResults) { + + this._dd.on('mouseenter', () => { this.ddMouseover = true; }); + this._dd.on('mouseleave', () => { this.ddMouseover = false; }); + + this._dd.on('mouseenter', '.dropdown-item', evt => { + if (this.haveResults) { $(evt.currentTarget).closest('div').find('.dropdown-item.active').removeClass('active'); $(evt.currentTarget).addClass('active'); - _this.mouseover = true; + this.mouseover = true; } }); - this._dd.on('mouseleave', '.dropdown-item', function (evt) { - _this.mouseover = false; - }); + + this._dd.on('mouseleave', '.dropdown-item', () => { this.mouseover = false; }); this.initialized = true; - }; - DropdownV5.prototype.checkInitialized = function () { - if (!this.initialized) { - this.init(); + } + + checkInitialized() { + if (!this.initialized) this.init(); + } + + get isMouseOver() { return this.mouseover; } + get isDdMouseOver() { return this.ddMouseover; } + get haveResults() { return this.items.length > 0; } + + focusNextItem(reversed) { + if (!this.haveResults) return; + var currElem = this._dd.find('.dropdown-item.active'); + var nextElem = reversed ? currElem.prev() : currElem.next(); + + if (nextElem.length === 0) { + nextElem = reversed ? this._dd.find('.dropdown-item').last() : this._dd.find('.dropdown-item').first(); } - }; - Object.defineProperty(DropdownV5.prototype, "isMouseOver", { - get: function () { - return this.mouseover; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(DropdownV5.prototype, "isDdMouseOver", { - get: function () { - return this.ddMouseover; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(DropdownV5.prototype, "haveResults", { - get: function () { - return (this.items.length > 0); - }, - enumerable: false, - configurable: true - }); - DropdownV5.prototype.focusNextItem = function (reversed) { - if (this.haveResults) { - var currElem = this._dd.find('.dropdown-item.active'); - var nextElem = reversed ? currElem.prev() : currElem.next(); - if (nextElem.length === 0) { - nextElem = reversed ? this._dd.find('.dropdown-item').last() : this._dd.find('.dropdown-item').first(); - } - currElem.removeClass('active'); - nextElem.addClass('active'); - this.scrollTo(nextElem); - } - }; - DropdownV5.prototype.focusPreviousItem = function () { - this.focusNextItem(true); - }; - DropdownV5.prototype.selectFocusItem = function () { - this._dd.find('.dropdown-item.active').trigger('click'); - }; - Object.defineProperty(DropdownV5.prototype, "isItemFocused", { - get: function () { - if (this._dd && this.isShown() && (this._dd.find('.dropdown-item.active').length > 0)) { - return true; - } - return false; - }, - enumerable: false, - configurable: true - }); - DropdownV5.prototype.show = function () { + currElem.removeClass('active'); + nextElem.addClass('active'); + this.scrollTo(nextElem); + } + + focusPreviousItem() { this.focusNextItem(true); } + selectFocusItem() { this._dd.find('.dropdown-item.active').trigger('click'); } + + get isItemFocused() { + return !!(this._dd && this.isShown() && this._dd.find('.dropdown-item.active').length > 0); + } + + show() { if (!this.shown) { this._dd.addClass('show'); this.shown = true; this._$el.trigger('autocomplete.dd.shown'); } - }; - DropdownV5.prototype.isShown = function () { - return this.shown; - }; - DropdownV5.prototype.hide = function () { + } + + isShown() { return this.shown; } + + hide() { if (this.shown) { this._dd.removeClass('show'); this.shown = false; this._$el.trigger('autocomplete.dd.hidden'); } - }; - DropdownV5.prototype.updateItems = function (items, searchText) { + } + + updateItems(items, searchText) { this.items = items; this.searchText = searchText; this.refreshItemList(); - }; - DropdownV5.prototype.showMatchedText = function (text, qry) { + } + + showMatchedText(text, qry) { var startIndex = text.toLowerCase().indexOf(qry.toLowerCase()); if (startIndex > -1) { var endIndex = startIndex + qry.length; - return text.slice(0, startIndex) + '' - + text.slice(startIndex, endIndex) + '' - + text.slice(endIndex); + return text.slice(0, startIndex) + '' + text.slice(startIndex, endIndex) + '' + text.slice(endIndex); } return text; - }; - DropdownV5.prototype.refreshItemList = function () { - var _this = this; + } + + refreshItemList() { this.checkInitialized(); this._dd.empty(); var liList = []; + if (this.items.length > 0) { - this.items.forEach(function (item) { - var itemFormatted = _this.formatItem(item); - if (typeof itemFormatted === 'string') { - itemFormatted = { text: itemFormatted }; - } - var itemText; - var itemHtml; - itemText = _this.showMatchedText(itemFormatted.text, _this.searchText); - if (itemFormatted.html !== undefined) { - itemHtml = itemFormatted.html; - } else { - itemHtml = itemText; - } - var disabledItem = itemFormatted.disabled; - var li = $(''); - li.addClass('dropdown-item') - //css bisa dimasukkan ke style default + cursor select - //.css({ 'overflow': 'hidden', 'text-overflow': 'ellipsis' }) + this.items.forEach(item => { + var itemFormatted = this.formatItem(item); + if (typeof itemFormatted === 'string') itemFormatted = { text: itemFormatted }; + + var itemText = this.showMatchedText(itemFormatted.text, this.searchText); + var itemHtml = itemFormatted.html !== undefined ? itemFormatted.html : itemText; + + var li = $('') + .addClass('dropdown-item') .html(itemHtml) .data('item', item); - if (disabledItem) { - li.addClass('disabled'); - } + + if (itemFormatted.disabled) li.addClass('disabled'); liList.push(li); }); this._dd.append(liList); this.show(); + } else if (this.noResultsText !== '') { + var li = $('').addClass('dropdown-item disabled').html(this.noResultsText); + liList.push(li); + this._dd.append(liList); + this.show(); + } else { + this.hide(); } - else { - if (this.noResultsText === '') { - this.hide(); - } - else { - var li = $(''); - li.addClass('dropdown-item disabled') - .html(this.noResultsText); - liList.push(li); - this._dd.append(liList); - this.show(); - } - } - }; - DropdownV5.prototype.itemSelectedLaunchEvent = function (item) { + } + + itemSelectedLaunchEvent(item) { this._$el.trigger('autocomplete.select', item); - }; - DropdownV5.prototype.scrollTo = function (el) { - var _he = this._dd.height(), _to = this._dd.scrollTop(), _ito = el.position().top, _ihe = el.outerHeight(), + } + + scrollTo(el) { + var _he = this._dd.height(), + _to = this._dd.scrollTop(), + _ito = el.position().top, + _ihe = el.outerHeight(), _nto = _to, _wra = false; - if (_ito < 0){ + + if (_ito < 0) { _wra = el.is(':first-child'); _nto = _wra ? 0 : _to - _he / 2; } else if (_ito > _he - _ihe) { @@ -284,12 +217,11 @@ var DropdownV5 = (function () { _nto = _wra ? (_ito + _ihe - _he) : _to + _he / 2; } this._dd.scrollTop(_nto); - }; - return DropdownV5; -}()); + } +}; -var AutoComplete = (function () { - function AutoComplete(element, options) { +var AutoComplete = class { + constructor(element, options) { this._selectedItem = null; this._defaultValue = null; this._defaultText = null; @@ -302,235 +234,189 @@ var AutoComplete = (function () { autoSelect: true, noResultsText: 'Pencarian Tidak Ketemu', preventEnter: false, - events: { - typed: null, - searchPre: null, - search: null, - searchPost: null, - select: null, - focus: null, - }, - //gnips: adding callback, keyfunc and breakvalue - selectFunc: function(){}, - keyFunc: function(){}, + events: { typed: null, searchPre: null, search: null, searchPost: null, select: null, focus: null }, + selectFunc: () => {}, + keyFunc: () => {}, + breakFocus: false, breakValue: [] }; this._el = element; this._$el = $(this._el); this.manageInlineDataAttributes(); + if (typeof options === 'object') { this._settings = $.extend(true, {}, this.getSettings(), options); } this.init(); } - AutoComplete.prototype.manageInlineDataAttributes = function () { + + manageInlineDataAttributes() { var s = this.getSettings(); - if (this._$el.data('url')) { - s.resolverSettings.url = this._$el.data('url'); - } - if (this._$el.data('default-value')) { - this._defaultValue = this._$el.data('default-value'); - } - if (this._$el.data('default-text')) { - this._defaultText = this._$el.data('default-text'); - } - if (this._$el.data('noresults-text') !== undefined) { - s.noResultsText = this._$el.data('noresults-text'); - } - }; - AutoComplete.prototype.getSettings = function () { - return this._settings; - }; - AutoComplete.prototype.init = function () { + if (this._$el.data('url')) s.resolverSettings.url = this._$el.data('url'); + if (this._$el.data('default-value')) this._defaultValue = this._$el.data('default-value'); + if (this._$el.data('default-text')) this._defaultText = this._$el.data('default-text'); + if (this._$el.data('noresults-text') !== undefined) s.noResultsText = this._$el.data('noresults-text'); + } + + getSettings() { return this._settings; } + + init() { this.bindDefaultEventListeners(); if (this._settings.resolver === 'ajax') { this.resolver = new AjaxResolver(this._settings.resolverSettings); } this._dd = new DropdownV5(this._$el, this._settings.formatResult, this._settings.autoSelect, this._settings.noResultsText); - }; - AutoComplete.prototype.bindDefaultEventListeners = function () { - var _this = this; - this._$el.on('keydown', function (evt) { - //gnips: check breakValue and call keydown function - (('' == _this._$el.val() || ((_this._settings.breakValue.length > 0) && (_this._settings.breakValue.indexOf(_this._$el.val()) != -1))) && _this._settings.keyFunc(evt.which, _this._$el.val())); + } + + bindDefaultEventListeners() { + this._$el.on('keydown', evt => { + var val = this._$el.val(); + if ((val === '' || (this._settings.breakValue.length > 0 && this._settings.breakValue.indexOf(val) !== -1))) { + this._settings.keyFunc(evt.which, val); + } + switch (evt.which) { case 9: - if (_this._dd.isItemFocused) { - _this._dd.selectFocusItem(); + if (!this._settings.breakFocus) { + if (this._dd.isItemFocused) this._dd.selectFocusItem(); + this._dd.hide(); } - _this._dd.hide(); break; case 13: - if (_this._dd.isItemFocused) { - _this._dd.selectFocusItem(); - } - _this._dd.hide(); - if (_this._settings.preventEnter) { - evt.preventDefault(); - } + if (this._dd.isItemFocused) this._dd.selectFocusItem(); + this._dd.hide(); + if (this._settings.preventEnter) evt.preventDefault(); break; case 40: - _this._dd.focusNextItem(); + this._dd.focusNextItem(); break; case 38: - _this._dd.focusPreviousItem(); + this._dd.focusPreviousItem(); break; } }); - this._$el.on('keyup', function (evt) { + + this._$el.on('keyup', evt => { switch (evt.which) { - case 16: - case 17: - case 18: - case 39: - case 37: - case 36: - case 35: + case 16: case 17: case 18: case 39: case 37: case 36: case 35: case 40: case 38: break; - case 13: - _this._dd.hide(); - break; - case 27: - _this._dd.hide(); - break; - case 40: - break; - case 38: + case 13: case 27: + this._dd.hide(); break; default: - _this._selectedItem = null; - var newValue = _this._$el.val(); - _this.handlerTyped(newValue); + this._selectedItem = null; + this.handlerTyped(this._$el.val()); } }); - this._$el.on('blur', function (evt) { - if (!_this._dd.isMouseOver && _this._dd.isDdMouseOver && _this._dd.isShown()) { - setTimeout(function () { _this._$el.focus(); }); - _this._$el.focus(); - } - else if (!_this._dd.isMouseOver) { - _this._dd.hide(); + + this._$el.on('blur', () => { + if (this._settings.breakFocus) return; + if (!this._dd.isMouseOver && this._dd.isDdMouseOver && this._dd.isShown()) { + setTimeout(() => { this._$el.focus(); }); + this._$el.focus(); + } else if (!this._dd.isMouseOver) { + this._dd.hide(); } }); - this._$el.on('autocomplete.select', function (evt, item) { - _this._selectedItem = item; - _this.itemSelectedDefaultHandler(item); + + this._$el.on('autocomplete.select', (evt, item) => { + this._selectedItem = item; + this.itemSelectedDefaultHandler(item); }); - this._$el.on('paste', function (evt) { - setTimeout(function () { - _this._$el.trigger('keyup', evt); - }, 0); + + this._$el.on('paste', evt => { + setTimeout(() => { this._$el.trigger('keyup', evt); }, 0); }); - }; - AutoComplete.prototype.handlerTyped = function (newValue) { + } + + handlerTyped(newValue) { if (this._settings.events.typed !== null) { newValue = this._settings.events.typed(newValue, this._$el); - if (!newValue) { - return; - } + if (!newValue) return; } if (newValue.length >= this._settings.minLength) { this._searchText = newValue; this.handlerPreSearch(); - } - else { + } else { this._dd.hide(); } - }; - AutoComplete.prototype.handlerPreSearch = function () { + } + + handlerPreSearch() { if (this._settings.events.searchPre !== null) { var newValue = this._settings.events.searchPre(this._searchText, this._$el); - if (!newValue) - return; + if (!newValue) return; this._searchText = newValue; } this.handlerDoSearch(); - }; - AutoComplete.prototype.handlerDoSearch = function () { - var _this = this; + } + + handlerDoSearch() { if (this._settings.events.search !== null) { - this._settings.events.search(this._searchText, function (results) { - _this.postSearchCallback(results); + this._settings.events.search(this._searchText, results => { + this.postSearchCallback(results); }, this._$el); + } else if (this.resolver) { + this.resolver.search(this._searchText, results => { + this.postSearchCallback(results); + }); } - else { - if (this.resolver) { - this.resolver.search(this._searchText, function (results) { - _this.postSearchCallback(results); - }); - } - } - }; - AutoComplete.prototype.postSearchCallback = function (results) { + } + + postSearchCallback(results) { if (this._settings.events.searchPost) { results = this._settings.events.searchPost(results, this._$el); - if ((typeof results === 'boolean') && !results) - return; + if (typeof results === 'boolean' && !results) return; } this.handlerStartShow(results); - }; - AutoComplete.prototype.handlerStartShow = function (results) { - //gnips: adding auto select when barcode result of 1 item only - if (1 == results.length && 1 == (void 0 !== results[0].bc ? results[0].bc : 0)) { - this._$el.trigger('autocomplete.select', results[0]), + } + + handlerStartShow(results) { + var bcVal = results[0]?.bc ?? 0; + if (results.length === 1 && bcVal === 1) { + this._$el.trigger('autocomplete.select', results[0]); this._dd.hide(); - } else this._dd.updateItems(results, this._searchText); - }; - AutoComplete.prototype.itemSelectedDefaultHandler = function (item) { + } else { + this._dd.updateItems(results, this._searchText); + } + } + + itemSelectedDefaultHandler(item) { if (item != null) { var itemFormatted = this._settings.formatResult(item); - if (typeof itemFormatted === 'string') { - itemFormatted = { text: itemFormatted }; - } + if (typeof itemFormatted === 'string') itemFormatted = { text: itemFormatted }; this._$el.val(itemFormatted.text); - } - else { + } else { this._$el.val(''); } this._selectedItem = item; - //gnips: callback with selected item this._settings.selectFunc(item); this._dd.hide(); - }; - AutoComplete.prototype.defaultFormatResult = function (item) { - if (typeof item === 'string') { - return { text: item }; - } - else if (item.text) { - return item; - } - else { - return { text: item.toString() }; - } - }; - AutoComplete.prototype.manageAPI = function (APICmd, params) { - if (APICmd === 'set') { - this.itemSelectedDefaultHandler(params); - } - else if (APICmd === 'clear') { - this.itemSelectedDefaultHandler(null); - } - else if (APICmd === 'show') { - this._$el.trigger('keyup'); - } - else if (APICmd === 'updateResolver') { - this.resolver = new AjaxResolver(params); - } - }; - AutoComplete.NAME = 'autoComplete'; - return AutoComplete; -}()); + } -(function ($, window, document) { - $.fn[AutoComplete.NAME] = function (optionsOrAPI, optionalParams) { - return this.each(function () { - var pluginClass; - pluginClass = $(this).data(AutoComplete.NAME); - if (!pluginClass) { - pluginClass = new AutoComplete(this, optionsOrAPI); - $(this).data(AutoComplete.NAME, pluginClass); - } - pluginClass.manageAPI(optionsOrAPI, optionalParams); - }); - }; -})(jQuery, window, document); + defaultFormatResult(item) { + if (typeof item === 'string') return { text: item }; + if (item.text) return item; + return { text: item.toString() }; + } + + manageAPI(APICmd, params) { + if (APICmd === 'set') this.itemSelectedDefaultHandler(params); + else if (APICmd === 'clear') this.itemSelectedDefaultHandler(null); + else if (APICmd === 'show') this._$el.trigger('keyup'); + else if (APICmd === 'updateResolver') this.resolver = new AjaxResolver(params); + } +}; +AutoComplete.NAME = 'autoComplete'; + +// jQuery plugin wrapper +$.fn[AutoComplete.NAME] = function (optionsOrAPI, optionalParams) { + return this.each(function () { + var pluginClass = $(this).data(AutoComplete.NAME); + if (!pluginClass) { + pluginClass = new AutoComplete(this, optionsOrAPI); + $(this).data(AutoComplete.NAME, pluginClass); + } + pluginClass.manageAPI(optionsOrAPI, optionalParams); + }); +}; diff --git a/assets/js/fonia3.js b/assets/js/fonia3.js index 43992de..f8b199b 100644 --- a/assets/js/fonia3.js +++ b/assets/js/fonia3.js @@ -4,7 +4,7 @@ Desc. : JS - Fonia Custom Class v3 Created By : Siau Pheng (siaupheng@3fonia.com). Created Date : June 19th, 2009. - Last Modified : September 28th, 2026. + Last Modified : November 1st, 2026. (c) 3FONIA Software; WWW.3FONIA.COM. @@ -12,195 +12,226 @@ 'use strict'; +// Helper for invoking dynamic object functions safely +const _executeFuncByName = (functionName, ...args) => { + if (!functionName) return; + const parts = functionName.split('.'); + const fn = parts.reduce((curr, key) => (curr && curr[key]), window); + if (typeof fn === 'function') { + const parCon = parts.slice(0, -1).reduce((curr, key) => (curr && curr[key]), window) || window; + return fn.apply(parCon, args); + } + console.warn(`Fungsi ${functionName} tidak ada!`); + return null; +}; + var FoniaJS = { - version: "3.1.2", + version: "3.2.0", APP_ID: 0, APP_SID: "", WEB_HOST: "", WEB_FULLPATH: "", WEB_MOBILE: 0, AUTH_LEVEL: 9, - User: {ID:null, UID:0, GID:0, Level:0}, - phpversion: "", + User: { ID: null, UID: 0, GID: 0, Level: 0 }, locales: [], deflocal: "", - _debug: (jQuery.inArray(location.hostname, ["localhost","127.0.0.1"]) !== -1) ? true : false, + _debug: ["localhost", "127.0.0.1"].includes(location.hostname), - setConfig: function(key, skey) { - var _hasil, _adata = null; - if (typeof(key) === 'string' && key !== '') { - _hasil = $.base64.decode(key); - _adata = _hasil.split(";"); - this.APP_ID = _adata[0]; - this.APP_SID = _adata[1]; - this.WEB_HOST = _adata[2]; - this.WEB_FULLPATH = _adata[3]; - this.WEB_MOBILE = _adata[4]; - this.AUTH_LEVEL = parseInt(_adata[5]); - this.phpversion = ''; + setConfig(key, skey) { + if (typeof key === 'string' && key !== '') { + const data = $.base64.decode(key).split(";"); + this.APP_ID = data[0]; + this.APP_SID = data[1]; + this.WEB_HOST = data[2]; + this.WEB_FULLPATH = data[3]; + this.WEB_MOBILE = data[4]; + this.AUTH_LEVEL = parseInt(data[5], 10); } - if (typeof(skey) === 'string' && skey !== '') { - _hasil = $.base64.decode(skey); - _adata = _hasil.split(";"); - this.User.ID = _adata[0]; - this.User.UID = parseInt(_adata[1]); - this.User.GID = parseInt(_adata[2]); - this.User.Level = parseInt(_adata[3]); + if (typeof skey === 'string' && skey !== '') { + const sdata = $.base64.decode(skey).split(";"); + this.User.ID = sdata[0]; + this.User.UID = parseInt(sdata[1], 10); + this.User.GID = parseInt(sdata[2], 10); + this.User.Level = parseInt(sdata[3], 10); } }, - user_level: function(l) { - if (this.User.Level <= (l ?? 9)) return true; - return false; + + user_level(l = 9) { + return this.User.Level <= l; }, - user_level_not: function(l) { - if (this.User.Level !== (l ?? 9)) return true; - return false; + + user_level_not(l = 9) { + return this.User.Level !== l; }, - callMenu: function(p, q) { - var apar = ["p=" + p]; - if (q !== null) apar.push("q=" + q); + + callMenu(p, q) { + const sendParam = [`p=${p}`]; + if (q !== null) sendParam.push(`q=${q}`); + new Request({ url: "auth/menu", - sendParam: apar, + sendParam, onSuccess: (apop) => { - if (apop.login == false) { + if (apop.login === false) { this.showErrorLocale("Fonia.sess_expire"); setTimeout(() => { self.location = self.location.href; }, 1600); return false; } - if (apop.php === "" || !window[apop.func]) { + if (!apop.php || !window[apop.func]) { this.showErrorLocale("Fonia.page404"); return false; } window[apop.func]['PHP'] = apop.php; window[apop.func]['KODE'] = apop.kode; - if (apop.iswindow === true) { - if (IndexJS.index) IndexJS.index(); - new Request({ - url: apop.php + '/index', - onSuccess: (ajson) => { + const isWin = apop.iswindow === true; + if (isWin && IndexJS.index) IndexJS.index(); + new Request({ + url: `${apop.php}/index`, + onSuccess: (ajson) => { + if (isWin) { this.showWindow(apop.kode, apop.title, ajson.html, apop.width, apop.button, () => { - if (typeof window[apop.func]['index'] === 'function') window[apop.func]['index'](q); + _executeFuncByName(`${apop.func}.index`, q); }); - } - }).send(); - } else { - $("#pageToolbarBot").html(this.genToolButton(apop.button)); - new Request({ - url: apop.php + '/index', - onSuccess: (ajson) => { + } else { + $("#pageToolbarBot").html(this.genToolButton(apop.button)); $('#pageContent').html(ajson.html); - if (typeof window[apop.func]['index'] === 'function') window[apop.func]['index'](q); + _executeFuncByName(`${apop.func}.index`, q); } - }).send(); - } + } + }).send(); } }).send(); }, - loadMenu: function() { - $('.mlink').click((e) => { - var sbar = $(e.currentTarget).closest('#sidebarMain'); - var linkid = $(e.currentTarget).attr('id').replace('Link',''); + loadMenu() { + $('.mlink').on('click', (e) => { + const sbar = $(e.currentTarget).closest('#sidebarMain'); + const linkid = e.currentTarget.id.replace('Link', ''); FoniaJS.callMenu(linkid); - if (sbar.length > 0) { sbar.modal('toggle'); } + if (sbar.length) sbar.modal('toggle'); }); - $('.slink').click((e) => { - var ddown = $(e.currentTarget).closest('.dropdown-menu'); - if (ddown.length > 0) { ddown.dropdown('toggle'); } + $('.slink').on('click', (e) => { + const ddown = $(e.currentTarget).closest('.dropdown-menu'); + if (ddown.length) ddown.dropdown('toggle'); + }); + $('#HomeLink').on('click', () => { + this.closeAllWindows(); + if (IndexJS.index) IndexJS.index(); + }); + $('#ExitLink').on('click', () => { + new Request({ + url: "auth/logout", + onFailure: () => { self.location = self.location.href; }, + onSuccess: (respon) => { + self.location = (respon && respon.nexthost !== '/') ? respon.nexthost : self.location.href; + } + }).send(); }); - if ($('#HomeLink').length){ - $('#HomeLink').click(() => { - this.closeAllWindows(); - if (IndexJS.index) IndexJS.index(); - }); - } - if ($('#ExitLink').length) { - $('#ExitLink').click(() => { - new Request({ - url: "auth/logout", - onFailure: () => { - self.location = self.location.href; - }, - onSuccess: (respon) => { - var _nurl = self.location.href; - if (typeof respon !== 'undefined' && respon.nexthost !== '/') _nurl = respon.nexthost; - self.location = _nurl; - } - }).send(); - }); - } }, - showInfo: function(message, wtime) { - var _tmpto = $(''+this.locale("Fonia.auth_wait_msg")+'
${this.locale("Fonia.auth_wait_msg")}