UNPKG

inet-core

Version:
1 lines 250 kB
{"version":3,"file":"inet-core.mjs","sources":["../../src/lib/inet-core.js","../../src/iNet.ts","../../src/model/error-message.ts","../../src/model/response-data.ts","../../src/model/app-cloud-config.ts","../../src/http-url-encoding-codec.ts","../../src/loading-indicator.service.ts","../../src/http-client.service.ts","../../src/core.service.ts","../../src/suggestion.service.ts","../../src/infinite-scroller.directive.ts","../../src/model/new-password.ts","../../src/notification.service.ts","../../src/security.service.ts","../../src/role-access.directive.ts","../../src/ssourl.pipe.ts","../../src/time-ago.pipe.ts","../../src/user-profile.service.ts","../../src/accent.service.ts","../../src/cache-storage.service.ts","../../src/autosize.directive.ts","../../src/avatar.directive.ts","../../src/resource-loader.service.ts","../../src/dev-config.service.ts","../../src/init-app.ts","../../src/core.module.ts","../../src/websocket/websocket-abstract.ts","../../src/websocket/websocket-jboss.ts","../../src/websocket/websocket-client.ts","../../src/websocket/websocket-client.service.ts","../../src/utils/HtmlUtils.ts","../../src/uploader.service.ts","../../inet-core.ts"],"sourcesContent":["( function( global, factory ) {\n\n \"use strict\";\n\n if ( typeof module === \"object\" && typeof module.exports === \"object\" ) {\n\n // For CommonJS and CommonJS-like environments where a proper `window`\n // is present, execute the factory and get iNet.\n // For environments that do not have a `window` with a `document`\n // (such as Node.js), expose a factory as module.exports.\n // This accentuates the need for the creation of a real `window`.\n // e.g. var iNet = require(\"iNet\")(window);\n module.exports = global.document ?\n factory( global, true ) :\n function( w ) {\n return factory( w );\n };\n } else {\n factory( global );\n }\n\n// Pass this if window is not defined yet\n} )( typeof window !== \"undefined\" ? window : this, function( window, noGlobal ) {\n /*--------------------------------------------\n | C O N S T R U C T O R S |\n ============================================*/\n /**\n * Define the iNet instance.\n */\n /**\n * iNet core utilities and functions.\n *\n * The iNet namespace (global object) encapsulates all classes, singletons, and utility methods provided by iNet Solution's libraries.\n * @class iNet\n * @singleton\n */\n var iNet = {\n /**\n * @property {String}\n * @readonly\n * The version of the framework\n * @type String Major[.Minor[.Patch[.Build[Release]]]]\n *\n */\n version: '6.0.0.1',\n /**\n * The date release the framework\n * @property {String}\n * @readonly\n */\n build_date: '14/06/2022',\n /**\n * @property {String} BLANK_IMAGE_URL\n * URL to a 1x1 transparent gif image used by iNet to create inline icons with\n * CSS background images.\n */\n BLANK_IMAGE_URL: 'data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=='\n };\n\n /*--------------------------------------------\n | M E T H O D S |\n ============================================*/\n /**\n * Copies all the properties of config to obj.\n * Example:\n *\n * var a = {a:1,b:2,c:5};\n * var b = {b:3,d:7};\n * iNet.apply(a, b);\n * // a ={ a: 1, b: 3, c: 5, d: 7};\n *\n * @param {Object} obj The receiver of the properties\n * @param {Object} config The source of the properties\n * @param {Object} defaults A different object that will also be applied for default values\n * @return {Object} returns obj\n * @member iNet apply\n */\n iNet.apply = function (o, c, defaults) {\n // no \"this\" reference for friendly out of scope calls\n if (defaults) {\n iNet.apply(o, defaults);\n }\n if (o && c && typeof c == 'object') {\n for (var p in c) {\n o[p] = c[p];\n }\n }\n return o;\n };\n (function () {\n var ua = navigator.userAgent.toLowerCase(), toString = Object.prototype.toString,\n check = function (r) {\n return r.test(ua);\n },\n DOC = document,\n isStrict = DOC.compatMode == \"CSS1Compat\",\n docMode = document.documentMode,\n isOpera = check(/opera/),\n isChrome = check(/chrome/),\n isWebKit = check(/webkit/),\n isSafari = !isChrome && check(/safari/),\n isSafari2 = isSafari && check(/applewebkit\\/4/), // unique to Safari 2\n isSafari3 = isSafari && check(/version\\/3/),\n isSafari4 = isSafari && check(/version\\/4/),\n isIE = !isOpera && check(/msie/),\n isIE7 = isIE && (check(/msie 7/) || docMode == 7),\n isIE8 = isIE && (check(/msie 8/) && docMode != 7 && docMode != 9 && docMode != 10 || docMode == 8),\n isIE9 = isIE && (check(/msie 9/) && docMode != 7 && docMode != 8 && docMode != 10 || docMode == 9),\n isIE10 = isIE && (check(/msie 10/) && docMode != 7 && docMode != 8 && docMode != 9 || docMode == 10),\n isIE6 = isIE && !isIE7 && !isIE8 && !isIE9 && !isIE10,\n isSupport = (isIE && (docMode && !(docMode >= 7))) || !isIE,\n isGecko = !isWebKit && check(/gecko/),\n isGecko2 = isGecko && check(/rv:1\\.8/),\n isGecko3 = isGecko && check(/rv:1\\.9/),\n isGecko4 = isGecko && check(/rv:2\\.0/),\n isBorderBox = isIE && !isStrict,\n isWindows = check(/windows|win32/),\n isMac = check(/macintosh|mac os x/),\n isAir = check(/adobeair/),\n isLinux = check(/linux/),\n isSecure = /^https/i.test(window.location.protocol),\n propertyNameSplitRe= /[,;\\s]+/;\n iNet.apply(iNet, {\n /**\n * Returns true if the passed object is a JavaScript Function, otherwise false.\n * @param {Object} object The object to test\n * @return {Boolean}\n */\n isFunction: function (v) {\n return toString.apply(v) === '[object Function]';\n },\n /**\n * Returns the current context path.\n *\n * @return {String} The current context path\n */\n getContextPath: function () {\n var pathname = window.location.pathname;\n if (pathname == '/') {\n return '/';\n }\n\n var position = pathname.indexOf('/', 1);\n if (position == 0) {\n position = pathname.length;\n }\n return pathname.substr(0, position);\n },\n /**\n * return a new MediaQueryList object.\n * @param {String} media Is a string mediaQueryString\n * @return MediaQueryList object\n */\n matchMedia: function(media){\n return window.matchMedia(media);\n },\n /**\n * Returns the true if viewport is match with width value, otherwise false.\n * @param {Number} v The width to test\n * @returns {Boolean}\n */\n matchWidth: function(v){\n return iNet.matchMedia(\"(min-width:\"+v+\"px)\").matches;\n },\n /**\n * Returns the full url from the given relative path.\n *\n * @param {String} relativePath (required) The given relative path.\n *\n * @return {String} The string URL\n */\n getUrl: function (relativePath) {\n relativePath = relativePath || '';\n var url = window.location.protocol + '//';\n url += window.location.hostname;\n var __port = window.location.port;\n\n if (!iNet.isEmpty(__port)) {\n if (isSecure && (__port != 443)) {\n url += ':' + __port;\n }\n else if (!isSecure && __port != 80) {\n url += ':' + __port;\n }\n }\n // append the context path.\n var pathname = window.location.pathname;\n if (pathname.length > 1) {\n var position = pathname.indexOf('/', 1);\n if (position == 0)\n position = pathname.length;\n url += pathname.substr(0, position);\n }\n var prefix = iNet.prefix || 'smartcloud';\n var extension = iNet.extension || '.cpx';\n if (relativePath.indexOf('/') == 0) {\n return url + '/' + prefix + relativePath + extension;\n }\n else {\n return url + '/' + prefix + '/' + relativePath + extension;\n }\n },\n /**\n * Returns full url form given relative path with pattern\n * @param {String} url The URL\n * @param {String} pattern (optional) The pattern of module\n * @return {String} The string URL\n */\n getXUrl: function (url, pattern) {\n var __pattern = !iNet.isEmpty(pattern) ? pattern : iNet.pattern;\n if (!iNet.isEmpty(__pattern)) {\n return iNet.getUrl(__pattern + \"/\" + url)\n }\n return iNet.getUrl(url);\n },\n /**\n * Returns full url form given relative path with firm prefix\n * @param {String} path (required) The URL\n * @return {String} The string URL\n */\n getPUrl: function (path) {\n path = path || '';\n var url = window.location.protocol + '//';\n url += window.location.hostname;\n var __port = window.location.port;\n\n if (!iNet.isEmpty(__port)) {\n if (isSecure && (__port != 443)) {\n url += ':' + __port;\n }\n else if (!isSecure && __port != 80) {\n url += ':' + __port;\n }\n }\n // append the context path.\n var pathname = window.location.pathname;\n if (pathname.length > 1) {\n var position = pathname.indexOf('/', 1);\n if (position == 0)\n position = pathname.length;\n url += pathname.substr(0, position);\n }\n var prefix = iNet.firmPrefix || iNet.prefix || 'smartcloud';\n var extension = iNet.extension || '.cpx';\n if(prefix==='icloud') {\n prefix = 'smartcloud';\n }\n if (path.indexOf('/') == 0) {\n return url + '/' + prefix + path + extension;\n }\n else {\n return url + '/' + prefix + '/' + path + extension;\n }\n },\n /**\n * Returns the SSO redirect url from the given url path.\n *\n * @param {String} url (required) The given url.\n * @param {String} app (option) The given application.\n *\n * @return {String} The string SSO redirect URL\n */\n getSSOUrl: function(url, app){\n if(iNet.isEmpty(url)) {\n return '';\n }\n return iNet.urlAppend(iNet.getUrl('ssorequest/redirect'), (!iNet.isEmpty(app) ? 'application=' + app + '&' : '') + 'url=' + encodeURIComponent(url));\n },\n /**\n * Returns the Discovery redirect url from the given url path.\n *\n * @param {String} url (required) The given url.\n * @param {String} app (option) The given application.\n *\n * @return {String} The string SSO Discovery redirect URL\n */\n getSSODiscoveryUrl: function(url, app){\n if(iNet.isEmpty(url)) {\n return '';\n }\n return iNet.urlAppend(iNet.getUrl('ssodiscovery/redirect'), (!iNet.isEmpty(app) ? 'application=' + app + '&' : '') + 'url=' + encodeURIComponent(url));\n },\n /**\n * Returns the Discovery redirect url from the given url path.\n *\n * @param {String} app (option) The given application.\n * @param {Object} params (option) The given params.\n *\n * @return {String} The string SSO Callback redirect URL\n */\n getSSOCallback: function(app, params){\n var __params = params || {};\n if(!iNet.isEmpty(app)) {\n __params.application = app;\n }\n var __pairs= Object.keys(__params).map(function(k) {\n return encodeURIComponent(k) + \"=\" + encodeURIComponent(__params[k]);\n }).join('&');\n\n return iNet.urlAppend(iNet.getPUrl('ssocallback/redirect'), __pairs);\n },\n /**\n * Appends content to the query string of a URL, handling logic for whether to place\n * a question mark or ampersand.\n * @param {String} url The URL to append to.\n * @param {String} s The content to append to the URL.\n * @return (String) The resulting URL\n */\n urlAppend: function (url, s) {\n if (!iNet.isEmpty(s)) {\n return url + (url.indexOf('?') === -1 ? '?' : '&') + s;\n }\n return url;\n },\n /**\n * Clone simple variables including array, {}-like objects, DOM nodes and Date without keeping the old reference.\n * A reference for the object itself is returned if it's not a direct descendant of Object.\n *\n * @param {Object} obj The object to clone\n * @return {Object} The new object\n */\n clone: function (obj) {\n if (null == obj || \"object\" != typeof obj) {\n return obj;\n }\n var copy = obj.constructor();\n if(copy) {\n for (var attr in obj) {\n if (obj.hasOwnProperty(attr)) {\n copy[attr] = obj[attr];\n }\n }\n }\n return copy;\n },\n /**\n * @method copy\n * @member iNet\n * Copies a set of named properties fom the source object to the destination object.\n *\n * Example:\n *\n * var foo = { a: 1, b: 2, c: 3 };\n * var bar = iNet.copy({}, foo, 'a,c');\n * // bar = { a: 1, c: 3 };\n *\n * @param {Object} dest The destination object.\n * @param {Object} source The source object.\n * @param {String/String[]} names Either an Array of property names, or a comma-delimited list\n * of property names to copy.\n * @param {Boolean} [usePrototypeKeys=false] Pass `true` to copy keys off of the\n * prototype as well as the instance.\n * @return {Object} The `dest` object.\n */\n copy: function (dest, source, names, usePrototypeKeys) {\n if (typeof names === 'string') {\n names = names.split(propertyNameSplitRe);\n }\n for (var name, i = 0, n = names ? names.length : 0; i < n; i++) {\n name = names[i];\n // Only copy a property if the source actually *has* that property.\n // If we are including prototype properties, then ensure that a property of\n // that name can be found *somewhere* in the prototype chain (otherwise we'd be copying undefined in which may break things)\n if (source.hasOwnProperty(name) || (usePrototypeKeys && name in source)) {\n dest[name] = source[name];\n }\n }\n return dest;\n },\n /**\n * @method copyToIf\n * @member iNet\n * Copies a set of named properties fom the source object to the destination object\n * if the destination object does not already have them.\n *\n * Example:\n *\n * var foo = { a: 1, b: 2, c: 3 };\n * var bar = iNet.copyIf({ a:115 }, foo, 'a,c');\n * // bar = { a: 115, c: 3 };\n *\n * @param {Object} destination The destination object.\n * @param {Object} source The source object.\n * @param {String/String[]} names Either an Array of property names, or a single string\n * with a list of property names separated by \",\", \";\" or spaces.\n * @return {Object} The `dest` object.\n */\n copyIf: function (destination, source, names) {\n if (typeof names === 'string') {\n names = names.split(propertyNameSplitRe);\n }\n for (var name, i = 0, n = names ? names.length : 0; i < n; i++) {\n name = names[i];\n if (destination[name] === undefined) {\n destination[name] = source[name];\n }\n }\n return destination;\n },\n /**\n * Returns true if the passed object is a JavaScript Object, otherwise false.\n *\n * @param {Object} v The object to test\n * @return {Boolean}\n */\n isObject: function (v) {\n return v && typeof v == \"object\";\n },\n /**\n * Returns true if the passed object is a string.\n *\n * @param {Object} v The object to test\n * @return {Boolean}\n */\n isString: function (v) {\n return typeof v === 'string';\n },\n /**\n * Returns true if the passed object is a number. Returns false for\n * non-finite numbers.\n *\n * @param {Object} v The object to test\n * @return {Boolean}\n */\n isNumber: function (v) {\n return typeof v === 'number' && isFinite(v);\n },\n /**\n * Returns true if the passed object is a boolean.\n *\n * @param {Object} v The object to test\n * @return {Boolean}\n */\n isBoolean: function (v) {\n return typeof v === 'boolean';\n },\n /**\n * Returns true if the passed object is a JavaScript array, otherwise false.\n *\n * @param {Object} v The object to test\n * @return {Boolean}\n */\n isArray: function (v) {\n return toString.apply(v) === '[object Array]';\n },\n /**\n * Returns true if the passed object is not undefined.\n *\n * @param {Object} v The object to test\n * @return {Boolean}\n */\n isDefined: function (v) {\n return typeof v !== 'undefined';\n },\n /**\n * Returns true if the passed value is iterable, false otherwise\n * @param {Mixed} value The value to test\n * @return {Boolean}\n */\n isIterable: function(value) {\n return (value && typeof value !== 'string') ? value.length !== undefined : false;\n },\n /**\n * Returns true if the passed value is empty. The value is deemed to be\n * empty if it is * null * undefined * an empty array * a zero length * an empty object\n * string (Unless the allowBlank parameter is true)\n *\n * @param {Mixed} value The value to test\n * @param {Boolean} allowBlank (optional) true to allow empty strings (defaults to false)\n * @return {Boolean}\n */\n isEmpty: function (v, allowBlank) {\n return v === null || v === undefined || ((iNet.isArray(v) && !v.length)) || (!allowBlank ? v === '' : false) || iNet.isEmptyObject(v);\n },\n /**\n * Returns the given value itself if it's not empty, as described in {@link iNet#isEmpty}; returns the default\n * value (second argument) otherwise.\n *\n * @param {Object} value The value to test.\n * @param {Object} defaultValue The value to return if the original value is empty.\n * @param {Boolean} [allowBlank=false] `true` to allow zero length strings to qualify as non-empty.\n * @return {Object} value, if non-empty, else defaultValue.\n */\n valueFrom: function(value, defaultValue, allowBlank){\n return iNet.isEmpty(value, allowBlank) ? defaultValue : value;\n },\n /**\n * Return true if passed object is empty.\n * @param {Mixed} value The value to test\n * @returns {boolean}\n */\n isEmptyObject: function(v){\n if(!iNet.isObject(v)) {\n return false;\n }\n for(var key in v){\n return false;\n }\n return true;\n },\n /**\n * Returns true if the passed object is a email.\n *\n * @param {Object} v The object to test\n * @return {Boolean}\n */\n isEmail: function (v) {\n return /^(([^<>()[\\]\\\\.,;:\\s@\\\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\\\"]+)*)|(\\\".+\\\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/.test(v);\n },\n /**\n * Returns true if the passed value is a JavaScript Date object, false otherwise.\n * @param {Object} v The object to test\n * @return {Boolean}\n */\n isDate: function(v) {\n return toString.call(v) === '[object Date]';\n },\n /**\n * Returns true if the passed value is a JavaScript 'primitive', a string, number or boolean.\n * @param {Mixed} value The value to test\n * @return {Boolean}\n */\n isPrimitive: function(value) {\n var type = typeof value;\n return type === 'string' || type === 'number' || type === 'boolean';\n },\n /**\n * Returns `true` if the passed value is an HTMLElement\n * @param {Object} value The value to test.\n * @return {Boolean}\n */\n isElement: function(value) {\n return value ? value.nodeType === 1 : false;\n },\n /**\n * True if the detected browser is Opera.\n *\n * @type Boolean\n */\n isOpera: isOpera,\n /**\n * True if the detected browser uses WebKit.\n *\n * @type Boolean\n */\n isWebKit: isWebKit,\n /**\n * True if the detected browser is Chrome.\n *\n * @type Boolean\n */\n isChrome: isChrome,\n /**\n * True if the detected browser is Safari.\n *\n * @type Boolean\n */\n isSafari: isSafari,\n /**\n * True if the detected browser is Safari 3.x.\n *\n * @type Boolean\n */\n isSafari3: isSafari3,\n /**\n * True if the detected browser is Safari 4.x.\n *\n * @type Boolean\n */\n isSafari4: isSafari4,\n /**\n * True if the detected browser is Safari 2.x.\n *\n * @type Boolean\n */\n isSafari2: isSafari2,\n /**\n * True if the detected browser is Internet Explorer.\n *\n * @type Boolean\n */\n isIE: isIE,\n /**\n * True if the detected browser is Internet Explorer 6.x.\n *\n * @type Boolean\n */\n isIE6: isIE6,\n /**\n * True if the detected browser is Internet Explorer 7.x.\n *\n * @type Boolean\n */\n isIE7: isIE7,\n /**\n * True if the detected browser is Internet Explorer 8.x.\n *\n * @type Boolean\n */\n isIE8: isIE8,\n /**\n * True if the detected browser is Internet Explorer 9.x.\n *\n * @type Boolean\n */\n isIE9: isIE9,\n /**\n * True if the detected browser is Internet Explorer 10.x.\n *\n * @type Boolean\n */\n isIE10: isIE10,\n /**\n * True if the detected browser uses the Gecko layout engine (e.g. Mozilla,\n * Firefox).\n *\n * @type Boolean\n */\n isGecko: isGecko,\n /**\n * True if the detected browser uses a pre-Gecko 1.9 layout engine (e.g.\n * Firefox 2.x).\n *\n * @type Boolean\n */\n isGecko2: isGecko2,\n /**\n * True if the detected browser uses a Gecko 1.9+ layout engine (e.g.\n * Firefox 3.x).\n *\n * @type Boolean\n */\n isGecko3: isGecko3,\n /**\n * True if the detected browser uses a Gecko 1.9+ layout engine (e.g.\n * Firefox 4.x).\n *\n * @type Boolean\n */\n isGecko4: isGecko4,\n /**\n * True if the detected browser is Internet Explorer running in non-strict\n * mode.\n *\n * @type Boolean\n */\n isBorderBox: isBorderBox,\n /**\n * True if the detected platform is Linux.\n *\n * @type Boolean\n */\n isLinux: isLinux,\n /**\n * True if the detected platform is Windows.\n *\n * @type Boolean\n */\n isWindows: isWindows,\n /**\n * True if the detected platform is Mac OS.\n *\n * @type Boolean\n */\n isMac: isMac,\n /**\n * True if the detected platform is Adobe Air.\n *\n * @type Boolean\n */\n isAir: isAir,\n /**\n * True if the detected browser is Support.\n *\n * @type Boolean\n */\n isSupport: isSupport,\n /**\n * Converts any iterable (numeric indices and a length property) into a\n * true array Don't use this on strings. IE doesn't support \"abc\"[0]\n * which this implementation depends on. For strings, use this instead:\n * \"abc\".match(/./g) => [a,b,c];\n *\n * @param {Iterable} the iterable object to be turned into a true Array.\n * @return (Array) array\n */\n toArray: function () {\n return isIE ? function (a, i, j, res) {\n res = [];\n iNet.each(a, function (v) {\n res.push(v);\n });\n return res.slice(i || 0, j || res.length);\n } : function (a, i, j) {\n return Array.prototype.slice.call(a, i || 0, j || a.length);\n };\n }(),\n /**\n * Copies all the properties of config to obj if they don't already exist.\n *\n * @param {Object} obj The receiver of the properties\n * @param {Object} config The source of the properties\n * @return {Object} returns obj\n */\n applyIf: function (o, c) {\n if (o) {\n for (var p in c) {\n if (iNet.isEmpty(o[p])) {\n o[p] = c[p];\n }\n }\n }\n return o;\n },\n /**\n * Iterates an array or an iterable value and invoke the given callback function for each item.\n *\n * @param {Object} array The item at the current index in the passed array\n * @param {Object} fn The callback function\n * @param {Object} scope (optional) The scope (this reference) in which the specified function is executed.\n */\n each: function (array, fn, scope) {\n if (iNet.isEmpty(array, true)) {\n return;\n }\n for (var i = 0, len = array.length; i < len; i++) {\n if (fn.call(scope || array[i], array[i], i, array) === false) {\n return i;\n }\n }\n },\n /**\n * Creates namespaces to be used for scoping variables and classes so that they are not global. Specifying the last node of a namespace implicitly creates all other nodes.\n * Usage:\n *\n * iNet.namespace('iNet.ui', 'iNet.ui.form');\n *\n * // equivalent and preferable to the above syntax\n * iNet.ns('iNet.ui',, 'iNet.ui.form');\n *\n * iNet.ui.form.Control = function() { ... };\n *\n * @param {String...} namespaces\n * @return {Object} The (last) namespace object created.\n * @member iNet\n * @method namespace\n */\n namespace: function () {\n var o, d;\n iNet.each(arguments, function (v) {\n d = v.split(\".\");\n o = window[d[0]] = window[d[0]] || {};\n iNet.each(d.slice(1), function (v2) {\n o = o[v2] = o[v2] || {};\n });\n });\n return o;\n },\n /**\n * Get parameter from URL\n *\n * @param {String} name The parameter name\n * @param {String} url (optional) The URL\n *\n * @return {String} Returns the value of param\n */\n getParam: function (name, url) {\n if(!!window['ctx_'+ name]) {\n return window['ctx_'+ name];\n }\n name = name.replace(/[\\[]/, \"\\\\\\[\").replace(/[\\]]/, \"\\\\\\]\");\n var regexS = \"[\\\\?&]\" + name + \"=([^&#]*)\";\n var regex = new RegExp(regexS);\n var results = regex.exec(url || window.location.href);\n if (!results) {\n return \"\";\n }\n else {\n return results[1];\n }\n },\n /**\n * Parser html to string\n *\n * @param {String} v the given value\n * @return {String} The new string\n */\n parserHtml: function (v) {\n if (v === undefined || v === null || v.length === undefined) {\n return '';\n }\n v.replace(/</g, \"&lt;\");\n v.replace(/>/g, \"&gt;\");\n v.replace(/\\n/g, '<br />');\n return v;\n },\n /**\n * Generate the identifier.\n * @return {String} The string\n */\n generateId: function () {\n var sid=\"\";\n for (var i=0; i<24; i++)\n {\n sid+=Math.floor(Math.random()*0xF).toString(0xF);\n }\n return sid;\n },\n /**\n * Generate the UUID.\n * @return {String} The string UUID\n */\n generateUUID: function () {\n var d = new Date().getTime();\n var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {\n var r = (d + Math.random() * 16) % 16 | 0;\n d = Math.floor(d / 16);\n return (c == 'x' ? r : (r & 0x3 | 0x8)).toString(16);\n });\n return uuid;\n },\n /**\n * Generate the identifier as alphabet.\n * @return {String} The string\n */\n alphaGenerateId: function () {\n var __id = '';\n var __alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';\n var len = __alphabet.length;\n for (var index = 0; index < len; index++) {\n __id += __alphabet.charAt(Math.floor(Math.random() * len));\n }\n // return the identifier 24 character\n return __id.substr(len - 24);\n },\n /**\n * Returns the current timestamp\n * @param {Number} time (optional) the timestamp\n * @return {Number} The current timestamp\n */\n getDate: function (time) {\n var __time = time || new Date().getTime();\n try {\n return (new Date(__time)).getTime();\n }\n catch (e) {\n return (new Date()).getTime();\n }\n },\n /**\n * Get layout of framework\n * @returns {window} The given window document\n */\n getLayout: function () {\n return window.parent;\n },\n /**\n * Get current Application\n * @return {iNet.app.Application} The current application\n */\n getApp: function(){\n var layout = iNet.getLayout();\n var app= null;\n if(layout && layout.iNet) {\n app = layout.iNet.APP;\n }\n return app;\n },\n /**\n * Return number item of object\n * @param {Object} v The object to get size\n * @return {Number}\n */\n getSize: function (v) {\n var size = 0, key;\n if (iNet.isArray(v)) {\n size = v.length;\n } else if(iNet.isObject(v)) {\n for (key in v) {\n if (v.hasOwnProperty(key)) {\n size++;\n }\n }\n } else {\n size = v.length;\n }\n return size;\n },\n /**\n * Return currency with currency code\n * @deprecated 5.6\n * @param {Number} v The number of currency\n * @returns {String}\n */\n getCurrency: function (v) {\n var __lang = iNet.lang || iNet.language;\n var __numberArr = v.toString().split('.');\n __numberArr[0] = __numberArr[0].replace(/(\\d)(?=(\\d\\d\\d)+(?!\\d))/g, '$1,');\n var __result = __numberArr.join('.');\n switch (__lang) {\n case 'en' : return String.format('{0} USD', __result); break;\n default : return String.format('{0} VND', __result);\n }\n },\n /**\n * Returns the given value itself if it's not empty, as described in {@link iNet#isEmpty}; returns the default\n * value (second argument) otherwise.\n *\n * @param {Object} value The value to test.\n * @param {Object} defaultValue The value to return if the original value is empty.\n * @param {Boolean} [allowBlank=false] `true` to allow zero length strings to qualify as non-empty.\n * @return {Object} value, if non-empty, else defaultValue.\n */\n valueFrom: function(value, defaultValue, allowBlank){\n return iNet.isEmpty(value, allowBlank) ? defaultValue : value;\n },\n /**\n * @property {Function}\n * A reusable empty function.\n */\n emptyFn: function () {},\n /**\n * Create a new function from the provided `fn`, the arguments of which are pre-set to `args`.\n * New arguments passed to the newly created callback when it's invoked are appended after the pre-set ones.\n * This is especially useful when creating callbacks.\n * @param {Function} fn The original function.\n * @param {Array} args The arguments to pass to new callback.\n * @param {Object} scope (optional) The scope (`this` reference) in which the function is executed.\n * @return {Function} The new callback function.\n */\n pass: function(fn, args, scope) {\n if (!iNet.isArray(args)) {\n if (iNet.isIterable(args)) {\n args = iNet.Array.clone(args);\n } else {\n args = args !== undefined ? [args] : [];\n }\n }\n\n return function() {\n var fnArgs = args.slice();\n fnArgs.push.apply(fnArgs, arguments);\n return fn.apply(scope || this, fnArgs);\n };\n },\n /**\n * Overrides members of the specified target with the given values.\n * @param {Object} origclass The class to override\n * @param {Object} overrides The list of functions to add to origClass.\n * This should be specified as an object literal containing one or more methods.\n * @method override\n */\n override: function (origclass, overrides) {\n if (overrides) {\n var p = origclass.prototype;\n iNet.apply(p, overrides);\n if (iNet.isIE && overrides.toString != origclass.toString) {\n p.toString = overrides.toString;\n }\n }\n },\n /**\n * Defines a class or override\n * @param {Function} subclass The class inheriting the functionality\n * @param {Function} superclass The class being extended\n * @param {Object} overrides (optional) A literal with members which are copied\n * into the subclass's prototype, and are therefore shared between all instances of the new class.\n * @return {Function} The subclass constructor.\n * @method extend\n */\n extend: function () {\n // inline overrides\n var io = function (o) {\n for (var m in o) {\n this[m] = o[m];\n }\n };\n var oc = Object.prototype.constructor;\n\n return function (sb, sp, overrides) {\n if (iNet.isObject(sp)) {\n overrides = sp;\n sp = sb;\n sb = overrides.constructor != oc ? overrides.constructor : function () {\n sp.apply(this, arguments);\n };\n }\n var F = function () {\n }, sbp, spp = sp.prototype;\n\n F.prototype = spp;\n sbp = sb.prototype = new F();\n sbp.constructor = sb;\n sb.superclass = spp;\n if (spp.constructor == oc) {\n spp.constructor = sp;\n }\n sb.override = function (o) {\n iNet.override(sb, o);\n };\n sbp.superclass = sbp.supr = (function () {\n return spp;\n });\n sbp.override = io;\n iNet.override(sb, overrides);\n sb.extend = function (o) {\n iNet.extend(sb, o);\n };\n return sb;\n };\n }(),\n getIconByAppName: function (appName, domain) {\n if(iNet.isEmpty(domain) || iNet.isEmpty(appName))\n throw new Error(\"Domain or application name must not empty\");\n var url = new URL(domain);\n var __iconFile = appName.toLowerCase() + '.png';\n return url.origin + url.pathname.substring(0, url.pathname.indexOf(\"/\",2)) +'/images/' + __iconFile;\n },\n /*\n * Load JavaScript file (asynchronously)\n * @param {String} src The URL of an Javascript\n * @return {Function} onLoad The new callback function.\n */\n loadScript: function(src, onLoad) {\n var script = document.createElement('script');\n script.type = 'text/javascript';\n script.src = src;\n if (script.readyState) {\n script.onreadystatechange = function () {\n var state = this.readyState;\n if (state === 'loaded' || state === 'complete') {\n script.onreadystatechange = null;\n onLoad();\n }\n };\n } else {\n script.onload = onLoad;\n }\n document.getElementsByTagName('head')[0].appendChild(script);\n }\n });\n /**\n * Convenient alias for {@link iNet#namespace iNet.namespace}.\n * @inheritdoc iNet#namespace\n * @member iNet\n * @method ns\n */\n iNet.ns = iNet.namespace;\n })();\n\n /**\n * Support URL decode, encode.\n *\n * @class iNet.Url\n *\n */\n iNet.Url = {\n /**\n * URL encoding strings\n * @param string The string to encode\n * @returns {String} The new String\n */\n encode: function (string) {\n return escape(this._utf8_encode(string));\n },\n\n /**\n * URL decoding to string\n * @param string the String to decode\n * @returns {String} The new String\n */\n decode: function (string) {\n return this._utf8_decode(unescape(string));\n },\n //\n /**\n * private method for UTF-8 encoding\n * @param string The string to encode\n * @returns {string} The new String\n * @private\n */\n _utf8_encode: function (string) {\n string = string.replace(/\\r\\n/g, \"\\n\");\n var utftext = \"\";\n\n for (var n = 0; n < string.length; n++) {\n\n var c = string.charCodeAt(n);\n\n if (c < 128) {\n utftext += String.fromCharCode(c);\n }\n else if ((c > 127) && (c < 2048)) {\n utftext += String.fromCharCode((c >> 6) | 192);\n utftext += String.fromCharCode((c & 63) | 128);\n }\n else {\n utftext += String.fromCharCode((c >> 12) | 224);\n utftext += String.fromCharCode(((c >> 6) & 63) | 128);\n utftext += String.fromCharCode((c & 63) | 128);\n }\n }\n return utftext;\n },\n /**\n * private method for UTF-8 decoding\n * @param utftext The string to decode\n * @returns {string} The new String\n * @private\n */\n _utf8_decode: function (utftext) {\n var string = \"\";\n var i = 0;\n var c = 0, c1 = 0, c2 = 0, c3=0;\n\n while (i < utftext.length) {\n\n c = utftext.charCodeAt(i);\n\n if (c < 128) {\n string += String.fromCharCode(c);\n i++;\n }\n else if ((c > 191) && (c < 224)) {\n c2 = utftext.charCodeAt(i + 1);\n string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));\n i += 2;\n }\n else {\n c2 = utftext.charCodeAt(i + 1);\n c3 = utftext.charCodeAt(i + 2);\n string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));\n i += 3;\n }\n }\n return string;\n }\n };\n\n iNet.Template = {\n parse: function (templateId, obj) {\n var templateElement = document.getElementById(templateId);\n var converter = function (data) {\n return data;\n };\n\n function getTemplateText(element) {\n return element.innerHTML.toString();\n }\n\n if (iNet.isFunction(templateElement['converter']))\n converter = templateElement['converter'];\n\n var item = converter(obj);\n\n return getTemplateText(templateElement).replace(/{(\\w+)}/g, function (str, key) {\n return (typeof item[key] !== 'undefined') ? item[key] : '';\n });\n }\n };\n\n /*--------------------------------------------\n | S C O P E F U N C T I O N |\n ============================================*/\n /**\n * These functions are available on every Function object (any JavaScript function).\n * @class Function\n */\n iNet.apply(Function.prototype, {\n /**\n * Creates an interceptor function. The passed fcn is called before the\n * original one. If it returns false, the original one is not called. The\n * resulting function returns the results of the original function. The passed\n * fcn is called with the parameters of the original function.\n *\n * @param {Function} fcn The function to call before the original\n * @param {Object} scope (optional) The scope of the passed fcn (Defaults to scope of original function or window)\n * @return {Function} The new function\n */\n createInterceptor: function (fcn, scope) {\n var method = this;\n return !iNet.isFunction(fcn) ? this : function () {\n var me = this, args = arguments;\n fcn.target = me;\n fcn.method = method;\n return (fcn.apply(scope || me || window, args) !== false) ? method.apply(me || window, args) : null;\n };\n },\n\n /**\n * Creates a callback that passes arguments[0], arguments[1], arguments[2],\n * ... Call directly on any function. Example:\n * myFunction.createCallback(arg1, arg2);\n * //Will create a function that is bound to those 2 args. executes in the window scope.\n *\n * @return {Function} The new function\n */\n createCallback: function () {\n // make args available, in function below\n var args = arguments, method = this;\n return function () {\n return method.apply(window, args);\n };\n },\n\n /**\n * Creates a delegate (callback) that sets the scope to obj. Call directly\n * on any function.\n * Example:\n *\n * this.myFunction.createDelegate(this, [arg1, arg2]);\n * //Will create a function that is automatically scoped to obj so that the <tt>this</tt> variable inside the callback points to obj.\n *\n * @param {Object} obj (optional) The object for which the scope is set\n * @param {Array} args (optional) Overrides arguments for the call. (Defaults to the arguments passed by the caller)\n * @param {Boolean/Number} appendArgs (optional) if True args are appended to call args instead of overriding,\n * if a number the args are inserted at the specified position\n * @return {Function} The new function\n */\n createDelegate: function (obj, args, appendArgs) {\n var method = this;\n return function () {\n var callArgs = args || arguments;\n if (appendArgs === true) {\n callArgs = Array.prototype.slice.call(arguments, 0);\n callArgs = callArgs.concat(args);\n }\n else if (iNet.isNumber(appendArgs)) {\n callArgs = Array.prototype.slice.call(arguments, 0); // copy arguments first\n var applyArgs = [appendArgs, 0].concat(args); // create method call params\n Array.prototype.splice.apply(callArgs, applyArgs); // splice them in\n }\n return method.apply(obj || window, callArgs);\n };\n },\n\n /**\n * Calls this function after the number of millseconds specified, optionally\n * in a specific scope. Example usage:\n *\n * var sayHi = function(name){\n * alert('Hi, ' + name);\n * }\n *\n * // executes immediately:\n * sayHi('Fred');\n *\n * // executes after 2 seconds:\n * Function.defer(sayHi, 2000, this, ['Fred']);\n *\n * // this syntax is sometimes useful for deferring\n * // execution of an anonymous function:\n * Function.defer(function(){\n * alert('Anonymous');\n * }, 100);\n *\n * @param {Number} millis The number of milliseconds for the setTimeout call (if\n * less than or equal to 0 the function is executed immediately)\n * @param {Object} obj (optional) The object for which the scope is set\n * @param {Array} args (optional) Overrides arguments for the call. (Defaults to the arguments passed by the caller)\n * @param {Boolean/Number} appendArgs (optional) if True args are appended to call args instead of overriding,\n * if a number the args are inserted at the specified position\n * @return {Number} The timeout id that can be used with clearTimeout\n */\n defer: function (millis, obj, args, appendArgs) {\n var fn = this.createDelegate(obj, args, appendArgs);\n if (millis > 0) {\n return setTimeout(fn, millis);\n }\n fn();\n return 0;\n }\n });\n\n /**\n * Provides the methods of sending messages. Recieving messages is the same in both of available Plugin classes\n * @class iNet.PluginManager\n */\n iNet.PluginManager = {\n /**\n * Add EventListener to Listen to message from window\n * @param element - A DOM element\n * @param eventName - The event to listen\n * @param eventHandler - The callback to execute\n */\n bindEvent: function (element, eventName, eventHandler) {\n if (element.addEventListener) {\n element.addEventListener(eventName, eventHandler, false);\n } else if (element.attachEvent) {\n element.attachEvent('on' + eventName, eventHandler);\n }\n },\n /**\n * Send a message to the window\n * @param msg - The data to send\n * @param contentWindow - The window object\n */\n sendMessageTo: function (msg, contentWindow) {\n contentWindow = contentWindow || window.parent;\n // Make sure you are sending a string, and to stringify JSON\n contentWindow.postMessage(msg, '*');\n },\n /**\n * Send message to parent window\n * @param msg - The data to send\n */\n sendMessage: function(msg) {\n iNet.PluginManager.sendMessageTo(msg, window.parent);\n }\n };\n /**\n * Copyright (c) 2016 by Vy Nguyen (ntvy@inetcloud.vn)\n *\n * Created by ntvy on 14:55 25/03/2016\n *\n */\n\n /*--------------------------------------------\n | S T R I N G |\n ============================================*/\n /**\n * A collection of useful static methods to deal with strings.\n *\n * `String` is a global object that may be used to construct String instances.\n *\n * For example:\n *\n * var s1 = \"2 + 2\"; // creates a string primitive\n * var s2 = new String(\"2 + 2\"); // creates a String object\n *\n * @class String\n */\n iNet.applyIf(String, {\n /**\n * @property {Number} length\n * Reflects the length of the string.\n */\n /**\n * @method charAt\n * Returns the character at the specified index.\n */\n /**\n * @method charCodeAt\n * Returns a number indicating the Unicode value of the character at the given index.\n */\n /**\n * @method concat\n * Combines combines the text from one or more strings and returns a new string. Changes to the text in\n * one string do not affect the other string.\n */\n /**\n * @method indexOf\n * Returns the index within the calling `String` object of the first occurrence of the specified value,\n * or -1 if not found.\n */\n /**\n * @method lastIndexOf\n * Returns the index within the calling String object of the last occurrence of\n * the specified value, or -1 if not found. The calling string is searched\n * backward, starting at fromIndex.\n */\n /**\n * @method replace\n * Used to find a match between a regular expression and a string, and to replace the matched substring\n * with a new substring.\n */\n /**\n * @method search\n * Executes the search for a match between a regular expression and a specified string.\n */\n /**\n * @method slice\n * Extracts a section of a string and returns a new string.\n */\n /**\n * @method split\n * Splits a `String` object into an array of strings by separating the string into substrings.\n */\n /**\n * @method substr\n * Returns the characters in a string beginning at the specified location through the specified number\n * of characters.\n */\n /**\n * @method substring\n * Returns the characters in a string between two indexes into the string.\n */\n /**\n * @method toLocaleLowerCase\n * The characters within a string are converted to lower case while respecting the current locale. For\n * most languages, this will return the same as `toLowerCase`.\n */\n /**\n * @method toLowerCase\n * Returns the calling string value converted to lower case.\n */\n /**\n * @method toString\n * Returns a string representing the specified object. Overrides the `Object.toString` method.\n */\n /**\n * @method toUpperCase\n * Returns the calling string value converted to uppercase.\n */\n /**\n * @method valueOf\n * Returns the primitive value of the specified object. Overrides the `Object.valueOf` method.\n */\n /**\n * Allows you to define a tokenized string and pass an arbitrary number of\n * arguments to replace the tokens.\n * Example usage:\n *\n * var cls = 'my-class',\n * text = 'Some text';\n * var s = String.format('<div class=\"{0}\">{1}</div>', cls, text);\n * // s now contains the string: '<div class=\"my-class\">Some text</div>'\n * @param {String} format The values to replace tokens `{0}`, `{1}`, etc in order.\n * @return {String} The form