You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
8 lines
40 KiB
8 lines
40 KiB
/*!
|
|
* PageUtil.js
|
|
* Copyright (c) 2018 CreativeDream
|
|
* Website: xxx
|
|
* Version: 1.0.0 (03-05-2018)
|
|
* Requires: jQuery v1.7.1 or later
|
|
*/
|
|
var i18next="undefined"==typeof i18next?parent.top.i18next:i18next,IsWaiting=null,bLeavePage=!1,g_db={SupportLocalStorage:function(){"use strict";return typeof localStorage!="undefined"},SetItem:function(n,t){"use strict";var i=!1;return this.SupportLocalStorage()&&(localStorage.setItem(n,t),i=!0),i},GetItem:function(n){"use strict";var t=null;return this.SupportLocalStorage()&&(t=localStorage.getItem(n)),t},RemoveItem:function(n){"use strict";var t=!1;return this.SupportLocalStorage()&&(localStorage.removeItem(n),t=!0),t},GetDic:function(n){"use strict";var i=null,t;return this.SupportLocalStorage()&&(t=localStorage.getItem(n),null!==t&&(i=JSON.parse(t))),i},SetDic:function(n,t){"use strict";var i=!1;return this.SupportLocalStorage()&&(localStorage.setItem(n,JSON.stringify(t)),i=!0),i}},g_gd={webapilonginurl:"/api/Service/GetLogin",webapiurl:"/api/Cmd/GetData",projectname:"Eurotran",projectver:"Origtek",relpath:"",debugmode:window.location.host==="192.168.1.105",debugcolor:"#732C6B",IsEDU:g_db.GetItem("isedu")==="true"},g_ul={GetToken:function(){"use strict";return g_db.GetItem("token")},SetToken:function(n){"use strict";g_db.SetItem("token",n)},GetSignature:function(){"use strict";return g_db.GetItem("signature")},SetSignature:function(n){"use strict";g_db.SetItem("signature",n)},SetLang:function(n){"use strict";g_db.SetItem("lang",n)},GetLang:function(){"use strict";return g_db.GetItem("lang")},SetLoginMethod:function(n){"use strict";g_db.SetItem("LoginMethod",n)},GetLoginMethod:function(){"use strict";return g_db.GetItem("LoginMethod")},IsEDU:function(){"use strict";return g_db.GetItem("isedu")},RndNum:function(n){var i="",t;for(n=n||10,t=0;t<n;t++)i+=Math.floor(Math.random()*10);return i}},g_api={ConnectLite:function(n,t,i,r,u,f,e){return window.IsWaiting=e,this.ConnectLiteWithoutToken(n,t,i,r,u,f)},ConnectLiteWithoutToken:function(n,t,i,r,u,f){var o={},e={},s=g_ul.GetToken(),h=g_ul.GetLang(),c=g_ul.GetSignature();return e.ORIGID=g_db.GetItem("orgid"),e.USERID=g_db.GetItem("userid"),e.MODULE=n,e.TYPE=t,e.PROJECT=g_gd.projectname,e.PROJECTVER=g_gd.projectver,e.TRACEDUMP=null,i=i||{},g_db.GetItem("dblockDict")!==null&&(i.dblockDict=g_db.GetItem("dblockDict")),e.DATA=i,h!==null&&(e.LANG=h),s!==null&&(e.TOKEN=s),c!==null&&(e.SIGNATURE=c),e.CUSTOMDATA={},window.sProgramId&&(e.CUSTOMDATA.program_id=sProgramId),e.CUSTOMDATA.module_id="webapp",o.url=i.hasOwnProperty("url")?i.url:g_gd.webapiurl,o.successfunc=r,o.dicparameters=e,o.failfunc="function"==typeof u?u:function(n,t,i){alert("ConnectLite Fail jqXHR:"+n+" textStatus:"+t+" errorThrown:"+i)},o.useasync="boolean"==typeof f?f:!0,this.AjaxPost(o)},AjaxPost:function(n){"use strict";var t=$.extend({useasync:!0,successfunc:null,failfunc:null,alwaysfunc:null,url:null,dicparameters:null},n),i=function(n){n.RESULT===-1?layer.alert(i18next.t("message.TokenVerifyFailed"),{icon:0,title:i18next.t("common.Tips")},function(){window.top.location.href="/Page/login.html"}):t.successfunc&&t.successfunc(n)};return $.ajax({type:"POST",url:t.url,data:"="+btoa2(encodeURIComponent(JSON.stringify(t.dicparameters))),success:i,error:t.failfunc,beforeSend:function(n){var i=g_ul.GetToken(),r=$.now(),u=g_ul.RndNum();n.setRequestHeader("orgid",t.dicparameters.ORIGID);n.setRequestHeader("userid",t.dicparameters.USERID);n.setRequestHeader("token",i);n.setRequestHeader("timestamp",r);n.setRequestHeader("nonce",u)},async:!0!==t.useasync?!1:!0}).always(t.alwaysfunc)}},CanDo=function(n,t){"use strict";function r(){i.fn._showWaiting(typeof IsWaiting=="string"?IsWaiting:undefined)}function u(){i.fn._closeWaiting();setTimeout(function(){IsWaiting=null},3e3)}var i=function(n){return new i.fn._init(n)};return i.fn=i.prototype={constructor:i,_init:function(t){var i=this,o={cusBtns:[],goTop:!0,searchBar:!0,goBack:!0,insertGo:!0,updateGo:!0,deleteGo:!0,pageSize:parent.top.SysSet.GridRecords||0,gridPages:parent.top.SysSet.GridPages||15,queryPageidx:1,toFirstPage:!1},s,h,f,e,u,r,c,l;$.extend(o,t);for(s in i._pageParam)h=o[s],h&&(i._pageParam[s]=h);if(i.options=o,i.ids={},i.params={},i.UE_Editor={},i.currentPageValue=[],i.validator=null,i.CheckId="",i.action=i._getAction(),i.ProgramId=i._getProgramId(),i.QueryPrgId=i._getQueryPrgId(),i.EditPrgId=i._getEditPrgId(),n.sProgramId=i.ProgramId,i.data=i._data,i.pageParam=i._pageParam,i.setGrid=function(n){i.Grid=n},typeof i.options.cusBtns=="function"&&(i.options.cusBtns=i.options.cusBtns(i)),f=i.options.idKeys,e=i.options.paramKeys,f&&$.isArray(f))for(u in f)"clear,insert,remove".indexOf(u)===-1&&(r=f[u],i.ids[r]=i._getUrlParam(r),i.CheckId+=i.ids[r]||"");if(e&&$.isArray(e))for(u in e)"clear,insert,remove".indexOf(u)===-1&&(r=e[u],i.params[r]=i._getUrlParam(r));i.initButtonHandler=function(n,t){return i._buttonHandler.call(i,n,t)};i.getPage=function(n){return i._getPage(n)};i.getOne=function(n){return i._getOne(n)};i.getInsert=function(n,t){return i._getInsert(t)};i.getUpdate=function(n){return i._getUpdate(n)};i.getDelete=function(n){return i._getDelete(n)};i.getExcel=function(n){if(n)return i._getPage(n)};i.gridInsert=function(n){if(n)return i._gridInsert(n)};i.gridUpdate=function(n){if(n)return i._gridUpdate(n)};i.gridDelete=function(n){if(n)return i._gridDelete(n)};for(r in i)c=r.replace("_",""),l=o[c],l&&r!=="constructor"&&(i[c]=l);i.form||(i.form=i._form);i.jsGrid||(i.jsGrid=i._jsGrid);i._pageInit().done(function(){var t=i.options.ueEditorIds,r,n;if($.isArray(t))for(r in t)"clear,insert,remove".indexOf(r)===-1&&(n=t[r],$("#UE_"+n).length>0&&(i.UE_Editor[n]=UE.getEditor("UE_"+n)));typeof i.pageInit=="function"&&i.pageInit.call(i,i);typeof i.options.validRulesCus=="function"&&i.options.validRulesCus(i);typeof i.options.validRules=="function"&&(i.options.validRules=i.options.validRules(i));i.validator=i.form.validate(i.options.validRules||{})})},_service:{cotrl:"/Controller.ashx",com:"Common",opm:"OpmCom",eip:"EipCom",sys:"SysCom",auth:"Authorize"},_api:{getpage:"QueryPage",getlist:"QueryList",getone:"QueryOne",getcout:"QueryCout",insert:"Insert",update:"Update","delete":"Delete",ginsert:"GridInsert",gupdate:"GridUpdate",gdelete:"GridDelete",order:"UpdateOrderByValue"},_data:{},_form:$("#form_main"),_jsGrid:$("#jsGrid"),_pageParam:{pageIndex:1,pageSize:10,sortField:"OrderByValue",sortOrder:"asc"},_getProgramId:function(n){var r=n||t.location.href,i=r.split("/");return i=i[i.length-1].split("."),i[0]||""},_getEditPrgId:function(){var n=this._getProgramId();return n.replace("_Qry","_Upd")},_getQueryPrgId:function(){var n=this._getProgramId();return n.replace("_Upd","_Qry")},_buttonHandler:function(n){var t=this,u=n.id,i,f,r;if(!$.isEmptyObject(t.UE_Editor))for(i in t.UE_Editor)$("#"+i).length>0&&$("#"+i).val(t.UE_Editor[i].getContentTxt());switch(u){case"Toolbar_Qry":if(!t.form.valid())return t.validator.focusInvalid(),!1;f=$("#PerPageNum").val();t.Grid&&(t.Grid.pageSize=f===""?t.options.pageSize||10:f);t._cacheQueryCondition();t.Grid&&t.Grid.openPage(t.options.toFirstPage?1:t.pageParam.pageIndex);typeof t.options.afterQuery=="function"&&t.options.afterQuery(t);break;case"Toolbar_Save":if(!t.form.valid())return t.validator.focusInvalid(),!1;t.action==="add"?t.getInsert.call(t,t,t.action):t.getUpdate.call(t,t);break;case"Toolbar_ReAdd":if(!t.form.valid())return t.validator.focusInvalid(),!1;t.getInsert.call(t,t,"readd");break;case"Toolbar_Clear":t._clearPageVal();break;case"Toolbar_Leave":t._pageLeave();break;case"Toolbar_Add":parent.openPageTab(t.EditPrgId,"?Action=Add");break;case"Toolbar_Upd":break;case"Toolbar_Copy":break;case"Toolbar_Del":layer.confirm(i18next.t("message.ConfirmToDelete"),{icon:3,title:i18next.t("common.Tips")},function(n){t.getDelete.call(t);layer.close(n)});break;case"Toolbar_Exp":if(t.Grid.data.length===0)return showMsg(i18next.t("message.NoDataExport")),!1;t.getExcel({Excel:!0});break;default:r=t.options.cusBtns.filter(function(n){return n.id===u});r.length>0&&typeof r[0].action=="function"?r[0].action(t):alert("No handle '"+u+"'")}},_initGrid:function(){var n=this,t=$("body").height()-$(".page-title").height()-$("#searchbar").height()-87;typeof n.options.gridFields=="function"&&(n.options.gridFields=n.options.gridFields(n));n.jsGrid.jsGrid({width:"100%",height:t+"px",autoload:!0,pageLoading:!0,inserting:n.options.inserting||!1,editing:!0,sorting:!0,paging:!0,pageIndex:n.options.toFirstPage?1:n.options.queryPageidx,pageSize:n.options.pageSize,pageButtonCount:n.options.gridPages,invalidMessage:i18next.t("common.InvalidData"),confirmDeleting:!0,deleteConfirm:i18next.t("message.ConfirmToDelete"),pagePrevText:"<",pageNextText:">",pageFirstText:"<<",pageLastText:">>",fields:n.options.gridFields,onItemEditing:function(t){if(typeof n.options.onItemEditing=="function")n.options.onItemEditing(t)},onPageChanged:function(t){if(typeof n.options.onPageChanged=="function")n.options.onPageChanged(n,t);else n._cacheQueryCondition(t.pageIndex)},rowClick:function(t){if(typeof n.options.rowClick=="function")n.options.rowClick(n,t);else if(navigator.userAgent.match(/mobile/i)){var i=n._getParamsStr(n.ids,t.item);n._goToEdit(n.EditPrgId,"?Action=Upd"+i)}},rowDoubleClick:function(t){if(typeof n.options.rowDoubleClick=="function")n.options.rowDoubleClick(n,t);else{var i=n._getParamsStr(n.ids,t.item);parent.top.openPageTab(n.EditPrgId,"?Action=Upd"+i)}},controller:{loadData:function(t){return n.getPage(t)},insertItem:function(t){return n.gridInsert(t)},updateItem:function(t){return n.gridUpdate(t)},deleteItem:function(t){return n.gridDelete(t)}},onInit:function(t){n.setGrid(t.grid)}})},_getPage:function(n){var t=this,i=t._getFormSerialize();return $.extend(i,t.pageParam,n),t.pageParam.pageIndex=i.pageIndex,g_api.ConnectLite(t.ProgramId,t._api.getpage,i,function(i){if(i.RESULT){var r=i.DATA.rel;n.Excel&&(t._downLoadFile.call(t,r),layer&&n.Index&&layer.close(n.Index))}})},_getOne:function(){var n=this,t=clone(n.ids);return typeof n.options.getOneParams=="function"&&(t=n.options.getOneParams(n)),g_api.ConnectLite(n.ProgramId,n._api.getone,t,function(t){var i,u,f,r;if(t.RESULT){if(n.data=t.DATA.rel,i=n.options.jsonStrKeys,i&&$.isArray(i))for(u in i)"clear,insert,remove".indexOf(u)===-1&&(f=i[u],r=n.data[f],typeof r=="string"&&r!==""&&(n.data[f]=JSON.parse(r)));typeof n.options.getOneBack=="function"?n.options.getOneBack(n,n.data):(n._setFormVal(n.data),n._setUEValues(n.data));setTimeout(function(){n._getPageVal()},500)}},function(){showMsg(i18next.t("message.GetOne_Error"),"error")})},_getInsert:function(t){var i=this,r=i._getFormSerialize();return r=i._getUEValues(r),typeof i.options.getInsertParams=="function"&&(r=i.options.getInsertParams(i,r)),r=$.extend(i.data,r),g_api.ConnectLite(i.ProgramId,i._api.insert,r,function(r){var u,f;r.RESULT?(n.bRequestStorage=!1,u=r.DATA.rel,typeof i.options.getInsertBack=="function"?i.options.getInsertBack(i,u,t):i.options.goBack?t==="add"?i.options.insertGo?showMsgAndGo(i18next.t("message.Insert_Success"),i.QueryPrgId):showMsg(i18next.t("message.Insert_Success"),"success"):showMsgAndGo(i18next.t("message.Insert_Success"),i.ProgramId,"?Action=Add"):(f=i._getParamsStr(i.ids,u),showMsgAndGo(i18next.t("message.Insert_Success"),i.ProgramId,"?Action=Upd"+f))):showMsg(i18next.t("message.Insert_Failed")+"<br>"+r.MSG,"error")},function(){showMsg(i18next.t("message.Insert_Error"),"error")})},_getUpdate:function(){var t=this,i=t._getFormSerialize();return i=t._getUEValues(i),typeof t.options.getUpdateParams=="function"&&(i=t.options.getUpdateParams(t,i)),i=$.extend(t.data,i,t.ids),g_api.ConnectLite(t.ProgramId,t._api.update,i,function(i){if(i.RESULT){n.bRequestStorage=!1;var r=i.DATA.rel;typeof t.options.getUpdateBack=="function"?t.options.getUpdateBack(t,r):t.options.updateGo?showMsgAndGo(i18next.t("message.Modify_Success"),t.QueryPrgId):(showMsg(i18next.t("message.Modify_Success"),"success"),n.bLeavePage&&setTimeout(function(){t._pageLeave()},1e3))}else showMsg(i18next.t("message.Modify_Failed")+"<br>"+i.MSG,"error")},function(){showMsg(i18next.t("message.Modify_Error"),"error")})},_getDelete:function(){var n=this,t=clone(n.ids);return typeof n.options.getDeleteParams=="function"&&(t=n.options.getDeleteParams(n)),g_api.ConnectLite(n.ProgramId,n._api.delete,t,function(t){if(t.RESULT){var i=t.DATA.rel;typeof n.options.getDeleteBack=="function"?n.options.getDeleteBack(n,i):n.options.deleteGo?showMsgAndGo(i18next.t("message.Delete_Success"),n.QueryPrgId):showMsg(i18next.t("message.Delete_Success"),"success")}else showMsg(i18next.t("message.Delete_Failed")+"<br>"+t.MSG,"error")},function(){showMsg(i18next.t("message.Delete_Error"),"error")})},_gridInsert:function(n){var t=this;return typeof t.options.getGridInsertParams=="function"&&(n=t.options.getGridInsertParams(t,n)),g_api.ConnectLite(t.ProgramId,t._api.ginsert,n,function(n){if(n.RESULT){var i=n.DATA.rel;typeof t.options.getGridInsertBack=="function"?t.options.getGridInsertBack(t,i):showMsg(i18next.t("message.Insert_Success"),"success")}else showMsg(i18next.t("message.Insert_Failed")+"<br>"+n.MSG,"error")},function(){showMsg(i18next.t("message.Insert_Error"),"error")})},_gridUpdate:function(n){var t=this;return typeof t.options.getGridUpdateParams=="function"&&(n=t.options.getGridUpdateParams(t,n)),g_api.ConnectLite(t.ProgramId,t._api.gupdate,n,function(n){if(n.RESULT){var i=n.DATA.rel;typeof t.options.getGridUpdateBack=="function"?t.options.getGridUpdateBack(t,i):showMsg(i18next.t("message.Modify_Success"),"success")}else showMsg(i18next.t("message.Modify_Failed")+"<br>"+n.MSG,"error")},function(){showMsg(i18next.t("message.Modify_Error"),"error")})},_gridDelete:function(n){var t=this;return typeof t.options.getGridDeleteParams=="function"&&(n=t.options.getGridDeleteParams(t)),g_api.ConnectLite(t.ProgramId,t._api.gdelete,n,function(n){if(n.RESULT){var i=n.DATA.rel;typeof t.options.getGridDeleteBack=="function"?t.options.getGridDeleteBack(t,i):showMsg(i18next.t("message.Delete_Success"),"success")}else showMsg(i18next.t("message.Delete_Failed")+"<br>"+n.MSG,"error")},function(){showMsg(i18next.t("message.Delete_Error"),"error")})},_getExcel:function(){},_pageInit:function(){var n=this,i,r;if(navigator.userAgent.match(/mobile/i)&&$(".ismobile").hide(),$("#tabs").length>0)$("#tabs").tabs().find("li").on("click",function(){var t=this;$("#tabs>ul>li").removeClass("active");$(this).addClass("active");typeof n.options.tabAction=="function"&&n.options.tabAction(t,n)});if(setTimeout(function(){$.datepicker!==undefined&&($.datepicker.regional["zh-TW"]={dayNames:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"],dayNamesMin:["日","一","二","三","四","五","六"],monthNames:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],monthNamesShort:["01","02","03","04","05","06","07","08","09","10","11","12"],prevText:"上月",nextText:"次月",weekHeader:"週",showMonthAfterYear:!0,dateFormat:"yy/mm/dd"},$.datepicker.setDefaults($.datepicker.regional["zh-TW"]));$(".date-picker").length>0&&$(".date-picker").datepicker({changeYear:!0,changeMonth:!0,altFormat:"yyyy/MM/dd",onSelect:function(t,i){if(typeof n.options.onSelect=="function")n.options.onSelect(t,i)},afterInject:function(){}});$(".datetime-picker").length>0&&$(".datetime-picker").each(function(){var t=($(this).attr("hour")||9)*1,i=($(this).attr("minute")||0)*1,r=($(this).attr("stepminute")||15)*1;$(this).datetimepicker({changeYear:!0,changeMonth:!0,altFormat:"yyyy/MM/dd",timeFormat:"HH:mm",hour:t,minute:i,stepMinute:r,hourGrid:6,minuteGrid:15,onSelect:function(t,i){if(typeof n.options.onSelect=="function")n.options.onSelect(t,i)},afterInject:function(){}})});$(".time-picker").length>0&&$(".time-picker").each(function(){var t=($(this).attr("hour")||9)*1,i=($(this).attr("minute")||0)*1;$(this).timepicker({timeFormat:"HH:mm",hour:t,minute:i,minuteGrid:30,stepMinute:30,onSelect:function(t,i){if(typeof n.options.onSelect=="function")n.options.onSelect(t,i)}})})},1e3),$(".color-picker").length>0&&$(".color-picker").each(function(){var n=this;$(n).spectrum({color:"#000000",showInput:!0,className:"full-spectrum",showInitial:!0,showPalette:!0,showSelectionPalette:!0,maxPaletteSize:10,preferredFormat:"hex",hide:function(t){$(n).val(t.toHexString())},palette:[["rgb(0, 0, 0)","rgb(67, 67, 67)","rgb(102, 102, 102)","rgb(204, 204, 204)","rgb(217, 217, 217)","rgb(255, 255, 255)","rgb(152, 0, 0)","rgb(255, 0, 0)","rgb(255, 153, 0)","rgb(255, 255, 0)","rgb(0, 255, 0)"],["rgb(230, 184, 175)","rgb(244, 204, 204)","rgb(252, 229, 205)","rgb(255, 242, 204)","rgb(217, 234, 211)","rgb(208, 224, 227)","rgb(201, 218, 248)","rgb(207, 226, 243)","rgb(217, 210, 233)","rgb(234, 209, 220)","rgb(221, 126, 107)","rgb(234, 153, 153)","rgb(249, 203, 156)","rgb(255, 229, 153)","rgb(182, 215, 168)","rgb(162, 196, 201)","rgb(164, 194, 244)","rgb(159, 197, 232)","rgb(180, 167, 214)","rgb(213, 166, 189)","rgb(204, 65, 37)","rgb(224, 102, 102)","rgb(246, 178, 107)","rgb(255, 217, 102)","rgb(147, 196, 125)","rgb(118, 165, 175)","rgb(109, 158, 235)","rgb(111, 168, 220)","rgb(142, 124, 195)","rgb(194, 123, 160)","rgb(166, 28, 0)","rgb(204, 0, 0)","rgb(230, 145, 56)","rgb(241, 194, 50)","rgb(106, 168, 79)","rgb(69, 129, 142)","rgb(60, 120, 216)","rgb(61, 133, 198)","rgb(103, 78, 167)","rgb(166, 77, 121)","rgb(91, 15, 0)","rgb(102, 0, 0)","rgb(120, 63, 4)","rgb(127, 96, 0)","rgb(39, 78, 19)","rgb(12, 52, 61)","rgb(28, 69, 135)","rgb(7, 55, 99)","rgb(32, 18, 77)","rgb(76, 17, 48)","rgb(0, 255, 255)","rgb(74, 134, 232)","rgb(0, 0, 255)","rgb(153, 0, 255)","rgb(255, 0, 255)"]]})}),n._keyInput(),n._select2Init(),n._uniformInit(),n.options.goTop){i=$("<div>",{"class":"gotop",html:'<img src="../../images/gotop_1.png" />',click:function(){return $("body,html").animate({scrollTop:0},120),!1}});$("body").append(i.hide());$(t).on("scroll",function(){var r=($(t).height(),$(this).scrollTop()),f=-45,u=n._getToolBar();r>0?i.fadeIn():i.fadeOut();r>35?(f=r-80,u.addClass("toolbar-float").removeClass("toolbar-fix")):u.removeClass("toolbar-float").addClass("toolbar-fix");u.css("margin-top",f+"px")})}if(n.ProgramId){if(r=g_ul.GetLang()||"zh-TW",n._setLang(r),n._getPageVal(),n._createPageTitle(),n.options.searchBar)var f=$("#searchbar").height(),e=$("<i>",{"class":"fa fa-arrow-up slide-box",click:function(){$(this).hasClass("fa-arrow-up")?($(this).removeClass("fa-arrow-up").addClass("fa-arrow-down"),u.slideUp(),!n.Grid||(n.Grid.height=n.Grid.dfheight.replace("px","")*1+f+"px")):($(this).removeClass("fa-arrow-down").addClass("fa-arrow-up"),u.slideDown(),!n.Grid||(n.Grid.height=n.Grid.dfheight));!n.Grid||n.Grid.refresh();var t=$(".jsgrid-grid-body.slimscroll");t.parent().css("height",t.css("height"))}}),o=$("<div>",{"class":"col-sm-12 up-down-go"}).append(e),u=$("#searchbar").after(o);return n._reSetQueryPm(),n._getAuthority(n).done(function(){})}},_getAuthority:function(t){var i=this,r=i._getTopMod();return g_api.ConnectLite("Authorize","GetAuthorize",{ProgramID:i.ProgramId,TopModuleID:r},function(r){var s,f,l,a;if(r.RESULT){var v=r.DATA.rel,e=[],u={},o=null,h=i._getToolBar(),y=function(){h.ToolBar({btns:e,fncallback:i.initButtonHandler});i._transLang(h)},c=function(){$.fn.ToolBar?y():c()};$.each(v,function(n,t){if(t.AllowRight){var i=t.AllowRight.split("|");$.each(i,function(n,t){var i=$.trim(t);u[i.toLowerCase()]===undefined&&(u[i.toLowerCase()]=i)})}});u.upd||(delete u.save,delete u.readd);i.action==="upd"&&delete u.readd;i.action==="add"&&delete u.del;delete u.upd;delete u.view;for(s in u)if(f={},f.key=u[s],s==="leave")o=f,o.hotkey="ctrl + l";else{switch(s){case"qry":f.hotkey="enter";break;case"add":f.hotkey="ctrl + i";break;case"readd":f.hotkey="ctrl + r";break;case"save":f.hotkey="ctrl + s";break;case"del":f.hotkey="ctrl + d";break;case"clear":f.hotkey="ctrl + q"}e.push(f)}if(i.options.cusBtns.length>0&&e.push.apply(e,i.options.cusBtns),o&&e.push(o),c(),t.ProgramId.indexOf("_Upd")>-1)l=t._getAction(),l==="upd"&&parent.top.msgs.server.checkEdit(t.ProgramId,t.CheckId),t.form.find(":input,select").not("[data-type=select2]").change(function(){$(this).attr("data-trigger")||(n.bRequestStorage=!0)}),setTimeout(function(){t.form.find("[data-type=select2]").change(function(){$(this).attr("data-trigger")||(n.bRequestStorage=!0)})},3e3);else if(t.ProgramId.indexOf("_Qry")>-1&&parent.top.msgs.server.removeEditPrg(t.ProgramId.replace("_Qry","_Upd")),a=$("#Toolbar_Qry"),a.length>0){$("select").on("change",function(n,t){setTimeout(function(){t!=="clear"&&$("#Toolbar_Qry").click()},10)});$(':input[type="radio"],:input[type="checkbox"]').on("click",function(n,t){t!=="clear"&&$("#Toolbar_Qry").click()})}}})},_getTopMod:function(){var n=this,t="",r=g_db.GetDic("programList")||[],u=r.filter(function(t){return t.ModuleID===n.ProgramId})[0],i=function(r){var u=n._getParentMod(r);u.ParentID?i(u.ParentID):t=u.ModuleID};return i(u.ParentID),t},_getFormSerialize:function(n,t){var r=this,i={};return n=n||r.form,reFreshInput(n),i=t?n.serializeJSON():n.serializeObject(),reSetInput(n),i},_getParentMod:function(n){var i=this,t=g_db.GetDic("programList")||[];return t.filter(function(t){return t.ModuleID===n&&t.FilePath==="#"})[0]},_getPageVal:function(n){var t=this,i=n!==undefined?$("#"+n):t.form;t.currentPageValue=[];i.find(":input","textarea","select").each(function(){var n={};if(n.ID=this.id,n.Type=this.type,n.ID&&n.Type){switch(this.type){case"text":case"email":case"url":case"number":case"range":case"date":case"search":case"color":case"password":case"hidden":case"textarea":n.Value=$(this).val();break;case"checkbox":case"radio":n.Checked=this.checked;break;case"select-multiple":case"select-one":case"select":n.Value=$(this).val()||"";n.Html=$(this).html()}t.currentPageValue.push(n)}})},_getUrlParam:function(t){var r=new RegExp("(^|&)"+t+"=([^&]*)(&|$)"),i=n.location.search.substr(1).match(r);return i!==null?unescape(i[2]):null},_createPageTitle:function(){var t=this,f=$(".page-title"),i=g_db.GetItem("programList"),e="",r=[],o=function(n){var i=t._getParentMod(n);i.ModuleID&&r.unshift('<div class="ng-scope layout-row"> <a class="md-button" href="#"><span class="ng-binding ng-scope" data-i18n=common.'+i.ModuleID+'><\/span><\/a> <i class="fa fa-angle-right" aria-hidden="true"><\/i> <\/div>');i.ParentID&&o(i.ParentID)},s,u,n;i!==null&&i!==""&&(s=$.parseJSON(i),u=s.filter(function(n){return n.ModuleID===t.ProgramId}),u.length!==0)&&(n=u[0],n.ParentID)&&(o(n.ParentID),r.push('<div class="ng-scope layout-row"> <a class="md-button" href="#"><span class="ng-binding ng-scope" data-i18n=common.'+n.ModuleID+"><\/span><\/a> <\/div>"),e=r.join(""),$.templates({tmpl:'<div class="bread-crumbs layout-row ismobile" layout="row"> {{: ModTree }} <\/div > <div class="title ismobile"> <h2 data-i18n="{{:ProgramName}}"><\/h2> {{if showTable=="Y"}}<h5>(Use:{{:MainTableName}})<\/h5>{{/if}} <\/div>'}),f.html($.render.tmpl({ProgramName:"common."+n.ModuleID,showTable:parent.top.SysSet.TbShowOrHide,MainTableName:n.MainTableName,ModTree:e})),t._transLang(f),navigator.userAgent.match(/mobile/i)&&$(".ismobile").hide())},_reSetQueryPm:function(){var t=this,n=parent[t.ProgramId+"_query"];n&&(t._setFormVal(n),n.pageidx&&(t.options.queryPageidx=n.pageidx))},_setFormVal:function(n){var t=this;t.form.find("[name]").each(function(){var u=this.id,e=this.name?this.name.replace("[]",""):"",o=this.type,i=n[e]||t._getJsonVal(n,u)||"",r,f;if(i){switch(o){case"text":case"email":case"url":case"number":case"range":case"date":case"search":case"color":case"textarea":case"select-one":case"select":case"hidden":r=$(this).attr("data-type");r&&r==="pop"?(f=n[e+"Name"]||i,$(this).attr("data-value",i),f&&$(this).val(f)):($(this).hasClass("date-picker")?i=newDate(i,"date"):($(this).hasClass("date-picker")||$(this).hasClass("datetime-picker")||$(this).hasClass("date"))&&(i=newDate(i)),i&&$(this).val(i),$(this).data("old",i),r&&r==="int"&&i&&$(this).attr("data-value",i.toString().replace(/[^\d.]/g,"")));r==="select2"&&$(this).trigger("change","setval");break;case"checkbox":typeof i=="object"?i.indexOf(this.value)>-1&&(this.checked=i):this.checked=typeof i=="string"?i===this.value:i;$.uniform&&$.uniform.update($(this).prop("checked",this.checked));break;case"radio":this.checked=this.value===i;$.uniform&&$.uniform.update($(this).prop("checked",this.checked))}(u==="ModifyUserName"||u==="CreateUserName")&&"select-one".indexOf(this.type)===-1?$(this).text(i):(u==="ModifyDate"||u==="CreateDate")&&$(this).text(newDate(i))}})},_getJsonVal:function(n,t){for(var i=n,u=t.split("_"),r=0;r<u.length;r++){if(!i[u[r]]){i="";break}i=i[u[r]]}return i},_getParamsStr:function(n,t){var i="";for(var r in n)i+="&"+r+"="+encodeURIComponent(t[r]);return i},_clearPageVal:function(){for(var u=this,r=u.currentPageValue,f=$("#Toolbar_Qry"),i=0;i<r.length;i++){var t=r[i],n=$("#"+t.ID),o=n.parent();try{switch(t.Type){case"text":case"email":case"url":case"number":case"range":case"date":case"search":case"color":case"password":case"hidden":case"textarea":n.val(t.Value);break;case"checkbox":case"radio":n[0].checked=t.Checked;$.uniform&&$.uniform.update(n.prop("checked",n[0].checked));break;case"select-multiple":case"select-one":case"select":t.Html&&n.html(t.Html);n.val(t.Value);n.attr("data-type")==="select2"&&n.trigger("change","clear")}}catch(e){alert(e)}}f.length>0&&$("#Toolbar_Qry").click()},_pageLeave:function(){var i=this,t=function(){parent.top.openPageTab(i.QueryPrgId);parent.top.msgs.server.removeEditPrg(i.ProgramId)};if(parent.bLockDataForm0430!==undefined&&t(),n.bRequestStorage)return layer.confirm(i18next.t("message.HasDataTosave"),{icon:3,title:i18next.t("common.Tips"),btn:[i18next.t("common.Yes"),i18next.t("common.No")]},function(t){layer.close(t);n.bLeavePage=!0;$("#Toolbar_Save").click()},function(){t()}),!1;t()},_cacheQueryCondition:function(n){var r=this,e=n||r.form,t=r.ProgramId||r._getProgramId()||"",u={},f,i;if(r.options.toFirstPage=!1,t)if(parent[t+"_query"]||(parent[t+"_query"]={}),typeof e=="number")parent[t+"_query"].pageidx=e;else{f=clone(parent[t+"_query"]);u=r._getFormSerialize();for(i in u)parent[t+"_query"][i]=u[i];for(i in f)if(i!=="pageidx"&&parent[t+"_query"][i]!==f[i]){r.options.toFirstPage=!0;break}}},_getServerUrl:function(){return n.location.origin||this._getHost()},_getHost:function(){var t=location.origin+"/";return n.location.origin||(t=n.location.protocol+"//"+n.location.hostname+(n.location.port?":"+n.location.port:"")),t},_getToolBar:function(){return $("#Toolbar")},_getAction:function(){var n=this;return n._getUrlParam("Action")===null?"add":n._getUrlParam("Action").toLowerCase()},_downLoadFile:function(t,i){var u=this,f=u._getServerUrl(),r=f+"/Controller.ashx";r+="?action=downfile&path="+t;i&&(r+="&filename="+i);n.location.href=r;u._closeWaiting()},_showWaiting:function(t){$.blockUI({message:$('<div id="Divshowwaiting"><img src="/images/ajax-loader.gif">'+(t||"Waiting...")+"<\/div>"),css:{"font-size":"36px",border:"0px","border-radius":"10px","background-color":"#FFF",padding:"15px 15px",opacity:.5,color:"orange",cursor:"wait","z-index":1000000001},baseZ:1e9});n.setTimeout($.unblockUI,6e4)},_closeWaiting:function(n){$(function(){n===undefined&&(n=100);setTimeout($.unblockUI,n)})},_select2Init:function(n){var t=n===undefined?$("select[data-type=select2]"):n.find("select[data-type=select2]");t.length>0&&t.each(function(){$(this).find("option").length>0&&!$(this).attr("data-hasselect2")&&($(this).select2().attr("data-hasselect2",!0),$(this).next().after($(this)))})},_goToEdit:function(n,t){var i=this;parent.top.layer.open({type:1,title:!1,area:["100px","70px"],shade:.75,shadeClose:!0,content:'<div class="pop-box"> <button type="button" data-i18n="common.Edit" id="RowEdit" class="btn-custom green">編輯<\/button> <\/div>',success:function(r,u){r.find("#RowEdit").click(function(){parent.top.openPageTab(n,t);parent.top.layer.close(u)});i._transLang(r)}})},_uniformInit:function(n){var t=$("input[type=radio]:not(.no-uniform)");n&&(t=n.find("input[type=radio]:not(.no-uniform)"));t.length>0&&t.each(function(){$(this).uniform()})},_keyInput:function(){if($("[data-keyint]").length>0)$("[data-keyint]").on("keyup blur",function(){this.value=this.value.replace(/\D/g,"")});if($("[data-keyeng]").length>0)$("[data-keyeng]").on("keyup blur",function(){this.value=this.value.replace(/[^a-zA-Z]/g,"")});if($("[data-keyeng]").length>0)$("[data-keyeng]").on("keyup blur",function(){this.value=this.value.replace(/[^\u4E00-\u9FA5]/g,"")});if($("[data-keytelno]").length>0)$("[data-keytelno]").on("keyup blur",function(n){n.keyCode!==8&&n.keyCode!==37&&n.keyCode!==39&&n.keyCode!==46&&(this.value=this.value.replace(/[^0-9\-\+\#\ ]/g,""))});if($("[data-keyintg]").length>0)$("[data-keyintg]").on("keyup blur",function(){this.value=this.value.replace(/[^0-9\-\+\#]/g,"")});if($("[data-keyeng]").length>0)$("[data-keyeng]").on("keyup blur",function(){this.value=this.value.replace(/[^\a-\z\A-\Z]/g,"")});if($("[data-keyinteng]").length>0)$("[data-keyinteng]").on("keyup blur",function(){this.value=this.value.replace(/[^0-9\a-\z\A-\Z\_]/g,"")});if($("[data-keycneng]").length>0)$("[data-keycneng]").on("keyup blur",function(){this.value=this.value.replace(/[/d]/g,"")});if($("[data-keymemberid]").length>0)$("[data-keymemberid]").on("keyup blur",function(){this.value=this.value.replace(/[^\w\.\/]/ig,"")});$("[_maxlength]").length>0&&$("[_maxlength]").each(function(){var n=$(this).attr("_maxlength");if(n)$(this).on("input propertychange",function(){for(var i=this.value,u="",r=0,t=0;t<i.length;t++){if((i.charCodeAt(t)&65280)!=0&&r++,r++,r>n*1){this.value=u;break}u+=i[t]}})})},_setLang:function(n,t,i){if(n){g_ul.SetLang(n);i18next="undefined"==typeof i18next?parent.top.i18next:i18next;var r=this,u=r._getServerUrl();$.getJSON(u+"/Scripts/lang/"+(parent.top.OrgID||"TE")+"/"+n+".json?v=20180801",function(u){var f={};f[n]={translation:u};i18next.init({lng:n,resources:f,useLocalStorage:!1,localStorageExpirationTime:864e5},function(n,u){r._transLang(t);typeof i=="function"&&i(u)})})}},_transLang:function(n){i18next="undefined"==typeof i18next?parent.top.i18next:i18next;var t=n===undefined?$("[data-i18n]"):n.find("[data-i18n]"),i=n===undefined?$("[placeholderid]"):n.find("[placeholderid]");t.each(function(n,t){var r=$(t).attr("data-i18n"),i;r&&(i=i18next.t(r),t.nodeName==="INPUT"&&t.type==="button"?$(t).val(i):$(t).html(i))});i.each(function(n,t){var i=$(t).attr("placeholderid"),r;i&&(r=i18next.t(i),r!==i&&$(t).attr("placeholder",r))})},_getUEValues:function(n){var t=this,i;if(!$.isEmptyObject(t.UE_Editor))for(i in t.UE_Editor)n[i]=t.UE_Editor[i].getContent();return n},_setUEValues:function(n){var t=this,r=function(i){t.UE_Editor[i].ready(function(){t.UE_Editor[i].setContent(n[i]||"")})},i;if(!$.isEmptyObject(t.UE_Editor))for(i in t.UE_Editor)r(i)}},n.guid=function(){var t=new Uint16Array(8),r=n.crypto||n.msCrypto,i=function(n){for(var t=n.toString(16);t.length<4;)t="0"+t;return t};return r.getRandomValues(t),i(t[0])+i(t[1])+"-"+i(t[2])+"-"+i(t[3])+"-"+i(t[4])+"-"+i(t[5])+i(t[6])+i(t[7])},n.createOptions=function(n,t,i,r,u,f){var o,s,h,e,c;if(f=f||!0,n=n||[],o=[],s=[],typeof n=="number")for(h=n;n>0;)e=h-n+1,e=$.trim(e),o.push($("<option />",{value:e,title:e,html:e})),n--;else o=[$("<option />",{value:"",html:"請選擇..."})],c=n.length,c>0&&$.each(n,function(n,e){if(f!==!1||s.indexOf($.trim(e[t])<0&&f===!1)){var h=$("<option />",{value:$.trim(e[t]),title:$.trim(e[i]),html:(r?$.trim(e[t])+"-":"")+$.trim(e[i])});u&&h.attr(u,e[u]);o.push(h)}s.push($.trim(e[t]))});return $("<div />").append(o).html()},n.createRadios=function(n,t,i,r,u,f,e){n=n||[];u=u||"";e=e===!1?!0:undefined;var o="",s=n.length;return s>0&&$.each(n,function(n,s){var h=r+"_"+u+"_"+n,c=$("<input />",{type:"radio",id:h,name:r,"data-trigger":e,value:$.trim(s[t])}).attr("val",$.trim(s[t]));o+='<label for="'+h+'">'+c[0].outerHTML+((f?$.trim(s[t])+"-":"")+$.trim(s[i]))+"<\/label>"}),o},n.createCheckList=function(n,t,i,r,u){n=n||[];var f="",e=n.length;return e>0&&$.each(n,function(n,o){var s=$("<input />",{type:"checkbox",id:t+(u===undefined?"":u)+"_"+n,name:r+"[]",value:$.trim(o[t]),"class":"input-mini"});f+="<label for='"+t+(u===undefined?"":u)+"_"+n+"' style='"+(e===n+1?"":"float:left;")+"padding-left: 10px'>"+s[0].outerHTML+$.trim(o[i])+"<\/label>"}),f},n.onresize=function(){var n=$("body").height();$("#main-wrapper").length&&$("#main-wrapper").css("min-height",n-88+"px");setContentHeight()},n.fnframesize=function(i){var r=null,u;t.getElementById?r=t.getElementById(i):eval("pTar = "+i+";");r&&!n.opera&&(r.style.display="block",r.contentDocument&&r.contentDocument.body.offsetHeight?(u=$(t.body).outerHeight(!0),r.height=u-125,r.width=r.contentDocument.body.scrollWidth+20):r.Document&&r.Document.body.scrollHeight&&(r.height=r.Document.body.scrollHeight,r.width=r.Document.body.scrollWidth))},n.setContentHeight=function(){var n=function(n){var r=t.getElementsByTagName("iframe"),i,u;if(r!==null)for(i=0;i<r.length;i++)u=r[i],u.id.indexOf("ueditor_")===-1&&(u.height=n)},r=$(".page-inner"),i=$(t.body).outerHeight(!0)-110;n(i)},n.refreshLang=function(n){if(n&&n.length===0)return!1;i.fn._transLang(n)},n.reFreshInput=function(n){n.find("[disabled]").each(function(){$(this).attr("hasdisable",1).removeAttr("disabled")})},n.reSetInput=function(n){n.find("[hasdisable]").each(function(){$(this).removeAttr("hasdisable").prop("disabled",!0)})},n.newDate=function(n,t,i){var r="";return n?(typeof n=="string"?(r=n.replace("T"," ").replaceAll("-","/"),r.indexOf(".")>-1&&(r=r.slice(0,r.indexOf(".")))):r=new Date(n),r=new Date(r)):i||(r=new Date),r===""?"":t?r.formate("yyyy/MM/dd"):r.formate("yyyy/MM/dd HH:mm")},n.clone=function(n){var i,t,r;if(typeof n!="object"||n===null)return n;if(n instanceof Array)for(i=[],t=0,r=n.length;t<r;t++)i[t]=typeof n[t]=="object"&&n[t]!==null?arguments.callee(n[t]):n[t];else{i={};for(t in n)i[t]=typeof n[t]=="object"&&n[t]!==null?arguments.callee(n[t]):n[t]}return i},n.disableInput=function(n,t,i){i=i===undefined||i===null?!0:i;n=n.find(":input,select-one,select,checkbox,radio,textarea");t&&(n=n.not(t));n.each(function(){$(this).prop("disabled",i)})},n.getHtmlTmp=function(n){return $.ajax({async:!0,url:n,success:function(n){typeof callback=="function"&&callback(n)}})},n.uniformInit=function(n){var t=$("input[type=radio]:not(.no-uniform)");n&&(t=n.find("input[type=radio]:not(.no-uniform)"));t.length>0&&t.each(function(){$(this).uniform()})},n.EditFile=function(n,t){layer.open({type:1,title:i18next.t("common.EditFile"),shade:.75,maxmin:!0,area:["500px","350px"],content:'<div class="pop-box"> <div class="input-group input-append"> <input type="text" maxlength="30" id="FileName" name="FileName" class="form-control w100p"> <span class="input-group-addon add-on"> <\/span> <\/div><br/> <div class="input-group w100p"> <input type="text" maxlength="250" id="Link" name="Link" class="form-control w100p" placeholder="URL"> <\/div><br/> <div class="input-group"> <textarea name="FileDescription" id="FileDescription" class="form-control w100p" rows="5" cols="500"><\/textarea> <\/div> <\/div>',btn:[i18next.t("common.Confirm"),i18next.t("common.Cancel")],success:function(t){$(".pop-box .input-group-addon").text("."+n.subname);$("#FileName").val(n.filename);$("#Link").val(n.link);uniformInit(t)},yes:function(i){var u=$("#FileName").val(),r={FileName:u,Link:$("#Link").val(),Description:$("#FileDescription").val()};if(!r.FileName)return showMsg(i18next.t("message.FileName_Required")),!1;r.FileName+="."+n.subname;g_api.ConnectLite(Service.com,"EditFile",r,function(f){if(f.RESULT){n.filename=u;n.link=r.Link;n.description=r.Description;var e=t.find(".jFiler-item-title>b"),o=t.find(".file-name li:first"),s=t.find(".jFiler-item-description span");e.length>0&&e.attr("title",r.FileName).text(r.FileName);o.length>0&&o.text(r.FileName);s.length>0&&s.text(r.Description);layer.close(i);showMsg(i18next.t("message.Modify_Success"),"success")}else showMsg(i18next.t("message.Modify_Failed"),"error")})}})},n.DelFile=function(n,t,i){return i=i===undefined||i===null?!0:i,n&&$.trim(n)?g_api.ConnectLite(Service.com,"DelFile",{FileID:n,IDType:t||""},function(n){n.RESULT?i&&(n.DATA.rel?showMsg(i18next.t("message.Delete_Success"),"success"):showMsg(i18next.t("message.Delete_Failed"),"error")):showMsg(i18next.t("message.Delete_Failed"),"error")}):$.Deferred().resolve().promise()},n.optionListSearch=function(n,t,i){$("option",n).attr("title",function(){return this.innerHTML});$("option",t).attr("title",function(){return this.innerHTML});var u=n.html(),r="";$.each(n.find("option"),function(){$(this).val()+$(this).text()!=="undefined"&&(r+=$(this).val()+"|"+$(this).text()+",")});i.off("keyup").on("keyup",function(){var i=this.value;n.empty();i!==""?$.each(r.split(","),function(t,r){if(r.toLowerCase().indexOf(i.toLowerCase())>=0){var u=r.split("|")[0],f=r.split("|")[1];n.append('<option value="'+u+'">'+f+"<\/option>")}}):n.html(u);t.html()!==""&&$.each(t.find("option"),function(){n.find("option[value="+$(this).val().replace(".","\\.")+"]").remove()})})},n.optionListMove=function(n,t){var i=n.find("option").size(),r=n.find("option:selected").size();i>0&&r>0&&n.find("option:selected").each(function(){$(this).prependTo(t)})},n.slimScroll=function(n,t){if($.fn.slimScroll){var i={allowPageScroll:!0,color:"#ee7624",opacity:1};n&&(i.height=n);t&&(i.reduce=t);$(".slimscroll").slimscroll(i)}},n.packParams=function(n,t){return n.ModifyUser=parent.top.UserInfo.MemberID,n.ModifyDate=(new Date).formate("yyyy/MM/dd HH:mm"),t||(n.CreateUser=n.ModifyUser,n.CreateDate=n.ModifyDate),n},n.DownLoadFile=function(t,r){var u=gServerUrl+"/Controller.ashx";u+="?action=downfile&path="+t;r&&(u+="&filename="+r);n.location.href=u;i.fn._closeWaiting()},n.gServerUrl=i.fn._getServerUrl(),n.ComFn={W_Com:"comw",GetList:"QueryList",GetAdd:"Add",GetUpd:"Update",GetDel:"Delete",GetUserList:"GetUserList",GetArguments:"GetArguments"},n.Service=i.fn._service,n.transLang=i.fn._transLang,$(t).ajaxStart(r).ajaxStop(u),i.fn._init.prototype=i.fn,i}(window,document);Date.prototype.dateAdd=function(n,t){var r=this,i={y:"FullYear",q:"Month",m:"Month",w:"Date",d:"Date",h:"Hours",n:"Minutes",s:"Seconds",ms:"MilliSeconds"};return eval("r.set"+i[n]+"(r.get"+i[n]+"()+"+({q:3,w:7}[n]||1)*t+")"),r};Date.prototype.diff=function(n){return(this.getTime()-n.getTime())/864e5};Date.prototype.formate=function(n){var i={"M+":this.getMonth()+1,"d+":this.getDate(),"h+":this.getHours()%12==0?12:this.getHours()%12,"H+":this.getHours(),"m+":this.getMinutes(),"s+":this.getSeconds(),"q+":Math.floor((this.getMonth()+3)/3),S:this.getMilliseconds()},t;/(y+)/.test(n)&&(n=n.replace(RegExp.$1,(this.getFullYear()+"").substr(4-RegExp.$1.length)));/(E+)/.test(n)&&(n=n.replace(RegExp.$1,(RegExp.$1.length>1?RegExp.$1.length>2?"星期":"周":"")+{"0":"日","1":"一","2":"二","3":"三","4":"四","5":"五","6":"六"}[this.getDay()+""]));for(t in i)new RegExp("("+t+")").test(n)&&(n=n.replace(RegExp.$1,RegExp.$1.length===1?i[t]:("00"+i[t]).substr((""+i[t]).length)));return n};String.prototype.replaceAll=function(n,t){return this.replace(new RegExp(n,"gm"),t)};String.prototype.toMoney=Number.prototype.toMoney=function(){return this.toString().replace(/\d+?(?=(?:\d{3})+$)/g,function(n){return n+","})};String.prototype.toFloat=Number.prototype.toFloat=function(n){n=n?parseInt(n):0;var t=this;return n<=0?Math.round(t):Math.round(t*Math.pow(10,n))/Math.pow(10,n)};String.prototype.toPoint=function(){return this.replace("%","")/100};String.prototype.toPercent=Number.prototype.toPercent=function(){var n=Number(this*100).toFixed(1);return n+"%"};Array.prototype.clear=function(){for(var t=[],n=0;n<this.length;n++)this[n]&&t.push(this[n]);return t};Array.prototype.insert=function(n,t){this.splice(n,0,t)};Array.prototype.remove=function(n){var t=this.indexOf(n);t>-1&&this.splice(t,1)};jQuery.whenArray=function(n){return jQuery.when.apply(this,n)};
|