function Globals(){function e(){lang=o("web_lang"),token=o("_apitoken"),assetUrl=o("asset_url"),DevExpress.localization.locale(lang),DevExpress.config({editorStylingMode:"underlined"}),lang&&0!=lang.length||(i("web_lang","vi"),lang="vi")}lang=o("web_lang"),token=o("_apitoken"),assetUrl=o("asset_url"),e();var t=r("/locales/"+lang+".json"),n=JSON.parse($.ajax({url:t,async:!1}).responseText);function o(e){for(var t=e+"=",n=decodeURIComponent(document.cookie),o=n.split(";"),i=0;i<o.length;i++){var r=o[i];while(" "==r.charAt(0))r=r.substring(1);if(0==r.indexOf(t))return r.substring(t.length,r.length)}return""}function i(e,t,n){n=n||1;var o=new Date;o.setTime(o.getTime()+24*n*60*60*1e3);var i="expires="+o.toUTCString();document.cookie=e+"="+t+";"+i+";path=/"}function r(e){return assetUrl+"/"+e}this.language=n,this.getCookie=o,this.setCookie=i,this.asset=r,this.uuidv4=function(){return"xxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0,n="x"==e?t:3&t|8;return n.toString(16).toUpperCase()}))},this.apiGetDataList=function(e,t){return t=t||0,token?$.ajax({url:r("api/"+e),async:!1,type:"GET",data:{limit:t},dataType:"json",headers:{Authorization:"Bearer "+token},timeout:3e4,success:function(e){},error:function(e){u(e)}}).responseJSON:[]},this.apiPostDataList=function(e,t){var n=this.loadingPage;return null!==n&&"undefined"!==typeof n&&n.show(),token?$.ajax({url:r("api/"+e),async:!1,type:"POST",data:t,dataType:"json",headers:{Authorization:"Bearer "+token},timeout:3e4,success:function(e){null!==n&&"undefined"!==typeof n&&n.hide()},error:function(e){u(e),null!==n&&"undefined"!==typeof n&&n.hide()}}).responseJSON:(null!==n&&"undefined"!==typeof n&&n.hide(),[])},this.apiInsertData=function(e,t,o){if(l=this.loadingPage,null!==l&&"undefined"!==typeof l&&l.show(),e||(e={}),e.__tcms_model_binding=o,token){var i=$.Deferred();return $.ajax({url:r("api/"+t+"/create"),type:"POST",data:e,dataType:"json",headers:{Authorization:"Bearer "+token},success:function(e){return a(e),DevExpress.ui.notify({message:n.inserted},"success",100),null!==l&&"undefined"!==typeof l&&l.hide(),i.resolve()},error:function(e){return u(e),a(!1),null!==l&&"undefined"!==typeof l&&l.hide(),i.reject()}}),i.promise()}return null!==l&&l.hide(),[]};var s="";function a(e){return null==e||"undefined"===typeof e?s:s=e}function u(e){jQuery.isReady?d(e):setTimeout((function(){d(e)}),1e3)}function d(e){if(e.status&&(e.responseText?DevExpress.ui.notify("["+e.status+"] "+e.responseText,"error"):DevExpress.ui.notify("["+e.status+"] "+e.statusText,"error")),504==e.status&&-1!==e.responseText.indexOf("Expired token")){var t=DevExpress.ui.dialog.custom({title:n.expired,messageHtml:"<b>"+n.expired_token+"</b>",buttons:[{text:"OK",onClick:function(e){return{buttonText:e.component.option("text")}}},{text:n.cancel,onClick:function(e){return{buttonText:e.component.option("text")}}}]});t.show().done((function(e){"OK"==e.buttonText&&(location.href=r("login"))}))}}this.IdOfInserted=a,this.apiUpdateData=function(e,t,o){if(l=this.loadingPage,null!==l&&"undefined"!==typeof l&&l.show(),e||(e={}),e.__tcms_model_binding=o,token){var i=$.Deferred();return $.ajax({url:r("api/"+t+"/update"),type:"POST",data:e,dataType:"json",headers:{Authorization:"Bearer "+token},success:function(e){return DevExpress.ui.notify({message:n.updated},"success",1e3),null!==l&&"undefined"!==typeof l&&l.hide(),i.resolve()},error:function(e){return u(e),null!==l&&"undefined"!==typeof l&&l.hide(),i.reject()}}),i.promise()}return null!==l&&"undefined"!==typeof l&&l.hide(),[]},this.apiDeleteData=function(e,t){if(l=this.loadingPage,null!==l&&"undefined"!==typeof l&&l.show(),token){var o=$.Deferred();return $.ajax({url:r("api/"+t+"/delete"),type:"POST",data:{data:e},dataType:"json",headers:{Authorization:"Bearer "+token},success:function(e){return DevExpress.ui.notify({message:n.deleted},"success",1e3),null!==l&&"undefined"!==typeof l&&l.hide(),o.resolve()},error:function(e){return u(e),null!==l&&"undefined"!==typeof l&&l.hide(),o.reject()}}),o.promise()}return null!==l&&"undefined"!==typeof l&&l.hide(),[]},this.showSessionError=u;var l=null;this.loadingPage=l,this.formatDate=function(e,t="date"){var n=new Date(e),o=""+(n.getMonth()+1),i=""+n.getDate(),r=n.getFullYear();return hour=""+n.getHours(),minutes=""+n.getMinutes(),seconds=""+n.getSeconds(),o.length<2&&(o="0"+o),i.length<2&&(i="0"+i),hour.length<2&&(hour="0"+hour),minutes.length<2&&(minutes="0"+minutes),seconds.length<2&&(seconds="0"+seconds),"date"==t?[r,o,i].join("-"):"time"==t?[hour,minutes].join(":"):[r,o,i].join("-")+" "+[hour,minutes,seconds].join(":")}}