1function ready(f) { 2 /in/.test(document.readyState) ? setTimeout('ready(' + f + ')', 9) : f() 3} 4 5function setRatesAndPricing() { 6 const block_rnp = document.querySelectorAll('.block-rates-and-pricing'); 7 for (let i = 0; i < block_rnp.length; i++) { 8 block_rnp[i].id = "rnp-id-" + i; 9 10 getJsonDataRnP(block_rnp[i].id); 11 } 12} 13 14function getJsonDataRnP(parentClassName) { 15 fetch('/storage/rates/forex-1-unit.json') 16 .then(response => response.json()) 17 .then(data => { 18 if (data) { 19 const forex_1_content = document.querySelector(`#${parentClassName} .forex-1`); 20 21 fetch('/currentLang') 22 .then(response => response.text()) 23 .then(lang => { 24 let currency; 25 let code; 26 let selling; 27 let buying_tt; 28 let buying_od; 29 let imgArray = ['U.S.DOLLAR.svg', 'EURO.svg', 'BRITISH POUND.svg', 'SINGAPORE DOLLAR.svg', 'BRUNEI DOLLAR.svg', 'AUSTRALIAN DOLLAR.svg', 'CANADIAN DOLLAR.svg', 'NEW ZEALAND DOLLAR.svg', 'SWISS FRANC.svg']; 30 31 switch (lang) { 32 case 'ms': 33 const forex_1_text = document.querySelectorAll(`#${parentClassName} .sub-text-paragraph`)[0]; 34 forex_1_text.innerHTML = "RM tempatan kepada satu unit Matawang Asing"; 35 const forex_100_text = document.querySelectorAll(`#${parentClassName} .sub-text-paragraph`)[1]; 36 forex_100_text.innerHTML = "RM tempatan kepada 100 unit Matawang Asing"; 37 break; 38 case 'en': 39 default: 40 break; 41 } 42 43 for (let i = -1; i < data.length; i++) { 44 45 const ratesElement = document.createElement('DIV'); 46 47 if(i < 0) { 48 switch (lang) { 49 case 'ms': 50 ratesElement.innerHTML = 51 '<div class="sub-text-buy-sell text-left">Jualan TT/OD</div>' + 52 '<hr class="dotted-hr-grey">' + 53 '<div class="sub-text-buy-sell text-left">Belian TT</div>' + 54 '<hr class="dotted-hr-grey">' + 55 '<div class="sub-text-buy-sell text-left">Belian OD</div>'; 56 ratesElement.className = 'rates-details'; 57 break; 58 case 'en': 59 default: 60 ratesElement.innerHTML = 61 '<div class="sub-text-buy-sell text-left">Selling TT/OD</div>' + 62 '<hr class="dotted-hr-grey">' + 63 '<div class="sub-text-buy-sell text-left">Buying TT</div>' + 64 '<hr class="dotted-hr-grey">' + 65 '<div class="sub-text-buy-sell text-left">Buying OD</div>'; 66 ratesElement.className = 'rates-details'; 67 break; 68 } 69 } else { 70 71 currency = data[i].currency; 72 code = data[i].code; 73 selling = data[i].selling.ttod; 74 buying_tt = data[i].buying.tt; 75 buying_od = data[i].buying.od; 76 77 if (selling == "#VALUE!") { selling = "N/A"; } 78 if (buying_tt == "#VALUE!") { buying_tt = "N/A"; } 79 if (buying_od == "#VALUE!") { buying_od = "N/A"; } 80 81 ratesElement.innerHTML = 82 '<img src="/img/' + imgArray[i] + '" class="flag-img" alt=""/>' + 83 '<div class="sub-text-currency-code mt-2">'+ currency + '</div>' + 84 '<div class="sub-text-currency-code">'+ code + '</div>' + 85 '<div class="sub-text-buy-sell">'+ selling + '</div>' + 86 '<hr class="dotted-hr-grey">' + 87 '<div class="sub-text-buy-sell">'+ buying_tt + '</div>' + 88 '<hr class="dotted-hr-grey">' + 89 '<div class="sub-text-buy-sell">'+ buying_od + '</div>'; 90 ratesElement.className = 'rates-details'; 91 } 92 93 if (forex_1_content) { 94 forex_1_content.append(ratesElement); 95 } 96 } 97 }); 98 } 99 100 fetch('/storage/rates/forex-100-unit.json') 101 .then(response => response.json()) 102 .then(data => { 103 if (data) { 104 const forex_100_content = document.querySelector(`#${parentClassName} .forex-100`); 105 106 fetch('/currentLang') 107 .then(response => response.text()) 108 .then(lang => { 109 110 let currency; 111 let code; 112 let selling; 113 let buying_tt; 114 let buying_od;
115 let imgArray = ['DANISH KRONE.svg', 'HONG KONG DOLLAR.svg', 'INDIAN RUPEE.svg', 'INDONESIAN RUPIAH.svg', 'JAPANESE YEN.svg', 'NORWEGIAN KRONE.svg', 'PAKISTAN RUPEE.svg', 'PHILIPPINE PESO.svg', 'SAUDI RIYAL.svg', 'SOUTH AFRICAN RAND.svg', 'SWEDISH KRONA.svg', 'THAI BAHT.svg', 'FIJI DOLLAR.svg', 'PAPUA NEW GUINEA KINA.svg', 'OMAN RIAL.svg', 'BANGLADESH TAKA.svg', 'SRI LANKA RUPEE.svg', 'KUWAIT DINAR.svg', 'CHINESE RENMINBI.svg', 'UAE DIRHAM.svg']; 116 117 for (let i = -1; i < data.length; i++) { 118 119 const ratesElement100 = document.createElement('DIV'); 120 121 if(i < 0) { 122 switch (lang) { 123 case 'ms': 124 ratesElement100.innerHTML = 125 '<div class="sub-text-buy-sell text-left">Jualan TT/OD</div>' + 126 '<hr class="dotted-hr-grey">' + 127 '<div class="sub-text-buy-sell text-left">Belian TT</div>' + 128 '<hr class="dotted-hr-grey">' + 129 '<div class="sub-text-buy-sell text-left">Belian OD</div>'; 130 ratesElement100.className = 'rates-details'; 131 break; 132 case 'en': 133 default: 134 ratesElement100.innerHTML = 135 '<div class="sub-text-buy-sell text-left">Selling TT/OD</div>' + 136 '<hr class="dotted-hr-grey">' + 137 '<div class="sub-text-buy-sell text-left">Buying TT</div>' + 138 '<hr class="dotted-hr-grey">' + 139 '<div class="sub-text-buy-sell text-left">Buying OD</div>'; 140 ratesElement100.className = 'rates-details'; 141 break; 142 } 143 } else { 144 145 currency = data[i].currency; 146 code = data[i].code; 147 selling = data[i].selling.ttod; 148 buying_tt = data[i].buying.tt; 149 buying_od = data[i].buying.od; 150 151 if (selling == "#VALUE!") { selling = "N/A"; } 152 if (buying_tt == "#VALUE!") { buying_tt = "N/A"; } 153 if (buying_od == "#VALUE!") { buying_od = "N/A"; } 154 155 ratesElement100.innerHTML = 156 '<img src="/img/' + imgArray[i] + '" class="flag-img" alt=""/>' + 157 '<div class="sub-text-currency-code mt-2">'+ currency + '</div>' + 158 '<div class="sub-text-currency-code">'+ code + '</div>' + 159 '<div class="sub-text-buy-sell">'+ selling + '</div>' + 160 '<hr class="dotted-hr-grey">' + 161 '<div class="sub-text-buy-sell">'+ buying_tt + '</div>' + 162 '<hr class="dotted-hr-grey">' + 163 '<div class="sub-text-buy-sell">'+ buying_od + '</div>'; 164 ratesElement100.className = 'rates-details'; 165 } 166 167 if (forex_100_content) { 168 forex_100_content.append(ratesElement100); 169 } 170 }
171 setAccordionRnP(parentClassName); 172 }); 173 } 174 }); 175 176 fetch('/storage/rates/forex-date.json') 177 .then(response => response.json()) 178 .then(data => { 179 if (data) { 180 fetch('/currentLang') 181 .then(response => response.text()) 182 .then(lang => { 183 const forex_date = document.querySelectorAll(`#${parentClassName} .sub-text-warning.mt-2`)[0]; 184 const rates_quoted_text = document.querySelectorAll(`#${parentClassName} .sub-text-warning.mt-2`)[1]; 185 186 let date = data[0].date; 187 188 switch (lang) { 189 case 'ms': 190 date = date.replace('EXCHANGE RATE AS AT','KADAR PERTUKARAN SETAKAT').replace('TIME', 'MASA').replace('AM','PAGI').replace('PM','PETANG'); 191 rates_quoted_text.innerHTML = "Kadar yang disebutkan adalah berdasarkan Kadar Kaunter Pertukaran Wang Asing harian AFFIN BANK dan boleh berubah tanpa notis terlebih dahulu."; 192 break; 193 case 'en': 194 default: 195 break; 196 } 197 198 if (forex_date) { 199 forex_date.innerHTML = '(' + date + ')'; 200 } 201 }); 202 } 203 }); 204 }); 205} 206 207function changeTabsRnP(event) { 208 if (!event) return; 209 210 let parentClassName = event.parentElement.parentElement.parentElement.parentElement.className.replace(/\ /g, '.'); 211 212 const tabs = document.querySelectorAll(`.block-rates-and-pricing .r-n-p-tab`); 213 const tabsContent = document.querySelectorAll(`.block-rates-and-pricing .tab-content`); 214 215 const clicked = event; 216
217 tabs.forEach(t => t.classList.remove('tab--active')); 218 tabsContent.forEach(c => c.classList.remove('content--active')); 219 clicked.classList.add('tab--active'); 220 221 document.querySelector(`.${parentClassName} .tab-content--${clicked.dataset.tab}`).classList.add('content--active'); 222} 223 224function setAccordionRnP(parentClassName) { 225 const acc = document.querySelectorAll(`#${parentClassName} .r-n-p-collapsible`); 226 let i; 227 228 if (acc) { 229 for (i = 0; i < acc.length; i++) { 230 // if (acc[i].classList.contains("rnp-loaded")) return; 231 // acc[i].classList.add("rnp-loaded"); 232 acc[i].addEventListener('click', function () { 233 const content = this.nextElementSibling; 234 const parentContent = this.parentElement; 235 236 if (parentContent.classList.contains("content") && parentContent.style.maxHeight) { 237 parentContent.style.maxHeight = parentContent.scrollHeight + content.scrollHeight + 'px'; 238 } 239 240 if (content.style.maxHeight) { 241 content.style.maxHeight = null; 242 } else { 243 content.style.maxHeight = content.scrollHeight + 'px'; 244 } 245 246 for (let i = 0; i < this.childNodes.length; i++) { 247 const temp = this.childNodes[i]; 248 249 if (temp instanceof Element) { 250 if (temp.classList.contains("accordion-symbol")) { 251 if (temp.innerHTML === '+') { 252 temp.innerHTML = "-"; 253 } else { 254 temp.innerHTML = "+"; 255 } 256 break; 257 } 258 } else { 259 if (temp.classList && temp.classList.contains("accordion-symbol")) { 260 if (temp.innerHTML === '+') { 261 temp.innerHTML = "-"; 262 } else { 263 temp.innerHTML = "+"; 264 } 265 break; 266 } 267 } 268 } 269 }); 270 } 271 } 272 273 setOverflowBtnRnP(parentClassName); 274} 275 276function setOverflowBtnRnP(parentClassName){ 277 const forex_1_next_btn = document.querySelector(`#${parentClassName} .forex-1__button--next`); 278 const forex_1_prev_btn = document.querySelector(`#${parentClassName} .forex-1__button--prev`); 279 const forex_100_next_btn = document.querySelector(`#${parentClassName} .forex-100__button--next`); 280 const forex_100_prev_btn = document.querySelector(`#${parentClassName} .forex-100__button--prev`); 281 282 if ($(`#${parentClassName} .forex-1`)[0] && ($(`#${parentClassName} .forex-1`)[0].scrollWidth > $(`#${parentClassName} .forex-1`).innerWidth())) { 283 // alert("1 show"); 284 $(forex_1_next_btn).show(); 285 $(forex_1_prev_btn).show(); 286 } else { 287 // alert("1 hide"); 288 $(forex_1_next_btn).hide(); 289 $(forex_1_prev_btn).hide(); 290 } 291 292 if ($(`#${parentClassName} .forex-100`)[0] && ($(`#${parentClassName} .forex-100`)[0].scrollWidth > $(`#${parentClassName} .forex-100`).innerWidth())) { 293 // alert("100 show"); 294 $(forex_100_next_btn).show(); 295 $(forex_100_prev_btn).show(); 296 } else { 297 // alert("100 hide"); 298 $(forex_100_next_btn).hide(); 299 $(forex_100_prev_btn).hide(); 300 } 301 302 if (forex_1_next_btn) { 303 forex_1_next_btn.addEventListener('click', function () { 304 $(`#${parentClassName} .forex-1`).animate({scrollLeft: '+=200'}, 200); 305 }); 306 } 307 308 if (forex_1_prev_btn) { 309 forex_1_prev_btn.addEventListener('click', function () { 310 $(`#${parentClassName} .forex-1`).animate({scrollLeft: '-=200'}, 200); 311 }); 312 } 313 314 if (forex_100_next_btn) { 315 forex_100_next_btn.addEventListener('click', function () { 316 $(`#${parentClassName} .forex-100`).animate({scrollLeft: '+=200'}, 200); 317 }); 318 } 319 320 if (forex_100_prev_btn) { 321 forex_100_prev_btn.addEventListener('click', function () { 322 $(`#${parentClassName} .forex-100`).animate({scrollLeft: '-=200'}, 200); 323 }); 324 } 325} 326 327 328ready(function() { // TODO: this is just a workaround, it should be fixed with properly logic in future 329 let index = 0; 330 const maxIndex = 60; 331 332 const timer = setInterval(function() { 333 if (document.querySelector('.block-rates-and-pricing')) { 334 setRatesAndPricing(); 335 clearInterval(timer); 336 } 337 338 if (index >= maxIndex) { 339 clearInterval(timer); 340 } else { 341 index++; 342 } 343 344 }, 1000) 345}
345)
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.