1// Check Status ransaction 2window.checkStatusTransaction = (statusCode) => { 3 var status = ''; 4 if (statusCode === 3) { 5 status = 'Approved'; 6 } else if (statusCode === 2) { 7 status = 'Rejected'; 8 } else if (statusCode === 1) { 9 status = 'Cancelled'; 10 } else { 11 status = 'Pending'; 12 } 13 14 return status; 15} 16 17// CONVERT NOMINAL 18window.convertNominal = function (code, nominal) { 19 var pattern = '!#'; 20 var symbol = ''; 21 var separator = ''; 22 var precision = 0; 23 var decimal = ','; 24 25 switch (code) { 26 case 'CNY': 27 symbol = 'Â¥'; 28 separator = '.'; 29 precision = 2; 30 break; 31 32 case 'VND': 33 symbol = 'â«'; 34 separator = ','; 35 precision = 0; 36 break; 37 38 case 'MYR': 39 symbol = 'MYR'; 40 separator = '.'; 41 precision = 2; 42 break; 43 44 case 'THB': 45 symbol = '฿'; 46 separator = '.'; 47 precision = 2; 48 break; 49 50 case 'IDR': 51 symbol = 'IDR '; 52 separator = '.'; 53 precision = 2; 54 break; 55 56 case 'USD': 57 symbol = 'USD '; 58 separator = '.'; 59 precision = 2; 60 break; 61 62 case 'KRW': 63 pattern = '# !'; 64 symbol = ' ì'; 65 separator = '.'; 66 precision = 2; 67 break; 68 69 default: 70 symbol = ''; 71 separator = '.'; 72 precision = 2; 73 break; 74 } 75 76 var format = function format(value) { 77 return currency(value, { 78 pattern: pattern, 79 precision: precision, 80 symbol: symbol, 81 separator: separator, 82 decimal: decimal 83 }); 84 }; 85 86 var convert = 0; 87 88 if (nominal) { 89 convert = parseFloat(nominal); 90 } 91 92 convert = format(convert).format(true); 93 return convert; 94}; 95// END CONVERT NOMINAL 96 97// CONTENT OPEN 98$(document).on('click', '.contentOpen', function () { 99 if ($(this).attr('open-href')) { 100 var openUrl = $(this).attr('open-href'); 101 var openType = $(this).attr('open-type'); 102 103 if (openType === 'new-tab') { 104 window.open(openUrl, '_blank'); 105 } else if (openType === 'pop-up') { 106 openPopupTab(openUrl, '', 1180, 675, openType); 107 } else if (openType === 'pop-up-parent') { 108 openNewParentTab(openUrl, 'parent tab', 1024, 690, 0, 0, 'yes'); 109 } else if (openType === 'trigger-function') { 110 Function(openUrl)(); 111 } else { 112 window.location.href = openUrl; 113 } 114 } 115}); 116 117function openPopupTab(url, params, width, height, name, target = '') { 118 var screenLeft = 0, 119 screenTop = 0; 120 if (!name) name = ''; 121 if (!width) width = 1060; 122 if (!height) height = 665; 123 var defaultParams = {}; 124 125 if (typeof window.screenLeft !== 'undefined') { 126 screenLeft = window.screenLeft; 127 screenTop = window.screenTop; 128 } else if (typeof window.screenX !== 'undefined') { 129 screenLeft = window.screenX; 130 screenTop = window.screenY; 131 } 132 133 var features_dict = { 134 toolbar: 'no', 135 location: 'no', 136 directories: 'no', 137 left: screenLeft + ($(window).width() - width) / 2, 138 top: screenTop + ($(window).height() - height) / 2, 139 status: 'yes', 140 menubar: 'no', 141 scrollbars: 'yes', 142 resizable: 'no', 143 width: width, 144 height: height 145 }; 146 features_arr = []; 147 148 for (var k in features_dict) { 149 features_arr.push(k + '=' + features_dict[k]); 150 } 151 152 features_str = features_arr.join(','); 153 var win = window.open(url, name, features_str); 154 155 if (target == '_parent') { 156 win = window.open(url, target, name, features_str); 157 } 158 win.focus(); 159 return false; 160} 161 162function openNewParentTab(url, name, width, height, left, top, scrollbars) { 163 window.open(url, name, 'left=' + left + ', top=' + top + ', width=' + width + ', height=' + height + ', scrollbars=' + scrollbars + ', location=no, menubar=no, titlebar=no, hotkeys=no, toolbars=no, status =no, resizable=yes'); 164} 165 166// GLOBAL ALERT 167// must be include izi-toast plugin 168window.buzzer = (arg) => { 169 iziToast[arg.status]({ 170 timeout: arg.timeout ?? 3000, 171 overlay: arg.overlay ?? true, 172 close: arg.close ?? true, 173 position: 'topCenter', 174 title: '', 175 message: arg.msg, 176 onClosed: arg.onClosed ?? '', 177 buttons: arg.button ?? '', 178 }); 179} 180 181// count down function 182window.countdowntime = function (servertime, time, elementId) { 183var arrtime = time.split(' '); 184 185time = new Date(arrtime[0]); 186time.setHours(arrtime[1].split(':')[0], arrtime[1].split(':')[1]); 187 188servertime = new Date(servertime); 189 // Update the count down every 1 second 190 let y = 0; 191 var x = setInterval(function() { 192 y++; 193 var now = new Date() 194 now.setHours(servertime.getHours(), now.getMinutes()); 195 var close = time - now; 196 // referesh every one hours 197 var sec = `${now.getMinutes()}${now.getSeconds()}`; 198 if (sec == '01') { 199 window.location = window.location.pathname; 200 } 201 // cek if time bet is close pass time now 202 if (time < servertime) { 203 time.setDate(servertime.getDate() + 1); 204 } 205 // check if count down finish count from 206 // if (close < 0) { 207 // time.setDate(servertime.getDate() + 1); 208 // } 209 210 // Find the distance between now and the count down date 211 var distance = time - now; 212 213 // Time calculations for days, hours, minutes and seconds 214 var days = Math.floor(distance / (1000 * 60 * 60 * 24)); 215 var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); 216 var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); 217 var seconds = Math.floor((distance % (1000 * 60)) / 1000); 218 219 if (days > 0) { 220 hours = hours + 24 * days; 221 } 222 223 var h = (hours > 0) ? `${hours}` : 00; 224 var m = (minutes > 0) ? `${minutes}` : 00; 225 var times = `${h}:${m}:${seconds}`; 226 227 // check if count down finish set to bet CLose 228 if (close < 0) { 229 (y > 1) ? times = 'BET CLOSED': times 230 } 231 232 if ($.isArray(elementId)) { 233 document.querySelector(elementId[0]).innerHTML = `${h}` 234 document.querySelector(elementId[1]).innerHTML = `${m}` 235 document.querySelector(elementId[2]).innerHTML = `${seconds}` 236 }else { 237 document.querySelector(elementId).innerHTML = times; 238 } 239 // If the count down is finished, write some text 240 if (distance < 0) { 241 clearInterval(x); 242 } 243 }, 1000); 244} 245 246 247// time : string 248// elementId : string / array(idhours, idminutes, idsecond) 249window.countdowntimeOdl = function (servertime, time, elementId) { 250 // Set the date we're counting down to 251 var options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' }; 252 var date = new Date(); 253 date.setHours(servertime.split(':')[0], servertime.split(':')[1]); //set to servertime 254 255 if(time == ':' || time == '00:') { 256 date.setDate(date.getDate() + 1); 257 date.setHours('00','00','01'); 258 time = '00:01'; 259 } 260 261 var dateset = date.toLocaleDateString("en-US", options); 262 var countDownDate = new Date(`${dateset} ${time}`); 263 264 if (time.substring(0, 1) < date.getHours()) { 265 countDownDate.setDate(countDownDate.getDate() + 1); 266 } 267 // Update the count down every 1 second 268 var x = setInterval(function() { 269 270 // Get todays date and time 271 var now = new Date().setHours(servertime.split(':')[0], servertime.split(':')[1]); 272 273 // Find the distance between now and the count down date 274 var distance = countDownDate - now; 275 // Time calculations for days, hours, minutes and seconds 276 var days = Math.floor(distance / (1000 * 60 * 60 * 24)); 277 var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); 278 var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); 279 var seconds = Math.floor((distance % (1000 * 60)) / 1000); 280
281 var h = (hours > 0) ? `${hours}` : 00; 282 var m = (minutes > 0) ? `${minutes}` : 00; 283 284 if ($.isArray(elementId)) { 285 document.querySelector(elementId[0]).innerHTML = `${h}` 286 document.querySelector(elementId[1]).innerHTML = `${m}` 287 document.querySelector(elementId[2]).innerHTML = `${seconds}` 288 }else { 289 document.querySelector(elementId).innerHTML = `${h}:${m}:${seconds}` 290 } 291 292 // If the count down is finished, write some text 293 if (distance < 0) { 294 clearInterval(x); 295 } 296 }, 1000); 297} 298// color : string 299//funtion for check color is dark or not 300window.getBrightness = function (color) { 301 // check if color in gradient 302 var regex_gr = /gradient/gi; //for gradient 303 var regex_rgb = /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/i; //for rgb 304 305 if(regex_gr.test(color)){ 306 // in gradient 307 // Mencari semua nilai warna dalam gradien 308 const rgbValues = color.match(/rgb\((\d+), (\d+), (\d+)\)/g); 309 310 // Menghitung nilai kecerahan dari setiap titik gradien 311 const brightnessValues = rgbValues.map(rgbValue => { 312 const [r, g, b] = rgbValue.match(/\d+/g).map(Number); 313 return Math.sqrt( 314 0.299 * Math.pow(r, 2) + 315 0.587 * Math.pow(g, 2) + 316 0.114 * Math.pow(b, 2) 317 ); 318 }); 319 var totalBrightness = 0; 320 for (var i = 0; i < brightnessValues.length; i++) { 321 totalBrightness += brightnessValues[i]; 322 } 323 var brightness = totalBrightness / brightnessValues.length; 324 325 }else if(regex_rgb.test(color)){ 326 // in RGB 327 var match = color.match(regex_rgb); 328 var red = parseInt(match[1]); 329 var green = parseInt(match[2]); 330 var blue = parseInt(match[3]); 331 var brightness = Math.round(((red * 299) + (green * 587) + (blue * 114)) / 1000); 332 }else{ 333 // in normal color 334 // Mengambil nilai RGB dari warna 335 var red = parseInt(color.substr(1, 2), 16); 336 var green = parseInt(color.substr(3, 2), 16); 337 var blue = parseInt(color.substr(5, 2), 16); 338 339 // Menghitung nilai kecerahan warna 340 var brightness = (red * 299 + green * 587 + blue * 114) / 1000; 341 } 342 // Jika nilai kecerahan warna di bawah batas, maka warna dianggap gelap 343 return brightness; 344} 345// color : string 346//funtion for check color is dark or not 347window.isColorDark = function (color) { 348 var brightness = getBrightness(color); 349 // Jika nilai kecerahan warna di bawah batas, maka warna dianggap gelap 350 return brightness < 128; 351} 352 353//maincolor, coloroption1, coloroption2 = String 354// global funtion untuk menentukan color yg pas dengan inputan main color 355window.findMatchingColor = function(mainColor, colorOption1, colorOption2, minimalbrightness = 50, maxbrightness = 210) { 356 var brightness = getBrightness(mainColor); 357 // Jika nilai kecerahan warna di bawah batas, maka warna dianggap gelap 358 return (brightness < minimalbrightness || brightness > maxbrightness) ? colorOption1 : colorOption2; 359} 360 361// check img exist by domain 362// variable url : string (url img) 363// return : url img 364window.checkImgExist = function (url) { 365 return new Promise(function(resolve, reject) { 366 var img = new Image(); 367 img.onload = function() { 368 resolve(url); 369 }; 370 img.onerror = function() { 371 reject(url); 372 }; 373 img.src = url; 374 }); 375} 376 377window.randomStr = function (len){ 378 var arr = '12345abcde'; 379 let ans = ''; 380 for (let i = len; i > 0; i--) { 381 ans += 382 arr[(Math.floor(Math.random() * arr.length))]; 383 } 384 385 return ans; 386}
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.