(function(){function D(a){var c=a.name,b=a.type,g=a.nodeName.toLowerCase();if(!c||a.disabled||b=="reset"||b=="button"||(b=="checkbox"||b=="radio")&&!a.checked||g=="select"&&a.selectedIndex==-1)return null;if(g=="select"){var d=a.selectedIndex;if(d<0)return null;c=[];a=a.options;g=(b=b=="select-one")?d+1:a.length;for(d=b?d:0;d<g;d++){var f=a[d];if(f.selected){var e=f.value;e||(e=f.attributes&&f.attributes.value&&!f.attributes.value.specified?f.text:f.value);if(b)return e;c.push(e)}}return c}return a.value}
function E(a){a=a.elements;if(!a)return"";for(var c=[],b=0,g=a.length;b<g;b++){var d=a[b],f=d.name;if(f)if((d=D(d))&&d.constructor==Array)for(var e=0,o=d.length;e<o;e++)c.push({name:f,value:d[e]});else d!==null&&typeof d!="undefined"&&c.push({name:f,value:d})}return $.param(c)}function s(a,c,b,g,d,f){var e=$(F.createElement("DIV")),o,t,p,u=null,v=null,w={},q,G=function(i){q.attr("disabled","disabled");t.css({height:o.height(),width:o.width()}).show();if(d&&d(i,e)===false)x();else{i=E(i[0]);$.ajax({url:c,
type:"POST",dataType:"json",data:i,success:function(n){if(n.state){b(n);e.dialog("destroy").remove()}else y(n.error)},error:function(){y("\u8bf7\u6c42\u5f02\u5e38")},complete:x})}},H=function(i){o=e.parent();t=$('<div class="masker"></div>').insertBefore(e);i.submit(function(n){n.preventDefault();n.stopPropagation();q.eq(0).click()});g&&g(i,e)},x=function(){t.hide();q.attr("disabled","").removeAttr("disabled")},y=function(i){p||(p=$('<div class="warning"></div>').prependTo(e));clearTimeout(u);u=null;
p.html(i).show();u=setTimeout(function(){p.slideUp()},3E3)};w[z.BUTTON_OK]=function(){G(v,e)};w[z.BUTTON_CANCEL]=function(){e.dialog("close")};typeof a=="object"||(a={title:a?a.toString():""});a=$.extend({width:450,height:"auto",maxHeight:500,resizable:false,modal:true},a,{autoOpen:false,buttons:w,close:function(){e.dialog("destroy").remove();f&&f()}});e.dialog(a).load(c,function(){v=e.find("form:first");H(v,e);e.dialog("open")});q=e.nextAll("div.btn_area").children("button");return e}function h(a){k&&
k.removeClass("checked");(k=a)&&k.addClass("checked")}function A(a){var c=$('\t<li class="dir" path="'+a.path+'" title="'+a.name+'">\t\t<div></div>\t\t<span>'+a.name+"</span>\t</li>"),b=null;c.click(function(){if(b){clearTimeout(b);b=null;j.load(c.attr("path"))}else{h(c);b=setTimeout(function(){b=null},500)}}).bind("contextMenu",function(){h(c)});c.contextMenu("#"+(l=="dir"?"master-dir-menu":"slave-dir-menu"),function(g){j[g](c)});return c}function B(a){var c=$('\t<li class="file" path="'+a.path+
'" title="'+a.name+'">\t\t<div></div>\t\t<span>'+a.name+"</span>\t</li>");if(l!="dir"){var b=null;c.click(function(){if(b){clearTimeout(b);b=null;j.check(c.attr("path"))}else{h(c);b=setTimeout(function(){b=null},500)}}).bind("contextMenu",function(){h(c)})}else{c.css("cursor","default");c.bind("contextMenu",function(){h(null)})}c.contextMenu("#"+(l=="dir"?"slave-file-menu":"master-file-menu"),function(g){j[g](c)});return c}var F=document;$();var z={BUTTON_OK:"\u786e\u5b9a",BUTTON_CANCEL:"\u53d6\u6d88"},
r=null,l=null,k=null,m=null,C=null,j={init:function(a,c){l=a;m=$("#container");$("#center").mousedown(function(){h(null)}).contextMenu("#main-menu",function(f){j[f]()});$("#ctrl>span").click(function(){j[this.getAttribute("action")]()});var b=/{PSN:(\d+)}(.*)/i.exec(c),g=b?b[1]:1;b=b?b[2].replace(/(%2f)|(\\+)/ig,"/").replace(/^\/+|\/+$/g,"").replace(/\/+/g,"/").split("/"):[];var d=b.pop();b.unshift("{PSN:"+g+"}");b=b.join("/");C=$("#navigator").navigator({dirUrl:"?app=system&controller=psn&action=dir",
dirVar:"path"}).bind("cd",function(f,e){j.load(e.replace(/^\/+|\/+$/g,""))});this.load(b,d&&function(){var f=m.find('li[title="'+d+'"]');f.length&&h(f)});$("#bottom>button").click(function(){j[this.getAttribute("action")](k)})},check:function(a){var c;if(a){c=a.attr("path");if(a.hasClass("dir")&&l!="dir"){this.load(c);return}}else if(l=="dir")c=r;else return;dialogCallback.ok(c)},cancel:function(){dialogCallback.cancel()},open:function(a){this.load(a.attr("path"))},load:function(a,c){r=a;k=null;m.empty();
$.getJSON("?app=system&controller=psn&action=load&path="+a,function(b){for(var g=0,d;d=b.dirs[g++];)m.append(A(d));for(g=0;d=b.files[g++];)m.append(B(d));C.trigger("setNav",["/"+b.path,"/"+b.alias]);c&&c()})},mkdir:function(){s({title:"\u65b0\u5efa\u76ee\u5f55",width:300},"?app=system&controller=psn&action=mkdir&path="+r,function(a){a=A(a.data);m.append(a);h(a)})},mkfile:function(){s({title:"\u65b0\u5efa\u6587\u4ef6",width:300},"?app=system&controller=psn&action=mkfile&path="+r,function(a){a=B(a.data);
m.append(a);l!="dir"&&h(a)})},remove:function(a){ct.confirm('\u6b64\u64cd\u4f5c\u4e0d\u53ef\u6062\u590d\uff0c\u786e\u5b9a\u8981\u5220\u9664"'+a.attr("title")+'"\u5417\uff1f',function(){var c="?app=system&controller=psn&action=remove&path="+a.attr("path");$.getJSON(c,function(b){if(b.state){ct.ok("\u5220\u9664\u6210\u529f");k&&a[0]==k[0]&&h(null);a.fadeOut("fast",function(){a.remove()})}else ct.error("\u5220\u9664\u5931\u8d25")})})},rename:function(a){var c="?app=system&controller=psn&action=rename&path="+
a.attr("path");s({title:"\u91cd\u547d\u540d",width:300},c,function(b){a.attr("path",b.data.path);a.attr("title",b.data.name);a.find("span").text(b.data.name)})}};window.PSN=j})();
