var App=function(){var n={tooltip:true,popover:true,nanoScroller:true,nestableLists:true,hiddenElements:true,bootstrapSwitch:true,dateTime:true,select2:true,tags:true,slider:true};function t(){$(".wizard-ux").wizard();$(".wizard-ux").on("changed",function(){$(".bslider").slider()});$(".wizard-next").on("click",function(t){$(".wizard-ux").wizard("next");t.preventDefault()});$(".wizard-previous").on("click",function(t){$(".wizard-ux").wizard("previous");t.preventDefault()})}function s(){if($("#sidebar-collapse").length<1)return;var t=$("#sidebar-collapse")[0];var e=$("#cl-wrapper");if(e.hasClass("sb-collapsed")){$(".fa",t).addClass("fa-angle-left").removeClass("fa-angle-right");e.removeClass("sb-collapsed")}else{$(".fa",t).removeClass("fa-angle-left").addClass("fa-angle-right");e.addClass("sb-collapsed")}}function e(){var i=window.location.pathname.replace(/^\//,"").replace(/[^\w]/g,"-");$(".page-aside").each(function(t){var e=$(this).attr("page-key")||i;var a=$(this),n=e+".page-aside-"+t;$(this).find(".header > .collapse-button").on("click",function(){a.addClass("collapsed");store.set(n,"collapsed");a.trigger("collapsed")});$(this).children(".collapsed-button").on("click",function(){a.removeClass("collapsed");store.set(n,"");a.trigger("expanded")});if(store.get(n)=="collapsed"){$(this).find(".header > .collapse-button").trigger("click")}})}function a(){var t=$("#main-container > .page-aside");var e=t.width();if(e<270){t.find(".header > .collapse-button").trigger("click");return}}function r(t){return typeof t=="object"&&t instanceof jQuery?t:$(t)}var o=$("<div id='sub-menu-nav' style='position:fixed;z-index:9999;'></div>");var l=/&|<|>| |\'|\"/g,c={"&":"&amp;","<":"&lt;",">":"&gt;"," ":"&nbsp;","'":"&#39;",'"':"&quot;"};var f=/&amp;|&lt;|&gt;|&nbsp;|&#39;|&quot;/g,p={"&amp;":"&","&lt;":"<","&gt;":">","&nbsp;":" ","&#39;":"'","&quot;":'"'};var d=/\n|  |\t/g,u={"\n":"<br />","  ":"&nbsp; ","\t":"&nbsp; &nbsp; "};function h(t,e){if(($("#cl-wrapper").hasClass("sb-collapsed")||$(window).width()>=753&&$(window).width()<=964)&&$("ul",t).length>0){$(t).removeClass("ocult");var a=$("ul",t);if(!$(".dropdown-header",t).length){var n='<li class="dropdown-header">'+$(t).children().html()+"</li>";a.prepend(n)}o.appendTo("body");var i=$(t).offset().top+8-$(window).scrollTop();var r=$(t).width();o.css({top:i,left:r+8});o.html('<ul class="sub-menu">'+a.html()+"</ul>");o.show();a.css("top",i)}else{o.hide()}}function g(){var t=220;var e=500;var a=$('<a href="#" class="back-to-top"><i class="fa fa-angle-up"></i></a>');a.appendTo("body");$(window).on("scroll",function(){if($(this).scrollTop()>t){$(".back-to-top").fadeIn(e)}else{$(".back-to-top").fadeOut(e)}});$(".back-to-top").on("click",function(t){t.preventDefault();$("html, body").animate({scrollTop:0},e);return false})}function v(t){var e,a='a.show-password[data-target]:not([pwdshow]),a[data-toggle="password"]:not([pwdshow])';if(!t){e=$(a)}else{e=$(t).find(a)}e.on("click",function(){var t=$(this).data("target")?$($(this).data("target")):$(this).parent(".input-group-addon,.input-group-btn").prev("input");if(t.attr("type")=="text"){t.attr("type","password");$(this).html('<i class="fa fa-eye"></i> '+App.t("显示"))}else{t.attr("type","text");$(this).html('<i class="fa fa-eye-slash"></i> '+App.t("隐藏"))}});e.attr("pwdshow","1")}function m(t,n,i){if(String(n).charAt(0)!="/")n="/"+n;$(t).find("td.editable").each(function(){var t="number",e=$(this).data("id"),a=this;$(this).children("span").editable({url:BACKEND_URL+n,type:t,pk:e,name:"sort",title:App.t("修改排序"),ajaxOptions:{dataType:"json",success:function(t){if(t.Code!=1)return App.message({text:t.Info,class_name:"danger"});if(i)i.apply(a,arguments);return App.message({text:t.Info,class_name:"success"})},error:function(t){return App.message({text:t.responseText,class_name:"danger"})}}})})}function w(t,e,a,n,i,r){$.ajax({url:e,method:t||"POST",dataType:i||"text",timeout:2e3,success:a,error:n,data:r})}var y=null,b=null;return{clientID:{},i18n:{SYS_INFO:"System Information",UPLOAD_ERR:"Upload Error",PLEASE_SELECT_FOR_OPERATE:"Please select the item you want to operate",PLEASE_SELECT_FOR_REMOVE:"Please select the item you want to delete",CONFIRM_REMOVE:"Are you sure you want to delete them?",SELECTED_ITEMS:"You have selected %d items",SUCCESS:"The operation was successful",FAILURE:"Operation failed",UPLOADING:"File uploading, please wait...",UPLOAD_SUCCEED:"Upload successfully",BUTTON_UPLOAD:"Upload"},lang:"en",sprintf:sprintfWrapper.init,t:function(t){if(typeof App.i18n[t]=="undefined"){if(t.startsWith("#")){var e=t.substring(1),a=e.indexOf("#");if(a>1){t=e.substring(a+1);arguments[0]=t}}if(arguments.length<2)return t;return App.sprintf.apply(this,arguments)}if(arguments.length<2)return App.i18n[t];arguments[0]=App.i18n[t];return App.sprintf.apply(this,arguments)},langInfo:function(){if(y!=null)return y;var t=App.lang.split("-",2);y={encoding:t[0],country:""};if(t.length>1)y.country=t[1].toUpperCase();return y},langTag:function(t){var e=App.langInfo();if(e.country){if(t==null){t="-"}return e.encoding+t+e.country}return e.encoding},initTool:function(){o.on("mouseenter",function(t){$(this).addClass("over")}).on("mouseleave",function(){$(this).removeClass("over");o.fadeOut("fast")});$(document).on("click",function(){o.hide()});$(document).on("touchstart click",function(t){o.fadeOut("fast")});o.on("click",function(t){t.stopPropagation()})},initLeftNav:function(){$(".cl-vnavigation li ul").each(function(){$(this).parent().addClass("parent")});$(".cl-vnavigation li ul li.active").each(function(){$(this).parent().show().parent().addClass("open")});if(!$(".cl-vnavigation").data("initclick")){$(".cl-vnavigation").data("initclick",true);$(".cl-vnavigation").on("click",".parent > a",function(t){$(".cl-vnavigation .parent.open > ul").not($(this).parent().find("ul")).slideUp(300,"swing",function(){$(this).parent().removeClass("open")});var e=$(this).parent().find("ul");e.slideToggle(300,"swing",function(){var t=$(this).parent();if(t.hasClass("open")){t.removeClass("open")}else{t.addClass("open")}$("#cl-wrapper .nscroller").nanoScroller({preventPageScrolling:true})});t.preventDefault()})}$(".cl-vnavigation li").on("mouseenter",function(t){h(this,t)}).on("mouseleave",function(t){o.removeClass("over");setTimeout(function(){if(!o.hasClass("over")&&!$(".cl-vnavigation li:hover").length>0){o.hide()}},500)});$(".cl-vnavigation li").on("click",function(t){if(($("#cl-wrapper").hasClass("sb-collapsed")||$(window).width()>755&&$(window).width()<963)&&$("ul",this).length>0&&!($(window).width()<755)){h(this,t);t.stopPropagation()}})},initLeftNavAjax:function(t,e){App.markNavByURL(t);App.attachPjax(e,{onclick:function(t){if($(t).data("marknav")){App.unmarkNav($(t),$(t).data("marknav"));App.markNav($(t),$(t).data("marknav"))}},onend:function(t,e,a){$(a.container).find('[data-popover="popover"]').popover();$(a.container).find('.ttip, [data-toggle="tooltip"]').tooltip();v(a.container)}});App.attachAjaxURL(e)},init:function(t){$.extend(n,t);App.initLeftNav();App.initTool();App.showRequriedInputStar();$(".cl-toggle").on("click",function(t){var e=$(".cl-vnavigation");e.slideToggle(300,"swing",function(){});t.preventDefault()});$("#sidebar-collapse").on("click",function(){s()});$("#global-searcher-collapse>a").on("click",function(){$("#global-searcher-container").toggleClass("show")});function r(t){}var e=$("#cl-wrapper");if(e.hasClass("fixed-menu")){var o=e.find(".menu-space");o.addClass("nano nscroller");function a(){var t=$("#cl-wrapper");var e=t.find(".collapse-button");var a=e.outerHeight();var n=$("#head-nav").height();var i=$(window).height()-(e.is(":visible")?a:0)-n;o.css("height",i);t.find(".nscroller").nanoScroller({preventPageScrolling:true});r(t)}$(window).on("resize",function(){a()});a();e.find(".nscroller").nanoScroller({preventPageScrolling:true})}else{$(window).on("resize",function(){var t=$("#cl-wrapper");if($(window).width()>767){var e=$("#head-nav").height();t.css("padding-top",e)}r(t)});r(e)}g();v();if($(".ui-datepicker").length>0)$(".ui-datepicker").datepicker();if(n.tooltip){$('.ttip, [data-toggle="tooltip"]').tooltip()}if(n.popover){$('[data-popover="popover"]').popover()}if(n.nanoScroller){$(".nscroller:not(.has-scrollbar)").nanoScroller()}if(n.bootstrapSwitch){if($(".switch:not(.has-switch)").length>0)$(".switch:not(.has-switch)").bootstrapSwitch()}if(n.dateTime){if($(".datetime").length>0)$(".datetime").datetimepicker({autoclose:true})}if(n.select2){if($(".select2").length>0)$(".select2").select2({width:"100%"})}if(n.tags){if($(".tags").length>0)$(".tags").select2({tags:0,width:"100%"})}if(n.slider){if($(".bslider").length>0)$(".bslider").slider()}if(n.hiddenElements){$(".dropdown").on("shown.bs.dropdown",function(){$(".nscroller").nanoScroller()});$(".nav-tabs").on("shown.bs.tab",function(t){$(".nscroller").nanoScroller()})}App.startLazyload();App.autoFixedThead();$(window).trigger("scroll")},autoFixedThead:function(t){if(t==null)t="";var e=function(){return $(window).width()>=753?$("#head-nav").height():0};App.topFloatThead(t+"thead.auto-fixed",e)},pageAside:e,tableReponsiveInit:a,getJQueryObject:r,toggleSideBar:s,wizard:t,markNavByURL:function(t){if(!t)t=window.location.pathname;if(t=="/index")return;var e=$('#leftnav a[href="'+BACKEND_URL+t+'"]');if(e.length<1)e=$('#leftnav a[href="'+t+'"]');App.markNav(e,"left");var a=$('#topnav a[href="'+BACKEND_URL+t+'"]:first');if(a.length<1)a=$('#topnav a[href="'+t+'"]:first');App.markNav(a,"top")},markNav:function(t,e){if(t.length<1)return;var a=t.parent("li").addClass("active");switch(e){case"left":a.parent(".from-left").show().parent("li").addClass("open");var n=$("#leftnav").attr("data-project");var i=$('#topnav li[data-project="'+n+'"]');if(i.length>0&&!i.hasClass("active")){i.addClass("active").siblings(".active").removeClass("active").find(".active").removeClass("active")}break;case"top":a.closest(".from-top").parent("li").addClass("active").siblings("li.active").removeClass("active");break}},unmarkNav:function(t,e){var a=t.parent("li");var n=a.siblings("li.active");if(n.length>0){n.removeClass("active");if(e!="top")return}switch(e){case"left":if(a.parent("ul.sub-menu").length>0){var i=$(".col-menu-2").children("li.open");if(i.length>0)i.removeClass("open").find("li.active").removeClass("active")}$("#leftnav > .open").removeClass("open").children("ul.sub-menu").hide().children("li.active").removeClass("active");$("#leftnav .active").removeClass("active");break;case"top":var r=a.closest("ul.dropdown-menu.from-top");if(r.length>0){if(r.hasClass("col-menu-2")){r.find("li.active").removeClass("active")}n=r.parent("li").addClass("active").siblings("li.active")}if(n.length>0){n.removeClass("active").children("ul.dropdown-menu.from-top").find("li.active").removeClass("active")}break}},message:function(t,e){if(typeof t=="string"){switch(t){case"remove":var a=e;return $.gritter.remove(a);case"clear":return $.gritter.removeAll(e||{})}}var n={title:App.i18n.SYS_INFO,text:"",image:"",class_name:"clean",sticky:false};if(typeof t!="object")t={text:t,class_name:"clean"};if(typeof t.type!="undefined"&&t.type)t.class_name=t.type;t=$.extend({},n,t||{});switch(t.class_name){case"dark":case"primary":case"clean":case"info":if(t.title)t.title='<i class="fa fa-info-circle"></i> '+App.t(t.title);break;case"error":t.class_name="danger";case"danger":if(t.title)t.title='<i class="fa fa-comment-o"></i> '+App.t(t.title);break;case"warning":if(t.title)t.title='<i class="fa fa-warning"></i> '+App.t(t.title);break;case"success":if(t.title)t.title='<i class="fa fa-check"></i> '+App.t(t.title);break}if(e!=null)t.sticky=e;if(t.text)t.text=App.t(t.text);var a=$.gritter.add(t);return a},attachAjaxURL:function(t){if(t==null)t=document;$(t).on("click","[data-ajax-url]",function(){var n=$(this),t=n.data("ajax-confirm");if(n.data("processing")){alert(App.t("Processing, please wait for the operation to complete"));return}if(t&&!confirm(t))return;n.data("processing",true);var e=n.data("ajax-url"),a=n.data("ajax-method")||"get",i=n.data("ajax-params")||{},r=n.attr("title")||App.i18n.SYS_INFO,o=n.data("ajax-accept")||"html",s=n.data("ajax-target"),l=n.data("ajax-callback"),c=n.data("ajax-toggle"),f=n.data("ajax-onsuccess"),p=n.data("ajax-reload")||false;if(!r)r=n.text();var d=n.children(".fa");var u=c&&d.length>0;if(u){d.addClass("fa-spin")}else{App.loading("show")}n.trigger("processing");if(typeof i==="function")i=i.apply(this,arguments);i=App.setClientID(i);$[a](e,i||{},function(t){n.data("processing",false);n.trigger("finished",arguments);if(u){d.removeClass("fa-spin")}else{App.loading("hide")}if(l)return l.apply(this,arguments);if(s){var e;if(o=="json"){if(t.Code!=1){return App.message({title:r,text:t.Info,type:"error",time:5e3,sticky:false})}e=t.Data}else{e=t}$(s).html(e);n.trigger("partial.loaded",arguments);$(s).trigger("partial.loaded",arguments);if(f)window.setTimeout(f,0);return}if(t.Code==1){if(f)window.setTimeout(f,2e3);if(p)window.setTimeout(function(){window.location.reload()},2e3)}if(o=="json"){return App.message({title:r,text:t.Info,type:t.Code==1?"success":"error",time:5e3,sticky:false})}App.message({title:r,text:t,time:5e3,sticky:false})},o).error(function(t,e,a){n.data("processing",false);n.trigger("finished",arguments);if(u){d.removeClass("fa-spin")}else{App.loading("hide")}App.message({title:r,text:t.responseText,type:"error",time:5e3,sticky:false})})})},startLazyload:function(t){if(t==null)t=document;$(t).find("[lazyload-url]:not([loaded])").each(function(){var n=$(this);n.attr("loaded","1");var t=n.attr("lazyload-url"),e=n.attr("lazyload-method")||"get",a=n.attr("lazyload-params")||{},i=n.attr("title")||App.i18n.SYS_INFO,r=n.attr("lazyload-accept")||"html",o=n.attr("lazyload-target"),s=n.attr("lazyload-onsuccess");if(!i)i=n.text();if(!o)o=this;$(o).html('<i class="fa fa-spinner fa-spin"></i>');if(typeof a==="function")a=a.apply(this,arguments);a=App.setClientID(a||{});$.ajax({type:e,url:t,async:true,dataType:r,data:a||{},success:function(t){n.trigger("finished",arguments);var e;if(r=="json"){if(t.Code!=1){$(o).html('<span class="lazyload-error text-danger">'+t.Info+"</span>&nbsp;");return}e=t.Data.html||""}else{e=t}$(o).html(e);if(s)window.setTimeout(s,0)},error:function(t,e,a){n.trigger("finished",arguments);$(o).html('<span class="lazyload-error text-danger">'+t.responseText+"</span>&nbsp;")}})})},appendNotifyClientID:function(t,e){if(!e){if(t){if(t.length==1&&(t=="?"||t=="&")){e=t;t=""}else{e=t.indexOf("?")>0?"&":"?"}}else{e="?"}}return t+e+"notifyClientID="+App.getClientID()},postFormData:function(t,e,a,n,i){var r=$(t);var o=new FormData(r[0]);if(e){for(var s in e){o.append(s,e[s])}}var l=App.getClientID();if(l)o.append("notifyClientID",l);if(!i)i="json";var c=r.attr("action");$.ajax({type:"post",url:c,data:o,dataType:i,cache:false,processData:false,contentType:false}).success(function(t){a&&a.apply(this,arguments)}).error(function(t,e,a){n&&n.apply(this,arguments)})},attachPjax:function(t,e,f){if(!$.support.pjax)return;if(t==null)t="a";if(f==null)f=5e3;var a={onclick:null,onsend:null,oncomplete:null,ontimeout:null,onstart:null,onend:null};var p=$.extend({},a,e||{});$(document).on("click",t+"[data-pjax]",function(t){var e=$(this).data("pjax"),a=$(this).data("keepjs");var n=$(this).data("onclick"),i=$(this).data("toggleclass");$.pjax.click(t,e,{timeout:f,keepjs:a});if(p.onclick)p.onclick(this);if(n&&typeof window[n]=="function")window[n](this);if(i){var r=i.split(":"),o,s;if(r.length>1){o=r[0];i=r[1]}i=i.replace(/^\./g,"");if(o){var l=o.indexOf("."),c;if(l>0){c=o.substring(l+1);o=o.substring(0,l)}switch(o){case"parent":s=$(this).parent(c);break;case"parents":s=$(this).parents(c);break;case"closest":s=$(this).closest(c);break;default:s=$(this).parent(c);break}}else{s=$(this)}s.addClass(i).siblings("."+i).removeClass(i)}$(".sp_result_area").remove();$(".tox").remove();$(".select2-hidden-accessible").remove();$(".select2-sizer").remove();$(".select2-drop").remove();$("#select2-drop-mask").remove()}).on("pjax:send",function(t,e,a){App.loading("show");if(p.onsend)p.onsend(t,e,a)}).on("pjax:complete",function(t,e,a,n){App.loading("hide");if(p.oncomplete)p.oncomplete(t,e,a,n)}).on("pjax:timeout",function(t,e,a){console.log("timeout");App.loading("hide");if(p.ontimeout)p.ontimeout(t,e,a)}).on("pjax:start",function(t,e,a){if(p.onstart)p.onstart(t,e,a)}).on("pjax:end",function(t,e,a){App.loading("hide");if(p.onend)p.onend(t,e,a);if(a.container){App.bottomFloat(a.container+" .pagination");App.bottomFloat(a.container+" .form-submit-group",0,true);$(a.container+" .switch:not(.has-switch)").bootstrapSwitch();App.autoFixedThead(a.container+" ")}if(a.type=="GET")$("#global-search-form").attr("action",a.url);App.startLazyload(a.container);App.formWithNotify()})},attachTurn:function(t,e){var a={elem:t,target:$(t).data("target"),show:{Y:true,N:false},event:"click"};if(typeof e=="string"){a.target=e;e={}}var i=$.extend(a,e||{});if(i.event==null)i.event="click";if($(i.elem).length<1)return;$(i.elem).on(i.event,function(){var t=$(this).val(),e=$(i.target);var a=$(this).data("turn");if(a){a=a=="on"||a=="1"||a=="true"||a=="Y";if(a){e.show()}else{e.hide()}}else if(typeof a!="undefined"){e.hide()}if(i.prop){for(var n in i.prop){e.prop(n,i.prop.prop[t])}return}if(t in i.show){if(i.show[t]){e.show()}else{e.hide()}}});switch($(i.elem)[0].tagName.toUpperCase()){case"INPUT":$(i.elem+":checked").trigger(i.event);break;case"SELECT":if(!$(i.elem).children("option:first").prop("selected")){$(i.elem).trigger(i.event)}break}},wsURL:function(t){var e="ws:";if(window.location.protocol=="https:")e="wss:";var a=String(t).indexOf("//");if(a==-1){t=e+"//"+window.location.host+t}else{t=e+String(t).substring(a)}return t},websocket:function(e,t,a,n){t=App.wsURL(t);var i=new WebSocket(t);i.onopen=function(t){console.log("Websocket Server is connected");if(a!=null&&typeof a==="function")a.apply(this,arguments)};i.onclose=function(t){console.log("Websocket Server is disconnected");if(n!=null&&typeof n==="function")n.apply(this,arguments)};i.onmessage=function(t){e(t.data)};i.onerror=function(t){console.dir(t)};if(a!=null&&typeof a=="object"){i=$.extend({},i,a)}return i},notifyRecvDefault:function(t,e,a){var n="notify-default-shower",i="notify-default-shower-body";var r="#"+n,o="#"+i;if(a==null)a=false;if(a&&!t){if($(r).length>0)$(o).slideUp("slow",function(){$(r).remove()});return}if($(r).length<1){$("body").append('<div id="'+n+'" style="min-height:30px;position:fixed;display:block;top:50px;text-align:center;z-index:2200;width:100%;pointer-events:none">\t\t\t\t<div id="'+i+'" style="padding:0 10px 1px 10px;background:rgba(255,166,0,0.8);border:1px solid salmon;border-radius:5px;display:inline-block;margin:0 auto;color:black;text-shadow:0 1px 1px #ccc;font-size:1em;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;max-width:100%;line-height:30px;pointer-events:auto"></div>\t\t\t\t</div>\t\t\t\t</div>');if(!a){var s=window.setInterval(function(){var t=Number($(r).attr("updated")||0);if((new Date).getTime()-t>5e3&&!$("#loading-status").is(":visible")){window.clearInterval(s);$(o).slideUp("slow",function(){$(r).remove()})}},1e3)}}$(r).attr("updated",(new Date).getTime());if(e)t="["+Number(e).toFixed(2)+"%] "+t;$(o).text(t)},formWithNotify:function(){var t=App.getClientID();if(!t)return;var e=$("#pcont").find("form[notify]");if(e.length<1)return;var a=e.find("input[name=notifyClientID]");if(a.length<1){e.append('<input type="hidden" name="notifyClientID" value="'+t+'">')}else if(a.val()!=t){a.val(t)}},getClientID:function(t){if(t==null||!t)t="notify";if(typeof App.clientID[t]=="undefined")return null;return App.clientID[t]},setClientID:function(t,e){var a=App.getClientID(e);if(!a)return t;if(typeof t=="array"){t=append({name:"notifyClientID",value:a})}else{t["notifyClientID"]=a}return t},messageNotify:function(t,e){if(!e.avatar)e.avatar=ASSETS_URL+"/images/user_50.png";if("lastMessageId"in App)App.message("remove",App.lastMessageId);var a="";if(e.sound){a='<audio style="visibility:hidden;position:absolute;bottom:0;" controls="controls" hidden="true" src="'+e.sound+'"></audio>'}App.lastMessageId=App.message({title:App.text2html(t),text:"<strong>"+e.author+"</strong>"+(e.isAdmin?'<span class="badge badge-warning">'+App.t("管理员")+"</span>":"")+':<br /><a href="'+e.url+'" class="text-white">'+e.content+"</a>"+a,image:e.avatar,class_name:"dark",sticky:true,after_open:e.sound?function(t){var e=t.find("audio")[0];e.currentTime=0;e.play()}:function(){}})},notifyListen:function(){var l={notify:0,element:0,modal:0},c={notify:20,element:50,modal:50},i=0,r=function(t){var e=$.parseJSON(t);if(!e){App.message({text:t||"Websocket Server is disconnected",type:"error"});return false}if(typeof App.clientID["notify"]=="undefined"){App.clientID["notify"]=e.client_id;App.formWithNotify()}if(typeof e.content=="undefined"||!e.content){return false}switch(e.mode){case"-":break;case"element":var a=$("#notify-element-"+e.type);if(a.length<1){var n="recv_notice_"+e.type;if(typeof window[n]!="undefined"){return window[n](e)}if(e.status>0){console.info(e.content)}else{console.error(e.content)}App.notifyRecvDefault(e.content,e.progress?e.progress.percent:0);return false}if(l[e.mode]>=c[e.mode]){a.find("li:first").remove();l[e.mode]--}if(e.title){var i="badge-danger";if(e.status>0)i="badge-success";t='<span class="badge '+i+'">'+App.text2html(e.title)+"</span> "+App.text2html(e.content)}else{t=App.text2html(e.content)}a.append("<li>"+t+"</li>");l[e.mode]++;break;case"modal":var a=$("#notify-modal-"+e.type);if(a.length<1){var n="recv_notice_"+e.type;if(typeof window[n]!="undefined"){return window[n](e)}if(e.status>0){console.info(e.content)}else{console.error(e.content)}App.notifyRecvDefault(e.content,e.progress?e.progress.percent:0);return false}if(e.title){var i="badge-danger";if(e.status>0)i="badge-success";t='<span class="badge '+i+'">'+App.text2html(e.title)+"</span> "+App.text2html(e.content)}else{t=App.text2html(e.content,e.progress?e.progress.percent:0)}if(!a.data("shown")){l[e.mode]=0;a.data("shown",true);var r=a.find(".modal-body"),o=r.children("ul.modal-body-ul");if(o.length<1){r.html('<ul class="modal-body-ul" id="notify-modal-'+e.type+'-container"><li>'+t+"</li></ul>")}else{o.html("<li>"+t+"</li>")}a.niftyModal("show",{afterOpen:function(t){},afterClose:function(t){a.data("shown",false)}})}else{var s=$("#notify-modal-"+e.type+"-container");if(l[e.mode]>=c[e.mode]){s.find("li:first").remove();l[e.mode]--}s.append("<li>"+t+"</li>")}l[e.mode]++;break;case"notify":var a=$("#notice-message-container");if(a.length<1){App.message({title:App.i18n.SYS_INFO,text:'<ul id="notice-message-container" class="no-list-style" style="max-height:500px;overflow-y:auto;overflow-x:hidden"></ul>',sticky:true});a=$("#notice-message-container")}if(l[e.mode]>=c[e.mode]){a.find("li:first").remove();l[e.mode]--}if(e.title){var i="badge-danger";if(e.status>0)i="badge-success";t='<span class="badge '+i+'">'+App.text2html(e.title)+"</span>"+App.text2html(e.content)}else{t=App.text2html(e.content)}a.append("<li>"+t+"</li>");l[e.mode]++;break;default:if(e.type=="message"&&typeof e.content=="object"){App.messageNotify(e.title,e.content);return}if(e.status>0){console.info(e.content)}else{console.error(e.content)}App.notifyRecvDefault(e.content,e.progress?e.progress.percent:0);break}return true},o=function(t){if(!!window.EventSource){var e={"Last-Event-Id":""};var a=new EventSource(BACKEND_URL+"/user/sse",{headers:e});a.addEventListener("notice",function(t){e["Last-Event-Id"]=t.lastEventId;r(t.data)},false);return}var n=App.websocket(r,BACKEND_URL+"/user/notice",t,function(){window.setTimeout(function(){i++;try{n.close()}catch(t){}if(typeof App.clientID["notify"]!="undefined"){delete App.clientID["notify"]}o(function(){i=0})},500*(i+1))});return n};o()},text2html:function(t,e){t=String(t);if(!e)t.replace(/<|>/g,function(t){return t=="<"?"&lt;":"&gt;"});return App.textNl2br(t)},ifTextNl2br:function(t){t=String(t);if(/<[^>]+>/.test(t))return t;return App.textNl2br(t)},textNl2br:function(t){return t.replace(d,function(t){return u[t]})},trimSpace:function(t){return String(t).replace(/^[\s]+|[\s]+$/g,"")},checkedAll:function(t,e){return $(e).not(":disabled").prop("checked",$(t).prop("checked"))},attachCheckedAll:function(t,e,a){$(t).on("ifChecked ifUnchecked click",function(){App.checkedAll(this,e);if(a)$(a).text($(e+":checked").length)})},alertBlock:function(t,e,a){switch(a){case"info":if(e==null)e="Info!";return'<div class="alert alert-info">\t\t\t\t\t\t\t\t<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>\t\t\t\t\t\t\t\t<i class="fa fa-info-circle sign"></i><strong>'+e+"</strong> "+t+"</div>";case"warn":if(e==null)e="Alert!";return'<div class="alert alert-warning">\t\t\t\t\t\t\t\t<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>\t\t\t\t\t\t\t\t<i class="fa fa-warning sign"></i><strong>'+e+"</strong> "+t+"</div>";case"error":if(e==null)e="Error!";return'<div class="alert alert-danger">\t\t\t\t\t\t\t\t<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>\t\t\t\t\t\t\t\t<i class="fa fa-times-circle sign"></i><strong>'+e+"</strong> "+t+"</div>";default:if(e==null)e="Success!";return'<div class="alert alert-success">\t\t\t\t\t\t\t\t<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>\t\t\t\t\t\t\t\t<i class="fa fa-check sign"></i><strong>'+e+"</strong> "+t+"</div>"}},alertBlockx:function(t,e,a){switch(a){case"info":if(e==null)e="Info!";return'<div class="alert alert-info alert-white rounded">\t\t\t\t\t\t\t\t<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>\t\t\t\t\t\t\t\t<div class="icon"><i class="fa fa-info-circle"></i></div>\t\t\t\t\t\t\t\t<strong>'+e+"</strong> "+t+"</div>";case"warn":if(e==null)e="Alert!";return'<div class="alert alert-warning alert-white rounded">\t\t\t\t\t\t\t\t<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>\t\t\t\t\t\t\t\t<div class="icon"><i class="fa fa-warning"></i></div>\t\t\t\t\t\t\t\t<strong>'+e+"</strong> "+t+"</div>";case"error":if(e==null)e="Error!";return'<div class="alert alert-danger alert-white rounded">\t\t\t\t\t\t\t\t<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>\t\t\t\t\t\t\t\t<div class="icon"><i class="fa fa-times-circle"></i></div>\t\t\t\t\t\t\t\t<strong>'+e+"</strong> "+t+"</div>";default:if(e==null)e="Success!";return'<div class="alert alert-success alert-white rounded">\t\t\t\t\t\t\t\t<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>\t\t\t\t\t\t\t\t<div class="icon"><i class="fa fa-check"></i></div>\t\t\t\t\t\t\t\t<strong>'+e+"</strong> "+t+"</div>"}},showDbLog:function(t,e){if(e==null)e=".block-flat:first";if(typeof t.length=="undefined")t=[t];for(var a=0;a<t.length;a++){var n=t[a];var i=n.Started;if(n.SQLs&&n.SQLs.length>0){for(var r=0;r<n.SQLs.length;r++)i+='<code class="wrap">'+n.SQLs[r]+"</code>"}else{i+='<code class="wrap">'+n.SQL+"</code>"}var o="success";if(n.Error){i+="("+n.Error+")";o="error"}else{i+="("+n.Elapsed+")"}$(e).before(App.alertBlockx(i,null,o))}},loading:function(t){var e=$("#loading-status");switch(t){case"show":if(e.length>0){e.show()}else{$("body").append('<div id="loading-status"><i class="fa fa-spinner fa-spin fa-3x"></i></div>')}break;case"hide":if(e.length>0){e.hide()}}},insertAtCursor:function(t,e,a,n){if(typeof TextAreaEditor!="undefined"){TextAreaEditor.setSelectText(t,e,a,n);return}if(document.selection){t.focus();sel=document.selection.createRange();sel.text=e;sel.select()}else if(t.selectionStart||t.selectionStart=="0"){var i=t.selectionStart;var r=t.selectionEnd;var o=t.scrollTop;t.value=t.value.substring(0,i)+e+t.value.substring(r,t.value.length);if(o>0)t.scrollTop=o;t.focus();t.selectionStart=i+e.length;t.selectionEnd=i+e.length}else{t.value+=e;t.focus()}},attachInsertableCode:function(t){var e={selector:"",isHTML:false,posStart:null,posEnd:null,posStartChar:null,posEndChar:null};var i=$.extend(e,t||{});if(i.isHTML==null)i.isHTML=false;if(i.selector==null)i.selector="";var a="",r="";if(i.isHTML){a="html";r="html"}else{a="text";r="text"}var n=".insertable-code-"+a+"[data-target]";var o=typeof i.selector=="string"?$(i.selector+n):$(i.selector).find(n);o.each(function(){if($(this).data("insertable-code-attached"))return;$(this).data("insertable-code-attached",true);var t=$(this).children("code");var n=$($(this).data("target"));$(this).children("code:not(.clickable)").addClass("clickable");t.on("click",function(){var t=$(this)[r]();var e=i.posStart,a=i.posEnd;if(i.posStartChar!==null){e=t.indexOf(i.posStartChar)+1}if(i.posEndChar!==null){if(e===null)e=0;a=t.indexOf(i.posEndChar,e)-1}App.insertAtCursor(n[0],t,e,a)})})},searchFS:function(t,i,r,o,s){if(i==null)i=10;if(o==null)o=BACKEND_URL+"/user/autocomplete_path";$(t).typeahead({hint:true,highlight:true,minLength:1},{source:function(t,e,a){var n={query:t,size:i,type:r};if(s){n=s(n);if(!n){e([]);return}}$.ajax({url:o,type:"get",data:n,dataType:"json",async:false,success:function(t){var a=[];if(!t.Data)return;$.each(t.Data,function(t,e){a.push(e)});e(a)}})},limit:i})},randomString:function(t){t=t||32;var e="ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678";var a=e.length;var n="";for(i=0;i<t;i++){n+=e.charAt(Math.floor(Math.random()*a))}return n},bottomFloat:function(t,r,o){if($(t).length<1)return;if(r==null)r=0;$(t).not("[disabled-fixed]").each(function(){$(this).attr("disabled-fixed","fixed");var e=this;var a=$(e).offset().top+r;var n=$(e).outerWidth(),i=$(e).outerHeight();if(!o)o=$(e).data("auto-width");if(o)$(e).css("width",n);$(window).on("scroll",function(){var t=$(this).scrollTop()+$(window).height();if(t>=a){if($(e).hasClass("always-bottom")){$(e).removeClass("always-bottom");$(e).next(".fixed-placeholder").hide()}return}if(!$(e).hasClass("always-bottom")){$(e).addClass("always-bottom");if($(e).next(".fixed-placeholder").length>0){$(e).next(".fixed-placeholder").show()}else{$(e).after('<div style="width:'+n+"px;height:"+i+'px" class="fixed-placeholder"></div>')}}})})},topFloat:function(t,r,o){if($(t).length<1)return;if(r==null)r=0;$(t).not("[disabled-fixed]").each(function(){$(this).attr("disabled-fixed","fixed");var e=this;var a=$(e).offset().top;var n=$(e).outerWidth(),i=$(e).outerHeight();if(!o)o=$(e).data("auto-width");if(o)$(e).css("width",n);$(window).on("scroll",function(){var t=$(this).scrollTop();if(t<=a){if($(e).hasClass("always-top")){$(e).removeClass("always-top");$(e).next(".fixed-placeholder").hide()}return}if(!$(e).hasClass("always-top")){$(e).addClass("always-top").css("top",r);if($(e).next(".fixed-placeholder").length>0){$(e).next(".fixed-placeholder").show()}else{$(e).after('<div style="width:'+n+"px;height:"+i+'px" class="fixed-placeholder"></div>')}}})})},topFloatRawThead:function(t,e){if($(t).length<1)return;var s=null;if(typeof e=="function"){s=e}else{if(e==null)e=0;s=function(){return e}}$(t).not("[disabled-fixed]").each(function(){$(this).attr("disabled-fixed","fixed");var p=this,d=$(p).parent("table"),n=d.closest(".table-responsive");var i=n.length>0;var r=$(p).offset().top,t=Number(String(d.css("margin-top")).replace(/px$/,""));$(p).css({"background-color":"white"});d.data("originalMarginTop",t);var o=function(t){if(t==null)t=false;var e=d.width(),a=$(window).scrollLeft();var n=$(p).width(),i=1;if(!t){if(Math.abs(e-n)>1){i=n/e}if(d.data("offset-left")!=d.offset().left){$(p).css({left:d.offset().left})}else if(d.data("scroll-left")!=a){var r=d.offset().left-a;$(p).css({left:r});if(i==1)return}}var o=$(p).data("ratio")||0;$(p).data("ratio",i);d.data("offset-left",d.offset().left);d.data("scroll-left",a);var s=d.children("colgroup").length>0?d.children("colgroup").children("col"):d.children("col"),l=$(p).find("td,th");if(s.length<1){var c="";$(p).css({width:d.width()});l.each(function(){var t=$(this).outerWidth(),e=t*i;c+='<col style="min-width:'+e+"px;width:"+e+'px;max-width:auto" />';$(this).css({"min-width":e,width:e,"max-width":"auto"})});d.prepend(c);return}if(o==i)return;$(p).css({width:e});var f=d.children("tbody").length>0?d.children("tbody").children("tr:first").find("td"):d.children("tr:first").find("td");l.each(function(t){var e=s.eq(t),a=f.eq(t);var n=!a||e.outerWidth()>a.outerWidth()?e.outerWidth():a.outerWidth();$(this).css({width:n})})};o(true);window.setTimeout(function(){o()},500);$(window).on("scroll resize",function(){o();var t=$(this).scrollTop(),e=d.height()+r-$(p).outerHeight()*2;if(t<=r||t>=e){if($(p).hasClass("always-top")){$(p).removeClass("always-top");d.css({"margin-top":d.data("originalMarginTop")})}if(i){$(p).off("scroll").data("scroll-reponsive",false);n.off("scroll").data("scroll-thead",false)}return}if(d.height()>$(window).height()){if(!$(p).hasClass("always-top")){$(p).addClass("always-top");d.css({"margin-top":d.data("originalMarginTop")+$(p).height()})}var a={top:s()};if(i){if(!n.data("scroll-thead")){n.on("scroll",function(){$(p).css({left:n.offset().left+$(this).scrollLeft()*-1})}).data("scroll-thead",true)}}$(p).css(a)}})});$(window).trigger("scroll")},topFloatThead:function(t,e,a){if(!a)return App.topFloatRawThead(t,e);if($(t).length<1)return;var o=null;if(typeof e=="function"){o=e}else{if(e==null)e=0;o=function(){return e}}$(t).not("[disabled-fixed]").each(function(){$(this).attr("disabled-fixed","fixed");var a=this,n=$(a).parent("table"),s=n.closest(".table-responsive");var l=s.length>0;var i=$(a).offset().top,t=$(a).data("copy");if(t){$("#tableCopy"+t).remove()}else{t=Math.random();$(a).data("copy",t)}var c=$('<div class="always-top" style="overflow:hidden;display:block;width:'+(l?s.width():n.width())+"px;top:"+o()+'px;box-shadow:0 1px 5px rgba(0,0,0,0.3)"></div>');var f=$('<table class="'+n.attr("class")+'" style="background-color:white;table-layout:fixed;position:relative" id="tableCopy'+t+'"></table>');var p=$(a).clone();f.append(p);c.html(f);var r=function(i){if(i==null)i=false;if(!i){var t=l?s.width():n.width();if(c.width()!=t){c.css({width:t})}else if(f.data("scroll-left")!=$(window).scrollLeft()){f.css({left:$(a).offset().left-$(window).scrollLeft()});return}else{return}}f.data("offset-left",n.offset().left);f.data("scroll-left",$(window).scrollLeft());var r=p.find("td,th"),o=$(a).find("td,th");o.each(function(t){var e=r.eq(t);e.css({width:$(this).outerWidth()});if(!i)return;var a=e.find("input:checkbox");if(a.length<1)return;var n=o.find("input:checkbox");a.each(function(t){n.eq(t).on("click change",function(){a.prop("checked",$(this).prop("checked"))})})});var t=l?s.width():n.width(),e=$(a).outerHeight();f.css({width:t,height:e})};r(true);c.hide();n.after(c);window.setTimeout(function(){r()},500);$(window).on("scroll",function(){r();var t=$(this).scrollTop(),e=n.height()+i-$(a).outerHeight()*2;if(t<=i||t>=e)return c.hide();c.show()});if(s.length>0&&!s.data("scroll-thead")){s.on("scroll",function(){f.css({left:$(this).scrollLeft()*-1})}).data("scroll-thead",true)}})},getImgNaturalDimensions:function(t,e){if(t&&t.naturalWidth){e({w:t.naturalWidth,h:t.naturalHeight});return}var a=new Image;a.onload=function(){e({w:a.width,h:a.height})};if(t)a.src=t.src},reportBug:function(t){$.post(t,{panic:$("#panic-content").html(),url:window.location.href},function(t){},"json")},replaceURLParam:function(t,e,a){if(a==null)a=window.location.href;e=encodeURIComponent(e);var n=String(a).indexOf("?");if(n<0)return a+"?"+t+"="+e;var i=a.substring(n),r=new RegExp("([\\?&]"+t+"=)[^&]*(&|$)");if(!r.test(i))return a+"&"+t+"="+e;a=a.substring(0,n);i=i.replace(r,"$1"+e+"$2");return a+i},switchLang:function(t){window.location=App.replaceURLParam("lang",t)},extends:function(t,e){var a=function(){};a.prototype=e.prototype;t.prototype=new a;t.prototype.constructor=t},formatBytes:function(t,e){if(e==null)e=2;var a=["YB","ZB","EB","PB","TB","GB","MB","KB","B"];var n=a.length;for(n--;n>0&&t>1024;n--){t/=1024}return t.toFixed(e)+a[n]},format:function(t,e,a){if(a){if(typeof a[e.y]=="function")return a[e.y](t,e);if(typeof a[""]=="function")return a[""](t,e)}return t},genTable:function(t,e,a){var n='<table class="table table-bordered table-condensed no-margin">';var i="<thead>",r="<tbody>";var o=a&&typeof a=="function"?a:function(t){return false};for(var s=0;s<t.length;s++){var l=t[s];if(s==0){for(var c in l){if(o(c))continue;i+='<th class="'+c+'"><strong>'+c+"</strong></th>"}}r+="<tr>";for(var c in l){if(o(c))continue;r+='<td class="'+c+'">'+App.format(l[c],{x:s,y:c},e)+"</td>"}r+="</tr>"}i+="</thead>";r+="</tbody>";n+=i+r+"</table>";return n},httpStatusColor:function(t){if(t>=500)return"danger";if(t>=400)return"warning";if(t>=300)return"info";return"success"},htmlEncode:function(t){if(!t)return t;return String(t).replace(l,function(t){return c[t]})},htmlDecode:function(t){if(!t)return t;return String(t).replace(f,function(t){return p[t]})},logShow:function(t,e,l,a){var n=$(t).data("modal-title"),i=$("#log-show-modal");if(n)i.find(".modal-header h3").text(n);if(!i.data("init")){i.data("init",true);$(window).off().on("resize",function(){i.css({height:$(window).height(),width:"100%","max-width":"100%",left:0,top:0,transform:"none"});i.find(".md-content").css("height",$(window).height());$("#log-show-content").css("height",$(window).height()-140)});$("#log-show-last-lines").on("change",function(t){var e=$(this).data("target");if(!e)return;var a=$(this).val();e.data("last-lines",a);e.trigger("click")});$("#log-show-charset").on("change",function(t){var e=$(this).data("target");if(!e)return;var a=$(this).val();e.data("charset",a);e.trigger("click")});i.find(".modal-footer .btn-refresh").on("click",function(t){var e=$("#log-show-last-lines").data("target");if(!e)return;e.trigger("click")});$(window).trigger("resize")}if(l==null)l="";var c=a&&typeof a=="function"?a:function(t){return App.genTable(t)};var r=function(t){var e=$(t).data("url");var a=$(t).data("last-lines");if(a==null)a=100;$("#log-show-last-lines").data("target",$(t));var n=null;if($("#log-show-charset").length>0){$("#log-show-charset").data(`target`,$(t));n=$(t).data("charset")}var o="log-show-content",s="#"+o;var i=$("#log-show-modal");i.niftyModal("show",{afterOpen:function(r){var t={lastLines:a,pipe:l};if(n)t.charset=n;$.get(e,t,function(t){if(t.Code==1){var e=r.find(".modal-header .modal-subtitle");if(typeof t.Data.title!="undefined"){if(t.Data.title)t.Data.title=" ("+t.Data.title+")";e.html(t.Data.title)}else{e.empty()}if(typeof t.Data.list!="undefined"){var a='<div id="'+o+'">'+c(t.Data.list)+"</div>";$(s).parent(".modal-body").css("padding",0);$(s).replaceWith(a);var n=$(s).parent(".modal-body")[0];n.scrollTop=n.scrollHeight}else{if($(s)[0].tagName.toUpperCase()!="TEXTAREA"){$(s).replaceWith("<textarea name='content' class='form-control' id='"+o+"'></textarea>")}$(s).text(t.Data.content);var i=$(s)[0];i.scrollTop=i.scrollHeight}if(typeof t.Data.charset!="undefined"&&$("#log-show-charset").length>0&&$("#log-show-charset").val()!=t.Data.charset){$("#log-show-charset").find('option[value="'+t.Data.charset+'"]').prop("selected",true)}$(window).trigger("resize")}else{$(s).text(t.Info)}},"json")},afterClose:function(t){$("#log-show-last-lines").find("option:selected").prop("selected",false);if($("#log-show-charset").length>0)$("#log-show-charset").find("option:selected").prop("selected",false)}})};if(e)return r(t);$(t).on("click",function(){r(this)})},tableSorting:function(t){t=t==null?"":t+" ";function f(t,e){var a,n,i;if(!e){a="fa-arrow-up";i="up";n="fa-arrow-down"}else{a="fa-arrow-down";i="down";n="fa-arrow-up"}if(t.length>0){var r=t.children(".fa");if(r.length<1){t.append('<i class="fa '+a+'"></i>')}else{r.removeClass(n).addClass(a)}t.addClass("sort-active sort-"+i);t.siblings(".sort-active").removeClass("sort-active").removeClass("sort-up").removeClass("sort-down").find(".fa").remove()}}$(t+'[sort-current!=""]').each(function(){var t=String($(this).attr("sort-current"));var e=t.substring(0,1)=="-";if(e)t=t.substring(1);var a=$(this).find('[sort="'+t+'"]');if(a.length<1&&t){a=$(this).find('[sort="-'+t+'"]')}f(a,e)});$(t+"[sort-current] [sort]").css("cursor","pointer").on("click",function(t){var e=$(this).parents("[sort-current]");var a=e.attr("sort-current");var n=e.attr("sort-url")||window.location.href;var i=e.attr("sort-trigger")||e.data("sort-trigger");var r=$(this).attr("sort");if(a&&(a==r||a=="-"+r)){var o=/^\-/;a=o.test(a)?a.replace(o,""):"-"+a}else{a=r}e.attr("sort-current",a);n=App.replaceURLParam("sort",a,n);if(i){e.data("sort-url",n);var s=a.substring(0,1)=="-";f($(this),s);window.setTimeout(i,0)}else{var l=e.attr("sort-setto");if(l){var c=$(this);$.get(n,{},function(t,e,a){if(String(a.getResponseHeader("Content-Type")).split(";")[0]=="application/json"){try{t=JSON.parse(t)}catch(t){return App.message({text:t,type:"error"})}if(t.Code!=1)return App.message({text:t.Info,type:"error"});t=t.Data.html}$(l).html(t);if($(l).length>0&&$(l)[0].tagName.toUpperCase()=="TBODY"){var n=c.parents("[sort-current]");var i=n.attr("sort-current");var r=i.substring(0,1)=="-";f(c,r)}},"html")}else{window.location=n}}})},switchStatus:function(e,a,t,n,i){if(a==null)a=$(e).data("type");var r=$(e).val();var o=$(e).data("v-checked")||r||"N",s=$(e).data("v-unchecked")||(o=="N"?"Y":"N");if(a){var l=String(a).split("=");a=l[0];if(l.length>1&&l[1]){var c=l[1].split("|");if(c[0]==o){o=c[0];s=c[1]}else{o=c[1];s=c[0]}}}if(t==null)t=$(e).data("url");var f=$(e),p=e.checked?o:s,d={id:f.data("id")};d[a]=p;if(i&&typeof i=="function")d=i(d,a,p);if(String(t).charAt(0)!="/")t=BACKEND_URL+"/"+t;$.get(t,d,function(t){if(t.Code==1){f.attr("data-"+a,p);f.prop("checked",p==r)}App.message({title:App.i18n.SYS_INFO,text:t.Info,time:5e3,sticky:false,class_name:t.Code==1?"success":"error"});if(n)n.call(e,t)},"json")},bindSwitch:function(t,e,a,n,i,r){if(e==null)e="click";var o=new RegExp("switch-([\\w\\d]+)");$(t).on(e,function(){if(n==null){var t=String($(this).attr("class")).match(o);n=t[1]}App.switchStatus(this,n,a,i,r)})},removeSelected:function(t,e,a,n){return App.opSelected(t,e,a,n,App.i18n.CONFIRM_REMOVE,App.i18n.PLEASE_SELECT_FOR_REMOVE)},removeSelected2:function(t,e,a,n,i){return App.opSelected2(t,e,a,n,i,App.i18n.CONFIRM_REMOVE,App.i18n.PLEASE_SELECT_FOR_REMOVE)},removeSelectedEvent:function(){var t=$(this).data("target"),e=$(this).data("field"),a=$(this).data("url"),n=$(this).data("callback");return App.opSelected2(this,t,e,a,n,App.i18n.CONFIRM_REMOVE,App.i18n.PLEASE_SELECT_FOR_REMOVE)},opSelected:function(t,e,a,n,i,r){return App.opSelected2(null,t,e,a,n,i,r)},opSelected2:function(t,e,a,n,i,r,o){if(n==null){n=window.location.href}else if(String(n).charAt(0)!="/"){n=BACKEND_URL+"/"+n}if(a==null)a="id";var s=[];$(e).each(function(){if($(this).is(":checked")&&!$(this).prop("disabled"))s.push({name:a,value:$(this).val()})});if(s.length<1){App.message({title:App.i18n.SYS_INFO,text:o||App.i18n.PLEASE_SELECT_FOR_OPERATE,type:"warning"});return false}var l=r;if(l){l+="\n"+App.sprintf(App.i18n.SELECTED_ITEMS,s.length);if(!confirm(l))return false}App.loading("show");var c="get";if(t&&t!==null&&typeof t=="object"){if(String($(t).data("method")).toLowerCase()=="post")c="post"}$[c](n,s,function(t){App.loading("hide");if(i&&typeof i==="function")return i();var e={title:App.i18n.SYS_INFO,text:t.Info,type:""};if(t.Code==1){e.type="success";if(!e.text)e.text="操作成功"}else{e.type="error";if(!e.text)e.text="操作失败"}App.message(e);window.setTimeout(function(){window.location.reload()},2e3)},"json");return true},parseBool:function(t){switch(String(t).toLowerCase()){case"0":case"false":case"n":case"no":case"off":case"null":return false;default:return true}},progressMonitor:function(e,a){NProgress.start();var n=window.setInterval(function(){var t=e()/a;if(t>=1){NProgress.set(1);window.clearInterval(n)}else{NProgress.set(t)}},50)},floatAtoi:function(t,e){var a={bottom:"7",right:"6",top:"5",left:"8",leftBottom:"4",rightBottom:"3",leftTop:"1",rightTop:"2"};if(typeof a[t]!=="undefined")return a[t];return e},float:function(t,e,a,n,i){if(!e)e="ajax";if(!a)a=e=="remind"?"rel":"src";if(!n)n="5-7";else{var r=String(n).split("-");var o=[];for(var s=0;s<r.length&&s<2;s++){var l=r[s];o.push(App.floatAtoi(l,l))}if(r.length==1){switch(r[0]){case"bottom":o.push(App.floatAtoi("top"));break;case"right":o.push(App.floatAtoi("left"));break;case"top":o.push(App.floatAtoi("bottom"));break;case"left":o.push(App.floatAtoi("right"));break;case"leftBottom":o.push(App.floatAtoi("rightBottom"));break;case"rightBottom":o.push(App.floatAtoi("leftBottom"));break;case"leftTop":o.push(App.floatAtoi("rightTop"));break;case"rightTop":o.push(App.floatAtoi("leftTop"));break;default:o.push(l);break}}n=o.join("-")}var c={targetMode:e,targetAttr:a,position:n};$(t).powerFloat($.extend(c,i||{}))},uploadPreviewer:function(t,e,a,n){if($(t).parent(".file-preview-shadow").length<1){var i={buttonText:'<i class="fa fa-cloud-upload"></i> '+App.t("BUTTON_UPLOAD"),previewTableContainer:"#previewTableContainer",url:"",previewTableShow:false,uploadProgress:function(t){var e=t*100;if(e>100){$.LoadingOverlay("hide");return}$.LoadingOverlay("progress",e)}};var r=$.extend({},i,e||{});var o=$(t).uploadPreviewer(r);$(t).data("uploadPreviewer",o);$(t).on("file-preview:changed",function(t){var e={image:ASSETS_URL+"/images/nging-gear.png",progress:false,maxSize:40,size:30,text:App.i18n.UPLOADING};if(r.uploadProgress){e.progress=true;e.progressFixedMargin="5px 0 0 0";e.image=""}$.LoadingOverlay("show",e);o.submit(function(t){$.LoadingOverlay("hide");if(t.Code==1){App.message({text:App.i18n.UPLOAD_SUCCEED,type:"success"});if(a!=null)a(t)}else{App.message({text:t.Info,type:"error"});if(n!=null)n(t)}},function(){if(n!=null)n()})})}},showRequriedInputStar:function(){$("form:not([required-redstar])").each(function(){$(this).attr("required-redstar","1");$(this).find("[required]").each(function(){var t=$(this).parent(".input-group");if(t.length>0){if(!t.hasClass("required"))t.addClass("required");return}t=$(this).closest('.form-group,div[class*="col-"]');if(t.length<1)return;var e;if(t.hasClass("form-group")){e=t.children(".control-label")}else{e=t.prev(".control-label")}if(e.length<1||e.hasClass("required"))return;e.addClass("required")})})},pushState:function(t,e,a){if(!window.history||!window.history.pushState)return;window.history.pushState(t,e,a)},replaceState:function(t,e,a){if(!window.history||!window.history.replaceState)return;window.history.replaceState(t,e,a)},formatJSON:function(t){t=$.trim(t);var e=t.substring(0,1);if(e=="["||e=="{"){var a=JSON.parse(t);t=JSON.stringify(a,null,"\t");return t}return""},formatJSONFromInnerHTML:function(t){if(t.data("jsonformatted"))return;t.data("jsonformatted",true);var e=App.formatJSON(t.html());if(e!="")t.html(e)},rewriteFormValueAsArray:function(t,e,a){var n=0;for(var i=0;i<t.length;i++){var r=t[i];if(r.name==e){if(a.length>n){r.value=a[n];n++}else{r.value=""}}}for(var i=n;i<a.length;i++){t.push({name:e,value:a[i]})}return t},plotTooltip:function(t,e,a){$("<div id='plot-tooltip'>"+a+"</div>").css({position:"absolute",display:"none",top:e+5,left:t+5,border:"1px solid #000",padding:"5px",color:"#fff","border-radius":"2px","font-size":"11px","background-color":"#000",opacity:.8}).appendTo("body").fadeIn(200)},plotHover:function(t,n){$(t).on("plothover",function(t,e,a){if(!a){$("#plot-tooltip").remove();b=null;return}if(b==a.dataIndex)return;b=a.dataIndex;$("#plot-tooltip").remove();if(n==null)n=function(t,e,a){var n=a.datapoint[0].toFixed(2),i=a.datapoint[1].toFixed(2);return a.series.label+" of "+n+" = "+i};App.plotTooltip(a.pageX,a.pageY,n.call(this,t,e,a))})},template:function(t,e,a){var n=$(t).attr("tpl"),i=String(n).split("=>");n=$.trim(i[0]).replace(/^#/,"");if($("#"+n).length<1)throw new Error("not found template: "+(typeof t=="string"?t:$(t).attr("id"))+"=>"+n);if(i.length>1){t=$.trim(i[1]);if($(t).length<1)throw new Error("[template] not found wrapper: "+t)}$(t).html(template(n,e));if(a==null)return;$(t).find("ul.pagination li > a[page]").on("click",function(){if($(this).closest("li.disabled").length>0)return;a($(this).attr("page"))});$(t).find("ul.pagination").on("refresh",function(){var t=1;if($(this).data("page")){t=$(this).data("page");$(this).data("page",false)}else{t=$(this).find("li.active > a[page]").data("page")||1}a(t)})},pagination:function(t,e){var a=[],n=t.page,i=t.pages;if(!e)e=10;var r=i-n,o=1,s=0;if(r<e){o=i-e+1}else{o=n-e/2}if(o<1)o=1;for(var l=o;l<=i;l++){s++;if(s>e)break;a.push(l)}var c={size:t.size,page:n,rows:t.rows,pages:i,pageNumbers:a};return c},withPagination:function(t,e,a){var n=App.pagination(t,e);if(a==null)a="tpl-pagination";t.pagination=template(a,n);return t},captchaUpdate:function(t,e){if(App.captchaHasError(e.Code)&&e.Data&&typeof e.Data.captchaIdent!=="undefined"){if(false==t instanceof jQuery)t=$(t);var a=t.find("input#"+e.Data.captchaIdent);a.val(e.Data.captchaID);a.siblings("img").attr("src",e.Data.captchaURL);if(e.Data.captchaName)t.find('input[name="'+e.Data.captchaName+'"]').focus()}},captchaHasError:function(t){return t>=-11&&t<=-9},treeToggle:function(t,a){var e={expandFirst:false,ajax:null,onclick:null};a=$.extend(e,a||{});if(!t)t=".treeview";var n=function(){var t=$(this).children(".fa"),e;if(t.length>0){e=$(this).next("ul.tree")}else if($(this).hasClass("fa")){t=$(this);e=$(this).parent().next("ul.tree")}else{return}if(t.hasClass("fa-folder-o")){t.removeClass("fa-folder-o").addClass("fa-folder-open-o")}else{t.removeClass("fa-folder-open-o").addClass("fa-folder-o")}e.toggle(300,function(){$(this).parent().toggleClass("open");$(".tree .nscroller").nanoScroller({preventPageScrolling:true});$(window).trigger("resize")})};$(t).on("click",".tree-toggler",function(){var t=this;if(typeof a.onclick==="function")a.onclick.apply(t,arguments);if($(t).data("loaded")||!a.ajax)return n.apply(t);$(t).data("loaded",true);var e=a.ajax;if(typeof a.ajax==="function"){e=a.ajax.apply(t,arguments)}if(typeof e.data==="function"){e.data=e.data.apply(t,arguments)}$.ajax(e).done(function(){n.apply(t,arguments)})});if(a.expandFirst)$(t+" label.tree-toggler:first").trigger("click")},isFunction:function(t){return typeof t==="function"},currentURL:function(){if(typeof window.IS_BACKEND!="undefined"&&window.IS_BACKEND){return BACKEND_URL}return FRONTEND_URL},passwordInputShowPassword:v,pwdShowCtrl:v,makeCheckerForUpgrade:function(t,e,a,n){var i=0,r=false;if(t==null||!t)t=100;var o=function(){if(r)return;r=true;w("POST",BACKEND_URL+"/manager/upgrade?t="+(new Date).getTime(),function(t){r=false;App.message("clear");if(t.Code!=1){if(n)n();return App.message({text:t.Info,type:"error"},true)}if(e!=t.Data.local.Number){if(n)n();return App.message({text:App.t("启动新版本失败！程序没有更新成功，当前启动的依然是旧版 v%s。自动升级功能可能不支持当前系统，建议您手动执行升级脚本进行升级。",t.Data.local.Number),type:"error"},true)}if(a)a();return App.message({text:App.t("恭喜，程序已经成功升级到 v%s",t.Data.local.Number),type:"success"},true)},function(){i++;if(i<t){window.setTimeout(function(){r=false;o()},3e3)}else{r=false;App.message("clear");if(n)n();App.message({text:'<span class="text-shadow:0 0 1px red">'+App.t("抱歉，程序重启失败，请手动进行重启处理")+"</span>",type:"warn"},true)}},"json",{local:true})};return o},ifShowElseHide:function(t,e){if(e)return $(t).show();return $(t).hide()},editableSortNumber:m,showUpgradeInfo:function(t){var n=$("#self-upgrade-modal");if(n.length<1)return;var e=n.find(".btn-upgrade:not([attached])");if(t==null)t="";if(e.length>0){e.attr("attached","1");e.on("click",function(){if(!confirm(App.t("建议升级前先备份相关文件和数据库，以防万一。")+"\n"+App.t("确定现在升级吗？")))return;var t=$(this);var n=function(){t.prop("disabled",true);t.prepend('<i class="fa fa-refresh fa-spin"></i>')};n();var i=function(){t.prop("disabled",false);t.children("i").remove()};var r=$("#self-upgrade-modal"),o=r.data("version");$.post(BACKEND_URL+"/manager/upgrade",{download:true,notifyClientID:App.clientID["notify"]||"any",nonce:r.data("nonce"),version:o},function(t){i();if(t.Code!=1)return App.message({text:t.Info,type:"error"});if(t.Data&&"nonce"in t.Data){if(!confirm(App.t("程序已经成功更新，是否现在重启？"))){r.niftyModal("hide");return}App.loading("show");n();App.notifyRecvDefault(App.t("正在重启中，请稍候..."),0,true);var e=function(){App.loading("hide");App.notifyRecvDefault("",0,true);i();r.niftyModal("hide")};var a=App.makeCheckerForUpgrade(100,o,e,e);$.post(BACKEND_URL+"/manager/upgrade",{exit:true,nonce:t.Data.nonce},function(t){e();if(t.Code!=1)return App.message({text:t.Info,type:"error"});return App.message({text:t.Info,type:"success"})},"json");window.setTimeout(a,5e3);return}r.niftyModal("hide");return App.message({text:t.Info,type:"success"})}).error(function(t,e,a){i()})})}$.get(BACKEND_URL+"/manager/upgrade",{version:t},function(t){if(t.Code!=1)return t.Info?App.message({text:t.Info,type:"error"}):false;if(!t.Data.isNew)return App.message({text:App.t("当前程序已经是版本 v%s，无需升级",t.Data.local.Number),type:"success"});var e=t.Data.remote,a=App.t("发布时间:")+" "+new Date(e.released_at*1e3).toLocaleString(LANGUAGE||"zh-CN",{dateStyle:"long"});n.find(".modal-header>h3").html(App.t("新版本: v%s",e.version));n.find(".modal-body").html('<div style="font-size:13px">'+e.description+'<div class="clear"><span class="pull-right">'+a+"</span></div></div>");n.data("nonce",t.Data.nonce);n.data("version",e.version);n.niftyModal("show",{})},"json")}}}();