1//'use strict'; 2 3var j, s; 4function vat(p, vat) { 5 6 if (p > 0 && p <= 0.0000001) { 7 return 0; 8 } 9 10 let priceParam = Number.isNaN(Number(p)) ? 0.0 : Number.parseFloat(p); 11 let vatParam = Number.isNaN(Number(vat)) > 0 ? 0 : Number.parseInt(vat); 12 priceParam = priceParam * (100 + vatParam) / 100; 13 return format(priceParam); 14} 15function format(p, d) { 16 let decimals = typeof d != "undefined" ? d : typeof DECIMAL_LENGTH !== 'undefined' ? DECIMAL_LENGTH : 2; 17 let n = !Number.isFinite(Number(+p)) ? 0 : +p, 18 prec = !Number.isFinite(Number(+decimals)) ? 2 : Math.abs(decimals), 19 sep = (typeof SEP_THO === 'undefined') ? '.' : SEP_THO, 20 dec = (typeof SEP_DEC === 'undefined') ? ',' : SEP_DEC, 21 s = '', 22 toFixedFix = function (n, prec) { 23 let k = Math.pow(10, prec); 24 return '' + Math.round(n * k) / k; 25 }; 26 s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.'); 27 if (s[0].length > 3) { 28 s[0] = s[0].replaceAll(/\B(?=(?:\d{3})+(?!\d))/g, sep); 29 } 30 if ((s[1] || '').length < prec) { 31 s[1] = s[1] || ''; 32 s[1] += new Array(prec - s[1].length + 1).join('0'); 33 } 34 return s.join(dec); 35 36} 37 38function moneyExchange(price, from, to) { 39 let k = from + '_TO_' + to; 40 if (typeof RATE === 'object' && typeof RATE[k] !== 'undefined') { 41 return price * RATE[k]; 42 } else { 43 return price; 44 } 45} 46 47 48function Template(options) {
49 let counter = 900; 50 Template.ready = function (fn) { 51 Template.instance.activeTemplate.set('ready', fn); 52 }; 53 54 Template.htmlObject = Template.htmlObject || {}; 55 let opt = { 56 'content': '', 57 'source': '#page-html', 58 'destination': '#page-content', 59 'assign': {}, 60 'routes': {}, 61 'id': 'last', 62 callback: 'callbackFn', 63 ready: function () { 64 65 } 66 }; 67 let filters = { 68 'default': function (p, defaultVal) { 69 return (typeof p === 'undefined' || p === '') ? defaultVal : p; 70 }, 71 limitTo: function (p, limit, begin) { 72 p = p + ""; 73 limit = limit > 0 ? limit : 10; 74 begin = begin > 0 ? begin : 0; 75 return p.substring(begin, limit); 76 }, 77 format: function (p, dec) { 78 return window.format(p, dec); 79 }, 80 exchange: function (p, from, to) { 81 return format(window.moneyExchange(p, from, to)); 82 }, 83 vat: function (p, vat) { 84 return window.vat(p, vat); 85 }, 86 currency: function (n, c) { 87 c = Number.isNaN(Number(c = Math.abs(c))) ? 2 : c, 88 s = n < 0 ? "-" : "", 89 i = Number.parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", 90 j = (j = i.length) > 3 ? j % 3 : 0; 91 return s + (j ? i.substr(0, j) + ',' : '') + i.substr(j).replaceAll(/(\d{3})(?=\d)/g, "$1" + ',') + (c ? '.' + Math.abs(n - i).toFixed(c).slice(2) : ""); 92 }, 93 date: function (p, format) { 94 p = Number.parseInt(p); 95 96 if (Number.isNaN(Number(p)) || p < 1000000000) { 97 p = 1000000000; 98 } else if (p < 9000000000) { 99 p = p * 1000; 100 } 101 102 format = format.replaceAll(/["']/g, ''); 103 104 function pad(s) { 105 return (s < 10) ? '0' + s : s; 106 } 107 let d = new Date(p); 108 109 format = format.replaceAll(/y+/ig, d.getFullYear()); 110 format = format.replaceAll(/d+/ig, pad(d.getDate())); 111 format = format.replaceAll(/m+/ig, pad(d.getMonth() + 1)); 112 format = format.replaceAll(/h+/ig, pad(d.getHours())); 113 format = format.replaceAll(/i+/ig, pad(d.getMinutes())); 114 format = format.replaceAll(/s+/ig, pad(d.getSeconds())); 115 return format; 116 }, 117 filter: function (p) { 118 119 }, 120 lowercase: function (p) { 121 return typeof p === 'string' ? p.toLowerCase() : p; 122 }, 123 number: function (p) { 124 125 }, 126 uppercase: function (p) { 127 return typeof p === 'string' ? p.toUpperCase() : p; 128 }, 129 indexOf: function (p, key) { 130 return p.indexOf(key); 131 }, 132 test: function (p, rgxStr) { 133 let rgx = new RegExp(rgxStr, "ig"); 134 let r = rgx.test(p); 135 return r ? 1 : 0; 136 }, 137 replace: function (p, oldVal, newVal) { 138 oldVal = oldVal.toString().replaceAll(/-OR-/ig, '|').replaceAll(/-AND-/ig, '&').trim(); 139 let re = new RegExp(oldVal, "ig"); 140 if (p === null) { 141 p = ''; 142 } 143 return p.toString().replace(re, newVal); 144 }, 145 reverse: function (p) { 146 return p.reverse(); 147 } 148 }; 149 150 for (let i in options) { 151 opt[i] = options[i]; 152 } 153 154 let _this = this; 155 156 this.assign = function (key, val) { 157 if (typeof key === 'object') { 158 for (let i in key) { 159 opt.assign[i] = key[i]; 160 } 161 } else { 162 opt.assign[key] = val; 163 } 164 }; 165 this.getVar = function (key) { 166 return opt.assign[key]; 167 }; 168 this.get = function (key) { 169 return opt[key]; 170 }; 171 this.set = function (key, val) { 172 opt[key] = val; 173 }; 174 175 this.display = function () { 176 177 let navs = typeof navigation === 'undefined' ? [] : navigation; 178 179 if ($("[ng-app]").length > 0) { 180 opt.source = "[ng-app]"; 181 opt.destination = "[ng-app]"; 182 } 183 184 if (typeof Template.htmlObject[opt.id] === 'undefined') { 185 opt.content = $(opt.source).is('textarea') ? $(opt.source).val() : $(opt.source).html(); 186 opt.content = opt.content.replaceAll(/\r?\n|\r/ig, ' '); 187 opt.content = opt.content.replaceAll(/\s+/g, ' '); 188 Template.htmlObject[opt.id] = opt.content; 189 } else { 190 opt.content = Template.htmlObject[opt.id]; 191 $(opt.source).html(opt.content); 192 } 193 194 let insideHtml = []; 195 $('<div>').html(opt.content).find('.angularTemplate,.angularNotRender').each(function () { 196 insideHtml.push($(this).html()); 197 }); 198 199 $(opt.source).css('visibility', 'hidden'); 200 201 replaceForeach(); 202 replaceIf(); 203 204 opt.content = $(opt.source).is('textarea') ? $(opt.source).val() : $(opt.source).html(); 205 opt.content = opt.content || ""; 206 207 replaceShortIf(); 208 209 replaceObject(); 210 replaceVariable(); 211 212 opt.content = opt.content.replaceAll(/\s+ng-(\w+?)\s*=/ig, " $1="); 213 opt.content = opt.content.replaceAll(/\{\{[\w.]+\}\}/ig, ''); 214 215 216 217 $(opt.destination).html(opt.content); 218 219 if (typeof navs === 'object' && navs.length > 0) { 220 let str = '<a href="/Y/">' + main_page + '</a>'; //anasayfa 221 222 if ($(document).width() <= 640) { 223 str = ''; 224 $(".Navigate").css('right', 10); 225 } 226 227 for (let i = 0; i < navs.length; i++) { 228 str += '<a href="' + navs[i].link + '">' + navs[i].text + '</a>'; 229 } 230 $('.Navigate:first').append(str); 231 } else { 232 $('.Navigate:first').remove(); 233 } 234 235 for (let i = 0; i < insideHtml.length; i++) { 236 $(opt.source).find('.angularTemplate,.angularNotRender').eq(i).html(insideHtml[i]); 237 } 238 $(opt.destination).show(); 239 $(opt.destination).css('visibility', 'visible'); 240 241 opt.ready(opt.assign); 242 let fn = opt['callback']; 243 244 if (typeof fn === 'string' && typeof window[fn] === 'function') { 245 window[fn](opt.assign); 246 } else { 247 } 248 }; 249 250 Template.instance = Template.instance || {}; 251 Template.instance['activeTemplate'] = this; 252 Template.instance[_this.get('id')] = this; 253 254 function getVal(str) { 255 str = str || ''; 256 str = str.trim(); 257 let val = ''; 258 if (str[0] === "'") { 259 val = str.replaceAll('\'', ''); 260 } else if (str.match(/^WINDOW\./g)) { 261 let exp = str.replace('WINDOW.', '').split('.'); 262 let obj = window[exp[0]]; 263 if (typeof obj === 'object' && obj !== null) { 264 if (obj[exp[1]] != null && typeof obj[exp[1]] === 'object' && typeof exp[2] === 'string') { 265 val = obj[exp[1]][exp[2]] || ''; 266 } else { 267 val = typeof obj[exp[1]] === 'undefined' ? '' : obj[exp[1]]; 268 } 269 } else { 270 val = typeof obj === 'undefined' ? '' : obj; 271 } 272 } else if (str.match(/\./g)) { 273 let exp = str.split('.'); 274 275 let obj = _this.getVar(exp[0]); 276 if (typeof obj === 'object' && obj !== null) { 277 if (obj[exp[1]] != null && typeof obj[exp[1]] === 'object' && typeof exp[2] === 'string') { 278 val = obj[exp[1]][exp[2]] || ''; 279 } else { 280 val = typeof obj[exp[1]] === 'undefined' ? '' : obj[exp[1]]; 281 } 282 } 283 } else if (str.match(/^-?(\d+)$/g)) { 284 val = Number.parseInt(str); 285 } else if (str.match(/^(\w+)$/g)) { 286 val = _this.getVar(str); 287 } 288 return val; 289 } 290 291 292 function replaceAngularTags(content, find, newVal) { 293 let r = /\{\{([^\{\}]+?)\}\}/g; 294 let m; 295 let str = ''; 296 while ((m = r.exec(content)) !== null) { 297 str = m[0].replace(find, newVal); 298 content = content.replace(m[0], str); 299 } 300 return content; 301 } 302 303 304 // regex içerisinde $1 alanından oldVal yerine newVal gelir. 305 function childReplace(content, regex, oldStr, newStr) { 306 let m, str; 307 let r = new RegExp(oldStr, "g"); 308 while ((m = regex.exec(content)) !== null) { 309 310 str = m[1].replace(r, newStr); 311 content = content.replace(m[1], str); 312 313 } 314 return content; 315 } 316 317 function replaceForeach() { 318 319 let exist = false;
320 321 let indexCounter = 0; 322 323 $(opt.source).find('[ng-repeat]').each(function () { 324 325 exist = true; 326 let str = $(this).attr('ng-repeat'); 327 $(this).removeAttr('ng-repeat'); 328 let re = /(\w+)\s+in\s+([\w.\|:']+)/i; 329 330 let content = $('<div>').append($(this).clone()).html(); 331 let newVar = 'VARS' + counter++; 332 333 334 let contentAll = ''; 335 if (str.match(re)) { 336 let arr = re.exec(str); 337 let obj = afterFnVal(arr[2]); 338 339 if (typeof obj !== 'object') { 340 $(this).html(arr[2] + " DeÄiÅkeni Bulunamadı!"); 341 $(this).remove(); 342 return false; 343 } 344 345 let mArr = []; 346 for (const [i, obji] of obj.entries()) { 347 let newVar = 'VARS' + counter++; 348 let fContent = content; 349 350 fContent = fContent.replaceAll(/\{\{([^\r\n\{\}]*?)\$index([^\r\n\{\}]*?)\}\}/g, "{{$1" + i + "$2}}"); 351 352 let fRe1 = new RegExp("(\\W)" + arr[1] + '(\\W)', "g"); 353 let fRe2 = new RegExp('(ng-if=".*?)' + arr[1] + '(.*?")', "g"); 354 let fRe3 = new RegExp('(ng-repeat=".*?)' + arr[1] + '(.*?")', "g"); 355 356 _this.assign(newVar, obji); 357 358 fContent = replaceAngularTags(fContent, fRe1, '$1' + newVar + '$2'); 359 360 let findStr = arr[1] + "\\."; 361 362 fContent = childReplace(fContent, /ng-if="(.*?)"/g, findStr, newVar + "."); 363 fContent = childReplace(fContent, /ng-repeat="(.*?)"/g, findStr, newVar + "."); 364 fContent = childReplace(fContent, /\{\{(.*?)\}\}/g, '\$index', indexCounter); 365 366 contentAll += fContent; 367 368 } 369 370 $(this).after(contentAll); 371 $(this).remove(); 372 } 373 indexCounter++; 374 }); 375 376 if (exist) { 377 replaceForeach(); 378 } 379 return true; 380 } 381 382 function compareVars(val1, val2, operator) { 383 let result = false;
384 switch (operator) { 385 case '==': 386 result = val1 == val2; 387 break; 388 case '!=': 389 result = val1 !== val2; 390 break; 391 case '<': 392 result = val1 < val2; 393 break; 394 case '>': 395 result = val1 > val2; 396 break; 397 case '>=': 398 result = val1 >= val2; 399 break; 400 case '<=': 401 result = val1 <= val2; 402 break; 403 } 404 return result; 405 } 406 407 //4 iÅlem çalıÅtır. 408 function operateVars(val1, val2, operator) { 409 410 let result = 0; 411 val1 = Number.parseFloat(val1); 412 val2 = Number.parseFloat(val2); 413 switch (operator) { 414 case '-': 415 result = val1 - val2; 416 break; 417 case '+': 418 result = val1 + val2; 419 break; 420 case '*': 421 result = val1 * val2; 422 break; 423 case '/': 424 result = val1 / val2; 425 break; 426 } 427 428 429 return result; 430 } 431 432 function replaceIf() { 433 434 435 436 $(opt.source).find("[ng-if]").each(function () { 437 let str = $(this).attr('ng-if'); 438 $(this).removeAttr('ng-if'); 439 440 let ifCondition = 'and'; 441 let strArr = []; // || str.indexOf('||') 442 if (str.indexOf('&&') > 0) { 443 strArr = str.split('&&'); 444 } else if (str.indexOf('||') > 0) { 445 strArr = str.split('||'); 446 ifCondition = 'or'; 447 } else { 448 strArr = [str]; 449 } 450 451 let resultStr = 'if: '; 452 for (let i = 0; i < strArr.length; i++) { 453 str = strArr[i]; 454 let re = /\s*(.+?)\s*([<>=!]{1,2})\s*(.+)\s*/i; 455 let content = $(this).html(); 456 let contentAll = ''; 457 if (str.match(re)) { 458 let arr = re.exec(str); 459 460 461 let val1 = afterFnVal(arr[1]); 462 let val2 = afterFnVal(arr[3]); 463 464 resultStr += compareVars(val1, val2, arr[2]) == true ? 'true' : 'false'; 465 } 466 } 467 468 469 if (ifCondition === 'and' && resultStr.indexOf('false') > 0) { 470 $(this).remove(); 471 } 472 if (ifCondition === 'or' && resultStr.indexOf('true') < 0) { 473 $(this).remove(); 474 } 475 }); 476 return true; 477 } 478 479 //EÄer bir fonk. var ise onu çalıÅtırıp sonucunu döndürür. 480 function afterFnVal(str) { 481 482 if (str.indexOf('|') < 1) { 483 return getVal(str); 484 } 485 486 let exp = str.split('|'); 487 let params = [exp[0]]; 488 let fn = exp[1]; 489 490 491 492 493 if (exp[1].indexOf(':') > 0) { 494 fn = exp[1].replaceAll(/^\s*(\w+):.*?$/ig, '$1'); 495 let arr = exp[1].replaceAll(/^.*?:/ig, '').split(':'); 496 497 for (let i = 0; i < arr.length; i++) { 498 params.push(arr[i]); 499 } 500 } 501 for (let i = 0; i < params.length; i++) { 502 params[i] = getVal(params[i]); 503 } 504 let result = params[0]; 505 if (fn.length > 2 && typeof filters[fn] === 'function') { 506 result = filters[fn].apply(this, params); 507 } else if (typeof window[fn] === 'function') { 508 result = window[fn].apply(this, params); 509 } 510 return result; 511 } 512 513 function replaceShortIf() { 514 let oldContent = opt.content; 515 let r = /\{\{\s*([^\r\n\t\|\{\}]+?)\s*([><=\!]+)\s*([^\{\}]+?)\s+\?\s+(.*?)\s*:\s*(.*?)\s*\}\}/gi; 516 let m; 517 while ((m = r.exec(oldContent)) !== null) { 518 519 let val1 = getVal(m[1]); 520 let val2 = getVal(m[3]); 521 let result = compareVars(val1, val2, m[2]); 522 let newVal = result ? getVal(m[4]) : getVal(m[5]); 523 524 opt.content = opt.content.replace(m[0], newVal); 525 } 526 } 527 528 function replaceObject() { 529 let oldContent = opt.content; 530 531 let r = /\{\{\s*(\w+)\.(\w+)\s*\}\}/gi; 532 let m; 533 while ((m = r.exec(oldContent)) !== null) { 534 let obj = _this.getVar(m[1]); 535 if (typeof obj !== 'object' || obj === null) { 536 continue; 537 } 538 let key = m[2]; 539 /* 540 if (typeof obj[key] === 'undefined') { 541 continue; 542 } 543 */ 544 545 if (typeof obj[key] === 'undefined' || obj[key] === null) { 546 obj[key] = ''; 547 } 548 opt.content = opt.content.replace(m[0], obj[key]); 549 } 550 } 551 552 function replaceVariable() { 553 let oldContent = opt.content; 554 let arr = []; 555 let newVal = ''; 556 let operator = ''; 557 558 let child = ""; 559 let fn = ""; 560 561 let r = /\{\{(\s*[^\r\n\t]+?\s*)\}\}/gi; 562 let m; 563 while ((m = r.exec(oldContent)) !== null) { 564 if (/[\+\*\/\-]/g.test(m[1]) && m[1].indexOf("'") < 0) { 565 fn = m[1].indexOf('(') > -1 && m[1].indexOf('|') > -1 ? m[1].replaceAll(/^.*?\|/ig, '|') : ''; 566 m[1] = m[1].replace(fn, '').replaceAll(/[\(\)]/g, ''); 567 568 arr = m[1].split(/[\+\*\/\-]/g); 569 operator = m[1].replaceAll(/^.*?([\+\*\/\-]).*?$/ig, "$1"); 570 newVal = operateVars(afterFnVal(arr[0]), afterFnVal(arr[1]), operator); 571 572 newVal = fn == '' ? newVal : afterFnVal(newVal + fn); 573 574 } else { 575 newVal = afterFnVal(m[1]); 576 } 577 opt.content = opt.content.replace(m[0], newVal); 578 continue; 579 } 580 } 581 582}
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.