1// use togelLinks data as global for all WLs 2var togelLinks = { 3 "HK 4D": 'http://www.hk45pools.com', 4 "HK TOTO": 'http://www.hk45pools.com', 5 "HONGKONG": 'http://www.hk45pools.com', 6 "SINGAPURA": 'https://www.singaporepools.com.sg', 7 "SINGAPORE": 'https://www.singaporepools.com.sg', 8 "JAPAN": 'http://www.japan4d.com', 9 "TAIPEI": 'http://www.taipeipools.com', 10 "MACAU": 'http://www.macau-lottery.com', 11 "CAMBODIA": 'http://www.gdclottery.com' 12} 13 14function validateIPAddress(ipAddress) { 15 return /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(ipAddress) 16} 17function isValidLocalHost(host) { 18 return (validateIPAddress(host) || host === 'localhost') 19} 20function popUpRegister(refCode) { 21 window["isCheckedUserName"] = false; 22 var location = window.location 23 var url = location.origin 24 var registerPage = "_View/Register.aspx" 25 if (isValidLocalHost(location.host)) { 26 url = getLocalHomeUrl() 27 registerPage = refCode !== '' ? registerPage + '?ref=' : registerPage 28 } 29 else 30 registerPage = refCode !== '' ? '/' + registerPage + '?ref=' : '/' + registerPage 31 32 var registerWindow = window.open(url + registerPage + refCode, 'Register', 'width=645,height=700,toolbars=no,scrollbars=no,status=no,resizable=no'); 33 registerWindow.onbeforeunload = function () { 34 //if (window["isCheckedUserName"]) { 35 // window.location.reload(true); 36 //} 37 //window.location.reload(true); 38 var imgCaptcha = $('img[src*="public/img.aspx"]').eq(0) 39 var src = imgCaptcha.attr('src') 40 imgCaptcha.attr('src', src + "?r=" + new Date().getTime()) 41 if (imgCaptcha.length === 0) 42 window.location.reload(true); 43 } 44 45} 46function popupRegister(refCode, width = 645, height = 700) { 47 window["isCheckedUserName"] = false; 48 var location = window.location 49 var url = location.origin 50 var registerPage = "_View/Register.aspx" 51 if (isValidLocalHost(location.host)) { 52 url = getLocalHomeUrl() 53 registerPage = refCode !== '' ? registerPage + '?ref=' : registerPage 54 } 55 else 56 registerPage = refCode !== '' ? '/' + registerPage + '?ref=' : '/' + registerPage 57 58 var registerWindow = window.open(url + registerPage + refCode, 'Register', `width=${width},height=${height},toolbars=no,scrollbars=no,status=no,resizable=no`); 59 registerWindow.onbeforeunload = function () { 60 //if (window["isCheckedUserName"]) { 61 // window.location.reload(true); 62 //} 63 //window.location.reload(true); 64 var imgCaptcha = $('img[src*="public/img.aspx"]').eq(0) 65 var src = imgCaptcha.attr('src') 66 imgCaptcha.attr('src', src + "?r=" + new Date().getTime()) 67 if (imgCaptcha.length === 0) 68 window.location.reload(true); 69 } 70} 71function popUpNawala(url, w, h) { 72 var location = window.location; 73 var httpUrl = location.origin; 74 if (url.indexOf('http') > -1) 75 httpUrl = url 76 else if (location.host == 'localhost') 77 httpUrl = getLocalHomeUrl() + url 78 else 79 httpUrl += '/' + url 80 window.open(httpUrl, 'Nawala Unblocker', 'width=' + w + ',height=' + h + ',toolbars=no,scrollbars=no,status=no,resizable=no'); 81} 82function openMail() { 83 var location = window.location; 84 var mailPage = 'Public/Mail.aspx' 85 var mailUrl = location.origin 86 if (isValidLocalHost(location.host)) 87 mailUrl = getLocalHomeUrl() + mailPage 88 else 89 mailUrl += '/' + mailPage 90 window.open(mailUrl, 'Mail Box', 'width=630,height=480,top=50,left=100,directories=no,titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no'); 91} 92function openLiveChat(url, w, h) { 93 window.open(url, 'LiveChat', 'width=' + w + ',height=' + h + ',toolbars=no,scrollbars=no,status=no,resizable=no'); 94} 95function popUpPromo(url, w, h) { 96 var location = window.location; 97 var httpUrl = location.origin; 98 if (url.indexOf('http') > -1) 99 httpUrl = url 100 else if (location.host == 'localhost') 101 httpUrl = getLocalHomeUrl() + url 102 else 103 httpUrl += '/' + url 104 window.open(httpUrl, 'Promotion', 'width=' + w + ',height=' + h + ',toolbars=no,scrollbars=no,status=no,resizable=no'); 105} 106function popupPromo(url, w, h) { 107 var location = window.location; 108 var httpUrl = location.origin; 109 if (url.indexOf('http') > -1) 110 httpUrl = url 111 else if (location.host == 'localhost') 112 httpUrl = getLocalHomeUrl() + url 113 else 114 httpUrl += '/' + url 115 window.open(httpUrl, 'Promotion', 'width=' + w + ',height=' + h + ',toolbars=no,scrollbars=no,status=no,resizable=no'); 116} 117function popupWindow(url, title, w, h) { 118 var location = window.location; 119 var httpUrl = location.origin; 120 if (url.indexOf('http') > -1) 121 httpUrl = url 122 else if (location.host == 'localhost') 123 httpUrl = getLocalHomeUrl() + url 124 else 125 httpUrl += '/' + url 126 window.open(httpUrl, title, 'width=' + w + ',height=' + h + ',toolbars=no,scrollbars=no,status=no,resizable=no'); 127} 128 129function changeBox(vLayout) { 130 if (!vLayout) { 131 document.getElementById('div1').style.display = 'none'; 132 document.getElementById('div2').style.display = ''; 133 document.getElementById('txtPassword').focus(); 134 } 135 else { 136 if (document.getElementById('Text1')) 137 document.getElementById('Text1').style.display = 'none'; 138 139 if (document.getElementById('txtPasswordLabel')) 140 document.getElementById('txtPasswordLabel').style.display = 'none'; 141 142 document.getElementById('txtPassword').style.display = ''; 143 document.getElementById('txtPassword').focus(); 144 } 145} 146function restoreBox(vLayout) { 147 if (!vLayout) { 148 if (document.getElementById('txtPassword').value == '') { 149 document.getElementById('div1').style.display = ''; 150 document.getElementById('div2').style.display = 'none'; 151 } 152 } 153 else { 154 if (document.getElementById('txtPassword').value == '') { 155 if (document.getElementById('Text1')) 156 document.getElementById('Text1').style.display = ''; 157 158 if (document.getElementById('txtPasswordLabel')) 159 document.getElementById('txtPasswordLabel').style.display = ''; 160 161 document.getElementById('txtPassword').style.display = 'none'; 162 } 163 } 164} 165function clearText(field) { 166 if (field.defaultValue == field.value) field.value = ''; 167 else if (field.value == '') field.value = field.defaultValue; 168} 169function getLocalHomeUrl() { 170 var localHomeUrl = window.location.href; 171 //if (localHomeUrl.indexOf('Header') >= 0) 172 // localHomeUrl = localHomeUrl.split('Header')[0] 173 return localHomeUrl.substr(0, localHomeUrl.lastIndexOf('/') + 1) 174} 175function getUrl() { 176 return (isValidLocalHost(window.location.host) ? getLocalHomeUrl() : window.location.origin + '/') + 'pgajax.axd'; 177} 178 179// Every drawTogel() in Defaults/Default*.aspx builds its markup by string 180// concatenation and hands the result to .html(), so each field of a togel record 181// reaches an HTML parser. GetHasilTogel already HtmlEncodes the fields, but that 182// is a single point of failure for ~150 call sites with 119 different markup 183// shapes, so records are whitelisted here as well: one shared gate instead of 184// rewriting every page. Sanitized values are safe in element text, in a quoted 185// attribute, and under both .html() and .text(). 186var togelNamedEntities = { 187 'amp': '&', 'lt': '<', 'gt': '>', 'quot': '"', 'apos': '\'', 'nbsp': ' ' 188} 189 190// Undo the server-side HtmlEncode without touching innerHTML, which would parse 191// the very payload we are defusing. Only the entity forms AntiXssEncoder emits are 192// recognised; anything else is left as literal text. 193function decodeTogelEntities(value) { 194 return String(value).replace(/&(#[0-9]{1,7}|#[xX][0-9a-fA-F]{1,6}|[a-zA-Z]{2,6});/g, function (match, body) { 195 if (body.charAt(0) !== '#') { 196 var named = togelNamedEntities[body.toLowerCase()] 197 return named === undefined ? match : named 198 } 199 var isHex = (body.charAt(1) === 'x' || body.charAt(1) === 'X') 200 var codePoint = isHex ? parseInt(body.substr(2), 16) : parseInt(body.substr(1), 10) 201 if (!isFinite(codePoint) || codePoint < 32 || codePoint > 0xffff) { 202 return '' 203 } 204 return String.fromCharCode(codePoint) 205 }) 206} 207 208// Decode first, then drop the characters that could close an element or an 209// attribute in the concatenated markup. Everything else survives, so non-ASCII 210// togel names still render. 211function sanitizeTogelText(value, maxLength) { 212 if (value === null || value === undefined) { 213 return '' 214 } 215 return decodeTogelEntities(value) 216 .replace(/[<>"'`&\\]/g, '') 217 .replace(/[\u0000-\u001f\u007f]/g, '') 218 .substr(0, maxLength || 64) 219} 220 221// Ball numbers are indexed per character straight into an <img src>, so nothing 222// but digits may get through. Short values stay short rather than being padded -- 223// a missing digit must not be invented into a result. 224function sanitizeTogelNumber(value) { 225 if (value === null || value === undefined) { 226 return '' 227 } 228 return decodeTogelEntities(value).replace(/[^0-9]/g, '').substr(0, 8) 229} 230 231// GetHasilTogel always emits dd/MM/yyy, so anything else is rejected outright. 232function sanitizeTogelDate(value) { 233 var text = sanitizeTogelText(value, 32) 234 return /^[0-9]{1,2}\/[0-9]{1,2}\/[0-9]{2,4}$/.test(text) ? text : '' 235} 236 237function sanitizeTogelRecords(records) { 238 if (Object.prototype.toString.call(records) !== '[object Array]') { 239 return [] 240 } 241 var safeRecords = [] 242 for (var i = 0; i < records.length; i++) { 243 var record = records[i] 244 if (!record || typeof record !== 'object') { 245 continue 246 } 247 var safeRecord = {} 248 for (var key in record) { 249 if (!Object.prototype.hasOwnProperty.call(record, key)) { 250 continue 251 } 252 var value = record[key] 253 if (key === 'Number') { 254 safeRecord[key] = sanitizeTogelNumber(value) 255 } 256 else if (key === 'Date') { 257 safeRecord[key] = sanitizeTogelDate(value) 258 } 259 else if (typeof value === 'number' || typeof value === 'boolean') { 260 safeRecord[key] = value 261 } 262 else { 263 safeRecord[key] = sanitizeTogelText(value, 64) 264 } 265 } 266 // Callers do record.Togel.toUpperCase() and record.Number[n] unguarded, so 267 // these three always exist as strings even when a row omits them. 268 if (typeof safeRecord.Togel !== 'string') { 269 safeRecord.Togel = '' 270 } 271 if (typeof safeRecord.Number !== 'string') { 272 safeRecord.Number = '' 273 } 274 if (typeof safeRecord.Date !== 'string') { 275 safeRecord.Date = '' 276 } 277 safeRecords.push(safeRecord) 278 } 279 return safeRecords 280} 281 282function fetchTogel(callback) { 283 $.ajax({
284 url: getUrl(), 285 type: 'GET', 286 data: { T: 'GetHasilTogel' }, 287 success: function (responseText) { 288 var records = [] 289 try { 290 records = sanitizeTogelRecords(JSON.parse(responseText)) 291 } 292 catch (e) { 293 // An unparseable response used to be handed to the callback as an 294 // Error, which then threw inside every drawTogel. Fall back to the 295 // empty set the "no data" branches already handle. 296 console.log(e) 297 } 298 callback(records) 299 } 300 }); 301} 302function fetchSlideImages(folderPath, callback) { 303 $.ajax({ 304 url: location.href + '/pgajax.axd', 305 type: 'GET', 306 data: { T: 'GetSlideImages', folderPath: folderPath }, 307 success: function (responseText) { 308 try { 309 var records = JSON.parse(responseText); 310 callback(records) 311 } 312 catch (e) { 313 console.log(e) 314 callback(e) 315 } 316 } 317 }); 318} 319function encodeHTML(str) { 320 var element = document.createElement('div'); 321 element.innerText = str; 322 return element.innerText; 323} 324 325// msgPath: page the marquee links to, relative to the site root. Defaults to the after-login 326// message list; the before-login pages pass 'Announcement.html' instead. 327function initMarquee(color, fontName, msgPath) { 328 setTimeout(function () { 329 var location = window.location; 330 var href = location.origin + '/'; 331 if (isValidLocalHost(location.host)) { 332 href = getLocalHomeUrl(); 333 } 334 if (!color) { 335 color = '#fff'; 336 } 337 if (!fontName) { 338 fontName = 'euphemia'; 339 } 340 341 var messageElement = document.getElementById('text-marquee'); 342 var message = messageElement ? messageElement.value : ''; 343 var sanitizedMessage = encodeHTML(message); 344 345 var marquee = document.createElement('marquee'); 346 marquee.setAttribute('onmouseout', 'scrollDelay=1'); 347 marquee.setAttribute('onmouseover', 'scrollDelay=10000'); 348 marquee.setAttribute('scrolldelay', '1'); 349 marquee.setAttribute('scrollamount', '4'); 350 351 var link = document.createElement('a'); 352 link.className = 'Message'; 353 link.href = href + (msgPath || 'Announcement.html'); 354 link.target = '_blank'; 355 link.style.color = color; 356 link.style.fontFamily = fontName; 357 link.style.textDecoration = 'none'; 358 link.innerText = sanitizedMessage; 359 360 marquee.appendChild(link); 361 362 // append marquee into div 363 var divMarquee = document.getElementById('div-marquee'); 364 divMarquee.innerHTML = ''; 365 divMarquee.appendChild(marquee); 366 if (window.refreshMarqueePolyfill) { 367 window.refreshMarqueePolyfill(divMarquee); 368 } 369 }, 1000); 370} 371 372// Polyfill Chromium marquee regression without changing existing markup. 373(function () { 374 if (window.__legacyMarqueePolyfillStarted) { 375 return; 376 } 377 window.__legacyMarqueePolyfillStarted = true; 378 379 var instances = []; 380 var observer = null; 381 var animationFrameId = null; 382 383 function toNumber(value, fallbackValue) { 384 var parsedValue = parseInt(value, 10); 385 return isNaN(parsedValue) ? fallbackValue : parsedValue; 386 } 387 388 function containsNode(element) { 389 return !!(document.documentElement && document.documentElement.contains(element)); 390 } 391 392 function getDirection(element) { 393 var direction = (element.getAttribute('direction') || 'left').toLowerCase(); 394 return direction === 'right' ? 'right' : 'left'; 395 } 396 397 function getPixelsPerSecond(element) { 398 var scrollAmount = toNumber(element.scrollAmount, toNumber(element.getAttribute('scrollamount'), 6)); 399 var scrollDelay = toNumber(element.scrollDelay, toNumber(element.getAttribute('scrolldelay'), 85)); 400 var minimumDelay = element.getAttribute('truespeed') !== null ? 1 : 60; 401
402 scrollDelay = Math.max(scrollDelay, minimumDelay); 403 return (scrollAmount * 1000) / scrollDelay; 404 } 405 406 function applyBaseStyles(element) { 407 var computedStyle = window.getComputedStyle ? window.getComputedStyle(element, null) : null; 408 409 if (element.getAttribute('width') && !element.style.width) { 410 element.style.width = element.getAttribute('width'); 411 } else if (!element.style.width) { 412 element.style.width = '100%'; 413 } 414 if (element.getAttribute('height') && !element.style.height) { 415 element.style.height = element.getAttribute('height'); 416 } 417 if (computedStyle && computedStyle.display === 'inline') { 418 element.style.display = 'block'; 419 } 420 421 element.style.overflow = 'hidden'; 422 element.style.position = 'relative'; 423 element.style.whiteSpace = 'nowrap'; 424 } 425 426 function setPosition(instance) { 427 instance.content.style.transform = 'translate3d(' + instance.position + 'px, 0, 0)'; 428 } 429 430 function resetPosition(instance) { 431 instance.position = getDirection(instance.element) === 'right' 432 ? -instance.contentWidth 433 : instance.containerWidth; 434 instance.lastTimestamp = null; 435 setPosition(instance); 436 } 437 438 function measure(instance, shouldResetPosition) { 439 if (!containsNode(instance.element)) { 440 return false; 441 } 442 443 applyBaseStyles(instance.element); 444 instance.content.style.transform = 'translate3d(0, 0, 0)'; 445 446 instance.containerWidth = Math.max(instance.element.clientWidth, Math.round(instance.element.getBoundingClientRect().width)); 447 instance.contentWidth = Math.max(instance.content.scrollWidth, instance.content.offsetWidth); 448 instance.needsMeasure = false; 449 450 if (!instance.containerWidth || !instance.contentWidth) { 451 return false; 452 } 453 454 if (shouldResetPosition || instance.position === null) { 455 resetPosition(instance); 456 } else { 457 setPosition(instance); 458 } 459 460 return true; 461 } 462 463 function createContentWrapper(element) { 464 var content = document.createElement('span'); 465 var images; 466 var i; 467 468 content.setAttribute('data-marquee-polyfill-content', 'true'); 469 content.style.display = 'inline-block'; 470 content.style.whiteSpace = 'nowrap'; 471 content.style.willChange = 'transform'; 472 473 while (element.firstChild) { 474 content.appendChild(element.firstChild); 475 } 476 477 element.appendChild(content); 478 479 images = content.getElementsByTagName('img'); 480 for (i = 0; i < images.length; i++) { 481 images[i].addEventListener('load', function () { 482 if (element.__marqueePolyfill) { 483 element.__marqueePolyfill.needsMeasure = true; 484 } 485 }); 486 } 487 488 return content; 489 } 490 491 function ensureAnimationLoop() { 492 if (!animationFrameId && window.requestAnimationFrame) { 493 animationFrameId = window.requestAnimationFrame(tick); 494 } 495 } 496 497 function polyfillMarquee(element) { 498 var instance; 499 var existingContent; 500 501 if (!element || element.tagName.toLowerCase() !== 'marquee') { 502 return; 503 } 504 505 if (element.__marqueePolyfill && element.__marqueePolyfill.content && containsNode(element.__marqueePolyfill.content)) { 506 return; 507 } 508 509 element.scrollDelay = toNumber(element.getAttribute('scrolldelay'), toNumber(element.scrollDelay, 85)); 510 element.scrollAmount = toNumber(element.getAttribute('scrollamount'), toNumber(element.scrollAmount, 6)); 511 512 existingContent = element.querySelector('[data-marquee-polyfill-content="true"]'); 513 if (!existingContent) { 514 existingContent = createContentWrapper(element); 515 } 516 517 instance = { 518 element: element, 519 content: existingContent, 520 containerWidth: 0, 521 contentWidth: 0, 522 position: null, 523 lastTimestamp: null, 524 isStopped: false, 525 needsMeasure: true 526 }; 527 528 element.start = function () { 529 instance.isStopped = false; 530 instance.lastTimestamp = null; 531 }; 532 element.stop = function () { 533 instance.isStopped = true; 534 instance.lastTimestamp = null; 535 }; 536 537 element.__marqueePolyfill = instance; 538 element.setAttribute('data-marquee-polyfilled', 'true'); 539 540 instances.push(instance); 541 measure(instance, true); 542 ensureAnimationLoop(); 543 } 544 545 function scan(root) { 546 var marquees; 547 var i; 548 549 if (!root) { 550 root = document; 551 } 552 553 if (root.nodeType === 1 && root.tagName && root.tagName.toLowerCase() === 'marquee') { 554 polyfillMarquee(root); 555 } 556 557 if (!root.querySelectorAll) { 558 return; 559 } 560 561 marquees = root.querySelectorAll('marquee'); 562 for (i = 0; i < marquees.length; i++) { 563 polyfillMarquee(marquees[i]); 564 } 565 } 566 567 function tick(timestamp) { 568 var activeInstances = []; 569 var i; 570 571 animationFrameId = null; 572 573 for (i = 0; i < instances.length; i++) { 574 var instance = instances[i]; 575 var speed; 576 var elapsedTime; 577 var movedDistance; 578 579 if (!containsNode(instance.element)) { 580 continue; 581 } 582 583 activeInstances.push(instance); 584 585 if ((instance.needsMeasure || !instance.containerWidth || !instance.contentWidth) && !measure(instance, instance.position === null)) { 586 continue; 587 } 588 589 if (instance.lastTimestamp === null) { 590 instance.lastTimestamp = timestamp; 591 } 592 593 elapsedTime = timestamp - instance.lastTimestamp; 594 instance.lastTimestamp = timestamp; 595 596 if (instance.isStopped) { 597 continue; 598 } 599 600 speed = getPixelsPerSecond(instance.element); 601 if (!speed) { 602 continue; 603 } 604 605 movedDistance = (speed * elapsedTime) / 1000; 606 607 if (getDirection(instance.element) === 'right') { 608 instance.position += movedDistance; 609 if (instance.position >= instance.containerWidth) { 610 instance.position = -instance.contentWidth; 611 } 612 } else { 613 instance.position -= movedDistance; 614 if (instance.position <= -instance.contentWidth) { 615 instance.position = instance.containerWidth; 616 } 617 } 618 619 setPosition(instance); 620 } 621 622 instances = activeInstances; 623 624 if (instances.length && window.requestAnimationFrame) { 625 animationFrameId = window.requestAnimationFrame(tick); 626 } 627 } 628 629 function observeNewMarquees() { 630 if (observer || !window.MutationObserver || !document.documentElement) { 631 return; 632 } 633 634 observer = new MutationObserver(function (mutations) { 635 var i; 636 var j; 637 638 for (i = 0; i < mutations.length; i++) { 639 for (j = 0; j < mutations[i].addedNodes.length; j++) { 640 if (mutations[i].addedNodes[j].nodeType === 1) { 641 scan(mutations[i].addedNodes[j]); 642 } 643 } 644 } 645 }); 646 647 observer.observe(document.documentElement, { 648 childList: true, 649 subtree: true 650 }); 651 } 652 653 function markAllForMeasure() { 654 var i; 655 for (i = 0; i < instances.length; i++) { 656 instances[i].needsMeasure = true; 657 } 658 } 659 660 window.refreshMarqueePolyfill = function (root) { 661 scan(root || document); 662 ensureAnimationLoop(); 663 }; 664 665 if (window.jQuery && !window.jQuery.fn.marquee) { 666 window.jQuery.fn.marquee = function () { 667 return this.each(function () { 668 window.refreshMarqueePolyfill(this); 669 }).on('start', function () { 670 if (this.start) { 671 this.start(); 672 } 673 }).on('stop', function () { 674 if (this.stop) { 675 this.stop(); 676 } 677 }); 678 }; 679 } 680 681 if (window.addEventListener) { 682 window.addEventListener('resize', markAllForMeasure); 683 document.addEventListener('DOMContentLoaded', function () { 684 scan(document); 685 }); 686 window.addEventListener('load', function () { 687 scan(document); 688 markAllForMeasure(); 689 ensureAnimationLoop(); 690 }); 691 } 692 693 observeNewMarquees(); 694 scan(document); 695 setTimeout(function () { 696 scan(document); 697 markAllForMeasure(); 698 ensureAnimationLoop(); 699 }, 1000); 700})(); 701 702 703function refreshCapcha(type, idCapchaImage) { 704 switch (type) { 705 case 'text': 706 // todo 707 // send a ajax request to server gen new capcha code then assign to session 708 break; 709 case 'image': 710 capchaImage = $('#' + idCapchaImage) 711 capchaImage.attr('src', 'public/img.aspx?r=' + new Date().getTime()) 712 break; 713 } 714} 715function getMailInfo() { 716 $('#tdMail').html('<img style="display:inline" width="15px" height="15px" src="Images/spinner.gif" />'); 717 $.ajax({
718 url: 'pgajax.axd', 719 type: 'GET', 720 data: { T: 'GetMail' }, 721 success: function (responseText) { 722 var res = JSON.parse(responseText); 723 var success = res.success; 724 if (success) { 725 $('#tdMail').html(decodeURIComponent(res.text)); 726 } else { 727 $('#tdMail').html(`<a class="navbar2" title="${res.message}" style="cursor:pointer">Mail (<span style="color:red !important;">Error</span>)</a>`); 728 } 729 } 730 }) 731} 732 733function convertDateTime(dateTimeStringISO8601) { 734 const dateTime = new Date(dateTimeStringISO8601); 735 736 const day = dateTime.getDate().toString().padStart(2, '0'); 737 const month = (dateTime.getMonth() + 1).toString().padStart(2, '0'); 738 const year = dateTime.getFullYear(); 739 const hour = dateTime.getHours().toString().padStart(2, '0'); 740 const minute = dateTime.getMinutes().toString().padStart(2, '0'); 741 const timeZoneOffset = -dateTime.getTimezoneOffset() / 60; // Switch sign 742 const timeZoneOffsetString = timeZoneOffset >= 0 ? `+${timeZoneOffset}` : timeZoneOffset.toString(); 743 744 const formattedDateTime = `${day}/${month}/${year} ${hour}:${minute} GMT${timeZoneOffsetString}`; 745 746 return formattedDateTime; 747} 748 749function formatGmtLabel(gmtNumber) { 750 const normalized = (gmtNumber || '').toString().trim().replace(/\s+/g, ''); 751 return /^GMT[+-]\d{1,2}$/i.test(normalized) ? normalized.toUpperCase() : 'GMT+0'; 752} 753 754function formatFallbackServerTime(gmtNumber) { 755 const normalized = (gmtNumber || '').toString().trim().replace(/\s+/g, ''); 756 const match = normalized.match(/^GMT([+-])(\d{1,2})$/i); 757 const offsetHours = match ? (match[1] === '+' ? 1 : -1) * parseInt(match[2], 10) : 0; 758 const utcNow = new Date(Date.now() + (new Date()).getTimezoneOffset() * 60000); 759 const targetDate = new Date(utcNow.getTime() + (offsetHours * 60 * 60 * 1000)); 760 761 const day = targetDate.getUTCDate().toString().padStart(2, '0');
762 const month = (targetDate.getUTCMonth() + 1).toString().padStart(2, '0'); 763 const year = targetDate.getUTCFullYear(); 764 const hour = targetDate.getUTCHours().toString().padStart(2, '0'); 765 const minute = targetDate.getUTCMinutes().toString().padStart(2, '0'); 766 767 return `${day}/${month}/${year} ${hour}:${minute} ${formatGmtLabel(gmtNumber)}`; 768} 769 770function formatServerTimeResponse(data, gmtNumber) { 771 if (!data) { 772 return ''; 773 } 774 775 if (typeof data.year === 'number' && typeof data.month === 'number' && typeof data.day === 'number') { 776 const day = data.day.toString().padStart(2, '0'); 777 const month = data.month.toString().padStart(2, '0'); 778 const year = data.year; 779 const hour = (data.hour ?? 0).toString().padStart(2, '0'); 780 const minute = (data.minute ?? 0).toString().padStart(2, '0'); 781 return `${day}/${month}/${year} ${hour}:${minute} ${formatGmtLabel(gmtNumber)}`; 782 } 783 784 if (data.datetime) { 785 return convertDateTime(data.datetime); 786 } 787 788 if (data.dateTime) { 789 return convertDateTime(data.dateTime); 790 } 791 792 return ''; 793} 794 795async function fetchServerTime(gmtNumber, htmlId) { 796 // gtmNumber: GMT+7 797 try { 798 const url = getUrl() + '?T=GetServerTime'; 799 const response = await fetch(url, { cache: 'no-store' }); 800 801 if (!response.ok) { 802 throw new Error(`HTTP ${response.status} when fetching server time`); 803 } 804 805 const data = await response.json(); 806 const formattedTime = formatServerTimeResponse(data, gmtNumber) || formatFallbackServerTime(gmtNumber); 807 $(htmlId).html(formattedTime); 808 } 809 catch (error) { 810 console.error('Error fetching server time:', error); 811 $(htmlId).html(formatFallbackServerTime(gmtNumber)); 812 } 813} 814 815///////////////////////////// Handle PLACE_HOLDER for LOGIN form ///////////////////////////// 816/** 817* @author Remy Sharp 818* @url http://remysharp.com/2007/01/25/jquery-tutorial-text-box-hints/ 819*/ 820/*(function ($) { 821 $.fn.hint = function (blurClass) { 822 if (!blurClass) { 823 blurClass = 'blur'; 824 } 825 826 return this.each(function () { 827 // get jQuery version of 'this' 828 var $input = $(this), 829 830 // capture the rest of the variable to allow for reuse 831 title = $input.attr('title'), 832 $form = $(this.form), 833 $win = $(window); 834 835 function remove() { 836 if ($input.val() === title && $input.hasClass(blurClass)) { 837 $input.val('').removeClass(blurClass); 838 } 839 } 840 841 // only apply logic if the element has the attribute 842 if (title) { 843 // on blur, set value to title attr if text is blank 844 $input.blur(function () { 845 if (this.value === '') { 846 $input.val(title).addClass(blurClass); 847 } 848 }).focus(remove).blur(); // now change all inputs to title 849 850 // clear the pre-defined text when form is submitted 851 $form.submit(remove); 852 $win.unload(remove); // handles Firefox's autocomplete 853 } 854 }); 855 }; 856})(jQuery); 857*/ 858// User for account header after login 859var DC_Event = {}; 860var CFG_DCRefresh = '5'; 861function DC_STAKE(event) { 862 if (+CFG_DCRefresh === 0) return; 863 864 DC_Event = JSON.parse(sessionStorage.getItem("DC_Event")) || DC_Event; 865 if (Object.keys(DC_Event).length) { 866 if (DC_Event.Type == "STK") { 867 if (Date.now() - DC_Event.Date < +CFG_DCRefresh * 1000) { 868 $("body", parent.window.frames["fraMain"].document).addClass("animationFade").one("webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend", function () { 869 $(this).removeClass("animationFade"); 870 }); 871 event.preventDefault(); 872 return; 873 } 874 $("body").addClass('') 875 } 876 } 877 878 DC_Event = { 'Type': 'STK', 'Date': Date.now() }; 879 sessionStorage.setItem("DC_Event", JSON.stringify(DC_Event)); 880} 881 882function DC_STT(event) { 883 if (+CFG_DCRefresh === 0) return; 884 885 DC_Event = JSON.parse(sessionStorage.getItem("DC_Event")) || DC_Event; 886 if (Object.keys(DC_Event).length) { 887 if (DC_Event.Type == "STT_TW") { 888 if (Date.now() - DC_Event.Date < +CFG_DCRefresh * 1000) { 889 $("body", parent.window.frames["fraMain"].document).addClass("animationFade").one("webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend", function () { 890 $(this).removeClass("animationFade"); 891 }); 892 event.preventDefault(); 893 return; 894 } 895 } 896 } 897 898 DC_Event = { 'Type': 'STT_TW', 'Date': Date.now() }; 899 sessionStorage.setItem("DC_Event", JSON.stringify(DC_Event)); 900} 901 902var isHeaderPage = () => { 903 if (/header/i.test(location.pathname)) return true; 904 try { 905 return window.parent?.frames['fraHeader'] !== undefined; 906 } catch { 907 return /header/i.test(document.referrer); 908 } 909}; 910function showServerLogs(contents) { 911 var contentList = contents.split('###'); 912 for (var i = 0; i < contentList.length; ++i) { 913 console.log(contentList[i]); 914 } 915} 916$(function () { 917 if (isHeaderPage()) { 918 $('body').css('overflow', 'hidden') 919 920 $('a[href="_norm/stake.aspx"').click(function (event) { 921 DC_STAKE(event.originalEvent) 922 }) 923 $('a[href="_norm/AccHistory.aspx"').click(function (event) { 924 DC_STT(event.originalEvent) 925 }) 926 } 927 // find all the input elements with title attributes 928 /*try { 929 $('input[title!=""]').hint(); 930 } catch (err) { 931 console.log(err) 932 }*/ 933 934});
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.