// 当前系统全局对象 var system = { version:"0.2 Beta" ,codeupdate:"20130131" ,config:{ autoReload: true ,reloadStep: 5000 ,pageSize: 30 ,defaultSelectNode: null } ,panel:null ,lang:null ,reloading:false ,autoReloadTimer:null ,downloadDir:"" ,islocal:false ,B64:new Base64() // 当前选中的种子编号 ,currentTorrentId:0 ,control:{ tree:null ,torrentlist:null } ,serverConfig:null ,serverSessionStats:null ,templates:{ "dialog-about.html":"" ,"dialog-system-config.html":"" ,"dialog-torrent-add.html":"" ,"dialog-torrent-addfile.html":"" ,"dialog-torrent-remove-confirm.html":"" } ,setlang:function(lang,callback) { // 如果未指定语言,则获取当前浏览器默认语言 if (!lang) { lang = navigator.language||navigator.browserLanguage; //this.debug("lang",lang); } if (!lang) lang="zh-CN"; // 如果语言代码中包含-,则需要将后半部份转为大写 if (lang.indexOf("-")!=-1) { // 因linux对文件有大小写限制,故重新赋值 lang=lang.split("-")[0].toLocaleLowerCase()+"-"+lang.split("-")[1].toLocaleUpperCase(); } // 如果该语言包没有定义,则使用英文 if (!this.languages[lang]) { lang = "en"; } $.getScript("lang/"+lang+".js",function(){ // 设置 easyui 语言 $.getScript("script/easyui/locale/easyui-lang-"+lang.replace("-","_")+".js") .done(function(script, textStatus){ if (callback) callback(); // 如果加载失败,则加载英文语言 }) .fail(function(jqxhr, settings, exception) { $.getScript("script/easyui/locale/easyui-lang-en.js",function(){ if (callback) callback(); }); }); }); } ,init:function(lang,islocal,devicetype) { this.readConfig(); /* alert(screen.width+","+this.config.mobileDeviceWidth); //return; if (screen.width<=this.config.mobileDeviceWidth&&devicetype!="computer") { location.href = "index.mobile.html"; return; } */ this.islocal = (islocal==1?true:false); this.panel = { main:$("#main") ,top:$("#m_top") ,toolbar:$("#m_toolbar") ,left_layout:$("#m_left_layout") ,left:$("#m_left") ,body:$("#m_body") ,layout_body:$("#layout_body") ,list:$("#m_list") ,attribute:$("#m_attribute") ,bottom:$("#m_bottom") ,title:$("#m_title") ,status:$("#m_status") ,statusbar:$("#m_statusbar") ,status_text:$("#status_text") ,droparea:$("#dropArea") }; if (this.lang==null) { this.setlang(lang,function(){system.initdata()}); } else this.initdata(); } ,initdata:function() { this.panel.title.text(this.lang.system.title+" "+this.version+" ("+this.codeupdate+")"); $(document).attr("title",this.lang.system.title+" "+this.version); var buttons = new Array(); var title = "" + this.lang.title.left+""; buttons.push(""); for (var key in this.lang.tree.toolbar.nav) { var value = this.lang.tree.toolbar.nav[key]; buttons.push(''+value+""); } buttons.push(""); if (buttons.length>1) { title+=buttons.join(""); this.panel.left_layout.panel("setTitle",title); for (var key in this.lang.tree.toolbar.nav) { $("#tree-toolbar-nav-"+key).linkbutton(); } } else { this.panel.left_layout.panel("setTitle",title); } this.panel.body.panel("setTitle",this.lang.title.list); this.panel.status.panel("setTitle",this.lang.title.status); this.panel.attribute.panel({ title:this.lang.title.attribute ,onExpand:function() { if (system.currentTorrentId!=0&&$(this).data("isload")) { system.getTorrentInfos(system.currentTorrentId); } else { system.clearTorrentAttribute(); } } ,onLoad:function() { if (!$(this).data("isload")) { $(this).data("isload",true); if (system.currentTorrentId!=0) { setTimeout(function(){ system.getTorrentInfos(system.currentTorrentId); },500); } } } }); // 设置语言 $.each(this.languages, function(key, value){ $("