1/* 2 Created on : Jan 20, 2017 3 Author : AIS5 4*/ 5 6$(function() { 7 window.MSYS = new commonSystem(); 8 $("#menu-toggle").on('click',function(e) { 9 e.preventDefault(); 10 $("#opdce_container").toggleClass("active"); 11 $('#main_icon').toggleClass("glyphicon-menu-left").toggleClass("glyphicon-menu-right"); 12 }); 13 $('.dropdown-toggle').on('click',function(e) { 14 e.preventDefault(); 15 $(this)/*.toggleClass("open")*/.find('.arrow').toggleClass("glyphicon-chevron-down").toggleClass("glyphicon-chevron-right"); 16 MSYS.resizeIframe(); 17 }); 18 $('.dropdown-menu').on('mouseleave',function(){ 19 //$(this).prev('.dropdown-toggle').toggleClass("open").find('.arrow').toggleClass("glyphicon-chevron-down").toggleClass("glyphicon-chevron-right"); 20 }); 21 22 $('.datepicker').datepicker({ 23 showOn: '' 24 }); 25 $(document).on("click",".datepicker_btn",function(){ 26 //$(this).parent().prev(".datepicker").datepicker("show"); 27 $(this).parent().parent().find(".datepicker").datepicker("show"); 28 }); 29 30 $(document).on('mouseup mousemove','textarea',function(){ 31 if(this.oldwidth === null){this.oldwidth = this.style.width;} 32 if(this.oldheight === null){this.oldheight = this.style.height;} 33 if(this.style.width != this.oldwidth || this.style.height != this.oldheight){ 34 if(this.resize_timeout){clearTimeout(this.resize_timeout);} 35 this.resize_timeout = setTimeout(function(){ 36 MSYS.resizeIframe(); 37 },200); 38 this.oldwidth = this.style.width; 39 this.oldheight = this.style.height; 40 } 41 }); 42 43 $( ".timepicker" ).timepicker({ 44 timeFormat: "HH:mm", 45 showMeridian: false, 46 minuteStep:15, 47 template:'dropdown', 48 maxHours:24 49 }); 50 51 MSYS.resizeIframe(); 52}); 53 54 55 56var commonSystem = function(_obj){ 57 var thisObj = this; 58 var baseUrl = ''; 59 var pObject = $('[name=new_opdc]', window.parent.document); 60 var progInv = false; 61 var timer = null; 62 var timeout = (4*60*60*1000); // 4 hour 63 64 this.resizeIframe = function(_time,_ele,_plus) { 65 var time = $.type(_time)=="number"? _time:100; 66 var plus = typeof _plus =="number"? _plus:0; 67 var ele; 68 switch($.type(_ele)){ 69 case 'undefined' : ele = $('#opdce_container');break; 70 case 'object' : ele = _ele;break; 71 case 'string' : 72 default : 73 ele = $(_ele);break; 74 } 75 76 if(ele.hasClass("ui-dialog-content")) ele = ele.parent(); 77 78 setTimeout(function(){ 79 if($.type(pObject)!='undefined' && pObject.length){ 80 //chck max height 81 var obj = pObject[0]; 82 obj.style.height = thisObj.chkMaxHeight(ele,plus) + 'px'; 83 84 // confirm height 85 var chkH = thisObj.chkMaxHeight(ele,plus); 86 if(pObject.height() != chkH) obj.style.height = chkH+ 'px'; 87 $('body').trigger('sys_resized'); 88 } 89 },time); 90 } 91 92 this.chkMaxHeight = function(_ele,_plus){ 93 var plus = typeof _plus =="number"? _plus:0; 94 var hdH = parseInt($('#opdce_header').outerHeight()); 95 var bdH = parseInt(_ele.height()); 96 var ctH = parseInt($('#opdce_container').height()); 97 //if(ctH>bdH) bdH = ctH; 98 bdH = (ctH>bdH)? ctH: bdH+plus; 99 var smnH = parseInt($('#sidebar_menu').outerHeight()) + parseInt($('#sidebar').outerHeight()); 100 var rslt = (smnH>bdH? smnH:bdH) + hdH; 101 return rslt; 102 } 103 104 this.centerElement = function(_ele){ 105 var ele; 106 switch($.type(_ele)){ 107 case 'object' : ele = _ele;break; 108 case 'string' : 109 default : 110 ele = $(_ele);break; 111 } 112 113 if(ele.hasClass("ui-dialog-content")) ele = ele.parent(); 114 else if(ele.attr('role')=='dialog') ele = ele.find('.modal-dialog'); 115 116 var tarH = parseInt(ele.height()); 117 var vwpH = (window.parent.innerHeight)? window.parent.innerHeight : document.documentElement.clientHeight||document.body.clientHeight||0; 118 var vwTop = $(window.parent).scrollTop(); 119 var parTop = pObject.length? pObject.offset().top : 0; 120 var topPos = (vwTop + ((vwpH - tarH)/2)) - parTop; 121 122 if(topPos < (vwTop - parTop)) topPos = vwTop - parTop; // if top < viewport top, top = viewport top 123 if(tarH >= $(window).height()){ // check if ele higher than viewport, top = viewport top 124 $(window.parent).scrollTop(parTop); 125 thisObj.resizeIframe(ele); 126 topPos = 0; 127 } 128 129 setTimeout(function(){ 130 ele.animate({ 131 top: topPos 132 }, 0); 133 },100); 134 } 135 136 this.getBaseUrl = function() { 137 var scripts = document.getElementsByTagName('script'), 138 scriptSrc; 139 for(var i in scripts){ 140 if(scripts[i].src && (scripts[i].src).search("ais5-control")>=0){ 141 scriptSrc = scripts[i].src; 142 break; 143 } 144 } 145 return scriptSrc.replace(/assets\/(.*?)\/(.*)/g, ''); 146 } 147 148 this.openUrl = function(url){ 149 window.location = baseUrl+url; 150 } 151 152 this.getTimeDiff = function(startDate, endDate) { 153 let rslt = {}; 154 let milisec_diff = endDate - startDate; 155 // let time_diff = new Date( milisec_diff ); 156 157 rslt['day'] = Math.floor(milisec_diff / 1000 / 60 / (60 * 24)); 158 rslt['hour'] = Math.floor((milisec_diff / 1000 / 60 / 60) % 24); 159 rslt['minute'] = Math.floor((milisec_diff / 1000 / 60) % 60); 160 rslt['second'] = parseFloat((milisec_diff / 1000) % 60).toFixed(4); 161 162 let text = ''; 163 if(rslt['day'] > 0) text+= rslt['day']+' วัภ'; 164 if(rslt['hour'] > 0) text+= rslt['hour']+' à¸à¸±à¹à¸§à¹à¸¡à¸ '; 165 if(rslt['minute'] > 0) text+= rslt['minute']+' à¸à¸²à¸à¸µ '; 166 if(rslt['second'] > 0) text+= rslt['second']+' วิà¸à¸²à¸à¸µ '; 167 rslt['text'] = text; 168 return rslt; 169 } 170 171 this.selectFormTar = ''; 172 this.selectFormDat = ''; 173 /*this.selectForm = function(_dataForm,_target,_data,_option){ 174 var options = { 175 header : 'à¹à¸¥à¸·à¸à¸à¸£à¸²à¸¢à¸à¸²à¸£', 176 width : '800' 177 }; 178 if($.type(_option)=='object'){ 179 options = $.extend( 180 {}, 181 options, 182 _option 183 ); 184 } 185 186 thisObj.selectFormTar = _target; 187 var dia = $('<div class="dialog">'); 188 $('body').append(dia); 189 dia.dialog({ 190 title: options['header'], 191 width: options['width'], 192 open: function( event, ui ) { 193 $.post(baseUrl+"sys_main/select_"+_dataForm, _data, function( data ) { 194 dia.append(data); 195 thisObj.centerElement(dia); // à¸à¸£à¸à¸à¸µà¹à¸à¸³à¹à¸«à¹ dialog à¸à¸¢à¸¹à¹à¸à¸¶à¹à¸à¸à¸¥à¸²à¸à¸à¸à¸à¸«à¸à¹à¸²à¸à¸ 196 }); 197 } 198 }); 199 }*/ 200 this.decodeScript = function(_tar){ 201 var $tar = _tar; 202 if(typeof _tar == 'string') $tar = $(_tar); 203 else if(typeof _tar !== 'object') return; 204 205 var scripts = []; 206 $.each($tar.find('script'),function(i, stag){ 207 let src = $(stag).attr('src'); 208 let scriptText = $(stag).text(); 209 $(stag).remove(); 210 211 var script = $('<script>'); 212 script.attr('type','text/javascript').html(scriptText); 213 script.attr('src', src); 214 scripts.push(script); 215 $('head').append(script); 216 }); 217 218 // var scriptText = $tar.find('script').text(); 219 // $tar.find('script').remove(); 220 221 // var script = $('<script>'); 222 // script.attr('type','text/javascript').html(scriptText); 223 // $('head').append(script); 224 225 $tar.on('hidden.bs.modal', function (e) { 226 // script.remove(); 227 $.each(scripts,function(i, scrp){scrp.remove();}); 228 }); 229 } 230 231 this.selectForm = function(_dataForm,_target,_data,_option){ 232 var options = { 233 header : 'à¹à¸¥à¸·à¸à¸à¸£à¸²à¸¢à¸à¸²à¸£', 234 width : '800', 235 'mode' : 'jquery', 236 'updiframe' : false, 237 'mdclass' : ' modal-notify modal-primary ' 238 }; 239 if($.type(_option)=='object'){ 240 options = $.extend( 241 {}, 242 options, 243 _option 244 ); 245 } 246 thisObj.selectFormTar = _target; 247 248 if($.inArray(options['mode'], ['bootstrap','boostrap'])>=0) BTNewDialog(_dataForm,_data,options); 249 else JQDialog(_dataForm,_data,options); 250 251 /*var diaH = ''; 252 var diaB = ''; 253 var diaF = ''; 254 var addClass = ''; 255 switch(true){ 256 case options['width'] >= 800 : addClass = 'modal-lg';break; 257 case options['width'] < 400 : addClass = 'modal-sm';break; 258 } 259 260 var dia = $('<div class="modal fade dialog" tabindex="-1" role="dialog">'); 261 var dia2 = $('<div class="modal-dialog '+addClass+'">');
262 var dia3 = $('<div class="modal-content ui-dialog-content">'); 263 dia2.append(dia3); 264 dia.append(dia2); 265 266 diaH+= '<div class="modal-header">'; 267 diaH+= '<button type="button" class="close" data-dismiss="modal">×</button>'; 268 diaH+= '<h4 class="modal-title">'+options['header']+'</h4>'; 269 diaH+= '</div>'; 270 dia3.append(diaH); 271 $.post(baseUrl+"sys_main/select_"+_dataForm, _data, function( data ) { 272 diaB+= '<div class="modal-body">'+data+'</div>'; 273 dia3.append(diaB); 274 dia.modal('show'); 275 }); 276 277 dia 278 .on('shown.bs.modal', function (e) { 279 thisObj.centerElement(dia); // à¸à¸£à¸à¸à¸µà¹à¸à¸³à¹à¸«à¹ dialog à¸à¸¢à¸¹à¹à¸à¸¶à¹à¸à¸à¸¥à¸²à¸à¸à¸à¸à¸«à¸à¹à¸²à¸à¸ 280 }) 281 .on('hidden.bs.modal', function (e) { 282 dia.remove(); 283 });*/ 284 } 285 286 var JQDialog = function(_dataForm,_data,_option){ 287 var options = _option; 288 289 var dia = $('<div class="dialog">'); 290 $('body').append(dia); 291 dia.dialog({ 292 title: options['header'], 293 width: options['width'], 294 'open': function( event, ui ) { 295 $.post(baseUrl+"sys_main/select_"+_dataForm, _data, function( data ) { 296 dia.append(data); 297 MSYS.selectFormTar.trigger('diaopened'); 298 thisObj.centerElement(dia); // à¸à¸£à¸à¸à¸µà¹à¸à¸³à¹à¸«à¹ dialog à¸à¸¢à¸¹à¹à¸à¸¶à¹à¸à¸à¸¥à¸²à¸à¸à¸à¸à¸«à¸à¹à¸²à¸à¸ 299 }); 300 }, 301 'close': function(){ 302 MSYS.selectFormTar.trigger('diaclosed'); 303 } 304 }); 305 } 306 307 var BTDialog = function(_dataForm,_data,_option){ 308 var options = _option; 309 310 var diaH = ''; 311 var diaB = ''; 312 var diaF = ''; 313 var addClass = ''; 314 switch(true){ 315 case options['width'] >= 800 : addClass = 'modal-lg';break; 316 case options['width'] < 400 : addClass = 'modal-sm';break; 317 } 318 319 var dia = $('<div class="modal fade dialog" tabindex="-1" role="dialog">'); 320 var dia2 = $('<div class="modal-dialog '+addClass+'">'); 321 var dia3 = $('<div class="modal-content ui-dialog-content">'); 322 dia2.append(dia3); 323 dia.append(dia2); 324 325 diaH+= '<div class="modal-header">'; 326 diaH+= '<button type="button" class="close" data-dismiss="modal">×</button>'; 327 diaH+= '<h4 class="modal-title">'+options['header']+'</h4>'; 328 diaH+= '</div>'; 329 dia3.append(diaH); 330 $.post(baseUrl+"sys_main/select_"+_dataForm, _data, function( data ) { 331 diaB+= '<div class="modal-body">'+data+'</div>'; 332 dia3.append(diaB); 333 dia.modal('show'); 334 }); 335 336 dia 337 .on('shown.bs.modal', function (e) { 338 MSYS.selectFormTar.trigger('diaopened'); 339 thisObj.centerElement(dia); // à¸à¸£à¸à¸à¸µà¹à¸à¸³à¹à¸«à¹ dialog à¸à¸¢à¸¹à¹à¸à¸¶à¹à¸à¸à¸¥à¸²à¸à¸à¸à¸à¸«à¸à¹à¸²à¸à¸ 340 if(options['updiframe']) thisObj.resizeIframe(500,dia,20); 341 }) 342 .on('hidden.bs.modal', function (e) { 343 MSYS.selectFormTar.trigger('diaclosed'); 344 if(options['updiframe']) thisObj.resizeIframe(); 345 dia.remove(); 346 }); 347 } 348 349 var BTNewDialog = function(_dataForm,_data,_option){ 350 var options = _option; 351 352 var diaH = ''; 353 var diaB = ''; 354 var diaF = ''; 355 var addClass = ''; 356 switch(true){ 357 case options['width'] >= 800 : addClass = 'modal-xl';break; 358 case options['width'] >= 400 : addClass = 'modal-lg';break; 359 case options['width'] < 400 : addClass = 'modal-sm';break; 360 } 361 if(options['mdclass']) addClass += options['mdclass']; 362 363 var dia = $('<div class="modal fade dialog" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="true">'); 364 var dia2 = $('<div class="modal-dialog '+addClass+'" role="document">'); 365 var dia3 = $('<div class="modal-content">'); 366 dia2.append(dia3); 367 dia.append(dia2); 368 369 diaH+= '<div class="modal-header">'; 370 diaH+= '<p class="heading">'+options['header']+'</p>'; 371 diaH+= '<button type="button" class="close" data-dismiss="modal" aria-label="Close">'; 372 diaH+= '<span aria-hidden="true" class="white-text">×</span>'; 373 diaH+= '</button>'; 374 diaH+= '</div>'; 375 dia3.append(diaH); 376 $.post(baseUrl+"sys_main/select_"+_dataForm, _data, function( data ) { 377 diaB+= '<div class="modal-body">'+data+'</div>'; 378 dia3.append(diaB); 379 dia.modal('show'); 380 }); 381 382 dia 383 .on('shown.bs.modal', function (e) { 384 // eval(dia.find('script').text()); 385 var scriptText = dia.find('script').text(); 386 dia.find('script').remove(); 387 script = $('<script>'); 388 script.attr('type','text/javascript').html(scriptText); 389 $('head').append(script); 390 391 MSYS.selectFormTar.trigger('diaopened'); 392 dia.trigger('focus'); 393 // thisObj.centerElement(dia); // à¸à¸£à¸à¸à¸µà¹à¸à¸³à¹à¸«à¹ dialog à¸à¸¢à¸¹à¹à¸à¸¶à¹à¸à¸à¸¥à¸²à¸à¸à¸à¸à¸«à¸à¹à¸²à¸à¸ 394 if(options['updiframe']) thisObj.resizeIframe(500,dia,20); 395 }) 396 .on('hidden.bs.modal', function (e) { 397 MSYS.selectFormTar.trigger('diaclosed'); 398 if(options['updiframe']) thisObj.resizeIframe(); 399 dia.remove(); 400 }); 401 } 402 var BTNewDialog_c = function(_dataForm,_data,_option){ 403 var options = _option; 404 console.log(options); 405 406 var diaH = ''; 407 var diaB = ''; 408 var diaF = ''; 409 var addClass = ''; 410 switch(true){ 411 case options['width'] >= 800 : addClass = 'modal-lg';break; 412 case options['width'] < 400 : addClass = 'modal-sm';break; 413 } 414 var dia = $('<div class="modal fade right" id="modalDiscount" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="true">'); 415 416 var dia = $('<div class="modal-dialog '+ options['style'] +addClass+' " data-backdrop="true" role="document">');
417 var dia3 = $('<div class="modal-content">'); 418 419 dia.append(dia3); 420 421 diaH+= '<div class="modal-header">'; 422 diaH+= '<p class="heading">'+options['header']+'</p>'; 423 diaH+= '<button type="button" class="close" data-dismiss="modal" aria-label="Close">'; 424 diaH+= '<span aria-hidden="true" class="white-text">×</span>'; 425 diaH+= '</button>'; 426 diaH+= '</div>'; 427 428 dia3.append(diaH); 429 $.post(baseUrl+"sys_main/select_"+_dataForm, _data, function( data ) { 430 diaB+= '<div class="modal-body">'+data+'</div>'; 431 dia3.append(diaB); 432 dia.modal('show'); 433 }); 434 435 dia 436 .on('shown.bs.modal', function (e) { 437 MSYS.selectFormTar.trigger('diaopened'); 438 thisObj.centerElement(dia); // à¸à¸£à¸à¸à¸µà¹à¸à¸³à¹à¸«à¹ dialog à¸à¸¢à¸¹à¹à¸à¸¶à¹à¸à¸à¸¥à¸²à¸à¸à¸à¸à¸«à¸à¹à¸²à¸à¸ 439 if(options['updiframe']) thisObj.resizeIframe(500,dia,20); 440 }) 441 .on('hidden.bs.modal', function (e) { 442 MSYS.selectFormTar.trigger('diaclosed'); 443 if(options['updiframe']) thisObj.resizeIframe(); 444 dia.remove(); 445 }); 446 } 447 448 var progressAnimate = function(_text){ 449 var text = ($.type(_text)=='undefined' || _text===true)? true:false; 450 var $ppc = $('.progress-pie-chart'), 451 percent = parseInt($ppc.data('percent')), 452 deg = 360*percent/100; 453 if (percent > 50) { 454 $ppc.addClass('gt-50'); 455 } 456 $('.ppc-progress-fill').css('transform','rotate('+ deg +'deg)'); 457 var progressTxt = (text===true)? percent+'%':''; 458 $('.ppc-percents span').html(progressTxt); 459 } 460 461 var progressAdjust = function(){ 462 var loading = $('#opdce_loading'); 463 var loadingDialog = loading.find('.loading_msg'); 464 //var loadingHeigth = loadingDialog.height(); 465 var loadingWidth = loadingDialog.width(); 466 //var winH = $(window).height(); 467 var winW = $(window).width(); 468 //var bodyTop = (winH-loadingHeigth)/2; 469 var bodyLeft = (winW-loadingWidth)/2; 470 //loadingDialog.css({position:'fixed',top:bodyTop,left:bodyLeft}); 471 loadingDialog.css({position:'fixed',left:bodyLeft}); 472 473 thisObj.centerElement(loadingDialog); 474 } 475 476 this.progressOpen = function(_autoAnimate,_autoClose){ 477 var autoAnimate = ($.type(_autoAnimate)=='undefined' || _autoAnimate==true)? true:false; 478 var autoClose = ($.type(_autoClose)=='undefined' || _autoClose==false)? false:true; 479 var loading = $('#opdce_loading'); 480 loading.show(); 481 // progressAdjust(); /* Delete 2021-05-19 */ 482 //thisObj.centerElement(loading.find('.loading_msg')); 483 if(progInv) { 484 clearInterval(progInv); 485 progInv = false; 486 } 487 488 var $pie = loading.find('.progress-pie-chart'); 489 $pie.data('percent',0); 490 if(autoAnimate){ 491 progInv = setInterval(function() { 492 var percent = parseInt($pie.data('percent'))+1; 493 thisObj.progressUpdate(percent,false); 494 if(autoClose && percent >= 100) thisObj.progressClose(); 495 }, 100); 496 }else { 497 progInv = false; 498 } 499 } 500 501 this.progressClose = function(_finish){ 502 if(progInv) { 503 clearInterval(progInv); 504 progInv = false; 505 } 506 507 if($.type(_finish)=='undefined' || _finish==true) thisObj.progressUpdate(100); 508 setTimeout(function(){ 509 $('#opdce_loading').hide(); 510 },500); 511 } 512 513 this.progressUpdate = function(_num,_text){ 514 var $pie = $('#opdce_loading').find('.progress-pie-chart'); 515 if($.type(_num)!='undefined' && _num) $pie.data('percent',_num); 516 progressAnimate(_text); 517 } 518 519 // Active ais5.combobox plugin 520 this.activeCombobox = function(_target){ 521 var target = _target? _target+' ' : ''; 522 thisObj.setTableInput(target); 523 activeAiscombo(target); 524 } 525 526 this.setCookie = function(key, value, expiry) { 527 let expires = new Date(); 528 expires.setTime(expires.getTime() + (expiry * 24 * 60 * 60 * 1000)); 529 document.cookie = key + '=' + value + ';path=/' + ';expires=' + expires.toUTCString(); 530 } 531 532 this.getCookie = function(key) { 533 let keyValue = document.cookie.match('(^|;) ?' + key + '=([^;]*)(;|$)'); 534 return keyValue ? keyValue[2] : null; 535 } 536 537 this.eraseCookie = function(key) { 538 let keyValue = thisObj.getCookie(key);
539 thisObj.setCookie(key, keyValue, '-1'); 540 } 541 542 this.clearCookie = function() { 543 let cookies = document.cookie.split(";"); 544 for (var i = 0; i < cookies.length; i++) { 545 let cookie = cookies[i]; 546 let eqPos = cookie.indexOf("="); 547 let key = eqPos > -1 ? cookie.substr(0, eqPos) : cookie; 548 // document.cookie = key + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT"; 549 thisObj.setCookie(key, keyValue, '-1'); 550 } 551 } 552 553 this.showFile = function(fPath, fname){ 554 let varExt = fname.split('.'); 555 let fileExt = (varExt[varExt.length - 1]).toLowerCase(); 556 557 if($.inArray(fileExt , ['jpg','jpeg','bmp','gif','png'])<0){ 558 _downloadURI(fPath, fname); 559 }else{ 560 let iosImg = new Image; 561 iosImg.src = fPath; 562 iosImg.crossOrigin = 'Anonymous'; 563 let nWindow = window.open('', '_blank', "location=0,status=0,scrollbars=1, width=800,height=600"); 564 nWindow.document.body.appendChild(iosImg); 565 } 566 } 567 568 var _downloadURI = function(uri, name) { 569 var link = document.createElement("a"); 570 link.download = n
570ame; 571 link.href = uri; 572 link.target = '_blank'; 573 document.body.appendChild(link); 574 link.click(); 575 document.body.removeChild(link); 576 delete link; 577 } 578 579 //=============================================== 580 //START User control 581 this.checkSession = function(_alert){ 582 if($.type(_alert) == 'undefined') _alert = true; 583 $.post(baseUrl+"sys_main/sys/check_session", function(result) { 584 if(result !== true && result !== 'true'){ 585 $('#opdce_timer').hide(); 586 if(_alert){ 587 alert('à¸à¸²à¸£à¸¥à¹à¸à¸à¸à¸´à¸à¸«à¸¡à¸à¸à¸²à¸¢à¸¸ à¸à¸£à¸¸à¸à¸²à¸¥à¹à¸à¸à¸à¸´à¸à¹à¸«à¸¡à¹à¸à¸µà¸à¸à¸£à¸±à¹à¸'); 588 //thisObj.locationReload(); 589 // location.reload(); 590 window.location.assign(baseUrl); 591 } 592 return false; 593 }else{ 594 thisObj.checkTimeout(); 595 return true; 596 } 597 }); 598 } 599 600 this.logout = function(){ 601 if (confirm('à¸à¹à¸à¸à¸à¸²à¸£à¸à¸à¸à¸à¸²à¸à¸£à¸°à¸à¸à¸«à¸£à¸·à¸à¹à¸¡à¹?')) { 602 $.post(baseUrl+"sys_main/sys/logout", function() { 603 window.location.assign(baseUrl); 604 }); 605 } 606 } 607 608 609 this.checkTimeout = function(){ 610 thisObj.showTimeout(timeout); 611 var cur_time = timeout; 612 if(timer) clearInterval(timer); 613 timer = setInterval(function(){ 614 // update time countdown 615 cur_time-= 1000; 616 thisObj.showTimeout(cur_time); 617 618 if(cur_time<=0) { 619 //cancel the previous timer and logout 620 clearInterval(timer); 621 $.post(baseUrl+"sys_main/sys/logout", function(data) { 622 if(data){ 623 location.reload(); 624 //window.location.assign(rootHost); 625 } 626 }); 627 } 628 629 },1000); 630 } 631 632 this.showTimeout = function(cur_time){ 633 var show_minute = Math.floor((cur_time/1000)/60); 634 var show_second = (cur_time - ((1000*show_minute)*60))/1000; 635 $('.timer_minutes').html(show_minute>9? show_minute: '0'+show_minute); 636 $('.timer_seconds').html(show_second>9? show_second: '0'+show_second); 637 } 638 639 this.toClickedMenu = function(){ 640 let hrf = $('body').find('.side-menu .nav-item a.active').attr('href'); 641 window.location = hrf; 642 } 643 644 this.sumDec = function(dec1, dec2){ 645 let decA = dec1.toString().split("."); 646 let decB = dec2.toString().split("."); 647 let partsnum = Number(decA[0]) + Number(decB[0]); 648 let dgA = (decA[1]? decA[1]:'00'); 649 let dgB = (decB[1]? decB[1]:'00'); 650 let dgALn = dgA.length; 651 let dgBLn = dgB.length; 652 let sLn = dgALn; 653 if(dgALn < dgBLn) { 654 sLn = dgBLn; 655 dgA = dgA.padEnd(dgBLn,'0'); 656 }else if(dgBLn < dgALn) { 657 sLn = dgALn; 658 dgB = dgB.padEnd(dgALn,'0'); 659 } 660 let partsdg = Number(dgA) + Number(dgB); 661 let dgpow = 10**sLn; 662 if(partsdg >=dgpow) { 663 partsnum += Math.floor(partsdg/dgpow); 664 partsdg %= dgpow; 665 } 666 partsdg = String(partsdg).padStart(sLn, '0'); 667 668 return parseFloat(partsnum+'.'+partsdg); 669 } 670 671 this.makePW = function(length, chars) { 672 let result = ''; 673 const characters = chars || 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$^|=+-'; 674 const charactersLength = characters.length; 675 let counter = 0; 676 while (counter < length) { 677 result += characters.charAt(Math.floor(Math.random() * charactersLength)); 678 counter += 1; 679 } 680 return result; 681 } 682 683 //END User control 684 685 // init common system 686 if(!baseUrl) baseUrl = thisObj.getBaseUrl(); 687 688 if(thisObj.checkSession(false)){ //check session when start program 689 thisObj.checkTimeout(); 690 } 691}
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.