1'use strict'; 2if(typeof JwTplJsLib !== 'object') { 3 var JwTplJsLib = (function(){ 4 const 5 op = 'jwtpl-sys-bodyAppDvOP', 6 ol = 'jwtpl-sys-bodyAppDvOL', 7 localHosts = ['localhost', '127.0.0.1', 'ad.sites.jobware.net', 'ai.sites.jobware.net', 'at.sites.jobware.net', 'am.sites.jobware.net'], 8 allowedRequestMethod = ['get', 'post', 'put', 'delete', 'patch', 'head', 'connect', 'options', 'trace'], 9 infoColor = '#007bff', 10 errorColor = '#ce0000'; 11 12 let 13 appName = "JwTplJsLib", 14 tplPrototype = '<#{tag}#{attr}>#{data}</#{tag}>', 15 guiTagPattern = '[data-jwtpl-sys-gui^="#{pattern}"]', 16 getByGuiTagPattern = '[data-jwtpl-sys-gui*="mn:${mod}"][data-jwtpl-sys-gui*="si:${skin}"][data-jwtpl-sys-gui*="tv:${version}"]', 17 dataStorage = [], 18 propStorage = [], 19 myLibsInit = false, 20 myLibs = {}, 21 logStorage = new Map(), 22 guiTagStorage = new Map(), 23 hasInitRun = false, 24 easyTooltipYOffset = 30, 25 getUrlAndCacheItVersion = 1, 26 getUrlAndCacheItOldVersions = []; 27 28 function setStorageItem(id,item){ 29 if(typeof dataStorage[id] === 'undefined'){ 30 dataStorage[id] = item; 31 } 32 } 33 34 function getStorageItem(id){ 35 return dataStorage[id]; 36 } 37 38 function setPropStorageItem(id,item){ 39 if(typeof propStorage[id] === 'undefined'){ 40 propStorage[id] = item; 41 } 42 } 43 44 function getPropStorageItem(id){ 45 return propStorage[id]; 46 } 47 48 function getAppGui() { 49 if(guiTagStorage.size > 0){return guiTagStorage;} 50 let appGui = JwTplJsLib.get('[data-jwtpl-sys-appgui]'); 51 if(appGui.length !== 1){return false;} 52 appGui = appGui[0].getAttribute('data-jwtpl-sys-appgui'); 53 appGui = appGui.split('|'); 54 JwTplJsLib.each(appGui, (it) => { 55 it = it.split('.'); 56 if(it.length === 3){ 57 guiTagStorage.set(it[0], it.slice(1)); 58 } 59 }); 60 return guiTagStorage; 61 } 62 63 return { 64 init: function(baseName, projectPath) { 65 if(hasInitRun === false){ 66 this._gui().init(); 67 this._cc().init(); 68 this._tpl().init(); 69 70 if(this._ptc() !== false ){ 71 this._ptc().initPtc(); 72 } 73 74 //:ToDo consent init 75 //:ToDo trid init 76 //:ToDo noli init 77 78 hasInitRun = true; 79 } 80 81 return hasInitRun; 82 }, 83 84 getHasInitRun: function (){ 85 return hasInitRun; 86 }, 87 88 reInit: function (){ 89 this._gui().reInit(); 90 return true; 91 }, 92 93 //@deprecated 94 ready : function(fn){ 95 if (document.readyState !== 'loading') { 96 fn(); 97 } else if (document.addEventListener) { 98 document.addEventListener('DOMContentLoaded', fn); 99 } else { 100 document.attachEvent('onreadystatechange', function () { 101 if (document.readyState !== 'loading'){ 102 fn(); 103 } 104 }); 105 } 106 }, 107 108 domOnload : function(fn) { 109 document.addEventListener('DOMContentLoaded', fn); 110 }, 111 112 isReady: function() { 113 return document.ready !== 'loading'; 114 }, 115 116 runIsReady: function(fn) { 117 if(this.isReady() === true){ 118 fn(); 119 return true; 120 } 121 return false; 122 }, 123 124 initLibs : function (){ 125 if (myLibsInit === false) { 126 if (typeof JwTplJsLibNoli == "object") { 127 myLibs['noli'] = JwTplJsLibNoli; 128 } else { 129 myLibs['noli'] = false; 130 } 131 if (typeof JwTplJsLibJoma == "object") { 132 myLibs['joma'] = JwTplJsLibJoma; 133 } else { 134 myLibs['joma'] = false; 135 } 136 if (typeof JwTplJsLibTrid == "object") { 137 myLibs['trid'] = JwTplJsLibTrid; 138 } else { 139 myLibs['trid'] = false; 140 } 141 if (typeof JwTplJsLibSaseli == "object") { 142 myLibs['saseli'] = JwTplJsLibSaseli; 143 } else { 144 myLibs['saseli'] = false; 145 } 146 if (typeof JwTplJsLibConsent == "object") { 147 myLibs['consent'] = JwTplJsLibConsent; 148 } else { 149 myLibs['consent'] = false; 150 } 151 152 if (typeof JwTplJsLibPtc == "object") { 153 myLibs['ptc'] = JwTplJsLibPtc; 154 } else { 155 myLibs['ptc'] = false; 156 } 157 158 myLibsInit = true; 159 } 160 }, 161 162 _noli:function () { if (myLibsInit === true) { return myLibs['noli']; } else { return false; }}, 163 _joma:function () { if (myLibsInit === true) { return myLibs['joma']; } else { return false; }}, 164 _trid:function () { if (myLibsInit === true) { return myLibs['trid']; } else { return false; }}, 165 _saseli:function () { if (myLibsInit === true) { return myLibs['saseli'];} else { return false; }}, 166 _consent:function() { if (myLibsInit === true) { return myLibs['consent'];} else { return false; }}, 167 _ptc:function() { if (myLibsInit === true) { return myLibs['ptc'];} else { return false; }}, 168 169 getMarketInfo: function(param) { 170 171 const allowedParams = new Map(); 172 allowedParams.set('addons',myLibs['ptc'].getAddons()); 173 allowedParams.set('adv',myLibs['ptc'].getPageAdv()); 174 allowedParams.set('advLink',myLibs['ptc'].getPageAdvLink()); 175 allowedParams.set('appSpuch',myLibs['ptc'].getAppSpuch()); 176 allowedParams.set('cat',myLibs['ptc'].getCat()); 177 allowedParams.set('catId',myLibs['ptc'].getCatId()); 178 allowedParams.set('cnt',myLibs['ptc'].getCnt()); 179 allowedParams.set('date',myLibs['ptc'].getPageDate()); 180 allowedParams.set('jobId',myLibs['ptc'].getPageJobId()); 181 allowedParams.set('jobJmId',myLibs['ptc'].getPageJobJmId()); 182 allowedParams.set('jsjn',myLibs['ptc'].getJsJn()); 183 allowedParams.set('jsjo',myLibs['ptc'].getJsJo()); 184 allowedParams.set('jsjr',myLibs['ptc'].getJsJr()); 185 allowedParams.set('jt',myLibs['ptc'].getJt()); 186 allowedParams.set('liq',myLibs['ptc'].getLiq()); 187 allowedParams.set('loc',myLibs['ptc'].getPageLoc()); 188 allowedParams.set('logo',myLibs['ptc'].getLogo()); 189 allowedParams.set('md',myLibs['ptc'].getMd()); 190 allowedParams.set('seg',myLibs['ptc'].getSeg()); 191 allowedParams.set('sort',myLibs['ptc'].getSort()); 192 allowedParams.set('title',myLibs['ptc'].getPageTitle()); 193 allowedParams.set('url',myLibs['ptc'].getPageUrl()); 194 195 if(allowedParams.has(param)){ 196 return allowedParams.get(param); 197 } 198 return this.printErrorMsg(".getMarketInfo(selector) - selector param is unknown"); 199 }, 200 201 getBaseName: function() { 202 let b = Object.keys(window).join('|').split('jwTplJsLibObject_'); 203 if(b.length == 2) { 204 b[1] += '|1'; 205 let b2 = b[1].split('|'); 206 if(b2.length >= 2) { 207 return 'jwTplJsLibObject_' + b2[0]; 208 } 209 } 210 return ''; 211 }, 212 213 getBaseObject: function() { 214 return this.type(window[this.getBaseName()])!== undefined ? window[this.getBaseName()] : false; 215 }, 216 217 getBaseCfg: function(key, defaultText = '') { 218 return this.getBaseObject()._globalGetCfg(key, defaultText); 219 }, 220 221 getProjectPath: function(){ 222 if(this.getBaseObject() !== false) { 223 return this.getBaseObject()._globalGetPath(); 224 } 225 return ''; 226 }, 227 228 getCurrentUrl: function() { 229 return window.location.href; 230 }, 231 232 get : function(selector, noCache = false){
233 if(this.type(selector) === undefined){ 234 this.printErrorMsg(".get(selector, noCache) - selector param is undefined"); 235 return false; 236 } 237 238 if(this.type(selector) !== 'String'){ 239 this.printErrorMsg(".get(selector, noCache) - selector param must be a string, [" + this.type(selector) + "] given instead"); 240 return false; 241 } 242 243 if(this.type(selector) === 'String' && selector.length < 1){ 244 this.printErrorMsg(".get(selector, noCache) - element param must be a not empty string"); 245 return false; 246 } 247 248 if(this.type(noCache) !== undefined && this.type(noCache) !== 'Boolean'){ 249 this.printErrorMsg(".get(selector, noCache) - noCache must be a boolean"); 250 return false; 251 } 252 253 if(noCache === true){ 254 try { 255 return document.querySelectorAll(selector); 256 } catch(e) { 257 this.printErrorMsg(".get(selector, noCache) - " + e); 258 return document.createDocumentFragment().childNodes; 259 } 260 } 261 262 let 263 itemHash = this.md5(selector), 264 storageItem = getStorageItem(itemHash); 265 266 if(this.type(storageItem) === undefined){ 267 let domElement; 268 try { 269 domElement = document.querySelectorAll(selector); 270 } catch(e) { 271 this.printErrorMsg(".get(selector, noCache) - " + e); 272 return document.createDocumentFragment().childNodes; 273 } 274 275 if(domElement.length > 0){ 276 setStorageItem(itemHash, domElement); 277 return getStorageItem(itemHash); 278 } 279 return domElement; 280 281 } else { 282 return storageItem; 283 } 284 }, 285 286 getByGuiTag: function(mod, skin, version = 'df') { 287 if(this.isStringRaw(mod) === true){ 288 mod = this.trim(mod); 289 mod = mod.toLowerCase(); 290 } else { 291 this.printErrorMsg(".getByGuiTag(mod, skin, version) - mod as string required"); 292 return false; 293 } 294 if(this.isInt(skin) === false || (this.isInt(skin) === true && skin < 1)){ 295 this.printErrorMsg(".getByGuiTag(mod, skin, version) - skin as int > 0 required"); 296 return false; 297 } 298 if(this.isStringRaw(version) === true){ 299 version = this.trim(version); 300 version = version.toLowerCase(); 301 if(['ov', 'df', 'rv'].includes(version) === false){ 302 this.printErrorMsg(".getByGuiTag(mod, skin, version) - version as 'ov', 'df' or 'rv' allowed"); 303 return false; 304 } 305 } else { 306 this.printErrorMsg(".getByGuiTag(mod, skin, version) - version as string required"); 307 return false; 308 } 309 310 let pattern = getByGuiTagPattern.replace('${mod}', mod).replace('${skin}', skin).replace('${version}', version); 311 return this.get(pattern, true); 312 }, 313 314 type : function (data, prototype) { 315 if (typeof (data) === 'undefined') { 316 return undefined; 317 } else if (data === null) { 318 return undefined; 319 } else { 320 let 321 context = data.constructor.toString().trim(); 322 323 if(context.indexOf('function') !== -1) { 324 context = context.substring(8, context.indexOf('(')).trim(); 325 } else if (context.indexOf('class') !== -1) { 326 context = context.substring(6, context.indexOf('{')).trim(); 327 } 328 329 return context; 330 } 331 }, 332 333 event : function (domElement, eventType, callback) { 334 if(this.type(domElement) === undefined){ 335 this.printErrorMsg(".event(domElement, eventType, callback) - domElement is undefined"); 336 return false; 337 } 338 339 if(this.type(eventType) !== 'String'){ 340 this.printErrorMsg(".event(domElement, eventType, callback) - eventType must be a string, [" + this.type(eventType) + "] given instead"); 341 return false; 342 } 343 344 if(this.type(eventType) === 'String' && eventType.length < 1){ 345 this.printErrorMsg(".event(domElement, eventType, callback) - eventType must be a not emtpy string"); 346 return false; 347 } 348
349 if(this.type(callback) === undefined){ 350 this.printErrorMsg(".event(domElement, eventType, callback) - you need to specify callback function"); 351 return false; 352 } 353 354 if(this.type(callback) !== 'Function'){ 355 this.printErrorMsg(".event(domElement, eventType, callback) - callback must be a function, [" + this.type(callback) + "] given instead"); 356 return false; 357 } 358 359 if (this.type(domElement.addEventListener) !== undefined){ 360 domElement.addEventListener(eventType, callback); 361 } else if (this.type(domElement.attachEvent) !== undefined){ 362 domElement.attachEvent("on" + eventType, callback); 363 } 364 365 return true; 366 }, 367 368 each : function (object, callback) { 369 if(this.type(object) === undefined){ 370 this.printErrorMsg(".each(object, callback) - element is undefined"); 371 return false; 372 } 373 374 if(this.type(callback) !== 'Function'){ 375 this.printErrorMsg(".each(object, callback) - callback must be a function, [" + this.type(callback) + "] given instead"); 376 return false; 377 } 378 379 let 380 type = this.type(object), 381 len = object.length; 382 383 if(type === 'String' || type === 'Array' || type === 'DOMTokenList'){ 384 for (let i = 0; i < len; i++) { 385 callback(object[i], i, this); 386 } 387 } 388 389 if (type === 'NodeList' || type === 'HTMLCollection') { 390 for (let i = 0; i < len; i++) { 391 callback(object.item(i), i, this); 392 } 393 } 394 395 if (type === 'Object') { 396 for (let i in object) { 397 callback(object[i], i, this); 398 } 399 } 400 }, 401 402 getUrlAndCacheIt: function(url, options = {'cache': true, 'storage': 'session', 'validTimeSec': 3600}) { 403 if(this.type(url) !== 'String'){ 404 this.printErrorMsg(".getUrlAndCacheIt(url, options)- url must be a string, [" + this.type(url) + "] given instead"); 405 return false; 406 } 407 if(this.isStringNotEmpty(url) === false){ 408 this.printErrorMsg(".getUrlAndCacheIt(url, options)- url must be a not empty string"); 409 return false; 410 } 411 if(options.hasOwnProperty('cache') === false || this.isBool(options.cache) === false){ 412 this.printErrorMsg(".getUrlAndCacheIt(url, options)- options.cache must be boolean"); 413 return false; 414 } 415 if(options.hasOwnProperty('storage') === false || ['session', 'local'].includes(options.storage) === false){ 416 this.printErrorMsg(".getUrlAndCacheIt(url, options)- options.storage type must be local or session"); 417 return false; 418 } 419 if(options.hasOwnProperty('validTimeSec') === false || this.isInt(options.validTimeSec) === false || options.validTimeSec < 60) { 420 this.printErrorMsg(".getUrlAndCacheIt(url, options)- options.validTimeSec must be integer and > 60 Sec"); 421 return false; 422 } 423 424 let 425 data = false, 426 cacheData = false, 427 writeData = {'ts': this.time.millis() + (options.validTimeSec * 1000), 'realData': ''}, 428 getIt = false, 429 cleanIt = false, 430 xhr = new XMLHttpRequest(), 431 storageKey = this.md5(url) + '_' + getUrlAndCacheItVersion; 432 433 if(options.cache === true) { 434 if(options.storage === 'local') { 435 if(localStorage.getItem(storageKey) !== null) { 436 cacheData = localStorage.getItem(storageKey); 437 } 438 } else { 439 if(sessionStorage.getItem(storageKey) !== null) { 440 cacheData = sessionStorage.getItem(storageKey); 441 } 442 } 443 if(cacheData === false) { 444 getIt = true; 445 } else { 446 cacheData = this.jsonParse(cacheData); 447 if(cacheData !== false && cacheData.hasOwnProperty('ts') === true && cacheData.hasOwnProperty('realData') === true && this.time.millis() < cacheData.ts) { 448 data = cacheData.realData; 449 } else { 450 getIt = true; 451 } 452 } 453 } else { 454 getIt = true; 455 } 456 457 if(getIt === true && this.type(xhr) === 'XMLHttpRequest') { 458 xhr.onreadystatechange = function () { 459 if (xhr.readyState == 4 && xhr.status == 200) { 460 try { 461 data = xhr.responseText; 462 if(options.cache === true) { 463 writeData.realData = data; 464 var writeDataStr = JwTplJsLib.jsonStringify(writeData); 465 if(writeDataStr !== false) { 466 if(options.storage === 'local') { 467 localStorage.setItem(storageKey, writeDataStr); 468 } else { 469 sessionStorage.setItem(storageKey, writeDataStr); 470 } 471 } 472 } 473 } catch (err) { 474 return false; 475 } 476 } 477 }; 478 479 xhr.open('GET', url, false); 480 xhr.send(); 481 } 482
483 if(cleanIt === true && this.isArray(getUrlAndCacheItOldVersions) === true) { 484 if(options.cache === false) { 485 getUrlAndCacheItOldVersions.push(getUrlAndCacheItVersion); 486 } 487 if(getUrlAndCacheItOldVersions.length > 0) { 488 this.each(getUrlAndCacheItOldVersions, (it) => { 489 localStorage.removeItem(this.md5(url) + '_' + it); 490 sessionStorage.removeItem(this.md5(url) + '_' + it); 491 }); 492 } 493 } 494 495 return data; 496 }, 497 498 ajax: function (options) { 499 if (this.type(options) !== 'Object') { 500 this.printErrorMsg(".ajax() - function parameter must be object like {url:'hostName', method: 'post', callback : function(){}}"); 501 return false; 502 } 503 504 if (options.hasOwnProperty('url') === false) { 505 this.printErrorMsg(".ajax() - options parameter must contain url like {url:'hostName', method: 'post', callback : function(){}}"); 506 return false; 507 } else { 508 if (this.type(options.url) !== 'String') { 509 this.printErrorMsg(".ajax() - options parameter url must be a string"); 510 return false; 511 } 512 513 if (this.type(options.url) === 'String' && options.url.length < 1) { 514 this.printErrorMsg(".ajax() - options parameter url must be a not empty string"); 515 return false; 516 } 517 } 518 519 if (options.hasOwnProperty('method') === false) { 520 this.printErrorMsg(".ajax() - options parameter must contain method like {url:'hostName', method: 'post', callback : function(){}}"); 521 return false; 522 } else { 523 if (this.type(options.method) !== 'String') { 524 this.printErrorMsg(".ajax() - options parameter method must be a string"); 525 return false; 526 } 527 528 if (this.type(options.method) === 'String' && options.method.length < 1) { 529 this.printErrorMsg(".ajax() - options parameter method must be a not empty string"); 530 return false; 531 } 532 533 let methodAllowed = false; 534 535 for (let i = 0; i < allowedRequestMethod.length; i++) { 536 if (options.method.toLowerCase() === allowedRequestMethod[i]) { 537 methodAllowed = true; 538 break; 539 } 540 } 541 542 if (methodAllowed === false) { 543 this.printErrorMsg(".ajax() - unknown request method [" + options.method + "]. allowed request methods are: " + allowedRequestMethod.join()); 544 return false; 545 } 546 } 547 548 if (options.hasOwnProperty('callback') === false) { 549 this.printErrorMsg(".ajax() - options parameter must contain callback function like {url:'hostName', method: 'post', callback : function(){}}"); 550 return false; 551 } else { 552 if (this.type(options.callback) !== 'Function') { 553 this.printErrorMsg(".ajax() - options parameter callback must be a valid function"); 554 return false; 555 } 556 } 557 558 if(options.hasOwnProperty('data') === true && this.type(options.data) !== 'String'){ 559 this.printErrorMsg(".ajax() - data parameter must be string, no matter xml or json"); 560 return false; 561 } 562 563 let 564 url = options.url, 565 method = options.method, 566 callback = options.callback, 567 data = options.data, 568 headers = options.headers, 569 xhr; 570 571 if (window.XMLHttpRequest) { 572 xhr = new XMLHttpRequest(); 573 } else if (window.ActiveXObject) { 574 xhr = new ActiveXObject("Microsoft.XMLHTTP"); 575 } 576 577 xhr.onreadystatechange = function () { 578 if (xhr.readyState === 4 && xhr.status === 200) { 579 callback(xhr.responseText); 580 } 581 } 582 583 try { 584 xhr.open(method, url, true); 585 } catch (DOMException) { 586 this.printErrorMsg(".ajax() - " + DOMException); 587 return false; 588 } 589
590 if(this.type(headers) !== undefined && this.type(headers) === 'Object'){ 591 this.each(headers, function(headerValue, headerKey){ 592 xhr.setRequestHeader(headerKey,headerValue); 593 }); 594 } 595 596 try { 597 if (this.type(data) !== undefined) { 598 xhr.send(data); 599 } else { 600 xhr.send(); 601 } 602 } catch (DOMException) { 603 this.printErrorMsg(".ajax() - " + DOMException); 604 return false; 605 } 606 607 return true; 608 }, 609 610 setLcItem: function(key, value, asSession = false) { 611 if(this.type(localStorage) !== undefined && this.type(sessionStorage) !== undefined){ 612 if(this.type(key) === undefined){ 613 this.printErrorMsg(".setLcItem(key, value) - key must be defined"); 614 return false; 615 } else if(this.type(key) !== 'String'){ 616 this.printErrorMsg(".setLcItem(key, value) - key must be string, [" + this.type(key) + "] given instead"); 617 return false; 618 } else if(this.type(key) === 'String' && this.trim(key) === ''){
619 this.printErrorMsg(".setLcItem(key, value) - key must be not empty string"); 620 return false; 621 } 622 623 if(this.type(value) === undefined){ 624 this.printErrorMsg(".setLcItem(key, value) - value must be defined"); 625 return false; 626 } else if(this.type(value) !== 'String'){ 627 this.printErrorMsg(".setLcItem(key, value) - value must be string, [" + this.type(value) + "] given instead"); 628 return false; 629 } 630 631 if(this.isString(this.getProjectPath()) === false){ 632 this.printErrorMsg(".setLcItem(key) - domain string is empty or not defined"); 633 return false; 634 } 635 636 key = this.md5(this.getProjectPath() + key); 637 638 if(asSession === true){ 639 sessionStorage.setItem(key, value); 640 } else { 641 localStorage.setItem(key, value); 642 } 643 644 return true; 645 646 } else { 647 this.printErrorMsg(".setLcItem(key, value) - no support for localStorage/sessionStorage object"); 648 return false; 649 } 650 }, 651 652 getLcItem: function(key, asSession = false) { 653 if(this.type(localStorage) !== undefined && this.type(sessionStorage) !== undefined){ 654 if(this.type(key) === undefined){ 655 return localStorage; 656 } else if(this.type(key) !== 'String'){ 657 this.printErrorMsg(".getLcItem(key) - key must be string, [" + this.type(key) + "] given instead"); 658 return false; 659 } else if(this.type(key) === 'String' && this.trim(key) === ''){
660 this.printErrorMsg(".getLcItem(key) - key must be not empty string"); 661 return false; 662 } 663 664 if(this.isString(this.getProjectPath()) === false){ 665 this.printErrorMsg(".getLcItem(key) - domain string is empty or not defined"); 666 return false; 667 } 668 669 key = this.md5(this.getProjectPath() + key); 670 671 if(this.type(localStorage.getItem(key)) === undefined) { 672 this.printInfoMsg(".getLcItem(key) - the key [" + key + '] doesnt exists'); 673 return false; 674 } else { 675 if(asSession === true){ 676 return sessionStorage.getItem(key); 677 } else { 678 return localStorage.getItem(key); 679 } 680 } 681 682 } else { 683 this.printErrorMsg(".getLcItem(key) - no support for localStorage/sessionStorage object"); 684 return false; 685 } 686 }, 687 688 removeLcItem: function(key, asSession = false) { 689 if(this.type(localStorage) !== undefined && this.type(sessionStorage) !== undefined){ 690 if(this.type(key) === undefined){ 691 this.printErrorMsg(".removeLcItem(key) - key must be defined"); 692 return false; 693 } else if(this.type(key) !== 'String'){ 694 this.printErrorMsg(".removeLcItem(key) - key must be string, [" + this.type(key) + "] given instead"); 695 return false; 696 } else if(this.type(key) === 'String' && this.trim(key) === ''){
697 this.printErrorMsg(".removeLcItem(key) - key must be not empty string"); 698 return false; 699 } 700 701 if(this.isString(this.getProjectPath()) === false){ 702 this.printErrorMsg(".removeLcItem(key) - domain string is empty or not defined"); 703 return false; 704 } 705 706 key = this.md5(this.getProjectPath() + key); 707 708 if(asSession === true) { 709 sessionStorage.removeItem(key); 710 return true; 711 } else { 712 localStorage.removeItem(key); 713 return true; 714 } 715 } else { 716 this.printErrorMsg(".removeLcItem(key) - no support for localStorages/sessionStorage object"); 717 return false; 718 } 719 }, 720 721 getLcLength: function() { 722 if(this.type(localStorage) !== undefined){ 723 return localStorage.length; 724 } else { 725 this.printErrorMsg(".getLcLength() - no support for localStorage object"); 726 return false; 727 } 728 }, 729 730 clearLc: function() { 731 if(this.type(localStorage) !== undefined){ 732 localStorage.clear(); 733 return true; 734 } else { 735 this.printErrorMsg(".getLcItem(key) - no support for localStorage object"); 736 return false; 737 } 738 }, 739 740 jsonParse: function(str) { 741 if(this.isString(str) === false){ 742 this.printErrorMsg(".parseJson(str) - function parameter must be a string"); 743 return false; 744 } 745 746 try{ 747 var json = JSON.parse(str); 748 return json; 749 } catch(e) { 750 return false; 751 } 752 }, 753 754 jsonStringify: function(json){ 755 if(this.type(json) !== 'Object'){ 756 this.printErrorMsg(".jsonStringify(json) - function parameter must be a JSON"); 757 return false; 758 } 759 760 try{ 761 var str = JSON.stringify(json); 762 return str; 763 } catch(e) { 764 return false; 765 } 766 }, 767 768 isJson: function(str){ 769 try{ 770 var json = JSON.parse(str); 771 return (typeof json === 'object'); 772 } catch(e) { 773 return false; 774 } 775 }, 776 777 assignTpl: function(data){ 778 if(this.type(data) !== 'Object'){ 779 this.printErrorMsg('.assignTpl(data) data must be an object or json like: {"tag": "div","tagData": "div content","tagAttr": {"id" : "jwtpl-dataLink"}}'); 780 return false; 781 } 782 783 if(data.hasOwnProperty('tag') === false){ 784 this.printErrorMsg('.assignTpl(data) data must have at least tag property like: {"tag": "div","tagData": "div content","tagAttr": {"id" : "jwtpl-dataLink"}}'); 785 return false; 786 } 787 788 var tpl = tplPrototype; 789 790 this.each(data, function(data, key, _this){ 791 if(key === 'tag') { 792 tpl = tpl.replace(/#{tag}/g, data); 793 } 794 795 if(key === 'tagData'){ 796 tpl = tpl.replace("#{data}", data); 797 } 798 799 if(key === 'tagAttr'){ 800 var attr = ''; 801 _this.each(data, function(d, n){ 802 attr += " " + n + '="' + d +'"'; 803 });
804 tpl = tpl.replace("#{attr}", attr); 805 } 806 }); 807 808 tpl = tpl.replace("#{attr}", ''); 809 return tpl; 810 }, 811 812 getModal: function(text, title) { 813 if(this.isString(text) === false){ 814 this.printErrorMsg('.getModal(text, title) - text parameter must be a not empty string'); 815 return false; 816 } 817 818 if(this.type(title) !== undefined && this.isString(title) === false){ 819 this.printErrorMsg('.getModal(text, title) - text parameter must be a not empty string'); 820 return false; 821 } 822 823 var 824 body, 825 modal, 826 titleBlock, 827 textBlock, 828 closeIcon; 829 830 if(this.type(title) !== undefined){ 831 titleBlock = this.assignTpl({ 832 'tag': 'h3', 833 'tagData': title, 834 'tagAttr': { 835 'class': 'jwtpl-sysModal-title' 836 } 837 }); 838 } 839 840 closeIcon = this.assignTpl({ 841 'tag': 'span', 842 'tagData': '', 843 'tagAttr': { 844 'class': 'jwtpl-gc-etclose jwtpl-sysModal-closeIcon' 845 } 846 }); 847 848 textBlock = this.assignTpl({ 849 'tag': 'div', 850 'tagData': text, 851 'tagAttr': { 852 'class': 'jwtpl-sysModal-text' 853 } 854 }); 855 856 if(this.type(titleBlock) !== undefined) { 857 modal = this.assignTpl({ 858 'tag': 'div', 859 'tagData': closeIcon + titleBlock + textBlock, 860 'tagAttr': { 861 'class': 'jwtpl-sysModal-inner fadeIn' 862 } 863 }); 864 } else { 865 modal = this.assignTpl({ 866 'tag': 'div', 867 'tagData': closeIcon + textBlock, 868 'tagAttr': { 869 'class': 'jwtpl-sysModal-inner fadeIn' 870 } 871 }); 872 } 873 874 modal = this.parseHTML(modal); 875 if(this.type(modal) !== 'HTMLCollection') { 876 this.printErrorMsg('.getModal(text, title) - cannot parse given html. error'); 877 return false; 878 } 879 880 body = this.get('body'); 881 if(body.length > 0){ 882 this.event(body[0], 'click', function(e){ 883 if(JwTplJsLib.hasClass(e.target, 'jwtpl-gc-etclose') === true){ 884 var modal = e.target.parentElement; 885 if(JwTplJsLib.type(modal) !== undefined){ 886 try { 887 body[0].removeChild(modal); 888 return true; 889 } catch(ex){ 890 JwTplJsLib.printErrorMsg('.getModal(text, title) - ' + ex); 891 return false; 892 } 893 894 } else { 895 this.printErrorMsg('.getModal(text, title) - no close trigger tag found. error'); 896 return false; 897 } 898 } 899 }); 900 } else { 901 this.printErrorMsg('.getModal(text, title) - no body tag found. error'); 902 return false; 903 } 904 905 $('body').prepend(modal); 906 }, 907 908 isTooltipOpen: function() { 909 return this.get('.jwtpl-sysTooltip-inner', true).length > 0; 910 }, 911 912 tooltip: function(options) { 913 if(this.isString(options) === false && this.isObject(options) === false){ 914 this.printErrorMsg(".tooltip(options) - options must either string or object"); 915 return false; 916 } 917 918 if(this.isObject(options) === true && options.hasOwnProperty('text') === false){ 919 this.printErrorMsg(".tooltip(options) - options must have at least text property"); 920 return false; 921 } 922 923 if(options.hasOwnProperty('text') === true && this.isString(options.text) === false){ 924 this.printErrorMsg(".tooltip(options) - text property must be string"); 925 return false; 926 } 927 928 let body = this.get('body'); 929 930 if(options.hasOwnProperty('noKill') === true && this.isBool(options.noKill) === true && options.noKill === true) { 931 932 } else { 933 let existingTooltips = this.get('.jwtpl-sysTooltip-inner', true); 934 935 if (existingTooltips.length > 0) { 936 this.each(existingTooltips, (it) => { 937 it.remove(); 938 }); 939 } 940 } 941 942 if(body.length > 0) { 943 let 944 tooltip = document.createElement('div'), 945 closeIcon = document.createElement('div'), 946 text = document.createElement('span'), 947 type = ''; 948 949 this.style(body[0], 'position', 'relative'); 950 this.addClass(tooltip, 'jwtpl-gc-hidden1 jwtpl-sysTooltip-inner'); 951 this.addClass(closeIcon, 'jwtpl-gc-etclose jwtpl-sysTooltip-close'); 952 this.addClass(text, 'jwtpl-sysTooltip-text'); 953 954 if(this.isString(options) === true){ 955 text.innerText = options; 956 tooltip.appendChild(text); 957 } 958 959 960 if(this.isObject(options) === true) { 961 if(options.hasOwnProperty('title') && this.type(options.title) === 'String'){ 962 let msgTitle = document.createElement('span'); 963 this.addClass(msgTitle, 'jwtpl-sysTooltip-title'); 964 if(this.isString(options.title) !== false){ 965 msgTitle.innerText = options.title 966 } else { 967 msgTitle.innerText = 'Information'; 968 } 969 tooltip.appendChild(msgTitle); 970 } 971 972 if(options.hasOwnProperty('xPos') && this.isInt(options.xPos) === true){ 973 if(options.hasOwnProperty('clickMode') && options.clickMode === true){ 974 tooltip.style.left = (options.xPos + 10) + 'px'; 975 } else { 976 tooltip.style.left = options.xPos + 'px'; 977 } 978 } else { 979 tooltip.style.left = '50%'; 980 this.style(tooltip, 'transform', 'translateX(-50%)'); 981 } 982 983 if(options.hasOwnProperty('yPos') && this.isInt(options.yPos) === true) { 984 if(options.hasOwnProperty('clickMode') && options.clickMode === true){ 985 tooltip.style.top = (options.yPos + 10) + 'px'; 986 } else { 987 tooltip.style.top = options.yPos + 'px'; 988 } 989 } else { 990 tooltip.style.top = 20 + 'px'; 991 } 992 993 if(options.hasOwnProperty('type') && this.isString(options.type) === true) { 994 type = options.type; 995 type = this.trim(type); 996 type = type.toLowerCase(); 997 type = this.ucFirst(type); 998 } else { 999 type = 'Unknown'; 1000 } 1001 1002 if(options.hasOwnProperty('link') === true){ 1003 let link = document.createElement('a'); 1004 1005 if(options.link.hasOwnProperty('href') === true && this.isString(options.link.href) === true) { 1006 link.href = options.link.href; 1007 } else { 1008 link.href = '#'; 1009 } 1010 1011 if(options.link.hasOwnProperty('target') === true && this.isString(options.link.target) === true) { 1012 if(['_blank', '_self', '_parent', '_top'].includes(options.link.target) === true) { 1013 link.target = options.link.target; 1014 } else { 1015 link.target = '_self'; 1016 } 1017 } else { 1018 link.target = '_self'; 1019 } 1020 1021 if(options.link.hasOwnProperty('text') === true && this.isString(options.link.text) === true) { 1022 link.innerText = options.link.text; 1023 } else { 1024 link.innerText = 'Link'; 1025 } 1026 1027 if(options.link.hasOwnProperty('title') === true && this.isString(options.link.title) === true) { 1028 link.title = options.link.title; 1029 } else { 1030 link.title = link.innerText; 1031 } 1032 1033 if(options.link.hasOwnProperty('onclick') === true && this.isString(options.link.onclick) === true) { 1034 link.setAttribute('onclick', options.link.onclick); 1035 } 1036 1037 this.addClass(link, 'jwtpl-sysTooltip-link'); 1038 tooltip.appendChild(link); 1039 } 1040 1041 text.innerHTML = options.text; 1042 tooltip.appendChild(text); 1043 } 1044 1045 this.event(closeIcon, 'click', (e) => { 1046 tooltip.remove(); 1047 });
1048 1049 body[0].insertAdjacentElement('beforeend', tooltip); 1050 tooltip.appendChild(closeIcon); 1051 this.removeClass(tooltip, 'jwtpl-gc-hidden1'); 1052 this.addClass(tooltip, 'jwtpl-sysTooltip-type' + type); 1053 1054 return true; 1055 } else { 1056 return false; 1057 } 1058 }, 1059 1060 closeTooltip: function() { 1061 let tooltip = this.get('.jwtpl-sysTooltip-inner', true); 1062 1063 if(tooltip.length > 0) { 1064 tooltip[0].remove(); 1065 return true; 1066 } else { 1067 return false; 1068 } 1069 }, 1070 1071 easyTooltip: function(text, x = 0, y = 0, noKill = false) { 1072 this.tooltip({ 1073 text: text, 1074 xPos: x, 1075 yPos: y, 1076 noKill: noKill 1077 }); 1078 }, 1079 1080 getDntStatus : function(){ 1081 var dnt = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack; 1082 if(dnt === '1' || dnt === 'yes'){ 1083 return true; 1084 } else { 1085 return false; 1086 } 1087 }, 1088 1089 setCookie : function(cookieName, cookieValue, exprireDays){ 1090 if(this.isLiveHost() === false){ 1091 if(this.type(cookieName) === undefined){ 1092 this.printErrorMsg(".setCookie(cookieName, cookieValue, expriredAt) - cookieName must be defined"); 1093 return false; 1094 } else if(this.type(cookieName) === 'String' && this.trim(cookieName) === ''){ 1095 this.printErrorMsg(".setCookie(cookieName, cookieValue, expriredAt) - cookieName must be not empty string"); 1096 return false; 1097 } 1098 1099 if(this.type(cookieValue) === undefined){ 1100 this.printErrorMsg(".setCookie(cookieName, cookieValue, expriredAt) - cookieValue must be defined"); 1101 return false; 1102 } else if(this.type(cookieValue) === 'String' && this.trim(cookieValue) === ''){ 1103 this.printErrorMsg(".setCookie(cookieName, cookieValue, expriredAt) - cookieValue must be not empty string"); 1104 return false; 1105 } 1106 } 1107 1108 var 1109 expires, 1110 date = new Date(); 1111 1112 if(this.type(exprireDays) !== undefined && this.type(exprireDays) === 'Number' && exprireDays > 0){ 1113 date.setTime(date.getTime() + (exprireDays * 24 * 60 * 60 * 1000)); 1114 expires = "expires=" + date.toUTCString(); 1115 } else { 1116 date.setTime(date.getTime() + (30 * 24 * 60 * 60 * 1000)); 1117 expires = "expires=" + date.toUTCString(); 1118 } 1119 1120 document.cookie = cookieName + "=" + cookieValue + ";" + expires + ";path=/;samesite=strict;"; 1121 return true; 1122 }, 1123 1124 getCookie : function(cookieName){ 1125 if(this.type(cookieName) !== undefined && this.type(cookieName) === 'String' && cookieName.length > 0){ 1126 var cookies = document.cookie; 1127 if(this.type(cookies) !== undefined && this.type(cookies) === 'String' && cookies.length > 0){ 1128 var cookieArray = cookies.split(';'); 1129 for(var i = 0; i < cookieArray.length;i++){ 1130 var cookieData = cookieArray[i].split('='); 1131 if(this.trim(cookieData[0]) === this.trim(cookieName.trim())){ 1132 if(this.type(cookieData[1]) !== undefined && this.type(cookieData[1]) === 'String' && cookieData[1].length > 0){ 1133 return decodeURIComponent(cookieData[1]); 1134 } 1135 } 1136 } 1137 } 1138 } else { 1139 this.printErrorMsg(".getCookie(cookieName) - cookieName must be a not empty string"); 1140 } 1141 return ''; 1142 }, 1143 1144 hasCookie : function(cookieName){ 1145 return this.getCookie(cookieName) !== ''; 1146 }, 1147 1148 deleteCookie : function(cookieName) { 1149 if(this.type(cookieName) !== undefined && this.type(cookieName) === 'String' && cookieName.length > 0){ 1150 document.cookie = cookieName + '=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;'; 1151 } 1152 return true; 1153 }, 1154 1155 isCookieEnabled : function(){ 1156 return navigator.cookieEnabled; 1157 }, 1158 1159 isCookieFull : function(size){ 1160 var length = document.cookie.length; 1161 if(this.isInt(size) === true){ 1162 return (length + size) > 3000; 1163 } else { 1164 return length > 3000; 1165 } 1166 }, 1167 1168 getRootValue: function(key) { 1169 if(this.isStringNotEmpty(key) === false){ 1170 this.printErrorMsg(".getRootValue(key) - key must be a string, [" + this.type(key) + "] given instead"); 1171 return false; 1172 } 1173 let value = getComputedStyle(document.documentElement).getPropertyValue(key).trim(); 1174 if(value === '""') { 1175 return ''; 1176 } 1177 else if(value.charAt(0) === '"' && value.charAt(value.length - 1) === '"') { 1178 return value.slice(1, -1); 1179 } else { 1180 return value; 1181 } 1182 }, 1183 1184 style : function (element, prop, val, additional = '') {
1185 if(this.type(element) === undefined){ 1186 this.printErrorMsg(".style(domElement, cssProperty, cssValue) - domElement is undefined"); 1187 return false; 1188 } 1189 1190 if(this.type(element.style) === undefined){ 1191 this.printErrorMsg(".style(domElement, cssProperty, cssValue) - domElement has no CSSStyleDeclaration property"); 1192 return false; 1193 } 1194 1195 if(this.type(prop) === undefined){ 1196 this.printErrorMsg(".style(domElement, cssProperty, cssValue) - you need to specify cssProperty e.g backgroud-color"); 1197 return false; 1198 } 1199 1200 if(this.type(prop) === 'Object'){ 1201 this.each(prop, function(property, value){ 1202 element.style.setProperty(property, value); 1203 }); 1204 return true; 1205 } 1206 1207 if(this.type(prop) !== 'String'){ 1208 this.printErrorMsg(".style(domElement, cssProperty, cssValue) - css cssProperty must be a string, [" + this.type(prop) + "] given instead"); 1209 return false; 1210 } 1211 1212 if(this.type(val) === undefined){ 1213 this.printErrorMsg(".style(domElement, cssProperty, cssValue) - you need to specify cssValue value e.g 10px"); 1214 return false; 1215 } 1216 1217 if(this.type(val) !== 'String'){ 1218 this.printErrorMsg(".style(domElement, cssProperty, cssValue) - css cssValue must be a string, [" + this.type(val) + "] given instead"); 1219 return false; 1220 } 1221 1222 if(additional !== '') { 1223 element.style.setProperty(prop, val, additional); 1224 } else { 1225 element.style.setProperty(prop, val); 1226 } 1227 1228 return true; 1229 }, 1230 1231 show : function (element) { 1232 if(this.type(element) === undefined){ 1233 this.printErrorMsg(".show(element) - element is undefined"); 1234 return false; 1235 } 1236 1237 var displayProp; 1238 1239 if(element.hasAttribute('class') === true){ 1240 if(this.isString(element.getAttribute('class')) === true){ 1241 var 1242 id = this.md5(element.getAttribute('class')), 1243 item = getPropStorageItem(id); 1244 1245 if(this.type(item) !== undefined && this.type(item.display) !== undefined && this.isString(item.display)){ 1246 displayProp = item.display; 1247 } 1248 } 1249 } 1250 1251 if(this.type(displayProp) !== undefined) { 1252 return this.style(element, 'display', displayProp); 1253 } else { 1254 return this.style(element, 'display', 'block'); 1255 } 1256 }, 1257 1258 hide : function (element) { 1259 if(this.type(element) === undefined){ 1260 this.printErrorMsg(".hide(element) - element is undefined"); 1261 return false; 1262 } 1263 1264 if(element.hasAttribute('class') === true){ 1265 var elementClass = element.getAttribute('class'); 1266 if(this.isString(elementClass) === true){ 1267 var 1268 id = this.md5(elementClass), 1269 cssProps = this.getCssProps(element); 1270 1271 if(cssProps !== false && this.isString(cssProps.getPropertyValue('display')) !== false){ 1272 setPropStorageItem(id, {'class': elementClass, 'display': cssProps.getPropertyValue('display')}); 1273 } 1274 } 1275 } 1276 1277 return this.style(element, 'display', 'none'); 1278 }, 1279 1280 addClass: function (element, name) { 1281 if(this.type(element) === undefined){ 1282 this.printErrorMsg(".addClass(domElement, className) - domElement is undefined"); 1283 return false; 1284 } 1285 1286 if(this.type(name) === undefined){ 1287 this.printErrorMsg(".addClass(domElement, className) - you need to specify className"); 1288 return false; 1289 } 1290 1291 if(this.type(name) !== 'String'){ 1292 this.printErrorMsg(".addClass(domElement, className) - className must be a string, [" + this.type(name) + "] given instead"); 1293 return false; 1294 } 1295 1296 if(this.type(element.className) === undefined){ 1297 this.printErrorMsg(".hasClass(domElement, className) - element has no css class property or is undefined"); 1298 return false; 1299 } 1300 1301 var 1302 i, 1303 classList, 1304 classParam; 1305 1306 classList = element.className.split(" "); 1307 classParam = name.split(" "); 1308 1309 for (i = 0; i < classParam.length; i++) { 1310 if (classList.indexOf(classParam[i]) === -1) { 1311 element.className += " " + classParam[i]; 1312 } 1313 } 1314 element.className = element.className.trim(); 1315 1316 return true; 1317 }, 1318 1319 removeClass: function (element, name) {
1320 if(this.type(element) === undefined){ 1321 this.printErrorMsg(".removeClass(domElement, className) - domElement is undefined"); 1322 return false; 1323 } 1324 1325 if(this.type(name) === undefined){ 1326 this.printErrorMsg(".removeClass(domElement, className) - you need to specify className"); 1327 return false; 1328 } 1329 1330 if(this.type(name) !== 'String'){ 1331 this.printErrorMsg(".removeClass(domElement, className) - className must be a string, [" + this.type(name) + "] given instead"); 1332 return false; 1333 } 1334 1335 if(this.type(element.className) === undefined){ 1336 this.printErrorMsg(".hasClass(domElement, className) - element has no css class property or is undefined"); 1337 return false; 1338 } 1339 1340 var 1341 i, 1342 classList, 1343 classParam; 1344 1345 classList = element.className.split(" "); 1346 classParam = name.split(" "); 1347 for (i = 0; i < classParam.length; i++) { 1348 while (classList.indexOf(classParam[i]) > -1) { 1349 classList.splice(classList.indexOf(classParam[i]), 1); 1350 } 1351 } 1352 1353 element.className = classList.join(" "); 1354 return true; 1355 }, 1356 1357 hasClass : function(element, name){ 1358 if(this.type(element) === undefined){ 1359 this.printErrorMsg(".hasClass(domElement, className) - domElement is undefined"); 1360 return false; 1361 } 1362 1363 if(this.type(name) === undefined){ 1364 this.printErrorMsg(".hasClass(domElement, className) - you need to specify className"); 1365 return false; 1366 } 1367 1368 if(this.type(name) !== 'String'){ 1369 this.printErrorMsg(".hasClass(domElement, className) - className must be a string, [" + this.type(name) + "] given instead"); 1370 return false; 1371 } 1372 1373 if(this.type(element.className) === undefined){ 1374 this.printErrorMsg(".hasClass(domElement, className) - element has no css class property or is undefined"); 1375 return false; 1376 } 1377 1378 var 1379 hasClass = false, 1380 classes = element.className.split(" "); 1381 1382 for(var i=0; i<classes.length; i++){ 1383 if(classes[i] === name){ 1384 hasClass = true; 1385 break; 1386 } 1387 } 1388 return hasClass; 1389 }, 1390 1391 toggleClass : function(element, name) { 1392 if(this.type(element) === undefined){ 1393 this.printErrorMsg(".toggleClass(domElement, className) - domElement is undefined"); 1394 return false; 1395 } 1396 1397 if(this.type(name) === undefined){ 1398 this.printErrorMsg(".toggleClass(domElement, className) - you need to specify className"); 1399 return false; 1400 } 1401 1402 if(this.type(name) !== 'String'){ 1403 this.printErrorMsg(".toggleClass(domElement, className) - className must be a string, [" + this.type(name) + "] given instead"); 1404 return false; 1405 } 1406 1407 if(this.type(element.className) === undefined){ 1408 this.printErrorMsg(".toggleClass(domElement, className) - element has no css class property or is undefined"); 1409 return false; 1410 } 1411 1412 if(this.hasClass(element, name) === true){ 1413 this.removeClass(element, name); 1414 return true; 1415 } else { 1416 this.addClass(element, name); 1417 return true; 1418 } 1419 return false; 1420 }, 1421 1422 toggle : function(element){ 1423 if(this.type(element) === undefined){ 1424 this.printErrorMsg(".toggle(domElement) - domElement is undefined"); 1425 return false; 1426 } 1427 1428 if(this.type(element.style) === undefined){ 1429 this.printErrorMsg(".toggle(domElement) - domElement has no CSSStyleDeclaration property"); 1430 return false; 1431 } 1432 1433 try{ 1434 if(window.getComputedStyle(element).display === "none"){ 1435 return this.show(element); 1436 } else { 1437 return this.hide(element); 1438 } 1439 } catch(err){ 1440 this.printErrorMsg(".toggle(domElement) - cannot invoke window.getComputedStyle(element) on element. exception: " + err); 1441 return false; 1442 } 1443 1444 return false; 1445 }, 1446 1447 getCssProps : function(element, property) {
1448 if(this.type(element) === undefined){ 1449 this.printErrorMsg(".getCssProps(element,property) - element is undefined"); 1450 return false; 1451 } 1452 1453 try { 1454 if(this.type(property) !== undefined){ 1455 return window.getComputedStyle(element).getPropertyValue(property); 1456 } else { 1457 return window.getComputedStyle(element); 1458 } 1459 1460 } catch(err) { 1461 this.printErrorMsg(".getCssProps(element,property) - " + err); 1462 return false; 1463 } 1464 }, 1465 1466 getCoords : function(element){ 1467 if(this.type(element) === undefined){ 1468 this.printErrorMsg(".getCoods(domElement) - domElement is undefined"); 1469 return false; 1470 } 1471 1472 try { 1473 var e = element.getBoundingClientRect(); 1474 } catch(err) { 1475 this.printErrorMsg(".getCoods(domElement) - " + err); 1476 return false; 1477 } 1478 1479 return { 1480 top: e.top + pageYOffset, 1481 left: e.left + pageXOffset 1482 }; 1483 }, 1484 1485 trim : function(str){ 1486 if(this.type(str) !== 'String'){ 1487 this.printErrorMsg(".trim() - function parameter must be a string"); 1488 return ''; 1489 } else { 1490 return str.replace(/^\s+|\s+$/g,''); 1491 } 1492 }, 1493 1494 modifyStrSeoUrl : function(url, replaceList) { 1495 if(this.type(url) !== 'String'){ 1496 this.printErrorMsg(".modifyUrl(url) - function parameter must be a string"); 1497 return ''; 1498 } else { 1499 replaceList = replaceList || {}; 1500 url = url.toLowerCase(); 1501 1502 if(replaceList.hasOwnProperty(url) === true && this.type(replaceList[url]) !== undefined) { 1503 url = replaceList[url]; 1504 } 1505 1506 url = url.replaceAll('ä','ae').replaceAll('ü', 'ue').replaceAll('ö', 'oe').replaceAll('Ã', 'ss'); 1507 url = url.replaceAll(' ','-'); 1508 url = url.replace(/[^a-z0-9]/g,'-'); 1509 url = url.replace(/[-]{2,}/g,'-'); 1510 1511 if(url.charAt(0) === '-') { 1512 url = url.substring(1, url.length); 1513 } 1514 1515 if(url.charAt(url.length - 1) === '-') { 1516 url = url.substring(0, url.length - 1); 1517 } 1518 1519 return url; 1520 } 1521 }, 1522 1523 ucFirst : function(str) { 1524 if(this.type(str) !== 'String'){ 1525 this.printErrorMsg(".ucFirst(str) - function parameter must be a string"); 1526 return ''; 1527 } else { 1528 return str.charAt(0).toUpperCase() + str.slice(1); 1529 } 1530 }, 1531 1532 ucWords : function(str, toUpper, toLower) { 1533 if(this.type(str) !== 'String'){ 1534 this.printErrorMsg(".ucWords(str, toUpper, toLower) - function parameter must be a string"); 1535 return ''; 1536 } else { 1537 toUpper = toUpper || []; 1538 toLower = toLower || []; 1539 1540 let 1541 stringArr = str.split(' '), 1542 result = []; 1543 1544 this.each(stringArr, function(item, index, _this){ 1545 if(_this.isString(item) === true && _this.trim(item).length > 0) { 1546 let sm = _this.trim(item.toLowerCase()); 1547 if(toUpper.includes(sm) === true) { 1548 item = item.toUpperCase(); 1549 } else if(toLower.includes(sm) === true) { 1550 item = item.toLowerCase(); 1551 } else { 1552 item = _this.ucFirst(item); 1553 } 1554 1555 result.push(item); 1556 } 1557 }); 1558 1559 return result.join(' '); 1560 } 1561 }, 1562 1563 mapCfg: function(cfg, key, fb) { 1564 if(this.isObject(cfg) === false){ 1565 this.printErrorMsg('.extractCfg(cfg, key, fb) - cfg must be object. check [' + this.getProjectPath() + 'resource/js/config.js]'); 1566 return fb; 1567 } 1568 1569 if(this.isObject(cfg) === true && this.len(cfg) == 0){ 1570 return fb; 1571 } 1572 1573 if(this.isString(key) === false) { 1574 this.printErrorMsg('.extractCfg(cfg, key, fb) - key must be string'); 1575 return fb; 1576 } 1577 1578 let prop = key; 1579 prop = prop.split('.'); 1580 1581 if(prop.length > 2) { 1582 this.printErrorMsg('.extractCfg(cfg, key, fb) - complexe structure for key = [' + key + ']. example: noli.itemList, obo.title'); 1583 return fb; 1584 } 1585 1586 if(prop.length == 2) { 1587 return (this.type(cfg[prop[0]]) !== undefined && this.type(cfg[prop[0]][prop[1]]) !== undefined) ? cfg[prop[0]][prop[1]] : fb; 1588 } else { 1589 return fb; 1590 } 1591 }, 1592 1593 parseHTML: function(str) { 1594 if(this.isString(str) !== true){ 1595 this.printErrorMsg(".parseHTML() - function parameter must be a string"); 1596 return ''; 1597 } 1598 1599 var tmp = document.implementation.createHTMLDocument(); 1600 tmp.body.innerHTML = str; 1601 return tmp.body.children; 1602 }, 1603 1604 parseInt: function(obj){
1605 if(this.type(obj) === undefined){ 1606 this.printErrorMsg(".parseInt(obj) - function parameter is undefined"); 1607 return false; 1608 } 1609 var parse = parseInt(obj); 1610 return isNaN(parse) === false ? parse : false; 1611 }, 1612 1613 parseFloat: function(obj){ 1614 if(this.type(obj) === undefined){ 1615 this.printErrorMsg(".parseFloat(obj) - function parameter is undefined"); 1616 return false; 1617 } 1618 var parse = parseFloat(obj); 1619 return isNaN(parse) === false ? parse : false; 1620 }, 1621 1622 isBool: function(element) { 1623 return this.type(element) === 'Boolean'; 1624 }, 1625 1626 isNull: function(element){ 1627 return this.type(element) === undefined; 1628 }, 1629 1630 isNumber: function(number){ 1631 return isNaN(number) === false; 1632 }, 1633 1634 isInt : function(int){ 1635 return this.type(int) === 'Number' && isFinite(int) && int === parseInt(int); 1636 }, 1637 1638 isFloat : function(float){ 1639 return this.type(float) === 'Number' && isFinite(float) && float === parseFloat(float); 1640 }, 1641 1642 //@deprecated 1643 isString: function(string){ 1644 return this.type(string) === 'String' && string.length > 0; 1645 }, 1646 1647 isStringNotEmpty: function(string){ 1648 return this.type(string) === 'String' && string.length > 0; 1649 }, 1650 1651 isStringRaw: function(string){ 1652 return this.type(string) === 'String'; 1653 }, 1654 1655 isArray : function(array){ 1656 return this.type(array) === 'Array' && this.type(array.length) !== undefined; 1657 }, 1658 1659 isFunction : function(fn){ 1660 return this.type(fn) === 'Function'; 1661 }, 1662 1663 isObject : function(obj){ 1664 return this.type(obj) === 'Object'; 1665 }, 1666 1667 isDomObject: function(ele) { 1668 return ele instanceof Element || ele instanceof HTMLDocument; 1669 }, 1670 1671 isMap: function(map) { 1672 return this.type(map) === 'Map'; 1673 }, 1674 1675 isMobile : function(){ 1676 let 1677 check = false, 1678 body = this.get('body'); 1679 1680 if(body.length > 0 && this.hasClass(body[0], 'jwtpl-sys-bodyAppDvM1') === true) { 1681 check = true; 1682 } else if(body.length > 0 && this.hasClass(body[0], 'jwtpl-sys-bodyAppDvM0') === true) { 1683 check = false; 1684 } else { 1685 (function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4))) check
1685= true;})(navigator.userAgent||navigator.vendor||window.opera); 1686 } 1687 return check; 1688 }, 1689 1690 isPortrait: function(){ 1691 let body = this.get('body'); 1692 return body.length > 0 ? this.hasClass(body[0], op) : false; 1693 }, 1694 isLandscape: function(){ 1695 let body = this.get('body'); 1696 return body.length > 0 ? this.hasClass(body[0], ol) : false; 1697 }, 1698 1699 isIos: function() { 1700 return /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform); 1701 }, 1702 1703 isIphone: function() { 1704 return /iPhone/i.test(navigator.platform); 1705 }, 1706 1707 isStartPage: function() { 1708 var 1709 body = this.get('body'); 1710 1711 if(body.length > 0) { 1712 if(this.hasClass(body[0], 'jwtpl-sys-bodyPtHp') === true) { 1713 return true; 1714 } else { 1715 return false; 1716 } 1717 } else { 1718 return false; 1719 } 1720 }, 1721 1722 len: function(obj) { 1723 if(this.type(obj) === 'String' || this.isArray(obj) === true) { 1724 return obj.length; 1725 } else if(this.isObject(obj) === true) { 1726 return Object.keys(obj).length; 1727 } else { 1728 this.printInfoMsg('.len() - there is no length function for type = [' + this.type(obj) + ']'); 1729 } 1730 }, 1731 1732 empty: function(domElement) { 1733 if(this.type(domElement) === undefined){ 1734 this.printErrorMsg(".empty(domElement) - domElement is undefined"); 1735 return false; 1736 } 1737 1738 domElement.innerHTML = ''; 1739 }, 1740 1741 width : function() { 1742 return window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; 1743 }, 1744 1745 height: function(el) { 1746 if(this.type(el) === undefined){ 1747 this.printErrorMsg(".height(domElement) - domElement is undefined"); 1748 return false; 1749 } 1750 1751 return this.isNull(el.offsetHeight) === false ? el.offsetHeight : false; 1752 }, 1753 1754 log: function(descr, modName = '') { 1755 if(this.isString(descr) === false) { 1756 this.printErrorMsg(".log(descr, modName = '') - descr must be a not emtpy string"); 1757 return false; 1758 } 1759 1760 let 1761 key = '', 1762 date = Date.now().toString(), 1763 rand = this.randomize().toString(), 1764 value = {ts: Date.now(), desc: descr, mod: modName}; 1765 1766 key = date + rand + '|' + descr; 1767 logStorage.set(key, value); 1768 1769 this.printElement(value); 1770 }, 1771 1772 getLog: function(){ 1773 return logStorage.size > 0 ? logStorage : ''; 1774 }, 1775 1776 printLog: function(){ 1777 for (const [key, value] of logStorage.entries()) {
1778 this.printInfoMsg(key + " :{" + 'ts:' + value.ts + ', ' + 'desc:' + value.desc + ', ' + 'mod:' + value.mod +'}'); 1779 } 1780 }, 1781 1782 randomize: function(count) { 1783 if(window.crypto) { 1784 if(this.isInt(count) === false || count < 1 || count > 100) { 1785 let randArray = new Uint32Array(1); 1786 window.crypto.getRandomValues(randArray); 1787 return randArray.length > 0 ? randArray[0] : false; 1788 } else { 1789 let randArray = new Uint32Array(count); 1790 window.crypto.getRandomValues(randArray); 1791 return randArray; 1792 } 1793 } else { 1794 return false; 1795 } 1796 }, 1797 1798 getAppCfg: function() { 1799 let 1800 cfg = '', 1801 body = this.get('body'); 1802 1803 if(body.length > 0) { 1804 for(let i=0; i<body[0].classList.length; i++) { 1805 let curr = body[0].classList[i]; 1806 if(curr.includes('jwtpl-sysDraft-appSpecial') == true) { 1807 if(curr.includes('Gen') === true) { 1808 curr = curr.substring(curr.indexOf('Cfg'), curr.indexOf('Gen')); 1809 } else { 1810 curr = curr.substring(curr.indexOf('Cfg'), curr.length); 1811 } 1812 cfg = curr; 1813 break; 1814 } 1815 } 1816 } 1817 1818 return cfg; 1819 }, 1820 1821 getAppGen: function() { 1822 let 1823 gen = '', 1824 body = this.get('body'); 1825 1826 if(body.length > 0) { 1827 for(let i=0; i<body[0].classList.length; i++) { 1828 let curr = body[0].classList[i]; 1829 if(curr.includes('jwtpl-sys-bodyAppCfgGen') == true) { 1830 curr = curr.substring(curr.indexOf('Gen'), curr.length); 1831 gen = curr; 1832 break; 1833 } 1834 } 1835 } 1836 1837 return gen; 1838 }, 1839 1840 getAppGenAsInt: function() { 1841 let appGenResult = this.getAppGen(); 1842 return parseInt(appGenResult.replace('Gen','')); 1843 }, 1844 1845 getAppInfo: function(getWhat = '') { 1846 let 1847 iam = {'version': '', 'app': '', 'spuch': ''}, 1848 body = this.get('body'); 1849 1850 getWhat = getWhat.toLocaleLowerCase(); 1851 getWhat = this.trim(getWhat); 1852 1853 if(body.length > 0) { 1854 let classList = body[0].classList; 1855 classList = Array.of(classList).join(','); 1856 classList = classList.replaceAll(' ', ','); 1857 classList += ','; 1858 if(classList.indexOf(',jwtpl-sys-bodyAppMmNg') !== -1) { 1859 iam.version = 'v9'; 1860 if(classList.indexOf(',jwtpl-sys-bodyPtViLi,') !== -1) { 1861 iam.app = 'viewer'; 1862 } else { 1863 iam.app = 'jobmarket'; 1864 } 1865 } else { 1866 iam.version = 'v8'; 1867 if(classList.indexOf(',jwtpl-vw,') !== -1) { 1868 iam.app = 'viewer'; 1869 } else { 1870 iam.app = 'jobmarket'; 1871 } 1872 } 1873 1874 if(iam.version === 'v9'){ 1875 this.each(body[0].classList, (it)=> { 1876 if(it.indexOf('jwtpl-sys-bodyAppSpuch') !== -1) { 1877 it = it.split('jwtpl-sys-bodyAppSpuch'); 1878 if(it.length == 2){ 1879 iam.spuch = it[1].toLowerCase(); 1880 } 1881 } 1882 }); 1883 } 1884 } 1885 1886 if(getWhat === '') { 1887 return iam; 1888 } else if(getWhat === 'version') { 1889 return iam.version; 1890 } else if(getWhat === 'app'){ 1891 return iam.app; 1892 } else if(getWhat === 'spuch'){ 1893 return iam.spuch; 1894 } else { 1895 return false; 1896 } 1897 }, 1898 1899 setBaseHrefUrl: function(baseUrl){ 1900 var hasChanged = false; 1901 1902 if(this.type(baseUrl) === 'String' && baseUrl.length > 10){ 1903 if(baseUrl.indexOf('http://') == 0 || baseUrl.indexOf('https://') == 0 || baseUrl.indexOf('//') == 0){ 1904 var baseTag = this.get('base'); 1905 1906 if(baseTag.length > 0 && this.type(baseTag[0]) !== undefined){ 1907 baseTag[0].setAttribute('href', baseUrl); 1908 hasChanged = true; 1909 } 1910 } 1911 } 1912 1913 return hasChanged; 1914 }, 1915 1916 getBaseHrefUrl: function(){ 1917 var 1918 baseHref = '', 1919 baseTag = this.get('base'); 1920 1921 if(baseTag.length > 0){ 1922 if(typeof baseTag[0] !== 'undefined' && baseTag[0].hasAttribute('href') === true && baseTag[0].getAttribute('href').length > 0){ 1923 baseHref = baseTag[0].getAttribute('href'); 1924 } 1925 } 1926 1927 return baseHref; 1928 }, 1929 1930 getUrlParameter : function(param){
1931 if(this.type(param) === undefined || this.type(param) !== 'String'){ 1932 this.printErrorMsg(".getUrlParameter(param) - param must be a not empty string"); 1933 return false; 1934 } 1935 1936 if(this.type(window.location.search) !== undefined && window.location.search.length > 0){ 1937 var 1938 query = window.location.search.substring(1), 1939 items = query.split("&"); 1940 1941 for(var i=0; i<items.length; i++){ 1942 var pair = items[i].split("="); 1943 if(pair[0] === param){ 1944 return pair[1]; 1945 } 1946 } 1947 } 1948 return false; 1949 }, 1950 1951 runMatchedFuncs: function(funcName) { 1952 if(this.isStringRaw(funcName) === false){ 1953 this.printErrorMsg(".runMatchedFuncs(funcName) - funcName as string required"); 1954 return false; 1955 } 1956 1957 funcName = this.trim(funcName); 1958 1959 if(funcName.startsWith('jwTplJsLibObjectCallMe_') === true) { 1960 let func = Object.keys(window).filter(function(el){ 1961 return el.indexOf(funcName) > -1; 1962 }); 1963 1964 if(func.length > 0) { 1965 this.each(func, (f) => { 1966 this.safeCall(f); 1967 }); 1968 return true; 1969 } 1970 } 1971 return false; 1972 }, 1973 1974 safeCall: function(funcName, realRet = false, param1 = -1 , param2 = -1, param3 = -1) { 1975 if(funcName.indexOf('.') !== -1) { 1976 let split = funcName.split('.'); 1977 1978 if(split.length === 2) { 1979 if(this.type(window[split[0]]) !== undefined && this.type(window[split[0]][split[1]]) !== undefined) { 1980 try { 1981 if(realRet === false){ 1982 if(param1 !== -1 && param2 !== -1 && param3 !== -1) { 1983 window[split[0]][split[1]](param1, param2, param3); 1984 } else if(param1 !== -1 && param2 !== -1) { 1985 window[split[0]][split[1]](param1, param2); 1986 } else if(param1 !== -1) { 1987 window[split[0]][split[1]](param1); 1988 } else { 1989 window[split[0]][split[1]]();
1990 } 1991 return true; 1992 } else { 1993 if(param1 !== -1 && param2 !== -1 && param3 !== -1) { 1994 return window[split[0]][split[1]](param1, param2, param3); 1995 } else if(param1 !== -1 && param2 !== -1) { 1996 return window[split[0]][split[1]](param1, param2); 1997 } else if(param1 !== -1) { 1998 return window[split[0]][split[1]](param1); 1999 } else { 2000 return window[split[0]][split[1]](); 2001 } 2002 } 2003 } catch(e){ 2004 return false; 2005 } 2006 } else { 2007 return false; 2008 } 2009 } else { 2010 return false; 2011 } 2012 } else { 2013 if(this.type(window[funcName]) !== undefined) { 2014 try { 2015 if(realRet === false){ 2016 if(param1 !== -1 && param2 !== -1 && param3 !== -1) { 2017 window[funcName](param1, param2, param3); 2018 } else if(param1 !== -1 && param2 !== -1) { 2019 window[funcName](param1, param2); 2020 } else if(param1 !== -1) { 2021 window[funcName](param1); 2022 } else { 2023 window[funcName](); 2024 } 2025 return true; 2026 } else { 2027 if(param1 !== -1 && param2 !== -1 && param3 !== -1) { 2028 return window[funcName](param1, param2, param3); 2029 } else if(param1 !== -1 && param2 !== -1) { 2030 return window[funcName](param1, param2); 2031 } else if(param1 !== -1) { 2032 return window[funcName](param1); 2033 } else { 2034 return window[funcName](); 2035 } 2036 } 2037 } catch(e){ 2038 return false; 2039 } 2040 } else { 2041 return false; 2042 } 2043 } 2044 }, 2045 2046 safeAction: function(callback) { 2047 try { 2048 return callback(); 2049 } catch (e) { 2050 this.printStackTrace(e.toString()); 2051 return false; 2052 } 2053 }, 2054 2055 getAppGuiForKey: function(key, mode = '') { 2056 let guiTags = getAppGui(); 2057 if(guiTags === false){return false;} 2058 if(this.isString(key) === false){ 2059 this.printErrorMsg(".getAppGuiForKey(key) - param must be a not empty string"); 2060 return false; 2061 } 2062 if(mode == 'skin'){ 2063 return this.type(guiTags.get(key)[0]) !== undefined ? guiTags.get(key)[0] : false; 2064 } else if(mode == 'display'){ 2065 return this.type(guiTags.get(key)[1]) !== undefined ? guiTags.get(key)[1] : false; 2066 } else { 2067 return guiTags.has(key) ? guiTags.get(key) : false; 2068 } 2069 }, 2070 2071 hasAppGuiForKey: function(key) { 2072 return this.getAppGuiForKey(key) !== false ? true : false; 2073 }, 2074 2075 getGuiTagForKey: function(key){ 2076 if(this.isString(key) === false) { 2077 return false; 2078 } 2079 let ele, pattern = guiTagPattern; 2080 pattern = pattern.replace('#{pattern}', key.toLowerCase()); 2081 ele = this.get(pattern); 2082 if(ele.length == 1) { 2083 return ele[0].getAttribute('data-jwtpl-sys-gui') !== null ? ele[0].getAttribute('data-jwtpl-sys-gui') : false; 2084 } else { 2085 return false; 2086 } 2087 }, 2088 2089 getObjByGuiKey: function(key) { 2090 let guiTag = this.getGuiTagForKey(key); 2091 return guiTag !== false ? guiTag.split('|') : false; 2092 }, 2093 2094 getGuiTagList: function () { 2095 return document.querySelectorAll('[data-jwtpl-sys-gui]'); 2096 }, 2097 2098 getGuiTag: function(key, target){ 2099 let attr = '', guiTag = '', tags = []; 2100 2101 if(this.isDomObject(target) === true) { 2102 attr = target.getAttribute('data-jwtpl-sys-gui'); 2103 if(this.type(attr) === undefined) { 2104 return false; 2105 } else { 2106 guiTag = target.getAttribute('data-jwtpl-sys-gui'); 2107 } 2108 } 2109 2110 if(this.isString(target) === true) { 2111 if(target.split('|').length == 9){ 2112 let ele, pattern = guiTagPattern; 2113 pattern = pattern.replace('#{pattern}', target.toLowerCase()); 2114 ele = this.get(pattern); 2115 if(ele.length == 1) { 2116 attr = ele[0].getAttribute('data-jwtpl-sys-gui'); 2117 if(this.type(attr) === undefined) { 2118 return false; 2119 } else { 2120 guiTag = ele[0].getAttribute('data-jwtpl-sys-gui'); 2121 } 2122 } 2123 } else { 2124 try { 2125 let ele = this.get(target); 2126 if(ele.length == 1) { 2127 attr = ele[0].getAttribute('data-jwtpl-sys-gui');
2128 if(this.type(attr) === undefined) { 2129 return false; 2130 } else { 2131 guiTag = ele[0].getAttribute('data-jwtpl-sys-gui'); 2132 } 2133 } 2134 } catch(e){ 2135 return false; 2136 } 2137 } 2138 } 2139 2140 if(guiTag.length > 0){ 2141 let tagCol = new Map(); 2142 tags = guiTag.split('|'); 2143 this.each(tags, (it) => { 2144 it = it.split(':') 2145 if(it.length == 2) { 2146 tagCol.set(it[0], it[1]); 2147 } 2148 }); 2149 2150 if(tags.length == 9){ 2151 key = key.toLowerCase(); 2152 if(key === 'name'){ 2153 return tagCol.has('mn') === true ? tagCol.get('mn') : false; 2154 } else if(key === 'key') { 2155 return tagCol.has('id') === true ? tagCol.get('id') : false; 2156 } else if(key === 'skin') { 2157 if(tagCol.has('si') === true){ 2158 let si = parseInt(tagCol.get('si')); 2159 return isNaN(si) === false ? si : false; 2160 } else { 2161 return false; 2162 } 2163 } else if(key === 'display') { 2164 let dm = parseInt(tagCol.get('dm')); 2165 return isNaN(dm) === false ? dm : false; 2166 } else if(key === 'version') { 2167 return tagCol.has('tv') === true ? tagCol.get('tv') : false; 2168 } else if(key === 'appjs') { 2169 let as = parseInt(tagCol.get('as')); 2170 return isNaN(as) === false ? (as == 1 ? true: false) : false; 2171 } else if(key === 'appkey') { 2172 return tagCol.has('ak') === true ? tagCol.get('ak') : false; 2173 } else if(key === 'pos') { 2174 return tagCol.has('mp') === true ? tagCol.get('mp') : false; 2175 } else if(key === 'colorme') { 2176 return tagCol.has('cm') === true ? parseInt(tagCol.get('cm')) : false; 2177 } else if(key === 'all') { 2178 return guiTag; 2179 } else { 2180 return false; 2181 } 2182 } 2183 } else { 2184 return false; 2185 } 2186 }, 2187 //de format de2 mit führenden Nullen 2188 time: { 2189 year:() => {return new Date().getFullYear();}, 2190 month:() => {return new Date().getMonth();}, 2191 day:() => {return new Date().getDate();}, 2192 hour:() => {return new Date().getHours();}, 2193 min:() => {return new Date().getMinutes();}, 2194 sec:() => {return new Date().getSeconds();}, 2195 date:() => {return new Date();}, 2196 msec:() => {return new Date().getMilliseconds();}, 2197 millis:() => {return Date.now();}, 2198 ts:() => {const d = new Date(); return `${d.getFullYear()}-${d.getMonth()+1}-${d.getDate()} ${d.getHours()}:${d.getMinutes()}:${d.getSeconds()}:${d.getMilliseconds()}`;}, 2199 de:() => {const d = new Date(); return `${d.getDate()}.${d.getMonth()+1}.${d.getFullYear()}`;}, 2200 en:() => {const d = new Date(); return `${d.getFullYear()}-${d.getMonth()+1}-${d.getDate()}`;} 2201 }, 2202 2203 sha1: async function(str) { 2204 const 2205 msgBuffer = new TextEncoder('utf-8').encode(str), 2206 hashBuffer = await crypto.subtle.digest('SHA-1', msgBuffer), 2207 hashArray = Array.from(new Uint8Array(hashBuffer)), 2208 hashHex = hashArray.map(b => ('00' + b.toString(16)).slice(-2)).join(''); 2209 2210 return hashHex; 2211 }, 2212 2213 md5 : function (str) { 2214 var xl; 2215 2216 var rotateLeft = function(lValue, iShiftBits) { 2217 return (lValue << iShiftBits) | (lValue >>> (32 - iShiftBits)); 2218 }; 2219 2220 var addUnsigned = function(lX, lY) { 2221 var lX4, lY4, lX8, lY8, lResult; 2222 lX8 = (lX & 0x80000000); 2223 lY8 = (lY & 0x80000000); 2224 lX4 = (lX & 0x40000000); 2225 lY4 = (lY & 0x40000000); 2226 lResult = (lX & 0x3FFFFFFF) + (lY & 0x3FFFFFFF); 2227 if (lX4 & lY4) { 2228 return (lResult ^ 0x80000000 ^ lX8 ^ lY8); 2229 } 2230 if (lX4 | lY4) { 2231 if (lResult & 0x40000000) { 2232 return (lResult ^ 0xC0000000 ^ lX8 ^ lY8); 2233 } else { 2234 return (lResult ^ 0x40000000 ^ lX8 ^ lY8); 2235 } 2236 } else { 2237 return (lResult ^ lX8 ^ lY8); 2238 } 2239 }; 2240 2241 var _F = function(x, y, z) { 2242 return (x & y) | ((~x) & z); 2243 }; 2244 var _G = function(x, y, z) { 2245 return (x & z) | (y & (~z)); 2246 }; 2247 var _H = function(x, y, z) { 2248 return (x ^ y ^ z); 2249 }; 2250 var _I = function(x, y, z) { 2251 return (y ^ (x | (~z))); 2252 }; 2253 2254 var _FF = function(a, b, c, d, x, s, ac) { 2255 a = addUnsigned(a, addUnsigned(addUnsigned(_F(b, c, d), x), ac)); 2256 return addUnsigned(rotateLeft(a, s), b); 2257 }; 2258 2259 var _GG = function(a, b, c, d, x, s, ac) { 2260 a = addUnsigned(a, addUnsigned(addUnsigned(_G(b, c, d), x), ac)); 2261 return addUnsigned(rotateLeft(a, s), b); 2262 }; 2263 2264 var _HH = function(a, b, c, d, x, s, ac) { 2265 a = addUnsigned(a, addUnsigned(addUnsigned(_H(b, c, d), x), ac)); 2266 return addUnsigned(rotateLeft(a, s), b); 2267 }; 2268 2269 var _II = function(a, b, c, d, x, s, ac) { 2270 a = addUnsigned(a, addUnsigned(addUnsigned(_I(b, c, d), x), ac)); 2271 return addUnsigned(rotateLeft(a, s), b); 2272 }; 2273 2274 var convertToWordArray = function(str) { 2275 var lWordCount; 2276 var lMessageLength = str.length; 2277 var lNumberOfWords_temp1 = lMessageLength + 8; 2278 var lNumberOfWords_temp2 = (lNumberOfWords_temp1 - (lNumberOfWords_temp1 % 64)) / 64; 2279 var lNumberOfWords = (lNumberOfWords_temp2 + 1) * 16; 2280 var lWordArray = new Array(lNumberOfWords - 1); 2281 var lBytePosition = 0; 2282 var lByteCount = 0; 2283 while (lByteCount < lMessageLength) { 2284 lWordCount = (lByteCount - (lByteCount % 4)) / 4; 2285 lBytePosition = (lByteCount % 4) * 8; 2286 lWordArray[lWordCount] = (lWordArray[lWordCount] | (str 2287 .charCodeAt(lByteCount) << lBytePosition)); 2288 lByteCount++; 2289 } 2290 lWordCount = (lByteCount - (lByteCount % 4)) / 4; 2291 lBytePosition = (lByteCount % 4) * 8; 2292 lWordArray[lWordCount] = lWordArray[lWordCount] 2293 | (0x80 << lBytePosition); 2294 lWordArray[lNumberOfWords - 2] = lMessageLength << 3; 2295 lWordArray[lNumberOfWords - 1] = lMessageLength >>> 29; 2296 return lWordArray; 2297 }; 2298 2299 var wordToHex = function(lValue) { 2300 var wordToHexValue = '', wordToHexValue_temp = '', lByte, lCount; 2301 for (lCount = 0; lCount <= 3; lCount++) { 2302 lByte = (lValue >>> (lCount * 8)) & 255; 2303 wordToHexValue_temp = '0' + lByte.toString(16); 2304 wordToHexValue = wordToHexValue 2305 + wordToHexValue_temp.substr( 2306 wordToHexValue_temp.length - 2, 2); 2307 } 2308 return wordToHexValue; 2309 }; 2310 2311 var utf8_encode = function(string) { 2312 string = (string + '').replace(/\r\n/g, "\n").replace(/\r/g, "\n"); 2313 2314 var utftext = ""; 2315 var start, end; 2316 var stringl = 0; 2317 2318 start = end = 0; 2319 stringl = string.length; 2320 for (var n = 0; n < stringl; n++) { 2321 var c1 = string.charCodeAt(n); 2322 var enc = null; 2323 2324 if (c1 < 128) { 2325 end++; 2326 } else if ((c1 > 127) && (c1 < 2048)) { 2327 enc = String.fromCharCode((c1 >> 6) | 192) 2328 + String.fromCharCode((c1 & 63) | 128); 2329 } else { 2330 enc = String.fromCharCode((c1 >> 12) | 224) 2331 + String.fromCharCode(((c1 >> 6) & 63) | 128) 2332 + String.fromCharCode((c1 & 63) | 128); 2333 } 2334 if (enc != null) { 2335 if (end > start) { 2336 utftext += string.substring(start, end); 2337 } 2338 utftext += enc; 2339 start = end = n + 1; 2340 } 2341 } 2342 2343 if (end > start) { 2344 utftext += string.substring(start, string.length); 2345 } 2346 2347 return utftext; 2348 } 2349 2350 var x = [], k, AA, BB, CC, DD, a, b, c, d, S11 = 7, S12 = 12, S13 = 17, S14 = 22, S21 = 5, S22 = 9, S23 = 14, S24 = 20, S31 = 4, S32 = 11, S33 = 16, S34 = 23, S41 = 6, S42 = 10, S43 = 15, S44 = 21; 2351 2352 str = utf8_encode(str); 2353 x = convertToWordArray(str);
2354 a = 0x67452301; 2355 b = 0xEFCDAB89; 2356 c = 0x98BADCFE; 2357 d = 0x10325476; 2358 2359 xl = x.length; 2360 for (k = 0; k < xl; k += 16) { 2361 AA = a; 2362 BB = b; 2363 CC = c; 2364 DD = d; 2365 a = _FF(a, b, c, d, x[k + 0], S11, 0xD76AA478); 2366 d = _FF(d, a, b, c, x[k + 1], S12, 0xE8C7B756); 2367 c = _FF(c, d, a, b, x[k + 2], S13, 0x242070DB); 2368 b = _FF(b, c, d, a, x[k + 3], S14, 0xC1BDCEEE); 2369 a = _FF(a, b, c, d, x[k + 4], S11, 0xF57C0FAF); 2370 d = _FF(d, a, b, c, x[k + 5], S12, 0x4787C62A); 2371 c = _FF(c, d, a, b, x[k + 6], S13, 0xA8304613); 2372 b = _FF(b, c, d, a, x[k + 7], S14, 0xFD469501); 2373 a = _FF(a, b, c, d, x[k + 8], S11, 0x698098D8); 2374 d = _FF(d, a, b, c, x[k + 9], S12, 0x8B44F7AF); 2375 c = _FF(c, d, a, b, x[k + 10], S13, 0xFFFF5BB1); 2376 b = _FF(b, c, d, a, x[k + 11], S14, 0x895CD7BE); 2377 a = _FF(a, b, c, d, x[k + 12], S11, 0x6B901122); 2378 d = _FF(d, a, b, c, x[k + 13], S12, 0xFD987193); 2379 c = _FF(c, d, a, b, x[k + 14], S13, 0xA679438E); 2380 b = _FF(b, c, d, a, x[k + 15], S14, 0x49B40821); 2381 a = _GG(a, b, c, d, x[k + 1], S21, 0xF61E2562); 2382 d = _GG(d, a, b, c, x[k + 6], S22, 0xC040B340); 2383 c = _GG(c, d, a, b, x[k + 11], S23, 0x265E5A51); 2384 b = _GG(b, c, d, a, x[k + 0], S24, 0xE9B6C7AA); 2385 a = _GG(a, b, c, d, x[k + 5], S21, 0xD62F105D); 2386 d = _GG(d, a, b, c, x[k + 10], S22, 0x2441453); 2387 c = _GG(c, d, a, b, x[k + 15], S23, 0xD8A1E681); 2388 b = _GG(b, c, d, a, x[k + 4], S24, 0xE7D3FBC8); 2389 a = _GG(a, b, c, d, x[k + 9], S21, 0x21E1CDE6); 2390 d = _GG(d, a, b, c, x[k + 14], S22, 0xC33707D6); 2391 c = _GG(c, d, a, b, x[k + 3], S23, 0xF4D50D87); 2392 b = _GG(b, c, d, a, x[k + 8], S24, 0x455A14ED); 2393 a = _GG(a, b, c, d, x[k + 13], S21, 0xA9E3E905); 2394 d = _GG(d, a, b, c, x[k + 2], S22, 0xFCEFA3F8); 2395 c = _GG(c, d, a, b, x[k + 7], S23, 0x676F02D9); 2396 b = _GG(b, c, d, a, x[k + 12], S24, 0x8D2A4C8A); 2397 a = _HH(a, b, c, d, x[k + 5], S31, 0xFFFA3942); 2398 d = _HH(d, a, b, c, x[k + 8], S32, 0x8771F681); 2399 c = _HH(c, d, a, b, x[k + 11], S33, 0x6D9D6122); 2400 b = _HH(b, c, d, a, x[k + 14], S34, 0xFDE5380C); 2401 a = _HH(a, b, c, d, x[k + 1], S31, 0xA4BEEA44); 2402 d = _HH(d, a, b, c, x[k + 4], S32, 0x4BDECFA9); 2403 c = _HH(c, d, a, b, x[k + 7], S33, 0xF6BB4B60); 2404 b = _HH(b, c, d, a, x[k + 10], S34, 0xBEBFBC70); 2405 a = _HH(a, b, c, d, x[k + 13], S31, 0x289B7EC6); 2406 d = _HH(d, a, b, c, x[k + 0], S32, 0xEAA127FA); 2407 c = _HH(c, d, a, b, x[k + 3], S33, 0xD4EF3085); 2408 b = _HH(b, c, d, a, x[k + 6], S34, 0x4881D05); 2409 a = _HH(a, b, c, d, x[k + 9], S31, 0xD9D4D039); 2410 d = _HH(d, a, b, c, x[k + 12], S32, 0xE6DB99E5); 2411 c = _HH(c, d, a, b, x[k + 15], S33, 0x1FA27CF8); 2412 b = _HH(b, c, d, a, x[k + 2], S34, 0xC4AC5665); 2413 a = _II(a, b, c, d, x[k + 0], S41, 0xF4292244); 2414 d = _II(d, a, b, c, x[k + 7], S42, 0x432AFF97); 2415 c = _II(c, d, a, b, x[k + 14], S43, 0xAB9423A7); 2416 b = _II(b, c, d, a, x[k + 5], S44, 0xFC93A039); 2417 a = _II(a, b, c, d, x[k + 12], S41, 0x655B59C3); 2418 d = _II(d, a, b, c, x[k + 3], S42, 0x8F0CCC92); 2419 c = _II(c, d, a, b, x[k + 10], S43, 0xFFEFF47D); 2420 b = _II(b, c, d, a, x[k + 1], S44, 0x85845DD1); 2421 a = _II(a, b, c, d, x[k + 8], S41, 0x6FA87E4F); 2422 d = _II(d, a, b, c, x[k + 15], S42, 0xFE2CE6E0); 2423 c = _II(c, d, a, b, x[k + 6], S43, 0xA3014314); 2424 b = _II(b, c, d, a, x[k + 13], S44, 0x4E0811A1); 2425 a = _II(a, b, c, d, x[k + 4], S41, 0xF7537E82); 2426 d = _II(d, a, b, c, x[k + 11], S42, 0xBD3AF235); 2427 c = _II(c, d, a, b, x[k + 2], S43, 0x2AD7D2BB); 2428 b = _II(b, c, d, a, x[k + 9], S44, 0xEB86D391); 2429 a = addUnsigned(a, AA); 2430 b = addUnsigned(b, BB); 2431 c = addUnsigned(c, CC); 2432 d = addUnsigned(d, DD); 2433 } 2434 2435 var temp = wordToHex(a) + wordToHex(b) + wordToHex(c) + wordToHex(d); 2436 2437 return temp.toLowerCase(); 2438 }, 2439 2440 2441 getHost : function(){ 2442 var host = '';
2443 if(this.type(window.location) !== undefined){ 2444 if(this.type(window.location.protocol) !== undefined && this.type(window.location.host) !== undefined){ 2445 host = window.location.protocol + '//' + window.location.host; 2446 } 2447 } 2448 2449 return host; 2450 }, 2451 2452 isLiveHost: function(){ 2453 return this.isLocalHost() === false; 2454 2455 }, 2456 2457 isLocalHost : function(){ 2458 var 2459 match = false, 2460 currentHost = this.getHost(); 2461 2462 for(var i=0; i<localHosts.length; i++){ 2463 if(currentHost.indexOf(localHosts[i]) != -1){ 2464 match = true; 2465 break; 2466 } 2467 } 2468 2469 return match; 2470 }, 2471 2472 isPreviewHost : function(){ 2473 var 2474 match = false, 2475 currentHost = this.getHost(); 2476 if(currentHost.includes("ap.sites.jobware.net")){ 2477 match = true; 2478 } 2479 return match; 2480 }, 2481 2482 isDevHost : function(){ 2483 var 2484 match = false, 2485 currentHost = this.getHost(); 2486 if(currentHost.includes("ad.sites.jobware.net")){ 2487 match = true; 2488 } 2489 return match; 2490 }, 2491 2492 isTestHost : function(){ 2493 var 2494 match = false, 2495 currentHost = this.getHost(); 2496 if(currentHost.includes("at.sites.jobware.net")){ 2497 match = true; 2498 } 2499 return match; 2500 }, 2501 2502 isIntegrationHost : function(){ 2503 var 2504 match = false, 2505 currentHost = this.getHost(); 2506 if(currentHost.includes("ai.sites.jobware.net")){ 2507 match = true; 2508 } 2509 return match; 2510 }, 2511 2512 isRealLocalHost : function(){ 2513 var 2514 match = false, 2515 currentHost = this.getHost(); 2516 if(currentHost.includes("localhost")){ 2517 match = true; 2518 } 2519 return match; 2520 }, 2521 2522 getConsentStatus: function(){ 2523 var status = false; 2524 var scriptTag = this.get('[data-jwtpl-sys-jsapiconsent]'); 2525 if(scriptTag.length > 0){ 2526 status = scriptTag[0].getAttribute('data-jwtpl-sys-jsapiconsent') 2527 } 2528 return status; 2529 }, 2530 2531 matchString: function(str, subject) { 2532 if(this.isStringNotEmpty(str) === false){ 2533 this.printErrorMsg(".matchString(str, subject) - str as string required"); 2534 return false; 2535 } 2536 if(this.isStringNotEmpty(subject) === false){ 2537 this.printErrorMsg(".matchString(str, subject) - str as string required"); 2538 return false; 2539 } 2540 str = this.trim(str); 2541 subject = this.trim(subject); 2542 let re = new RegExp(`.*^${str}$.*`, 'gi'); 2543 return re.test(subject); 2544 }, 2545 2546 matchRegex: function(regex, subject) { 2547 if(this.isString(regex) === false){ 2548 this.printErrorMsg(".matchRegex(regex, subject) - regex must be a not empty string"); 2549 return false; 2550 } 2551 if(this.isString(subject) === false){ 2552 this.printErrorMsg(".matchRegex(regex, subject) - subject must be a not empty string"); 2553 return false; 2554 } 2555 2556 var 2557 run, 2558 matches = [], 2559 regex = new RegExp(regex, 'g'); 2560 2561 while ((run = regex.exec(subject)) !== null) { 2562 if (run.index === regex.lastIndex) { 2563 regex.lastIndex++; 2564 } 2565 matches.push(run); 2566 } 2567 2568 return matches; 2569 }, 2570 2571 doJsCheckUp: function() { 2572 if(this.isLiveHost() === false){ 2573 let 2574 jq = this.type(jQuery) !== undefined, 2575 base = this.getBaseObject() !== false; 2576 2577 return [jq, base]; 2578 } 2579 }, 2580 2581 printElement : function(element){ 2582 if (this.isLocalHost() === true) { 2583 console.log(element); 2584 } 2585 }, 2586 2587 printInfoMsg : function(msg){ 2588 if (this.isLocalHost() === true) { 2589 if(this.type(msg) === 'String' && msg.length > 0){ 2590 console.info('%c' + appName + ':' + msg, 'color: ' + infoColor + ';'); 2591 } 2592 } 2593 }, 2594 2595 printErrorMsg : function(msg){ 2596 if (this.isLocalHost() === true) {
2597 if(this.type(msg) === 'String' && msg.length > 0){ 2598 console.error('%c' + appName + ':' + msg, 'color: ' + errorColor + ';'); 2599 } 2600 } 2601 }, 2602 2603 printStackTrace: function(msg){ 2604 if (this.isLocalHost() === true) { 2605 if(this.type(msg) === 'String' && msg.length > 0){ 2606 console.trace('%c' + appName + ':' + msg, 'color: ' + errorColor + ';'); 2607 } 2608 } 2609 }, 2610 2611 _gui: function() { 2612 const 2613 _api = this; 2614 return { 2615 init: function(){ 2616 this.doShadowMe(); 2617 this.doColorMe(); 2618// this.doSecureLoad(); 2619 this.doLazyLoad(); 2620 this.doBgLazyLoad(); 2621 this.doJsCfgLazyLoad(); 2622 this.doCiColor(); 2623// this.doAddonMarker(); 2624 return true; 2625 }, 2626 2627 reInit: function(){ 2628 this.doCiColor(); 2629 this.doColorMe(); 2630 return true; 2631 }, 2632 2633 doShadowMe: function() { 2634 if(_api.getAppGenAsInt() < 2){ 2635 return false; 2636 } 2637 let elementToFind = _api.get('.jwdrf-header-sticky.jwdrf-header-stickyInvers0',true), 2638 colorToConvert = window.getComputedStyle(document.documentElement).getPropertyValue('--jwtpldraft1bgcolor'), 2639 rgbArray = this.doHexToRGB(colorToConvert); 2640 if(elementToFind.length > 0 && colorToConvert !== ''){ 2641 _api.style(elementToFind[0], 'box-shadow', '0 0 10px 1px rgb(' + rgbArray[0] + ' ' + rgbArray[1] + ' ' + rgbArray[2] + ' / 80%)', 'important'); 2642 } 2643 }, 2644 2645 doHexToRGB: function(hex) { 2646 let normal = hex.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i); 2647 if (normal) return normal.slice(1).map(e => parseInt(e, 16)); 2648 let shorthand = hex.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])$/i); 2649 if (shorthand) return shorthand.slice(1).map(e => 0x11 * parseInt(e, 16)); 2650 return null; 2651 }, 2652 2653 doColorMe: function() { 2654 if(_api.getAppGenAsInt() < 2){ 2655 return false; 2656 } 2657 let list = _api.getGuiTagList(), 2658 myDevice = _api.isMobile() ? 'mobile' : 'desktop'; 2659 _api.each(list, module => { 2660 if(_api.getGuiTag('colorme',module) > 0){ 2661 let moduleFunction = _api.getGuiTag('name',module) + 'GetColorMeInfo', 2662 moduleGuiTag = _api.getGuiTag('all',module), 2663 moduleConfig = false; 2664 try { 2665 moduleConfig = window[_api.getBaseName()][moduleFunction](); 2666 } catch (e) { 2667 _api.printErrorMsg('Javascript Config failed for [ ' + moduleGuiTag + ' ] || [' + e + ']'); 2668 return false; 2669 } 2670 _api.each(moduleConfig, configString => { 2671 let splittedConfigString = configString.split('|'); 2672 let domKey = splittedConfigString[0], 2673 domDeviceFilter = splittedConfigString[1], 2674 domGuiFilter = splittedConfigString[2], 2675 domSubKey = splittedConfigString[3]; 2676 for(let i=4; i<splittedConfigString.length ; i++){ 2677 let domValue = splittedConfigString[i], 2678 splittedDomValue = domValue.split(':'); 2679 let colorVariable= 'var(--jwtplci[colornumber][colorcode]color)'; 2680 colorVariable = colorVariable.replace('[colornumber]',_api.getGuiTag('colorme',module)); 2681 colorVariable = colorVariable.replace('[colorcode]', splittedDomValue[1]); 2682 let elementToFind = false; 2683 if(myDevice === domDeviceFilter && ((domGuiFilter === 'all') || (_api.getGuiTag('display',module)==domGuiFilter))){ 2684 if(domKey.endsWith('-block')){ 2685 elementToFind = _api.get('[data-jwtpl-sys-gui="' + moduleGuiTag + '"]', true); 2686 } else { 2687 elementToFind = _api.get('[data-jwtpl-sys-gui="' + moduleGuiTag + '"] ' + domKey , true); 2688 } 2689 } 2690 if(elementToFind !== false){ 2691 for(let i=0; i< elementToFind.length; i++){ 2692 if(domSubKey === 'base'){ 2693 _api.style(elementToFind[i], splittedDomValue[0], colorVariable, 'important'); 2694 } else if(domSubKey === 'hover'){ 2695 let previousColor = elementToFind[i].style.color,
2696 previousBackgroundColor = elementToFind[i].style.backgroundColor; 2697 elementToFind[i].addEventListener('mouseenter', function() { 2698 _api.style(elementToFind[i], splittedDomValue[0], colorVariable, 'important'); 2699 }); 2700 elementToFind[i].addEventListener('mouseleave', function() { 2701 if(splittedDomValue[0] === 'color'){ 2702 _api.style(elementToFind[i], 'color', previousColor, 'important'); 2703 } else if(splittedDomValue[0] === 'background-color'){ 2704 _api.style(elementToFind[i], 'background-color', previousBackgroundColor, 'important'); 2705 } 2706 }); 2707 } 2708 } 2709 } 2710 2711 } 2712 }); 2713 } 2714 }); 2715 }, 2716 2717 doSecureLoad: function() { 2718 const liste = new Map(); 2719 liste.set(1, 1); 2720 liste.set(2, 2); 2721 liste.set(3, 4); 2722 liste.forEach((levelSecure,levelId)=>{ 2723 if(_api._consent().checkConsent(levelSecure) === true){ 2724 let secureImg = _api.get('[data-jwtpl-sysImg-sec'+ levelId +'LoadSrc]', true), 2725 dataAttribute = ''; 2726 if(secureImg.length > 0) { 2727 _api.each(secureImg, img => { 2728 dataAttribute = img.getAttribute('data-jwtpl-sysImg-sec'+ levelId + 'LoadSrc'); 2729 if(_api.isStringNotEmpty(dataAttribute) === true){ 2730 img.src = dataAttribute; 2731 img.removeAttribute('data-jwtpl-sysImg-sec'+ levelId +'LoadSrc'); 2732 } 2733 }); 2734 } 2735 }else{ 2736 let secureImg = _api.get('[data-jwtpl-sysImg-sec'+ levelId + 'LoadSrc]', true), 2737 dataAttribute = ''; 2738 if(secureImg.length > 0) { 2739 _api.each(secureImg, img => { 2740 img.src = _api.getProjectPath() + 'api/img/svg/shield-halved-solid.svg'; 2741 if(_api.hasClass(img, 'jwtpl-global-secureImage') !== true){ 2742 _api.addClass(img, 'jwtpl-global-secureImage'); 2743 _api._consent().checkConsentCallback(levelSecure, function () { 2744 let dataAttribute = img.getAttribute('data-jwtpl-sysImg-sec' + levelId + 'LoadSrc'); 2745 if(_api.isStringNotEmpty(dataAttribute) === true){ 2746 img.src = dataAttribute; 2747 img.removeAttribute('data-jwtpl-sysImg-sec' + levelId +'LoadSrc'); 2748 _api.removeClass(img, 'jwtpl-global-secureImage'); 2749 } 2750 }); 2751 // console.log('wir sind in doseculreload'); 2752 _api.event(img, 'click', function (e) { 2753 // console.log('wir sind in doseculreload im click'); 2754 _api._consent().getConsent(levelSecure, function () { 2755 let dataAttribute = img.getAttribute('data-jwtpl-sysImg-sec' + levelId +'LoadSrc'); 2756 if(_api.isStringNotEmpty(dataAttribute) === true){ 2757 img.src = dataAttribute; 2758 img.removeAttribute('data-jwtpl-sysImg-sec' + levelId + 'LoadSrc'); 2759 _api.removeClass(img, 'jwtpl-global-secureImage'); 2760 } 2761 }
2761, 'Um dieses Bild sehen zu können, müssen Sie dem markierten Consent zustimmen!'); 2762 }) 2763 // console.log('wir sind in doseculreload nach event'); 2764 } 2765 }); 2766 } 2767 } 2768 }) 2769 }, 2770 2771 doSecureLoad2: function() { 2772 if(_api._consent().checkConsent(4) === true){ 2773 let secureImg = _api.get('[data-jwtpl-sysImg-sec3LoadSrc]', true), 2774 dataAttribute = ''; 2775 if(secureImg.length > 0) { 2776 _api.each(secureImg, img => { 2777 dataAttribute = img.getAttribute('data-jwtpl-sysImg-sec3LoadSrc'); 2778 if(_api.isStringNotEmpty(dataAttribute) === true){ 2779 img.src = dataAttribute; 2780 img.removeAttribute('data-jwtpl-sysImg-sec3LoadSrc'); 2781 } 2782 }); 2783 } 2784 } else { 2785 let secureImg = _api.get('[data-jwtpl-sysImg-sec3LoadSrc]', true); 2786 if(secureImg.length > 0) { 2787 _api.each(secureImg, img => { 2788 img.src = _api.getProjectPath() + 'api/img/svg/shield-halved-solid.svg'; 2789 if(_api.hasClass(img, 'jwtpl-global-secureImage') !== true){ 2790 _api.addClass(img, 'jwtpl-global-secureImage'); 2791 } 2792 });
2793 } 2794 _api._consent().getConsent(4, function () { 2795 let secureImg = _api.get('[data-jwtpl-sysImg-sec3LoadSrc]', true), 2796 dataAttribute = ''; 2797 if(secureImg.length > 0) { 2798 _api.each(secureImg, img => { 2799 dataAttribute = img.getAttribute('data-jwtpl-sysImg-sec3LoadSrc'); 2800 if(_api.isStringNotEmpty(dataAttribute) === true){ 2801 img.src = dataAttribute; 2802 img.removeAttribute('data-jwtpl-sysImg-sec3LoadSrc'); 2803 _api.removeClass(img, 'jwtpl-global-secureImage'); 2804 } 2805 }); 2806 } 2807 }, 'Um dieses Bild sehen zu können, müssen Sie externe Inhalte erlauben!'); 2808 } 2809 }, 2810 2811 doLazyLoad: function() { 2812 const observer = new IntersectionObserver(function(entries, self) { 2813 entries.forEach(entry => { 2814 if(entry.isIntersecting) { 2815 if(_api.type(entry.target.dataset) !== undefined && _api.type(entry.target.dataset.jwtplSysimgLazysrc) !== undefined && _api.isStringNotEmpty(entry.target.dataset.jwtplSysimgLazysrc) === true) { 2816 entry.target.src = entry.target.dataset.jwtplSysimgLazysrc; 2817 entry.target.removeAttribute('data-jwtpl-sysImg-lazySrc'); 2818 self.unobserve(entry.target); 2819 } 2820 } 2821 }); 2822 }); 2823 2824 let lazyImg = _api.get('[data-jwtpl-sysImg-lazySrc]', true); 2825 if(lazyImg.length > 0) { 2826 _api.each(lazyImg, img => { 2827 observer.observe(img); 2828 }); 2829 } 2830 }, 2831 2832 doBgLazyLoad: function() { 2833 const observer = new IntersectionObserver(function(entries, self) { 2834 entries.forEach(entry => { 2835 if(entry.isIntersecting) { 2836 if(_api.type(entry.target.dataset) !== undefined && _api.type(entry.target.dataset.jwtplSysbgimgLazysrc) !== undefined && _api.isStringNotEmpty(entry.target.dataset.jwtplSysbgimgLazysrc) === true) { 2837 _api.style(entry.target, 'background', 'url(' + entry.target.dataset.jwtplSysbgimgLazysrc + ')'); 2838 entry.target.removeAttribute('data-jwtpl-sysBgImg-lazySrc'); 2839 self.unobserve(entry.target); 2840 } 2841 } 2842 }); 2843 }); 2844 2845 let lazyBgImg = _api.get('[data-jwtpl-sysBgImg-lazySrc]', true); 2846 if(lazyBgImg.length > 0) { 2847 _api.each(lazyBgImg, bgImg => { 2848 observer.observe(bgImg); 2849 }); 2850 } 2851 }, 2852 2853 doJsCfgLazyLoad: function() { 2854 if(_api.getAppInfo('spuch') === '' && _api.getBaseObject() !== false && _api.getBaseObject()._globalGetCfg('lazyLoad') !== false) { 2855 const observerBg = new IntersectionObserver(function(entries, self) { 2856 entries.forEach(entry => { 2857 if(entry.isIntersecting) { 2858 if(_api.type(entry.target.dataset) !== undefined && _api.type(entry.target.dataset.jwtplSysbgimgLazyjsrealsrc) !== undefined && _api.isStringNotEmpty(entry.target.dataset.jwtplSysbgimgLazyjsrealsrc) === true) { 2859 _api.style(entry.target, 'background', 'url(' + entry.target.dataset.jwtplSysbgimgLazyjsrealsrc + ')'); 2860 entry.target.removeAttribute('data-jwtpl-sysBgImg-lazyJsSrc'); 2861 entry.target.removeAttribute('data-jwtpl-sysBgImg-lazyJsRealSrc'); 2862 entry.target.removeAttribute('data-jwtpl-sysLoopBgImg-lazyJsSrc'); 2863 self.unobserve(entry.target); 2864 } 2865 } 2866 }); 2867 }); 2868 2869 const observerImg = new IntersectionObserver(function(entries, self) { 2870 entries.forEach(entry => { 2871 if(entry.isIntersecting) { 2872 if(_api.type(entry.target.dataset) !== undefined && _api.type(entry.target.dataset.jwtplSysimgLazyjsrealsrc) !== undefined && _api.isStringNotEmpty(entry.target.dataset.jwtplSysimgLazyjsrealsrc) === true) { 2873 entry.target.src = entry.target.dataset.jwtplSysimgLazyjsrealsrc; 2874 entry.target.removeAttribute('data-jwtpl-sysImg-lazyJsSrc'); 2875 entry.target.removeAttribute('data-jwtpl-sysImg-lazyJsRealSrc'); 2876 entry.target.removeAttribute('data-jwtpl-sysLoopImg-lazyJsSrc'); 2877 self.unobserve(entry.target); 2878 } 2879 } 2880 }); 2881 });
2882 2883 _api.each(_api.getBaseObject()._globalGetCfg('lazyLoad'), (values, key) => { 2884 key = key.toLowerCase(); 2885 if(_api.isStringNotEmpty(key) === true && key.length > 0) { 2886 if(!(key.includes('|cm:'))){ 2887 key = key.concat('|cm:0'); 2888 } 2889 let mods = _api.get('[data-jwtpl-sys-gui="' + key + '"]'); 2890 _api.each(mods, (it) => { 2891 let urlsBg= new Map(), urls = new Map(), def = new Map(); 2892 _api.each(values, (v,k) => { 2893 if(k.indexOf('loop/default/') !== -1) { 2894 def.set(k, v); 2895 } else if(k.indexOf('loop/urls/') !== -1) { 2896 urls.set(k, v); 2897 } else if(k.indexOf('loop/bg/urls/') !== -1) { 2898 urlsBg.set(k, v); 2899 } 2900 if(k.indexOf('loop/urls/') !== -1) { 2901 k = k.replace('loop/urls/', ''); 2902 let eles = it.querySelectorAll('[data-jwtpl-sysLoopImg-lazyJsSrc="' + k + '"]'); 2903 _api.each(eles, (e, i) => { 2904 let parent = e.parentElement; 2905 if(_api.isNull(parent) === false && parent.hasAttribute('href') === true && parent.getAttribute('href') !== '') { 2906 let 2907 url = parent.getAttribute('href').replace(_api.getProjectPath(), '/'), 2908 entry = urls.has('loop/urls/' + k) ? urls.get('loop/urls/' + k) : false; 2909 2910 if(entry !== false && _api.isNull(entry[url]) === false && entry[url] !== '') { 2911 e.setAttribute('data-jwtpl-sysImg-lazyJsRealSrc', entry[url]); 2912 observerImg.observe(e); 2913 } else { 2914 let dv = def.has('loop/default/' + k) ? def.get('loop/default/' + k) : false; 2915 if(dv !== false && dv !== '') { 2916 e.setAttribute('data-jwtpl-sysImg-lazyJsRealSrc', dv); 2917 observerImg.observe(e) 2918 } 2919 } 2920 } 2921 }); 2922 } else if(k.indexOf('loop/bg/urls/') !== -1) { 2923 k = k.replace('loop/bg/urls/', ''); 2924 let eles = it.querySelectorAll('[data-jwtpl-sysLoopBgImg-lazyJsSrc="' + k + '"]'); 2925 _api.each(eles, (e, i) => { 2926 if(e.hasAttribute('href') === true && e.getAttribute('href') !== '') { 2927 let 2928 url = e.getAttribute('href').replace(_api.getProjectPath(), '/'), 2929 entry = urlsBg.has('loop/bg/urls/' + k) ? urlsBg.get('loop/bg/urls/' + k) : false; 2930 2931 if(entry !== false && _api.isNull(entry[url]) === false && entry[url] !== '') { 2932 e.setAttribute('data-jwtpl-sysBgImg-lazyJsRealSrc', entry[url]); 2933 observerBg.observe(e); 2934 } else { 2935 let dv = def.has('loop/default/' + k) ? def.get('loop/default/' + k) : false; 2936 if(dv !== false && dv !== '') { 2937 e.setAttribute('data-jwtpl-sysBgImg-lazyJsRealSrc', dv); 2938 observerBg.observe(e); 2939 } 2940 } 2941 } 2942 }); 2943 } else if(k.indexOf('loop/bg') !== -1) { 2944 k = k.replace('loop/bg/', ''); 2945 let eles = it.querySelectorAll('[data-jwtpl-sysLoopBgImg-lazyJsSrc="' + k + '"]'); 2946 _api.each(eles, (e, i) => { 2947 if(_api.type(v[i]) !== undefined) { 2948 e.setAttribute('data-jwtpl-sysBgImg-lazyJsRealSrc', v[i]); 2949 observerBg.observe(e); 2950 } else { 2951 let dv = def.has('loop/default/' + k) ? def.get('loop/default/' + k) : false; 2952 if(dv !== false && dv !== '') { 2953 e.setAttribute('data-jwtpl-sysBgImg-lazyJsRealSrc', dv); 2954 observerBg.observe(e); 2955 } 2956 } 2957 }); 2958 } else if(k.indexOf('loop') !== -1) { 2959 k = k.replace('loop/', ''); 2960 let eles = it.querySelectorAll('[data-jwtpl-sysLoopImg-lazyJsSrc="' + k + '"]'); 2961 _api.each(eles, (e, i) => { 2962 if(_api.type(v[i]) !== undefined) { 2963 e.setAttribute('data-jwtpl-sysImg-lazyJsRealSrc', v[i]); 2964 observerImg.observe(e); 2965 } else { 2966 let dv = def.has('loop/default/' + k) ? def.get('loop/default/' + k) : false; 2967 if(dv !== false && dv !== '') { 2968 e.setAttribute('data-jwtpl-sysImg-lazyJsRealSrc', dv); 2969 observerImg.observe(e); 2970 } 2971 } 2972 });
2973 } else if(k.indexOf('bg/') !== -1) { 2974 k = k.replace('bg/', ''); 2975 let ele = it.querySelector('[data-jwtpl-sysBgImg-lazyJsSrc="' + k + '"]'); 2976 if(_api.type(ele) !== undefined) { 2977 ele.setAttribute('data-jwtpl-sysBgImg-lazyJsRealSrc', v); 2978 observerBg.observe(ele); 2979 } 2980 } else { 2981 let ele = it.querySelector('[data-jwtpl-sysImg-lazyJsSrc="' + k + '"]'); 2982 if(_api.type(ele) !== undefined) { 2983 ele.setAttribute('data-jwtpl-sysImg-lazyJsRealSrc', v); 2984 observerImg.observe(ele); 2985 } 2986 } 2987 }); 2988 }); 2989 } 2990 }); 2991 } 2992 }, 2993 2994 doCiColor: function() { 2995 if(_api.getBaseObject()._globalGetCfg('ciColor') !== false) { 2996 let ele; 2997 _api.each(_api.getBaseObject()._globalGetCfg('ciColor'), (it) => { 2998 2999 if(it.length === 4) { 3000 if(it[0] === 'font') { 3001 ele = _api.get('[data-jwtpl-sys-gui="' + it[2] + '"] ' + it[3],true); 3002 _api.each(ele, (e)=> { 3003 if(it[1].startsWith('--') === true && _api.getRootValue(it[1]).length > 0) { 3004 _api.style(e, 'color', it[1], _api.getRootValue(it[1]), 'important'); 3005 } else if(it[1].startsWith('#') === true && (it[1].length === 4 || it[1].length === 7)) { 3006 _api.style(e, 'color', it[1], 'important'); 3007 } 3008 }); 3009 } else if(it[0] === 'bg') { 3010 ele = _api.get('[data-jwtpl-sys-gui="' + it[2] + '"] ' + it[3],true); 3011 _api.each(ele, (e)=> { 3012 if(it[1].startsWith('--') === true && _api.getRootValue(it[1]).length > 0) { 3013 _api.style(e, 'background-color', it[1], _api.getRootValue(it[1]), 'important'); 3014 } else if(it[1].startsWith('#') === true && (it[1].length === 4 || it[1].length === 7)) { 3015 _api.style(e, 'background-color', it[1], 'important'); 3016 } 3017 }); 3018 } 3019 } 3020 }); 3021 } 3022 }, 3023 doAddonMarker: function() { 3024 let listAddOns = _api.getBaseObject()._globalGetCfg('addOns'), 3025 listIdentifiers = new Set(), 3026 encounteredValues = {}; 3027 for (let i = 0; i < listAddOns.length; i++) { 3028 let key = listAddOns[i][0]; 3029 let values = listAddOns[i][1].split(',').map(value => value.trim()); 3030 if (listIdentifiers.has(key)) { 3031 _api.printErrorMsg(`Der Bezeichner '${key}' wurde bereits hinzugefügt.`); 3032 return false; 3033 } else { 3034 listIdentifiers.add(key); 3035 } 3036 for (let value of values) { 3037 if (encounteredValues[value]) { 3038 _api.printErrorMsg(`Der Marker '${value}' wurde bereits hinzugefügt.`); 3039 return false; 3040 } else { 3041 encounteredValues[value] = true; 3042 var hiliElements = _api.get('.jwtpl-hili-block.jwtpl-hili-blockMultipleAddOn1 .jwtpl-sysHili-addon'); 3043 if (hiliElements.length > 0) { 3044 _api.each(hiliElements, element => { 3045 console.log(element.classList); 3046 var itemTitel = element.querySelector(".jwtpl-hili-itemTitel"), 3047 itemTitelText = itemTitel.innerHTML; 3048 if(itemTitelText != '' && itemTitelText.indexOf("jwtpl-hili-itemTitelJsSpan") == -1){ 3049 var eleSpanNewTitel = document.createElement("span"), 3050 eleSpan = document.createElement("span"); 3051 eleSpan.className = "jwtpl-sysHili-addonJsSpan " ; 3052 eleSpan.innerText = "Test" 3053 eleSpanNewTitel.className = "jwtpl-hili-itemTitelJsSpan"; 3054 eleSpanNewTitel.innerText = itemTitelText; 3055 itemTitel.innerHTML= ""; 3056 itemTitel.appendChild(eleSpan); 3057 itemTitel.appendChild(eleSpanNewTitel); 3058 }else{ 3059 var eleSpan = document.createElement("span"); 3060 eleSpan.className = "jwtpl-sysHili-addonJsSpan " ; 3061 eleSpan.innerText = "Test2" 3062 itemTitel.prepend(eleSpan); 3063 } 3064 }); 3065 } 3066 } 3067 } 3068 } 3069 } 3070 } 3071 }, 3072 3073 _cc: function() { 3074 const 3075 _api = this; 3076 return { 3077 init: function(){ 3078 return true; 3079 }, 3080 3081 getConsentMode: function() { 3082 let mode = _api.getConsentStatus().toLowerCase().replace('true|', '').replace('false|', ''); 3083 return _api.trim(mode); 3084 } 3085 } 3086 }, 3087 3088 _tpl: function() { 3089 const 3090 _api = this, 3091 jsonApiPath = '_api/json?jmax=', 3092 deleteNoMatchTags = false; 3093 3094 var 3095 data = false, 3096 tpl = false, 3097 path = JwTplJsLib.getProjectPath() + jsonApiPath; 3098 3099 return { 3100 init: function() { 3101 return true; 3102 }, 3103 3104 call: function(param) { 3105 if(_api.type(param) === undefined){ 3106 _api.printErrorMsg("._tpl.call(param) - param must be defined"); 3107 return false; 3108 } else if(_api.isString(param) === false){ 3109 _api.printErrorMsg("._tpl.call(param) - param must be not empty string"); 3110 return false; 3111 } 3112 3113 _api.ajax({ 3114 url: path + param, 3115 method:'get', 3116 callback:function(data){ 3117 var json = _api.jsonParse(data); 3118 if(json !== false){ 3119 JwTplJsLib._tpl().setData(json); 3120 } else { 3121 _api.printErrorMsg("._tpl.call(url) - cannot parse json for url [" + url + "]"); 3122 return false; 3123 } 3124 } 3125 });
3126 }, 3127 3128 setData: function(obj) { 3129 if(_api.isObject(obj) === true){ 3130 data = obj; 3131 var 3132 json = this.getDataItem('data.list'), 3133 tpl = this.getDataItem('data.tpl'); 3134 this.setTpl(tpl); 3135 this.assign(); 3136 } else { 3137 _api.printErrorMsg("._tpl.setData(obj) - obj must be an object, [" + _api.type(obj) + "] given instead"); 3138 } 3139 }, 3140 3141 getData: function() { 3142 return _api.isObject(data) === true ? data : false; 3143 }, 3144 3145 setTpl: function(template){ 3146 if(_api.isNull(template) === false && _api.isString(template) !== false){ 3147 tpl = template; 3148 } else { 3149 _api.printErrorMsg(".setTpl(tpl) - tpl must be a not empty string. [" + _api.type(template) + "] given instead"); 3150 } 3151 }, 3152 3153 getTpl: function(){ 3154 return tpl !== false ? tpl : false; 3155 }, 3156 3157 getDataItem: function(data){ 3158 if(_api.type(data) === undefined){ 3159 _api.printErrorMsg(".getSection(data) - data must be defined"); 3160 return false; 3161 } else if(_api.isString(data) === false){ 3162 _api.printErrorMsg(".getSection(data) - data must be not empty string"); 3163 return false; 3164 } 3165 3166 var 3167 entry = this.getData(); 3168 3169 if(entry !== false){ 3170 var 3171 split = data.split('.'), 3172 len = split.length; 3173 3174 if(len === 1 && _api.type(entry[split[0]]) !== undefined){ 3175 return entry[split[0]]; 3176 } if(len === 2 && _api.type(entry[split[0]]) !== undefined && _api.type(entry[split[0]][split[1]]) !== undefined){ 3177 return entry[split[0]][split[1]]; 3178 } if(len === 3 && (_api.type(entry[split[0]]) !== undefined) && (_api.type(entry[split[0]][split[1]]) !== undefined) && (_api.type(entry[split[0]][split[1]][split[2]]) !== undefined) ){ 3179 return entry[split[0]][split[1]][split[2]]; 3180 } if(len === 4 && (_api.type(entry[split[0]]) !== undefined) && (_api.type(entry[split[0]][split[1]]) !== undefined) && (_api.type(entry[split[0]][split[1]][split[2]]) !== undefined) && (_api.type(entry[split[0]][split[1]][split[2]][split[3]]) !== undefined)){ 3181 return entry[split[0]][split[1]][split[2]][split[3]]; 3182 } if(len === 5 && (_api.type(entry[split[0]]) !== undefined) && (_api.type(entry[split[0]][split[1]]) !== undefined) && (_api.type(entry[split[0]][split[1]][split[2]]) !== undefined) && (_api.type(entry[split[0]][split[1]][split[2]][split[3]]) !== undefined) && (_api.type(entry[split[0]][split[1]][split[2]][split[3]][split[4]]) !== undefined)){ 3183 return entry[split[0]][split[1]][split[2]][split[3]][split[4]]; 3184 } else{ 3185 _api.printInfoMsg('.getSection() - no property [' + split.join('.') + '] found'); 3186 return ''; 3187 } 3188 } else { 3189 _api.printInfoMsg('.getSection() - no ajax entry found'); 3190 return ''; 3191 } 3192 3193 return ''; 3194 }, 3195 3196 assign: function(){ 3197 var 3198 template = this.getTpl(), 3199 loops = _api.matchRegex('{#:loop}(.*?){#:\/loop}
3199', this.getTpl()); 3200 3201 if(_api.len(loops) > 0) { 3202 var loopData = loops[0]; 3203 for(var i=0; i<loopData.length; i++){ 3204 if(i > 0){ 3205 var 3206 tmp = '', 3207 data = this.getDataItem('data.list'); 3208 3209 for(var j=0; j<_api.len(data); j++){ 3210 var 3211 tagData, 3212 loopTpl = loopData[i]; 3213 3214 loopTpl = loopTpl.replaceAll('{#:loopIndex}', j); 3215 tagData =_api.matchRegex('{#:(.*?)}', loopTpl); 3216 3217 if(tagData.length > 0){ 3218 for(var k=0; k<tagData.length; k++){ 3219 if( _api.isNull(tagData[k][1]) === false){ 3220 if(_api.isString(this.getDataItem(tagData[k][1])) === true){ 3221 loopTpl = loopTpl.replace('{#:' + tagData[k][1] +'}', this.getDataItem(tagData[k][1])); 3222 } 3223 } 3224 } 3225 } 3226 tmp += loopTpl; 3227 } 3228 template = template.replace(loopData[i], tmp); 3229 template = template.replace('{#:loop}', '').replace('{#:/loop}', ''); 3230 } 3231 } 3232 } 3233 3234 var tplVars = _api.matchRegex('{#:(.*?)}', template); 3235 3236 if(_api.len(tplVars) > 0) { 3237 var tagsData = tplVars; 3238 for(var x=0; x<tplVars.length; x++){ 3239 if(_api.isNull(tplVars[x][1]) === false) { 3240 if(_api.isString(this.getDataItem(tplVars[x][1])) === true){ 3241 template = template.replace('{#:' + tplVars[x][1] + '}', this.getDataItem(tplVars[x][1])); 3242 } 3243 } 3244 } 3245 } 3246 return template; 3247 } 3248 } 3249 } 3250 } 3251 })(); 3252}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.