diff --git a/src/index.html b/src/index.html index eefcf64..5427de3 100644 --- a/src/index.html +++ b/src/index.html @@ -14,7 +14,7 @@ - + @@ -43,6 +43,10 @@ .tree-title { display: inline; } + + .iconfont { + background: url("") no-repeat; + }
@@ -65,7 +69,7 @@ | - +
Language:
@@ -75,7 +79,7 @@ | - + | @@ -94,7 +98,7 @@ - + diff --git a/src/tr-web-control/config.js b/src/tr-web-control/config.js index c045606..6c6c525 100644 --- a/src/tr-web-control/config.js +++ b/src/tr-web-control/config.js @@ -18,7 +18,9 @@ system.config = { //show Folders foldersShow: false, // theme - theme: "default" + theme: "default", + // 是否显示BT服务器 + showBTServers: false }; // 主题样式 diff --git a/src/tr-web-control/lang/default.js b/src/tr-web-control/lang/default.js index fd9a1d5..2aeebce 100644 --- a/src/tr-web-control/lang/default.js +++ b/src/tr-web-control/lang/default.js @@ -215,7 +215,9 @@ system.defaultLang = { "infos": "Author:culturist
Statement:Most of the icons used in this program from the network, if any violation of your rights, please contact me delete.", "check-update": "Check Update", "home": "Project Home", - "help": "Wiki" + "help": "Wiki", + "donate": "Donate", + "pt-plugin": "PT Plugin" }, "torrent-remove": { "title": "Remove confirm", diff --git a/src/tr-web-control/lang/zh-CN.js b/src/tr-web-control/lang/zh-CN.js index 72e426a..a3c7512 100644 --- a/src/tr-web-control/lang/zh-CN.js +++ b/src/tr-web-control/lang/zh-CN.js @@ -214,7 +214,9 @@ system.lang = { "infos": "程序设计:栽培者
使用帮助:查看
QQ群:723130968 Transmission Web Control", "check-update": "检查更新", "home": "项目主页", - "help": "使用帮助" + "help": "使用帮助", + "donate": "打赏", + "pt-plugin": "PT助手" }, "torrent-remove": { "title": "删除种子确认", diff --git a/src/tr-web-control/script/min/system.min.js b/src/tr-web-control/script/min/system.min.js index d19d3c2..fd2eecc 100644 --- a/src/tr-web-control/script/min/system.min.js +++ b/src/tr-web-control/script/min/system.min.js @@ -1,4 +1,4 @@ -var system={version:"1.5.0",rootPath:"tr-web-control/",codeupdate:"20180308",configHead:"transmission-web-control",config:{autoReload:true,reloadStep:5E3,pageSize:30,pagination:true,pageList:[10,20,30,40,50,100,150,200,250,300],defaultSelectNode:null,autoExpandAttribute:false,defaultLang:"",foldersShow:false},storageKeys:{dictionary:{folders:"dictionary.folders"}},dictionary:{folders:null},checkUpdateScript:"https://raw.githubusercontent.com/ronggang/transmission-web-control/dev/release/update.json", +var system={version:"1.5.0 beta",rootPath:"tr-web-control/",codeupdate:"20180312",configHead:"transmission-web-control",config:{autoReload:true,reloadStep:5E3,pageSize:30,pagination:true,pageList:[10,20,30,40,50,100,150,200,250,300],defaultSelectNode:null,autoExpandAttribute:false,defaultLang:"",foldersShow:false},storageKeys:{dictionary:{folders:"dictionary.folders"}},dictionary:{folders:null},checkUpdateScript:"https://raw.githubusercontent.com/ronggang/transmission-web-control/dev/release/update.json", contextMenus:{},panel:null,lang:null,reloading:false,autoReloadTimer:null,downloadDir:"",islocal:false,B64:new Base64,currentTorrentId:0,control:{tree:null,torrentlist:null},userConfig:{torrentList:{fields:[],sortName:null,sortOrder:"asc"}},serverConfig:null,serverSessionStats:null,templates:{},checkedRows:[],setlang:function(a,b){a||(a=this.config.defaultLang?this.config.defaultLang:navigator.language||navigator.browserLanguage);a||(a="zh-CN");if(a.indexOf("-")!=-1)a=a.split("-")[0].toLocaleLowerCase()+ "-"+a.split("-")[1].toLocaleUpperCase();this.languages[a]||(a="en");$.getScript(system.rootPath+"lang/"+a+".js",function(){system.lang=$.extend(true,system.defaultLang,system.lang);system.resetLangText();$.getScript(system.rootPath+"script/easyui/locale/easyui-lang-"+a.replace("-","_")+".js").done(function(){b&&b()}).fail(function(){$.getScript(system.rootPath+"script/easyui/locale/easyui-lang-en.js",function(){b&&b()})})})},init:function(a,b){this.readConfig();this.islocal=b==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")};this.lang==null?this.setlang(a,function(){system.initdata()}):this.initdata();this.initThemes()},resetLangText:function(a){a||(a=$);var b=a.find("*[system-lang]"); @@ -11,17 +11,18 @@ this.panel.top.find("#lang").change(function(){location.href="?lang="+this.value function(a){a.stopPropagation();a.preventDefault();system.panel.droparea.show();system.debug("dragover")},false);this.panel.droparea[0].addEventListener("drop",function(a){a.stopPropagation();a.preventDefault();system.panel.droparea.hide();system.debug("drop.e.dataTransfer:",a.dataTransfer);system.checkDropFiles(a.dataTransfer.files)},false);this.panel.droparea[0].addEventListener("dragleave",function(a){a.stopPropagation();a.preventDefault();system.panel.droparea.hide();system.debug("dragleave")}, false);$("#text-drop-title").html(this.lang["public"]["text-drop-title"]);$("#button-cancel-checked").on("click",function(){system.control.torrentlist.datagrid("uncheckAll")})},navToolbarClick:function(a){var b=a.id,c=$(a).data("status"),e=null;switch(b){case "tree-toolbar-nav-folders":e=this.panel.left.tree("find","folders");this.config.foldersShow=c==1?false:true;break;case "tree-toolbar-nav-statistics":e=this.panel.left.tree("find","statistics");break;case "torrent-head-buttons-autoExpandAttribute":e= {};e.target=null;this.config.autoExpandAttribute=c==1?false:true}if(e){if(c==1){$(a).linkbutton({iconCls:"icon-disabled"});$(e.target).parent().hide();c=0}else{$(a).linkbutton({iconCls:"icon-enabled"});$(e.target).parent().show();c=1}$(a).data("status",c);this.saveConfig()}},checkDropFiles:function(a){if(a&&a.length){for(var b=[],c=0;c0&&system.openDialogFromTemplate({id:"dialog-torrent-addfile",options:{title:system.lang.toolbar["add-torrent"], -width:620,height:300,resizable:true},datas:{files:b}})}},initTree:function(){this.panel.left.tree({data:[{id:"torrent-all",iconCls:"icon-home",text:this.lang.tree.all+" ("+this.lang.tree.status.loading+")",children:[{id:"downloading",text:this.lang.tree.downloading,iconCls:"icon-download"},{id:"paused",text:this.lang.tree.paused,iconCls:"icon-pause"},{id:"sending",text:this.lang.tree.sending,iconCls:"icon-seed"},{id:"check",text:this.lang.tree.check,iconCls:"icon-check"},{id:"actively",text:this.lang.tree.actively, -iconCls:"icon-actively"},{id:"error",text:this.lang.tree.error,iconCls:"icon-error"},{id:"warning",text:this.lang.tree.warning,iconCls:"icon-warning"}]},{id:"servers",text:this.lang.tree.servers,state:"closed",iconCls:"icon-servers",children:[{id:"servers-loading",text:this.lang.tree.status.loading,iconCls:"tree-loading"}]},{id:"folders",text:this.lang.tree.folders,children:[{id:"folders-loading",text:this.lang.tree.status.loading,iconCls:"tree-loading"}]},{id:"statistics",text:this.lang.tree.statistics.title, -state:"closed",iconCls:"icon-chart",children:[{id:"cumulative-stats",text:this.lang.tree.statistics.cumulative,children:[{id:"uploadedBytes",text:this.lang.tree.statistics.uploadedBytes},{id:"downloadedBytes",text:this.lang.tree.statistics.downloadedBytes},{id:"filesAdded",text:this.lang.tree.statistics.filesAdded},{id:"sessionCount",text:this.lang.tree.statistics.sessionCount},{id:"secondsActive",text:this.lang.tree.statistics.secondsActive}]},{id:"current-stats",text:this.lang.tree.statistics.current, -children:[{id:"current-uploadedBytes",text:this.lang.tree.statistics.uploadedBytes},{id:"current-downloadedBytes",text:this.lang.tree.statistics.downloadedBytes},{id:"current-filesAdded",text:this.lang.tree.statistics.filesAdded},{id:"current-sessionCount",text:this.lang.tree.statistics.sessionCount},{id:"current-secondsActive",text:this.lang.tree.statistics.secondsActive}]}]}],onSelect:function(c){system.loadTorrentToList({node:c})},lines:true});for(var a in this.lang.tree.toolbar.nav){var b=this.panel.left.tree("find", -a);switch(a){case "folders":if(system.config.foldersShow){$("#tree-toolbar-nav-"+a).click();$(b.target).parent().show()}else $(b.target).parent().hide()}}if(this.config.defaultSelectNode)(a=this.panel.left.tree("find",this.config.defaultSelectNode))&&this.panel.left.tree("select",a.target)},initTorrentTable:function(){function a(){b&&$(b).remove();b=$("
").appendTo("body");b.menu({onClick:function(j){if(j.iconCls=="icon-ok"){system.control.torrentlist.datagrid("hideColumn",j.name);b.menu("setIcon", -{target:j.target,iconCls:"icon-empty"})}else{system.control.torrentlist.datagrid("showColumn",j.name);b.menu("setIcon",{target:j.target,iconCls:"icon-ok"})}system.resetTorrentListFieldsUserConfig(system.control.torrentlist.datagrid("options").columns[0]);system.saveUserConfig()}});for(var d=system.control.torrentlist.datagrid("getColumnFields"),f=0;f").attr("class","torrent-list").appendTo(this.panel.list);var b=null,c=-1,e=false;$.get(system.rootPath+"template/torrent-fields.json?time="+new Date,function(d){d=d.fields;if(system.userConfig.torrentList.fields.length!=0)d=$.extend(d,system.userConfig.torrentList.fields);var f=JSON.stringify(d);system.userConfig.torrentList.fields=JSON.parse(f);for(var g in d){d[g].title=system.lang.torrent.fields[d[g].field]|| -d[g].field;system.setFieldFormat(d[g])}system.control.torrentlist.datagrid({autoRowHeight:false,pagination:system.config.pagination,rownumbers:true,remoteSort:false,checkOnSelect:false,pageSize:system.config.pageSize,pageList:system.config.pageList,idField:"id",fit:true,striped:true,sortName:system.userConfig.torrentList.sortName,sortOrder:system.userConfig.torrentList.sortOrder,drophead:true,columns:[d],onCheck:function(h,j){system.checkTorrentRow(h,j)},onUncheck:function(h,j){system.checkTorrentRow(h, -j)},onCheckAll:function(){system.checkTorrentRow("all",false)},onUncheckAll:function(){system.checkTorrentRow("all",true)},onSelect:function(h,j){if(c!=-1){e=true;system.control.torrentlist.datagrid("unselectRow",c);e=false}system.config.autoExpandAttribute&&system.panel.attribute.panel("options").collapsed&&system.panel.layout_body.layout("expand","south");system.getTorrentInfos(j.id);c=h},onUnselect:function(){if(system.config.autoExpandAttribute)if(e==false)system.panel.attribute.panel("options").collapsed|| -system.panel.layout_body.layout("collapse","south");system.currentTorrentId=0;c=-1},onBeforeLoad:function(){system.currentTorrentId=0},onSortColumn:function(h,j){var i=h;if(h=="remainingTime")i="remainingTimeRaw";i=system.control.torrentlist.datagrid("getData").originalRows.sort(arrayObjectSort(i,j));system.control.torrentlist.datagrid("loadData",i);system.resetTorrentListFieldsUserConfig(system.control.torrentlist.datagrid("options").columns[0]);system.userConfig.torrentList.sortName=h;system.userConfig.torrentList.sortOrder= -j;system.saveUserConfig()},onRowContextMenu:function(h,j){system.checkedRows.length==0&&system.control.torrentlist.datagrid("checkRow",j);h.preventDefault();system.showContextMenu("torrent-list",h)},onHeadDrop:function(){system.resetTorrentListFieldsUserConfig(system.control.torrentlist.datagrid("options").columns[0]);system.saveUserConfig()},onResizeColumn:function(){system.resetTorrentListFieldsUserConfig(system.control.torrentlist.datagrid("options").columns[0]);system.saveUserConfig()},onHeaderContextMenu:function(h){h.preventDefault(); +width:620,height:300,resizable:true},datas:{files:b}})}},initTree:function(){this.panel.left.tree({data:[{id:"torrent-all",iconCls:"iconfont tr-icon-home",text:this.lang.tree.all+" ("+this.lang.tree.status.loading+")",children:[{id:"downloading",text:this.lang.tree.downloading,iconCls:"iconfont tr-icon-download"},{id:"paused",text:this.lang.tree.paused,iconCls:"iconfont tr-icon-pause2"},{id:"sending",text:this.lang.tree.sending,iconCls:"iconfont tr-icon-upload"},{id:"check",text:this.lang.tree.check, +iconCls:"iconfont tr-icon-data-check"},{id:"actively",text:this.lang.tree.actively,iconCls:"iconfont tr-icon-actively"},{id:"error",text:this.lang.tree.error,iconCls:"iconfont tr-icon-errors"},{id:"warning",text:this.lang.tree.warning,iconCls:"iconfont tr-icon-warning"}]},{id:"servers",text:this.lang.tree.servers,state:"closed",iconCls:"iconfont tr-icon-servers",children:[{id:"servers-loading",text:this.lang.tree.status.loading,iconCls:"tree-loading"}]},{id:"folders",text:this.lang.tree.folders,iconCls:"iconfont tr-icon-folder", +children:[{id:"folders-loading",text:this.lang.tree.status.loading,iconCls:"tree-loading"}]},{id:"statistics",text:this.lang.tree.statistics.title,state:"closed",iconCls:"iconfont tr-icon-shuju",children:[{id:"cumulative-stats",text:this.lang.tree.statistics.cumulative,iconCls:"iconfont tr-icon-folder",children:[{id:"uploadedBytes",text:this.lang.tree.statistics.uploadedBytes,iconCls:"iconfont tr-icon-empty"},{id:"downloadedBytes",text:this.lang.tree.statistics.downloadedBytes,iconCls:"iconfont tr-icon-empty"}, +{id:"filesAdded",text:this.lang.tree.statistics.filesAdded,iconCls:"iconfont tr-icon-empty"},{id:"sessionCount",text:this.lang.tree.statistics.sessionCount,iconCls:"iconfont tr-icon-empty"},{id:"secondsActive",text:this.lang.tree.statistics.secondsActive,iconCls:"iconfont tr-icon-empty"}]},{id:"current-stats",text:this.lang.tree.statistics.current,iconCls:"iconfont tr-icon-folder",children:[{id:"current-uploadedBytes",text:this.lang.tree.statistics.uploadedBytes,iconCls:"iconfont tr-icon-empty"}, +{id:"current-downloadedBytes",text:this.lang.tree.statistics.downloadedBytes,iconCls:"iconfont tr-icon-empty"},{id:"current-filesAdded",text:this.lang.tree.statistics.filesAdded,iconCls:"iconfont tr-icon-empty"},{id:"current-sessionCount",text:this.lang.tree.statistics.sessionCount,iconCls:"iconfont tr-icon-empty"},{id:"current-secondsActive",text:this.lang.tree.statistics.secondsActive,iconCls:"iconfont tr-icon-empty"}]}]}],onSelect:function(c){system.loadTorrentToList({node:c})},lines:true});for(var a in this.lang.tree.toolbar.nav){var b= +this.panel.left.tree("find",a);switch(a){case "folders":if(system.config.foldersShow){$("#tree-toolbar-nav-"+a).click();$(b.target).parent().show()}else $(b.target).parent().hide()}}if(this.config.defaultSelectNode)(a=this.panel.left.tree("find",this.config.defaultSelectNode))&&this.panel.left.tree("select",a.target)},initTorrentTable:function(){function a(){b&&$(b).remove();b=$("
").appendTo("body");b.menu({onClick:function(i){if(i.iconCls=="icon-ok"){system.control.torrentlist.datagrid("hideColumn", +i.name);b.menu("setIcon",{target:i.target,iconCls:"icon-empty"})}else{system.control.torrentlist.datagrid("showColumn",i.name);b.menu("setIcon",{target:i.target,iconCls:"icon-ok"})}system.resetTorrentListFieldsUserConfig(system.control.torrentlist.datagrid("options").columns[0]);system.saveUserConfig()}});for(var d=system.control.torrentlist.datagrid("getColumnFields"),f=0;f").attr("class","torrent-list").appendTo(this.panel.list);var b=null,c=-1,e=false;$.get(system.rootPath+"template/torrent-fields.json?time="+new Date,function(d){d=d.fields;if(system.userConfig.torrentList.fields.length!=0)d=$.extend(d,system.userConfig.torrentList.fields);var f=JSON.stringify(d);system.userConfig.torrentList.fields=JSON.parse(f);for(var g in d){d[g].title= +system.lang.torrent.fields[d[g].field]||d[g].field;system.setFieldFormat(d[g])}system.control.torrentlist.datagrid({autoRowHeight:false,pagination:system.config.pagination,rownumbers:true,remoteSort:false,checkOnSelect:false,pageSize:system.config.pageSize,pageList:system.config.pageList,idField:"id",fit:true,striped:true,sortName:system.userConfig.torrentList.sortName,sortOrder:system.userConfig.torrentList.sortOrder,drophead:true,columns:[d],onCheck:function(h,i){system.checkTorrentRow(h,i)},onUncheck:function(h, +i){system.checkTorrentRow(h,i)},onCheckAll:function(){system.checkTorrentRow("all",false)},onUncheckAll:function(){system.checkTorrentRow("all",true)},onSelect:function(h,i){if(c!=-1){e=true;system.control.torrentlist.datagrid("unselectRow",c);e=false}system.config.autoExpandAttribute&&system.panel.attribute.panel("options").collapsed&&system.panel.layout_body.layout("expand","south");system.getTorrentInfos(i.id);c=h},onUnselect:function(){if(system.config.autoExpandAttribute)if(e==false)system.panel.attribute.panel("options").collapsed|| +system.panel.layout_body.layout("collapse","south");system.currentTorrentId=0;c=-1},onBeforeLoad:function(){system.currentTorrentId=0},onSortColumn:function(h,i){var k=h;if(h=="remainingTime")k="remainingTimeRaw";k=system.control.torrentlist.datagrid("getData").originalRows.sort(arrayObjectSort(k,i));system.control.torrentlist.datagrid("loadData",k);system.resetTorrentListFieldsUserConfig(system.control.torrentlist.datagrid("options").columns[0]);system.userConfig.torrentList.sortName=h;system.userConfig.torrentList.sortOrder= +i;system.saveUserConfig()},onRowContextMenu:function(h,i){system.checkedRows.length==0&&system.control.torrentlist.datagrid("checkRow",i);h.preventDefault();system.showContextMenu("torrent-list",h)},onHeadDrop:function(){system.resetTorrentListFieldsUserConfig(system.control.torrentlist.datagrid("options").columns[0]);system.saveUserConfig()},onResizeColumn:function(){system.resetTorrentListFieldsUserConfig(system.control.torrentlist.datagrid("options").columns[0]);system.saveUserConfig()},onHeaderContextMenu:function(h){h.preventDefault(); b||a();b.menu("show",{left:h.pageX,top:h.pageY})}})},"json")},resetTorrentListFieldsUserConfig:function(a){var b={};$.each(this.userConfig.torrentList.fields,function(c,e){b[e.field]=e});this.userConfig.torrentList.fields=[];$.each(a,function(c,e){var d=$.extend({},b[e.field]);d.width=e.width;d.hidden=e.hidden;system.userConfig.torrentList.fields.push(d)})},showContextMenu:function(a,b){var c=this.contextMenus[a];if(c)c.empty();else{c=$("
").attr("class","easyui-menu").css({"min-width":"180px"}).appendTo(this.panel.main); this.contextMenus[a]=c;c.menu()}var e=null;switch(a){case "torrent-list":e=["start","pause","-","rename","remove","recheck","-","morepeers","changeDownloadDir","-","menu-queue-move-top","menu-queue-move-up","menu-queue-move-down","menu-queue-move-bottom"];var d=this.panel.toolbar,f;for(f in e){var g=e[f];if(g=="-")$("").appendTo(c);else{var h=d.find("#toolbar_"+g);if(h.length>0)c.menu("appendItem",{text:h.attr("title"),id:g,iconCls:h.linkbutton("options").iconCls,disabled:h.linkbutton("options").disabled, onclick:function(){system.panel.toolbar.find("#toolbar_"+$(this).attr("id")).click()}});else{h=$("#"+g);h.length>0&&c.menu("appendItem",{text:h.attr("title"),id:g,iconCls:h.attr("id").replace("menu-queue-move","iconfont tr-icon"),disabled:d.find("#toolbar_queue").linkbutton("options").disabled,onclick:function(){$("#"+$(this).attr("id")).click()}})}h=null}}}c.menu("show",{left:b.pageX,top:b.pageY});e=c=null},checkTorrentRow:function(a,b){this.checkedRows=this.control.torrentlist.datagrid("getChecked"); @@ -38,54 +39,55 @@ transmission.exec({method:"torrent-stop"},function(){a.linkbutton({iconCls:b,dis this.lang.toolbar.tip.recheck).click(function(){var a=system.control.torrentlist.datagrid("getChecked");if(a.length>0)if(a.length==1)if(transmission.torrents.all[a[0].id].percentDone>0)confirm(system.lang.toolbar.tip["recheck-confirm"])&&system.changeSelectedTorrentStatus("verify",$(this));else system.changeSelectedTorrentStatus("verify",$(this));else confirm(system.lang.toolbar.tip["recheck-confirm"])&&system.changeSelectedTorrentStatus("verify",$(this))});this.panel.toolbar.find("#toolbar_morepeers").linkbutton({disabled:true}).click(function(){system.changeSelectedTorrentStatus("reannounce", $(this))});this.panel.toolbar.find("#toolbar_remove").linkbutton({disabled:true}).attr("title",this.lang.toolbar.tip.remove).click(function(){var a=system.control.torrentlist.datagrid("getChecked"),b=[],c;for(c in a)b.push(a[c].id);b.length!=0&&system.openDialogFromTemplate({id:"dialog-torrent-remove-confirm",options:{title:system.lang.dialog["torrent-remove"].title,width:350,height:150},datas:{ids:b}})});this.panel.toolbar.find("#toolbar_rename").linkbutton({disabled:true}).click(function(){var a= system.control.torrentlist.datagrid("getChecked");a.length!=0&&system.openDialogFromTemplate({id:"dialog-torrent-rename",options:{title:system.lang.dialog["torrent-rename"].title,width:520,height:180,resizable:true},datas:{id:a[0].id}})});this.panel.toolbar.find("#toolbar_changeDownloadDir").linkbutton({disabled:true}).attr("title",this.lang.toolbar.tip["change-download-dir"]).click(function(){var a=system.control.torrentlist.datagrid("getChecked"),b=[],c;for(c in a)b.push(a[c].id);b.length!=0&&system.openDialogFromTemplate({id:"dialog-torrent-changeDownloadDir", -options:{title:system.lang.dialog["torrent-changeDownloadDir"].title,width:520,height:200},datas:{ids:b}})});this.panel.toolbar.find("#toolbar_alt_speed").linkbutton().attr("title",this.lang.toolbar.tip["alt-speed"]).click(function(){var a=$(this),b=false;if(a.linkbutton("options").iconCls=="icon-alt-speed-false")b=true;transmission.exec({method:"session-set",arguments:{"alt-speed-enabled":b}},function(c){if(c.result=="success"){system.serverConfig["alt-speed-enabled"]=b;a.linkbutton({iconCls:"icon-alt-speed-"+ -b.toString()});b?$("#status_alt_speed").show():$("#status_alt_speed").hide()}});a.linkbutton({iconCls:"icon-loading"})});this.panel.toolbar.find("#toolbar_config").linkbutton().attr("title",this.lang.toolbar.tip["system-config"]).click(function(){system.openDialogFromTemplate({id:"dialog-system-config",options:{title:system.lang.toolbar["system-config"],width:620,height:440,resizable:true}})});this.panel.toolbar.find("#toolbar_reload").linkbutton().attr("title",this.lang.toolbar.tip["system-reload"]).click(function(){system.reloadData()}); +options:{title:system.lang.dialog["torrent-changeDownloadDir"].title,width:520,height:200},datas:{ids:b}})});this.panel.toolbar.find("#toolbar_alt_speed").linkbutton().attr("title",this.lang.toolbar.tip["alt-speed"]).click(function(){var a=$(this),b=false;if(a.linkbutton("options").iconCls=="iconfont tr-icon-rocket")b=true;transmission.exec({method:"session-set",arguments:{"alt-speed-enabled":b}},function(c){if(c.result=="success"){system.serverConfig["alt-speed-enabled"]=b;a.linkbutton({iconCls:"iconfont tr-icon-"+ +(b?"woniu":"rocket")});b?$("#status_alt_speed").show():$("#status_alt_speed").hide()}});a.linkbutton({iconCls:"icon-loading"})});this.panel.toolbar.find("#toolbar_config").linkbutton().attr("title",this.lang.toolbar.tip["system-config"]).click(function(){system.openDialogFromTemplate({id:"dialog-system-config",options:{title:system.lang.toolbar["system-config"],width:620,height:440,resizable:true}})});this.panel.toolbar.find("#toolbar_reload").linkbutton().attr("title",this.lang.toolbar.tip["system-reload"]).click(function(){system.reloadData()}); this.panel.toolbar.find("#toolbar_search").searchbox({searcher:function(a){system.searchTorrents(a)},prompt:this.lang.toolbar["search-prompt"]})},initStatusBar:function(){this.panel.statusbar.find("#status_title_downloadspeed").html(this.lang.statusbar.downloadspeed);this.panel.statusbar.find("#status_title_uploadspeed").html(this.lang.statusbar.uploadspeed)},connect:function(){this.showStatus(this.lang.system.status.connect,0);transmission.on.torrentCountChange=function(){system.reloadTorrentBaseInfos()}; -transmission.on.postError=function(){};transmission.init({islocal:true},function(){system.reloadSession(true);system.getServerStatus()})},reloadSession:function(a){transmission.getSession(function(b){system.serverConfig=b;$("#status_version").html("Transmission "+system.lang.statusbar.version+b.version+", RPC: "+b["rpc-version"]+", WEB Control: "+system.version+"("+system.codeupdate+")");if(b["alt-speed-enabled"]==true){system.panel.toolbar.find("#toolbar_alt_speed").linkbutton({iconCls:"icon-alt-speed-true"}); -$("#status_alt_speed").show()}else{system.panel.toolbar.find("#toolbar_alt_speed").linkbutton({iconCls:"icon-alt-speed-false"});$("#status_alt_speed").hide()}system.downloadDir=b["download-dir"];transmission.downloadDirs.length==0&&transmission.downloadDirs.push(system.downloadDir);parseInt(system.serverConfig["rpc-version"])>=15?transmission.getFreeSpace(system.downloadDir,function(c){system.serverConfig["download-dir-free-space"]=c.arguments["size-bytes"];system.showFreeSpace(c.arguments["size-bytes"])}): +transmission.on.postError=function(){};transmission.init({islocal:true},function(){system.reloadSession(true);system.getServerStatus()})},reloadSession:function(a){transmission.getSession(function(b){system.serverConfig=b;$("#status_version").html("Transmission "+system.lang.statusbar.version+b.version+", RPC: "+b["rpc-version"]+", WEB Control: "+system.version+"("+system.codeupdate+")");if(b["alt-speed-enabled"]==true){system.panel.toolbar.find("#toolbar_alt_speed").linkbutton({iconCls:"iconfont tr-icon-woniu"}); +$("#status_alt_speed").show()}else{system.panel.toolbar.find("#toolbar_alt_speed").linkbutton({iconCls:"iconfont tr-icon-rocket"});$("#status_alt_speed").hide()}system.downloadDir=b["download-dir"];transmission.downloadDirs.length==0&&transmission.downloadDirs.push(system.downloadDir);parseInt(system.serverConfig["rpc-version"])>=15?transmission.getFreeSpace(system.downloadDir,function(c){system.serverConfig["download-dir-free-space"]=c.arguments["size-bytes"];system.showFreeSpace(c.arguments["size-bytes"])}): system.showFreeSpace(system.serverConfig["download-dir-free-space"]);a&&system.showStatus(system.lang.system.status.connected)})},showFreeSpace:function(a){a=a;a=a==-1?system.lang["public"]["text-unknown"]:formatSize(a);$("#status_freespace").text(system.lang.dialog["system-config"]["download-dir-free-space"]+" "+a)},reloadTorrentBaseInfos:function(a,b){if(!this.reloading){clearTimeout(this.autoReloadTimer);this.reloading=true;var c={trackers:transmission.trackers,folders:transmission.torrents.folders}; -transmission.torrents.getallids(function(e){var d=[],f;for(f in e)d.push(e[f].id);e=transmission.torrents.getErrorIds(d,true);e.length>0?transmission.torrents.getallids(function(){system.resetTorrentInfos(c)},e):system.resetTorrentInfos(c)},a,b)}},resetTorrentInfos:function(a){var b=this.currentTorrentId,c=this.panel.left.tree("find","servers");if(c){var e=c.state;this.removeTreeNode("servers-loading")}else{this.appendTreeNode(null,[{id:"servers",text:this.lang.tree.servers,state:"closed",iconCls:"icon-servers"}]); -c=this.panel.left.tree("find","servers")}for(var d in transmission.trackers){var f=transmission.trackers[d],g=system.panel.left.tree("find",f.nodeid),h=f.name+this.showNodeMoreInfos(f.count,f.size);g?system.updateTreeNodeText(f.nodeid,h,f.connected?"icon-server":"icon-server-error"):system.appendTreeNode(c,[{id:f.nodeid,text:h,iconCls:f.connected?"icon-server":"icon-server-error"}]);a.trackers[f.nodeid]=null}e=="closed"&&this.panel.left.tree("collapse",c.target);for(d in a.trackers)(f=a.trackers[d])&& -system.removeTreeNode(f.nodeid);transmission.torrents.status[transmission._status.stopped]?system.updateTreeNodeText("paused",system.lang.tree.paused+this.showNodeMoreInfos(transmission.torrents.status[transmission._status.stopped].length)):system.updateTreeNodeText("paused",system.lang.tree.paused);transmission.torrents.status[transmission._status.seed]?system.updateTreeNodeText("sending",system.lang.tree.sending+this.showNodeMoreInfos(transmission.torrents.status[transmission._status.seed].length)): -system.updateTreeNodeText("sending",system.lang.tree.sending);if(transmission.torrents.status[transmission._status.seedwait]){g=system.panel.left.tree("find","sending");c=system.panel.left.tree("getChildren",g.target);h=system.lang.tree.wait+this.showNodeMoreInfos(transmission.torrents.status[transmission._status.seedwait].length);c.length>0?system.updateTreeNodeText(c[0].id,h):system.appendTreeNode(g,[{id:"seedwait",text:h,iconCls:"icon-wait"}])}else system.removeTreeNode("seedwait");transmission.torrents.status[transmission._status.check]? -system.updateTreeNodeText("check",system.lang.tree.check+this.showNodeMoreInfos(transmission.torrents.status[transmission._status.check].length)):system.updateTreeNodeText("check",system.lang.tree.check);if(transmission.torrents.status[transmission._status.checkwait]){g=system.panel.left.tree("find","check");c=system.panel.left.tree("getChildren",g.target);h=system.lang.tree.wait+this.showNodeMoreInfos(transmission.torrents.status[transmission._status.checkwait].length);c.length>0?system.updateTreeNodeText(c[0].id, -h):system.appendTreeNode(g,[{id:"checkwait",text:h,iconCls:"icon-wait"}])}else system.removeTreeNode("checkwait");transmission.torrents.status[transmission._status.download]?system.updateTreeNodeText("downloading",system.lang.tree.downloading+this.showNodeMoreInfos(transmission.torrents.status[transmission._status.download].length)):system.updateTreeNodeText("downloading",system.lang.tree.downloading);if(transmission.torrents.status[transmission._status.downloadwait]){g=system.panel.left.tree("find", -"downloading");c=system.panel.left.tree("getChildren",g.target);h=system.lang.tree.wait+this.showNodeMoreInfos(transmission.torrents.status[transmission._status.downloadwait].length);c.length>0?system.updateTreeNodeText(c[0].id,h):system.appendTreeNode(g,[{id:"downloadwait",text:h,iconCls:"icon-wait"}])}else system.removeTreeNode("downloadwait");system.updateTreeNodeText("actively",system.lang.tree.actively+this.showNodeMoreInfos(transmission.torrents.actively.length));system.updateTreeNodeText("error", -system.lang.tree.error+this.showNodeMoreInfos(transmission.torrents.error.length));system.updateTreeNodeText("warning",system.lang.tree.warning+this.showNodeMoreInfos(transmission.torrents.warning.length));g=system.panel.left.tree("getSelected");if(g!=null){h=system.control.torrentlist.datagrid("options").pageNumber;system.loadTorrentToList({node:g,page:h})}b!=0&&system.control.torrentlist.datagrid("selectRecord",b);system.reloading=false;if(system.config.autoReload)system.autoReloadTimer=setTimeout(function(){system.reloadData()}, -system.config.reloadStep);system.updateTreeNodeText("torrent-all",system.lang.tree.all+this.showNodeMoreInfos(transmission.torrents.count,transmission.torrents.totalSize));b="uploadedBytes,downloadedBytes,filesAdded,sessionCount,secondsActive".split(",");$.each(b,function(j,i){switch(i){case "uploadedBytes":case "downloadedBytes":system.updateTreeNodeText(i,system.lang.tree.statistics[i]+formatSize(system.serverSessionStats["cumulative-stats"][i]));system.updateTreeNodeText("current-"+i,system.lang.tree.statistics[i]+ -formatSize(system.serverSessionStats["current-stats"][i]));break;case "secondsActive":system.updateTreeNodeText(i,system.lang.tree.statistics[i]+getTotalTime(system.serverSessionStats["cumulative-stats"][i]*1E3));system.updateTreeNodeText("current-"+i,system.lang.tree.statistics[i]+getTotalTime(system.serverSessionStats["current-stats"][i]*1E3));break;default:system.updateTreeNodeText(i,system.lang.tree.statistics[i]+system.serverSessionStats["cumulative-stats"][i]);system.updateTreeNodeText("current-"+ -i,system.lang.tree.statistics[i]+system.serverSessionStats["current-stats"][i])}});for(d in transmission.torrents.folders)a.folders[transmission.torrents.folders[d].nodeid]=null;this.loadFolderList(a.folders);navigator.userAgent.indexOf("Firefox")>0&&system.panel.left.find("span.nav-total-size").css({"margin-top":"-19px"})},showNodeMoreInfos:function(a,b){var c="";if(a>0)c=" ("+a+")";if(b>0)c+="["+formatSize(b)+"]";return c}, -getServerStatus:function(){if(!this.reloading){clearTimeout(this.autoReloadTimer);this.reloading=true;transmission.getStatus(function(a){system.reloading=false;$("#status_downloadspeed").html(formatSize(a.downloadSpeed,false,"speed"));$("#status_uploadspeed").html(formatSize(a.uploadSpeed,false,"speed"));system.serverSessionStats=a;if(a.torrentCount==0){(a=system.panel.left.tree("find","servers"))&&system.panel.left.tree("remove",a.target);system.updateTreeNodeText("torrent-all",system.lang.tree.all)}})}}, -showStatus:function(a,b){$("#m_status").panel("options").collapsed&&$("#layout_left").layout("expand","south");this.panel.status_text.show();a&&this.panel.status_text.html(a);if(b!=0){if(b==undefined)b=3E3;this.panel.status_text.fadeOut(b,function(){$("#layout_left").layout("collapse","south")})}},updateTreeNodeText:function(a,b,c){if(a=this.panel.left.tree("find",a)){b={target:a.target,text:b};if(c!=undefined)b.iconCls=c;this.panel.left.tree("update",b)}},appendTreeNode:function(a,b){var c=null; -(c=typeof a=="string"?this.panel.left.tree("find",a):a)?this.panel.left.tree("append",{parent:c.target,data:b}):this.panel.left.tree("append",{data:b})},removeTreeNode:function(a){(a=this.panel.left.tree("find",a))&&this.panel.left.tree("remove",a.target)},loadTorrentToList:function(a){if(transmission.torrents.all){jQuery.extend({node:null,page:1},a);if(a.node){var b=null,c=this.panel.left.tree("getParent",a.node.target)||{id:""},e=this.panel.left.data("currentNodeId");if(e!=a.node.id){this.control.torrentlist.datagrid("uncheckAll"); -this.control.torrentlist.datagrid({pageNumber:1});e=a.node.id}this.panel.left.data("currentNodeId",e);switch(c.id){case "servers":b=transmission.trackers[a.node.id].torrents;break;default:switch(a.node.id){case "torrent-all":case "servers":b=transmission.torrents.all;break;case "paused":b=transmission.torrents.status[transmission._status.stopped];break;case "sending":b=transmission.torrents.status[transmission._status.seed];break;case "seedwait":b=transmission.torrents.status[transmission._status.seedwait]; -break;case "check":b=transmission.torrents.status[transmission._status.check];break;case "checkwait":b=transmission.torrents.status[transmission._status.checkwait];break;case "downloading":b=transmission.torrents.status[transmission._status.download];break;case "downloadwait":b=transmission.torrents.status[transmission._status.downloadwait];break;case "actively":b=transmission.torrents.actively;break;case "error":b=transmission.torrents.error;break;case "warning":b=transmission.torrents.warning;break; -case "search-result":b=transmission.torrents.searchResult;break;default:if(a.node.id.indexOf("folders-")!=-1)if(c=transmission.torrents.folders[a.node.id])b=c.torrents}}if(this.config.defaultSelectNode!=a.node.id){this.control.torrentlist.datagrid("loadData",[]);this.config.defaultSelectNode=a.node.id;this.saveConfig()}a=[];for(var d in b){if(!b[d])return;c=this.lang.torrent["status-text"][b[d].status];parseFloat(b[d].percentDone*100).toFixed(2);c==transmission._status.check&&parseFloat(b[d].recheckProgress* -100).toFixed(2);if(b[d].error!=0)c=""+c+"";else if(b[d].warning)c=""+c+"";e={};e=$.extend(e,b[d]);e.status=c;e.statusCode=b[d].status;e.completeSize=Math.max(0,b[d].totalSize-b[d].leftUntilDone);e.leecherCount=b[d].leecher;e.seederCount=b[d].seeder;a.push(e)}this.updateTorrentCurrentPageDatas(a)}}},updateTorrentCurrentPageDatas:function(a){var b=this.control.torrentlist.datagrid("getRows");if(a.length== -0&&b.length>0)this.control.torrentlist.datagrid("loadData",[]);else{var c=this.control.torrentlist.datagrid("options"),e=null;if(c.sortName){var d=e=c.sortName;if(e=="remainingTime")d="remainingTimeRaw";a=a.sort(arrayObjectSort(d,c.sortOrder))}if(b.length==0||a.length!=this.control.torrentlist.datagrid("getData").total&&a.length>c.pageSize)this.control.torrentlist.datagrid({loadFilter:pagerFilter,pageNumber:c.pageNumber,sortName:e,sortOrder:c.sortOrder}).datagrid("loadData",a);else{this.control.torrentlist.datagrid("getData").originalRows= -a;e=(c.pageNumber-1)*parseInt(c.pageSize);c=e+parseInt(c.pageSize);a=a.slice(e,c);c={};e={};for(var f in transmission.torrents.recently){d=transmission.torrents.recently[f];c[d.id]=true}for(f in a){d=a[f];e[d.id]=d}var g={};for(f=b.length-1;f>=0;f--){d=b[f];var h=e[d.id];if(h)if(c[d.id]){this.control.torrentlist.datagrid("updateRow",{index:f,row:h});g[d.id]=d}else if(transmission.torrents.removed)if(transmission.torrents.removed.length>0&&$.inArray(d.id,transmission.torrents.removed)!=-1)this.control.torrentlist.datagrid("deleteRow", -f);else g[d.id]=d;else g[d.id]=d;else this.control.torrentlist.datagrid("deleteRow",f)}for(f in a){d=a[f];g[d.id]||this.control.torrentlist.datagrid("appendRow",d)}}}},getTorrentNameBar:function(a){var b="",c=a.name;switch(a.status){case transmission._status.stopped:b="iconlabel icon-pause-small";break;case transmission._status.check:b="iconlabel icon-checking";break;case transmission._status.download:b="iconlabel icon-down";break;case transmission._status.seed:b="iconlabel icon-up";break;case transmission._status.seedwait:case transmission._status.downloadwait:case transmission._status.checkwait:b= -"iconlabel icon-wait"}c+="\n"+a.downloadDir;if(a.warning){b="iconlabel icon-warning-type1";c+="\n\n"+this.lang["public"]["text-info"]+": "+a.warning}if(a.error!=0){b="iconlabel icon-exclamation";c+="\n\n"+this.lang["public"]["text-info"]+": "+a.errorString}return''+a.name+""},getTorrentProgressBar:function(a,b){a+="%";var c="",e=0;e=typeof b=="object"?b.status:b;switch(e){case transmission._status.stopped:c="torrent-progress-stop";break;case transmission._status.checkwait:case transmission._status.check:c= -"torrent-progress-check";break;case transmission._status.downloadwait:case transmission._status.download:c="torrent-progress-download";break;case transmission._status.seedwait:case transmission._status.seed:c="torrent-progress-seed"}if(typeof b=="object"){if(b.warning)c="torrent-progress-warning";if(b.error!=0)c="torrent-progress-error"}return'
'+a+'
'}, -addTorrentsToServer:function(a,b,c,e){var d=b-a.length,f=a.shift();if(f){this.showStatus(this.lang.system.status.queue+(d+1)+"/"+b+"
"+f,0);transmission.addTorrentFromUrl(f,e,c,function(){system.addTorrentsToServer(a,b,c,e)})}else{this.showStatus(this.lang.system.status.queuefinish);this.getServerStatus()}},changeSelectedTorrentStatus:function(a,b,c){var e=this.control.torrentlist.datagrid("getChecked"),d=[];a||(a="start");for(var f in e)d.push(e[f].id);c||(c="torrent-"+a);if(d.length>0){if(b){var g= -b.linkbutton("options").iconCls;b.linkbutton({disabled:true,iconCls:"icon-loading"})}transmission.exec({method:c,arguments:{ids:d}},function(){b&&b.linkbutton({iconCls:g});system.control.torrentlist.datagrid("uncheckAll");system.reloadTorrentBaseInfos()})}},searchTorrents:function(a){if(a!=""){var b=transmission.torrents.search(a);if(b==null||b.length==0)this.removeTreeNode("search-result");else{var c=this.panel.left.tree("find","search-result");a=this.lang.tree["search-result"]+" : "+a+" ("+b.length+ -")";if(c==null){this.appendTreeNode("torrent-all",[{id:"search-result",text:a,iconCls:"icon-search"}]);c=this.panel.left.tree("find","search-result")}else this.panel.left.tree("update",{target:c.target,text:a});this.panel.left.tree("select",c.target)}}},getTorrentInfos:function(a){if(transmission.torrents.all[a])if(!transmission.torrents.all[a].infoIsLoading){if(this.currentTorrentId>0&&transmission.torrents.all[this.currentTorrentId])if(transmission.torrents.all[this.currentTorrentId].infoIsLoading)return; -this.currentTorrentId=a;if(!this.panel.attribute.panel("options").collapsed){var b=transmission.torrents.all[a];b.infoIsLoading=true;var c="fileStats,trackerStats,peers,leftUntilDone,status,rateDownload,rateUpload,uploadedEver,uploadRatio,error,errorString";b.moreInfosTag||(c+=",files,trackers,comment,dateCreated,creator,downloadDir");transmission.torrents.getMoreInfos(c,a,function(e){b.infoIsLoading=false;if(e!=null){jQuery.extend(b,e[0]);if(system.currentTorrentId==0||system.currentTorrentId!=a)system.clearTorrentAttribute(); -else{b.completeSize=b.totalSize-b.leftUntilDone;b.moreInfosTag=true;system.fillTorrentBaseInfos(b);system.fillTorrentFileList(b);system.fillTorrentServerList(b);system.fillTorrentPeersList(b);system.fillTorrentConfig(b);transmission.torrents.all[a]=b;transmission.torrents.datas[a]=b}}})}}},clearTorrentAttribute:function(){system.panel.attribute.find("#torrent-files-table").datagrid("loadData",[]);system.panel.attribute.find("#torrent-servers-table").datagrid("loadData",[]);system.panel.attribute.find("#torrent-peers-table").datagrid("loadData", -[]);system.panel.attribute.find("span[id*='torrent-attribute-value']").html("")},updateCurrentPageDatas:function(a,b,c){var e=c.datagrid("getRows"),d=c.datagrid("options"),f=null;if(d.sortName){f=d.sortName;b=b.sort(arrayObjectSort(f,d.sortOrder))}if(e.length==0||b.length!=c.datagrid("getData").total&&b.length>d.pageSize)c.datagrid({loadFilter:pagerFilter,pageNumber:1,sortName:f,sortOrder:d.sortOrder}).datagrid("loadData",b);else{c.datagrid("getData").originalRows=b;f=(d.pageNumber-1)*parseInt(d.pageSize); -d=f+parseInt(d.pageSize);b=b.slice(f,d);d={};for(var g in b){f=b[g];d[f[a]]=f}for(g=e.length-1;g>=0;g--){f=e[g];(b=d[f[a]])?c.datagrid("updateRow",{index:g,row:b}):c.datagrid("deleteRow",g)}}},fillTorrentBaseInfos:function(a){$.each(a,function(b,c){switch(b){case "rateDownload":case "rateUpload":c=formatSize(c,true,"speed");break;case "totalSize":case "uploadedEver":case "leftUntilDone":case "completeSize":c=formatSize(c);break;case "addedDate":case "dateCreated":case "doneDate":c=formatLongTime(c); -break;case "status":c=system.lang.torrent["status-text"][c];break;case "error":c==0?system.panel.attribute.find("#torrent-attribute-tr-error").hide():system.panel.attribute.find("#torrent-attribute-tr-error").show();break;case "comment":c=system.replaceURI(c)}system.panel.attribute.find("#torrent-attribute-value-"+b).html(c)})},fillTorrentFileList:function(a){var b=a.files,c=a.fileStats,e=[],d=a.name.length+1,f;for(f in b){var g=b[f],h=c[f],j=parseFloat(h.bytesCompleted/g.length*100).toFixed(2);e.push({name:g.name== -a.name?g.name:g.name.substr(d),index:f,bytesCompleted:h.bytesCompleted,percentDone:system.getTorrentProgressBar(j,transmission._status.download),length:g.length,wanted:system.lang.torrent.attribute.status[h.wanted],priority:''+system.lang.torrent.attribute.priority[h.priority]+""})}this.updateCurrentPageDatas("index",e,system.panel.attribute.find("#torrent-files-table"))},fillTorrentServerList:function(a){var b=a.trackerStats,c=[],e;for(e in b){var d= -b[e],f={},g;for(g in d)switch(g){case "lastAnnounceTime":case "nextAnnounceTime":f[g]=formatLongTime(d[g]);break;case "lastAnnounceSucceeded":case "lastAnnounceTimedOut":f[g]=system.lang.torrent.attribute.status[d[g]];break;default:f[g]=d[g]}c.push(f)}transmission.torrents.addTracker(a);this.updateCurrentPageDatas("id",c,system.panel.attribute.find("#torrent-servers-table"))},fillTorrentPeersList:function(a){a=a.peers;var b=[],c;for(c in a){var e=a[c],d={},f;for(f in e)d[f]=e[f];e=parseFloat(e.progress* -100).toFixed(2);d.progress=system.getTorrentProgressBar(e,transmission._status.download);b.push(d)}this.updateCurrentPageDatas("address",b,system.panel.attribute.find("#torrent-peers-table"))},fillTorrentConfig:function(a){system.panel.attribute.find("#torrent-attribute-tabs").data("selectedIndex")==4&&transmission.torrents.getConfig(a.id,function(b){if(b!=null){jQuery.extend(transmission.torrents.all[system.currentTorrentId],b[0]);system.currentTorrentId!=0&&$.each(b[0],function(c,e){var d=false, -f=false,g=false;switch(c){case "seedIdleMode":case "seedRatioMode":if(e==0){f=false;d=true}g=true;case "downloadLimited":case "uploadLimited":if(e==true||e==1)f=true;system.panel.attribute.find("input[enabledof='"+c+"']").prop("disabled",!f);g&&system.panel.attribute.find("#"+c).prop("indeterminate",d).data("_tag",e);system.panel.attribute.find("#"+c).prop("checked",f);break;default:system.panel.attribute.find("#"+c).val(e);system.panel.attribute.find("#"+c).numberspinner("setValue",e)}})}})},setFieldFormat:function(a){if(a.formatter)switch(a.formatter){case "size":a.formatter= -function(b){return formatSize(b)};break;case "speed":a.formatter=function(b){return formatSize(b,true,"speed")};break;case "longtime":a.formatter=function(b){return formatLongTime(b)};break;case "progress":a.formatter=function(b,c){var e=parseFloat(b*100).toFixed(2);return system.getTorrentProgressBar(e,transmission.torrents.all[c.id])};break;case "_usename_":switch(a.field){case "name":a.formatter=function(b,c){return system.getTorrentNameBar(transmission.torrents.all[c.id])}}break;case "ratio":a.formatter= -function(b){var c="";if(parseFloat(b)<1)c="text-status-warning";return''+b+""}}},reloadData:function(){this.reloadSession();this.reloading=false;this.getServerStatus();this.reloading=false;this.reloadTorrentBaseInfos()},loadFolderList:function(a){this.removeTreeNode("folders-loading");for(var b in a){var c=a[b];c&&system.removeTreeNode(c.nodeid)}transmission.downloadDirs.length!=0&&timedChunk(transmission.downloadDirs,this.appendFolder,this,10,function(){navigator.userAgent.indexOf("Firefox")> -0&&system.panel.left.find("span.nav-total-size").css({"margin-top":"-19px"})})},appendFolder:function(a){if(a){var b="folders";a=a.split("/");var c="folders-",e;for(e in a){var d=a[e];if(d!=""){c+=this.B64.encode(d);var f=this.panel.left.tree("find",c),g=transmission.torrents.folders[c];d=d+this.showNodeMoreInfos(g.count,g.size);if(f)this.updateTreeNodeText(c,d);else{this.appendTreeNode(b,[{id:c,text:d}]);if(b!="folders"){f=this.panel.left.tree("find",b);this.panel.left.tree("collapse",f.target)}}b= -c}}}},replaceURI:function(a){return a.replace(/(http|https|ftp):\/\/([^/:]+)(:\d*)?([^# ]*)/ig,function(b){return''+b+""})},readConfig:function(){this.readUserConfig();var a=this.getStorageData(this.configHead+".system");if(a)this.config=$.extend(this.config,JSON.parse(a));for(var b in this.storageKeys.dictionary)this.dictionary[b]=this.getStorageData(this.storageKeys.dictionary[b])},saveConfig:function(){this.setStorageData(this.configHead+".system",JSON.stringify(this.config)); -for(var a in this.storageKeys.dictionary)this.setStorageData(this.storageKeys.dictionary[a],this.dictionary[a]);this.saveUserConfig()},readUserConfig:function(){var a=window.localStorage[this.configHead];if(a){a=JSON.parse(a);this.userConfig=$.extend(true,this.userConfig,a)}},saveUserConfig:function(){window.localStorage[this.configHead]=JSON.stringify(this.userConfig)},uploadTorrentFile:function(a,b,c,e){if(window.FileReader){var d=$("input[id='"+a+"']")[0].files;$.each(d,function(f,g){transmission.addTorrentFromFile(g, -b,c,e,d.length)})}else alert(system.lang.publit["text-browsers-not-support-features"])},checkUpdate:function(){$.ajax({url:this.checkUpdateScript,dataType:"json",success:function(a){if(a&&a.update)if(system.codeupdate "+a.infos)}else $("#area-update-infos").hide()}})},changeLanguages:function(a){if(!(a==this.lang.name||!a)){this.config.defaultLang=a;this.saveConfig();location.href="?lang="+a}},getStorageData:function(a, -b){return window.localStorage[a]==null?b:window.localStorage[a]},setStorageData:function(a,b){window.localStorage[a]=b},openDialogFromTemplate:function(a){a=$.extend(true,{id:null,options:null,datas:null},a);if(a.id!=null){var b=a.id,c=a.options,e=a.datas,d=$("#"+b);if(d.length){d.dialog("open");e&&$.each(e,function(f,g){d.data(f,g)});d.dialog({content:system.templates[b]})}else{c=$.extend(true,{title:"",width:100,height:100,resizable:false,cache:true,content:"loading...",modal:true},c);$("
").attr("id", -b).appendTo(document.body).dialog(c);$.get(system.rootPath+"template/"+b+".html?time="+new Date,function(f){system.templates[b]=f;e&&$.each(e,function(g,h){$("#"+b).data(g,h)});$("#"+b).dialog({content:f})})}}},debug:function(a,b){window.console&&window.console.log&&window.console.log(a,b)},initThemes:function(){this.themes&&$("#select-themes").combobox({groupField:"group",data:this.themes,editable:false,panelHeight:"auto",onChange:function(a){var b=(a+";").split(";"),c=b[0];b=b[1]||"logo.png";$("#styleEasyui").attr("href", -"tr-web-control/script/easyui/themes/"+c+"/easyui.css");$("#logo").attr("src","tr-web-control/"+b);system.config.theme=a;system.saveConfig()},onLoadSuccess:function(){$(this).combobox("setValue",system.config.theme||"default")}})}};$(document).ready(function(){$.getScript(system.rootPath+"lang/default.js");$.getScript(system.rootPath+"lang/_languages.js",function(){system.init(location.search.getQueryString("lang"),location.search.getQueryString("local"))})}); +transmission.torrents.getallids(function(e){var d=[],f;for(f in e)d.push(e[f].id);e=transmission.torrents.getErrorIds(d,true);e.length>0?transmission.torrents.getallids(function(){system.resetTorrentInfos(c)},e):system.resetTorrentInfos(c)},a,b)}},resetTorrentInfos:function(a){var b=this.currentTorrentId,c=this.panel.left.tree("find","servers");if(c){var e=c.state;this.removeTreeNode("servers-loading")}else{this.appendTreeNode(null,[{id:"servers",text:this.lang.tree.servers,state:"closed",iconCls:"iconfont tr-icon-servers"}]); +c=this.panel.left.tree("find","servers")}var d=this.panel.left.tree("find","btservers"),f;for(f in transmission.trackers){var g=transmission.trackers[f];if(g.isBT){if(!system.config.showBTServers)continue;if(!d){this.appendTreeNode(c,[{id:"btservers",text:"BT",state:"open",iconCls:"iconfont tr-icon-bt"}]);d=this.panel.left.tree("find","btservers")}}var h=system.panel.left.tree("find",g.nodeid),i=g.name+this.showNodeMoreInfos(g.count,g.size);h?system.updateTreeNodeText(g.nodeid,i,g.connected?"iconfont tr-icon-server": +"iconfont tr-icon-server-error"):system.appendTreeNode(g.isBT?d:c,[{id:g.nodeid,text:i,iconCls:g.connected?"iconfont tr-icon-server":"iconfont tr-icon-server-error"}]);a.trackers[g.nodeid]=null}e=="closed"&&this.panel.left.tree("collapse",c.target);system.config.showBTServers&&this.panel.left.tree("collapse",d.target);for(f in a.trackers)(g=a.trackers[f])&&system.removeTreeNode(g.nodeid);transmission.torrents.status[transmission._status.stopped]?system.updateTreeNodeText("paused",system.lang.tree.paused+ +this.showNodeMoreInfos(transmission.torrents.status[transmission._status.stopped].length)):system.updateTreeNodeText("paused",system.lang.tree.paused);transmission.torrents.status[transmission._status.seed]?system.updateTreeNodeText("sending",system.lang.tree.sending+this.showNodeMoreInfos(transmission.torrents.status[transmission._status.seed].length)):system.updateTreeNodeText("sending",system.lang.tree.sending);if(transmission.torrents.status[transmission._status.seedwait]){h=system.panel.left.tree("find", +"sending");c=system.panel.left.tree("getChildren",h.target);i=system.lang.tree.wait+this.showNodeMoreInfos(transmission.torrents.status[transmission._status.seedwait].length);c.length>0?system.updateTreeNodeText(c[0].id,i):system.appendTreeNode(h,[{id:"seedwait",text:i,iconCls:"iconfont tr-icon-wait"}])}else system.removeTreeNode("seedwait");transmission.torrents.status[transmission._status.check]?system.updateTreeNodeText("check",system.lang.tree.check+this.showNodeMoreInfos(transmission.torrents.status[transmission._status.check].length)): +system.updateTreeNodeText("check",system.lang.tree.check);if(transmission.torrents.status[transmission._status.checkwait]){h=system.panel.left.tree("find","check");c=system.panel.left.tree("getChildren",h.target);i=system.lang.tree.wait+this.showNodeMoreInfos(transmission.torrents.status[transmission._status.checkwait].length);c.length>0?system.updateTreeNodeText(c[0].id,i):system.appendTreeNode(h,[{id:"checkwait",text:i,iconCls:"iconfont tr-icon-wait"}])}else system.removeTreeNode("checkwait");transmission.torrents.status[transmission._status.download]? +system.updateTreeNodeText("downloading",system.lang.tree.downloading+this.showNodeMoreInfos(transmission.torrents.status[transmission._status.download].length)):system.updateTreeNodeText("downloading",system.lang.tree.downloading);if(transmission.torrents.status[transmission._status.downloadwait]){h=system.panel.left.tree("find","downloading");c=system.panel.left.tree("getChildren",h.target);i=system.lang.tree.wait+this.showNodeMoreInfos(transmission.torrents.status[transmission._status.downloadwait].length); +c.length>0?system.updateTreeNodeText(c[0].id,i):system.appendTreeNode(h,[{id:"downloadwait",text:i,iconCls:"iconfont tr-icon-wait"}])}else system.removeTreeNode("downloadwait");system.updateTreeNodeText("actively",system.lang.tree.actively+this.showNodeMoreInfos(transmission.torrents.actively.length));system.updateTreeNodeText("error",system.lang.tree.error+this.showNodeMoreInfos(transmission.torrents.error.length));system.updateTreeNodeText("warning",system.lang.tree.warning+this.showNodeMoreInfos(transmission.torrents.warning.length)); +h=system.panel.left.tree("getSelected");if(h!=null){i=system.control.torrentlist.datagrid("options").pageNumber;system.loadTorrentToList({node:h,page:i})}b!=0&&system.control.torrentlist.datagrid("selectRecord",b);system.reloading=false;if(system.config.autoReload)system.autoReloadTimer=setTimeout(function(){system.reloadData()},system.config.reloadStep);system.updateTreeNodeText("torrent-all",system.lang.tree.all+this.showNodeMoreInfos(transmission.torrents.count,transmission.torrents.totalSize)); +b="uploadedBytes,downloadedBytes,filesAdded,sessionCount,secondsActive".split(",");$.each(b,function(k,j){switch(j){case "uploadedBytes":case "downloadedBytes":system.updateTreeNodeText(j,system.lang.tree.statistics[j]+formatSize(system.serverSessionStats["cumulative-stats"][j]));system.updateTreeNodeText("current-"+j,system.lang.tree.statistics[j]+formatSize(system.serverSessionStats["current-stats"][j]));break;case "secondsActive":system.updateTreeNodeText(j,system.lang.tree.statistics[j]+getTotalTime(system.serverSessionStats["cumulative-stats"][j]* +1E3));system.updateTreeNodeText("current-"+j,system.lang.tree.statistics[j]+getTotalTime(system.serverSessionStats["current-stats"][j]*1E3));break;default:system.updateTreeNodeText(j,system.lang.tree.statistics[j]+system.serverSessionStats["cumulative-stats"][j]);system.updateTreeNodeText("current-"+j,system.lang.tree.statistics[j]+system.serverSessionStats["current-stats"][j])}});for(f in transmission.torrents.folders)a.folders[transmission.torrents.folders[f].nodeid]=null;this.loadFolderList(a.folders); +navigator.userAgent.indexOf("Firefox")>0&&system.panel.left.find("span.nav-total-size").css({"margin-top":"-19px"})},showNodeMoreInfos:function(a,b){var c="";if(a>0)c=" ("+a+")";if(b>0)c+="["+formatSize(b)+"]";return c},getServerStatus:function(){if(!this.reloading){clearTimeout(this.autoReloadTimer);this.reloading=true;transmission.getStatus(function(a){system.reloading=false;$("#status_downloadspeed").html(formatSize(a.downloadSpeed, +false,"speed"));$("#status_uploadspeed").html(formatSize(a.uploadSpeed,false,"speed"));system.serverSessionStats=a;if(a.torrentCount==0){(a=system.panel.left.tree("find","servers"))&&system.panel.left.tree("remove",a.target);system.updateTreeNodeText("torrent-all",system.lang.tree.all)}})}},showStatus:function(a,b){$("#m_status").panel("options").collapsed&&$("#layout_left").layout("expand","south");this.panel.status_text.show();a&&this.panel.status_text.html(a);if(b!=0){if(b==undefined)b=3E3;this.panel.status_text.fadeOut(b, +function(){$("#layout_left").layout("collapse","south")})}},updateTreeNodeText:function(a,b,c){if(a=this.panel.left.tree("find",a)){b={target:a.target,text:b};if(c!=undefined)b.iconCls=c;this.panel.left.tree("update",b)}},appendTreeNode:function(a,b){var c=null;(c=typeof a=="string"?this.panel.left.tree("find",a):a)?this.panel.left.tree("append",{parent:c.target,data:b}):this.panel.left.tree("append",{data:b})},removeTreeNode:function(a){(a=this.panel.left.tree("find",a))&&this.panel.left.tree("remove", +a.target)},loadTorrentToList:function(a){if(transmission.torrents.all){jQuery.extend({node:null,page:1},a);if(a.node){var b=null,c=this.panel.left.tree("getParent",a.node.target)||{id:""},e=this.panel.left.data("currentNodeId");if(e!=a.node.id){this.control.torrentlist.datagrid("uncheckAll");this.control.torrentlist.datagrid({pageNumber:1});e=a.node.id}this.panel.left.data("currentNodeId",e);switch(c.id){case "servers":b=transmission.trackers[a.node.id].torrents;break;default:switch(a.node.id){case "torrent-all":case "servers":b= +transmission.torrents.all;break;case "paused":b=transmission.torrents.status[transmission._status.stopped];break;case "sending":b=transmission.torrents.status[transmission._status.seed];break;case "seedwait":b=transmission.torrents.status[transmission._status.seedwait];break;case "check":b=transmission.torrents.status[transmission._status.check];break;case "checkwait":b=transmission.torrents.status[transmission._status.checkwait];break;case "downloading":b=transmission.torrents.status[transmission._status.download]; +break;case "downloadwait":b=transmission.torrents.status[transmission._status.downloadwait];break;case "actively":b=transmission.torrents.actively;break;case "error":b=transmission.torrents.error;break;case "warning":b=transmission.torrents.warning;break;case "search-result":b=transmission.torrents.searchResult;break;default:if(a.node.id.indexOf("folders-")!=-1)if(c=transmission.torrents.folders[a.node.id])b=c.torrents}}if(this.config.defaultSelectNode!=a.node.id){this.control.torrentlist.datagrid("loadData", +[]);this.config.defaultSelectNode=a.node.id;this.saveConfig()}a=[];for(var d in b){if(!b[d])return;c=this.lang.torrent["status-text"][b[d].status];parseFloat(b[d].percentDone*100).toFixed(2);c==transmission._status.check&&parseFloat(b[d].recheckProgress*100).toFixed(2);if(b[d].error!=0)c=""+c+"";else if(b[d].warning)c=""+c+"";e={};e=$.extend(e,b[d]);e.status=c;e.statusCode=b[d].status;e.completeSize= +Math.max(0,b[d].totalSize-b[d].leftUntilDone);e.leecherCount=b[d].leecher;e.seederCount=b[d].seeder;a.push(e)}this.updateTorrentCurrentPageDatas(a)}}},updateTorrentCurrentPageDatas:function(a){var b=this.control.torrentlist.datagrid("getRows");if(a.length==0&&b.length>0)this.control.torrentlist.datagrid("loadData",[]);else{var c=this.control.torrentlist.datagrid("options"),e=null;if(c.sortName){var d=e=c.sortName;if(e=="remainingTime")d="remainingTimeRaw";a=a.sort(arrayObjectSort(d,c.sortOrder))}if(b.length== +0||a.length!=this.control.torrentlist.datagrid("getData").total&&a.length>c.pageSize)this.control.torrentlist.datagrid({loadFilter:pagerFilter,pageNumber:c.pageNumber,sortName:e,sortOrder:c.sortOrder}).datagrid("loadData",a);else{this.control.torrentlist.datagrid("getData").originalRows=a;e=(c.pageNumber-1)*parseInt(c.pageSize);c=e+parseInt(c.pageSize);a=a.slice(e,c);c={};e={};for(var f in transmission.torrents.recently){d=transmission.torrents.recently[f];c[d.id]=true}for(f in a){d=a[f];e[d.id]= +d}var g={};for(f=b.length-1;f>=0;f--){d=b[f];var h=e[d.id];if(h)if(c[d.id]){this.control.torrentlist.datagrid("updateRow",{index:f,row:h});g[d.id]=d}else if(transmission.torrents.removed)if(transmission.torrents.removed.length>0&&$.inArray(d.id,transmission.torrents.removed)!=-1)this.control.torrentlist.datagrid("deleteRow",f);else g[d.id]=d;else g[d.id]=d;else this.control.torrentlist.datagrid("deleteRow",f)}for(f in a){d=a[f];g[d.id]||this.control.torrentlist.datagrid("appendRow",d)}}}},getTorrentNameBar:function(a){var b= +"",c=a.name;switch(a.status){case transmission._status.stopped:b="iconlabel icon-pause-small";break;case transmission._status.check:b="iconlabel icon-checking";break;case transmission._status.download:b="iconlabel icon-down";break;case transmission._status.seed:b="iconlabel icon-up";break;case transmission._status.seedwait:case transmission._status.downloadwait:case transmission._status.checkwait:b="iconlabel icon-wait"}c+="\n"+a.downloadDir;if(a.warning){b="iconlabel icon-warning-type1";c+="\n\n"+ +this.lang["public"]["text-info"]+": "+a.warning}if(a.error!=0){b="iconlabel icon-exclamation";c+="\n\n"+this.lang["public"]["text-info"]+": "+a.errorString}return''+a.name+""},getTorrentProgressBar:function(a,b){a+="%";var c="",e=0;e=typeof b=="object"?b.status:b;switch(e){case transmission._status.stopped:c="torrent-progress-stop";break;case transmission._status.checkwait:case transmission._status.check:c="torrent-progress-check";break;case transmission._status.downloadwait:case transmission._status.download:c= +"torrent-progress-download";break;case transmission._status.seedwait:case transmission._status.seed:c="torrent-progress-seed"}if(typeof b=="object"){if(b.warning)c="torrent-progress-warning";if(b.error!=0)c="torrent-progress-error"}return'
'+a+'
'},addTorrentsToServer:function(a,b,c,e){var d=b-a.length,f=a.shift();if(f){this.showStatus(this.lang.system.status.queue+ +(d+1)+"/"+b+"
"+f,0);transmission.addTorrentFromUrl(f,e,c,function(){system.addTorrentsToServer(a,b,c,e)})}else{this.showStatus(this.lang.system.status.queuefinish);this.getServerStatus()}},changeSelectedTorrentStatus:function(a,b,c){var e=this.control.torrentlist.datagrid("getChecked"),d=[];a||(a="start");for(var f in e)d.push(e[f].id);c||(c="torrent-"+a);if(d.length>0){if(b){var g=b.linkbutton("options").iconCls;b.linkbutton({disabled:true,iconCls:"icon-loading"})}transmission.exec({method:c, +arguments:{ids:d}},function(){b&&b.linkbutton({iconCls:g});system.control.torrentlist.datagrid("uncheckAll");system.reloadTorrentBaseInfos()})}},searchTorrents:function(a){if(a!=""){var b=transmission.torrents.search(a);if(b==null||b.length==0)this.removeTreeNode("search-result");else{var c=this.panel.left.tree("find","search-result");a=this.lang.tree["search-result"]+" : "+a+" ("+b.length+")";if(c==null){this.appendTreeNode("torrent-all",[{id:"search-result",text:a,iconCls:"iconfont tr-icon-search"}]); +c=this.panel.left.tree("find","search-result")}else this.panel.left.tree("update",{target:c.target,text:a});this.panel.left.tree("select",c.target)}}},getTorrentInfos:function(a){if(transmission.torrents.all[a])if(!transmission.torrents.all[a].infoIsLoading){if(this.currentTorrentId>0&&transmission.torrents.all[this.currentTorrentId])if(transmission.torrents.all[this.currentTorrentId].infoIsLoading)return;this.currentTorrentId=a;if(!this.panel.attribute.panel("options").collapsed){var b=transmission.torrents.all[a]; +b.infoIsLoading=true;var c="fileStats,trackerStats,peers,leftUntilDone,status,rateDownload,rateUpload,uploadedEver,uploadRatio,error,errorString";b.moreInfosTag||(c+=",files,trackers,comment,dateCreated,creator,downloadDir");transmission.torrents.getMoreInfos(c,a,function(e){b.infoIsLoading=false;if(e!=null){jQuery.extend(b,e[0]);if(system.currentTorrentId==0||system.currentTorrentId!=a)system.clearTorrentAttribute();else{b.completeSize=b.totalSize-b.leftUntilDone;b.moreInfosTag=true;system.fillTorrentBaseInfos(b); +system.fillTorrentFileList(b);system.fillTorrentServerList(b);system.fillTorrentPeersList(b);system.fillTorrentConfig(b);transmission.torrents.all[a]=b;transmission.torrents.datas[a]=b}}})}}},clearTorrentAttribute:function(){system.panel.attribute.find("#torrent-files-table").datagrid("loadData",[]);system.panel.attribute.find("#torrent-servers-table").datagrid("loadData",[]);system.panel.attribute.find("#torrent-peers-table").datagrid("loadData",[]);system.panel.attribute.find("span[id*='torrent-attribute-value']").html("")}, +updateCurrentPageDatas:function(a,b,c){var e=c.datagrid("getRows"),d=c.datagrid("options"),f=null;if(d.sortName){f=d.sortName;b=b.sort(arrayObjectSort(f,d.sortOrder))}if(e.length==0||b.length!=c.datagrid("getData").total&&b.length>d.pageSize)c.datagrid({loadFilter:pagerFilter,pageNumber:1,sortName:f,sortOrder:d.sortOrder}).datagrid("loadData",b);else{c.datagrid("getData").originalRows=b;f=(d.pageNumber-1)*parseInt(d.pageSize);d=f+parseInt(d.pageSize);b=b.slice(f,d);d={};for(var g in b){f=b[g];d[f[a]]= +f}for(g=e.length-1;g>=0;g--){f=e[g];(b=d[f[a]])?c.datagrid("updateRow",{index:g,row:b}):c.datagrid("deleteRow",g)}}},fillTorrentBaseInfos:function(a){$.each(a,function(b,c){switch(b){case "rateDownload":case "rateUpload":c=formatSize(c,true,"speed");break;case "totalSize":case "uploadedEver":case "leftUntilDone":case "completeSize":c=formatSize(c);break;case "addedDate":case "dateCreated":case "doneDate":c=formatLongTime(c);break;case "status":c=system.lang.torrent["status-text"][c];break;case "error":c== +0?system.panel.attribute.find("#torrent-attribute-tr-error").hide():system.panel.attribute.find("#torrent-attribute-tr-error").show();break;case "comment":c=system.replaceURI(c)}system.panel.attribute.find("#torrent-attribute-value-"+b).html(c)})},fillTorrentFileList:function(a){var b=a.files,c=a.fileStats,e=[],d=a.name.length+1,f;for(f in b){var g=b[f],h=c[f],i=parseFloat(h.bytesCompleted/g.length*100).toFixed(2);e.push({name:g.name==a.name?g.name:g.name.substr(d),index:f,bytesCompleted:h.bytesCompleted, +percentDone:system.getTorrentProgressBar(i,transmission._status.download),length:g.length,wanted:system.lang.torrent.attribute.status[h.wanted],priority:''+system.lang.torrent.attribute.priority[h.priority]+""})}this.updateCurrentPageDatas("index",e,system.panel.attribute.find("#torrent-files-table"))},fillTorrentServerList:function(a){var b=a.trackerStats,c=[],e;for(e in b){var d=b[e],f={},g;for(g in d)switch(g){case "lastAnnounceTime":case "nextAnnounceTime":f[g]= +formatLongTime(d[g]);break;case "lastAnnounceSucceeded":case "lastAnnounceTimedOut":f[g]=system.lang.torrent.attribute.status[d[g]];break;default:f[g]=d[g]}c.push(f)}transmission.torrents.addTracker(a);this.updateCurrentPageDatas("id",c,system.panel.attribute.find("#torrent-servers-table"))},fillTorrentPeersList:function(a){a=a.peers;var b=[],c;for(c in a){var e=a[c],d={},f;for(f in e)d[f]=e[f];e=parseFloat(e.progress*100).toFixed(2);d.progress=system.getTorrentProgressBar(e,transmission._status.download); +b.push(d)}this.updateCurrentPageDatas("address",b,system.panel.attribute.find("#torrent-peers-table"))},fillTorrentConfig:function(a){system.panel.attribute.find("#torrent-attribute-tabs").data("selectedIndex")==4&&transmission.torrents.getConfig(a.id,function(b){if(b!=null){jQuery.extend(transmission.torrents.all[system.currentTorrentId],b[0]);system.currentTorrentId!=0&&$.each(b[0],function(c,e){var d=false,f=false,g=false;switch(c){case "seedIdleMode":case "seedRatioMode":if(e==0){f=false;d=true}g= +true;case "downloadLimited":case "uploadLimited":if(e==true||e==1)f=true;system.panel.attribute.find("input[enabledof='"+c+"']").prop("disabled",!f);g&&system.panel.attribute.find("#"+c).prop("indeterminate",d).data("_tag",e);system.panel.attribute.find("#"+c).prop("checked",f);break;default:system.panel.attribute.find("#"+c).val(e);system.panel.attribute.find("#"+c).numberspinner("setValue",e)}})}})},setFieldFormat:function(a){if(a.formatter)switch(a.formatter){case "size":a.formatter=function(b){return formatSize(b)}; +break;case "speed":a.formatter=function(b){return formatSize(b,true,"speed")};break;case "longtime":a.formatter=function(b){return formatLongTime(b)};break;case "progress":a.formatter=function(b,c){var e=parseFloat(b*100).toFixed(2);return system.getTorrentProgressBar(e,transmission.torrents.all[c.id])};break;case "_usename_":switch(a.field){case "name":a.formatter=function(b,c){return system.getTorrentNameBar(transmission.torrents.all[c.id])}}break;case "ratio":a.formatter=function(b){var c="";if(parseFloat(b)< +1)c="text-status-warning";return''+b+""}}},reloadData:function(){this.reloadSession();this.reloading=false;this.getServerStatus();this.reloading=false;this.reloadTorrentBaseInfos()},loadFolderList:function(a){this.removeTreeNode("folders-loading");for(var b in a){var c=a[b];c&&system.removeTreeNode(c.nodeid)}transmission.downloadDirs.length!=0&&timedChunk(transmission.downloadDirs,this.appendFolder,this,10,function(){navigator.userAgent.indexOf("Firefox")>0&&system.panel.left.find("span.nav-total-size").css({"margin-top":"-19px"})})}, +appendFolder:function(a){if(a){var b="folders";a=a.split("/");var c="folders-",e;for(e in a){var d=a[e];if(d!=""){c+=this.B64.encode(d);var f=this.panel.left.tree("find",c),g=transmission.torrents.folders[c];d=d+this.showNodeMoreInfos(g.count,g.size);if(f)this.updateTreeNodeText(c,d);else{this.appendTreeNode(b,[{id:c,text:d,iconCls:"iconfont tr-icon-file"}]);if(b!="folders"){f=this.panel.left.tree("find",b);this.panel.left.tree("collapse",f.target)}}b=c}}}},replaceURI:function(a){return a.replace(/(http|https|ftp):\/\/([^/:]+)(:\d*)?([^# ]*)/ig, +function(b){return''+b+""})},readConfig:function(){this.readUserConfig();var a=this.getStorageData(this.configHead+".system");if(a)this.config=$.extend(this.config,JSON.parse(a));for(var b in this.storageKeys.dictionary)this.dictionary[b]=this.getStorageData(this.storageKeys.dictionary[b])},saveConfig:function(){this.setStorageData(this.configHead+".system",JSON.stringify(this.config));for(var a in this.storageKeys.dictionary)this.setStorageData(this.storageKeys.dictionary[a], +this.dictionary[a]);this.saveUserConfig()},readUserConfig:function(){var a=window.localStorage[this.configHead];if(a){a=JSON.parse(a);this.userConfig=$.extend(true,this.userConfig,a)}},saveUserConfig:function(){window.localStorage[this.configHead]=JSON.stringify(this.userConfig)},uploadTorrentFile:function(a,b,c,e){if(window.FileReader){var d=$("input[id='"+a+"']")[0].files;$.each(d,function(f,g){transmission.addTorrentFromFile(g,b,c,e,d.length)})}else alert(system.lang.publit["text-browsers-not-support-features"])}, +checkUpdate:function(){$.ajax({url:this.checkUpdateScript,dataType:"json",success:function(a){if(a&&a.update)if(system.codeupdate "+a.infos)}else $("#area-update-infos").hide()}})},changeLanguages:function(a){if(!(a==this.lang.name||!a)){this.config.defaultLang=a;this.saveConfig();location.href="?lang="+a}},getStorageData:function(a,b){return window.localStorage[a]==null?b:window.localStorage[a]},setStorageData:function(a, +b){window.localStorage[a]=b},openDialogFromTemplate:function(a){a=$.extend(true,{id:null,options:null,datas:null},a);if(a.id!=null){var b=a.id,c=a.options,e=a.datas,d=$("#"+b);if(d.length){d.dialog("open");e&&$.each(e,function(f,g){d.data(f,g)});d.dialog({content:system.templates[b]})}else{c=$.extend(true,{title:"",width:100,height:100,resizable:false,cache:true,content:"loading...",modal:true},c);$("
").attr("id",b).appendTo(document.body).dialog(c);$.get(system.rootPath+"template/"+b+".html?time="+ +new Date,function(f){system.templates[b]=f;e&&$.each(e,function(g,h){$("#"+b).data(g,h)});$("#"+b).dialog({content:f})})}}},debug:function(a,b){window.console&&window.console.log&&window.console.log(a,b)},initThemes:function(){this.themes&&$("#select-themes").combobox({groupField:"group",data:this.themes,editable:false,panelHeight:"auto",onChange:function(a){var b=(a+";").split(";"),c=b[0];b=b[1]||"logo.png";$("#styleEasyui").attr("href","tr-web-control/script/easyui/themes/"+c+"/easyui.css");$("#logo").attr("src", +"tr-web-control/"+b);system.config.theme=a;system.saveConfig()},onLoadSuccess:function(){$(this).combobox("setValue",system.config.theme||"default")}})}};$(document).ready(function(){$.getScript(system.rootPath+"lang/default.js");$.getScript(system.rootPath+"lang/_languages.js",function(){system.init(location.search.getQueryString("lang"),location.search.getQueryString("local"))})}); function pagerFilter(a){if(typeof a.length=="number"&&typeof a.splice=="function")a={total:a.length,rows:a};var b=$(this),c=b.datagrid("options"),e=b.datagrid("getPager"),d=b.data("buttons");e.pagination({onSelectPage:function(g,h){c.pageNumber=g;c.pageSize=h;e.pagination("refresh",{pageNumber:g,pageSize:h});b.datagrid("loadData",a)},buttons:d});if(!a.originalRows)a.originalRows=a.rows;d=(c.pageNumber-1)*parseInt(c.pageSize);var f=d+parseInt(c.pageSize);a.rows=a.originalRows.slice(d,f);return a}; diff --git a/src/tr-web-control/script/min/transmission.torrents.min.js b/src/tr-web-control/script/min/transmission.torrents.min.js index 7419d88..9e63255 100644 --- a/src/tr-web-control/script/min/transmission.torrents.min.js +++ b/src/tr-web-control/script/min/transmission.torrents.min.js @@ -5,7 +5,7 @@ g.arguments.removed;transmission.torrents.splitid();b&&b(g.arguments.torrents)}e g.push(a)}for(c in this.datas){a=this.datas[c];if(!a)return;if($.inArray(a.id,g)!=-1&&g.length>0){if(this.all[a.id]){this.all[a.id]=null;delete this.all[a.id]}this.datas[c]=null;delete this.datas[c]}else{this.isRecentlyActive&&!this.all[a.id]&&this.newIds.push(a.id);a=$.extend(this.all[a.id],a);if(a.uploadedEver==0&&a.downloadedEver==0)a.uploadRatio="∞";a.infoIsLoading=false;var d=this.status[a.status];this.addTracker(a);if(!d){this.status[a.status]=[];d=this.status[a.status]}this.totalSize+=a.totalSize; if(a.rateDownload>0&&a.leftUntilDone>0){a.remainingTime=getTotalTime(a.leftUntilDone/a.rateDownload*1E3);a.remainingTimeRaw=Math.floor(a.leftUntilDone/a.rateDownload*1E3)}else if(a.rateDownload==0&&a.leftUntilDone==0&&a.totalSize!=0){a.remainingTime=0;a.remainingTimeRaw=0}else{a.remainingTime="∞";a.remainingTimeRaw=31536E8}d.push(a);a.error!=0&&this.error.push(a);if(a.rateUpload>0||a.rateDownload>0)this.actively.push(a);switch(a.status){case b.stopped:this.puased.push(a);break;case b.download:this.downloading.push(a)}this.all[a.id]= a;$.inArray(a.downloadDir,transmission.downloadDirs)==-1&&transmission.downloadDirs.push(a.downloadDir);if(transmission.options.getFolders)if(a.downloadDir){d=a.downloadDir.split("/");var j="folders-",h;for(h in d){var f=d[h];if(f!=""){j+=e.encode(f);(f=this.folders[j])||(f={count:0,torrents:[],size:0,nodeid:j});f.torrents.push(a);f.count++;f.size+=a.totalSize;this.folders[j]=f}}}this.count++}}transmission.downloadDirs=transmission.downloadDirs.sort();this.newIds.length>0&&this.getallids(null,this.newIds)}, -addTracker:function(b){var e=b.trackerStats,c=false,a=[];b.leecherCount=0;b.seederCount=0;if(e.length>0){for(var g in e){var d=e[g],j=d.lastAnnounceResult.toLowerCase(),h=d.host.getHostName().split(".");$.inArray(h[0],"www,tracker".split(","))!=-1&&h.shift();h=h.join(".");var f="tracker-"+h.replace(/\./g,"-"),i=transmission.trackers[f];if(!i){transmission.trackers[f]={count:0,torrents:[],size:0,connected:true};i=transmission.trackers[f]}i.name=h;i.nodeid=f;i.host=d.host;if(!d.lastAnnounceSucceeded&& +addTracker:function(b){var e=b.trackerStats,c=false,a=[];b.leecherCount=0;b.seederCount=0;if(e.length>0){for(var g in e){var d=e[g],j=d.lastAnnounceResult.toLowerCase(),h=d.host.getHostName().split(".");$.inArray(h[0],"www,tracker".split(","))!=-1&&h.shift();h=h.join(".");var f="tracker-"+h.replace(/\./g,"-"),i=transmission.trackers[f];if(!i){transmission.trackers[f]={count:0,torrents:[],size:0,connected:true,isBT:e.length>1};i=transmission.trackers[f]}i.name=h;i.nodeid=f;i.host=d.host;if(!d.lastAnnounceSucceeded&& d.announceState!=transmission._trackerStatus.inactive){c=true;b.warning=d.lastAnnounceResult;if(j=="could not connect to tracker")i.connected=false}if(i.torrents.indexOf(b)==-1){i.torrents.push(b);i.count++;i.size+=b.totalSize}b.leecherCount+=d.leecherCount;b.seederCount+=d.seederCount;a.indexOf(h)==-1&&a.push(h)}if(c){if(b.nextAnnounceTime){if(b.nextAnnounceTime>d.nextAnnounceTime)b.nextAnnounceTime=d.nextAnnounceTime}else b.nextAnnounceTime=d.nextAnnounceTime;this.warning.push(b)}if(b.leecherCount< 0)b.leecherCount=0;if(b.seederCount<0)b.seederCount=0;b.leecher=b.leecherCount+" ("+b.peersGettingFromUs+")";b.seeder=b.seederCount+" ("+b.peersSendingToUs+")";b.trackers=a.join(";")}},getPeers:function(b){transmission.exec({method:"torrent-get",arguments:{fields:"peers,peersFrom".split(","),ids:b}},function(e){console.log("data:",e)})},getMoreInfos:function(b,e,c){transmission.exec({method:"torrent-get",arguments:{fields:b.split(","),ids:e}},function(a){if(a.result=="success")c&&c(a.arguments.torrents); else c&&c(null)})},search:function(b,e){if(!b)return null;if(!e)e=this.all;var c=[];$.each(e,function(a){e[a].name.toLowerCase().indexOf(b.toLowerCase())!=-1&&c.push(e[a])});return this.searchResult=c},getFiles:function(b,e){transmission.exec({method:"torrent-get",arguments:{fields:"files,fileStats".split(","),ids:b}},function(c){if(c.result=="success")e&&e(c.arguments.torrents);else e&&e(null)})},getConfig:function(b,e){this.getMoreInfos(this.fields.config,b,e)},getErrorIds:function(b,e){var c=[], diff --git a/src/tr-web-control/script/system.js b/src/tr-web-control/script/system.js index dbdb40b..7849a06 100644 --- a/src/tr-web-control/script/system.js +++ b/src/tr-web-control/script/system.js @@ -1,8 +1,8 @@ // Current system global object var system = { - version: "1.5.0", + version: "1.5.0 beta", rootPath: "tr-web-control/", - codeupdate: "20180308", + codeupdate: "20180312", configHead: "transmission-web-control", // default config, can be customized in config.js config: { @@ -410,42 +410,42 @@ var system = { this.panel.left.tree({ data: [{ id: "torrent-all", - iconCls: "icon-home", + iconCls: "iconfont tr-icon-home", text: this.lang.tree.all + " (" + this.lang.tree.status.loading + ")", children: [{ id: "downloading", text: this.lang.tree.downloading, - iconCls: "icon-download" + iconCls: "iconfont tr-icon-download" }, { id: "paused", text: this.lang.tree.paused, - iconCls: "icon-pause" + iconCls: "iconfont tr-icon-pause2" }, { id: "sending", text: this.lang.tree.sending, - iconCls: "icon-seed" + iconCls: "iconfont tr-icon-upload" }, { id: "check", text: this.lang.tree.check, - iconCls: "icon-check" + iconCls: "iconfont tr-icon-data-check" }, { id: "actively", text: this.lang.tree.actively, - iconCls: "icon-actively" + iconCls: "iconfont tr-icon-actively" }, { id: "error", text: this.lang.tree.error, - iconCls: "icon-error" + iconCls: "iconfont tr-icon-errors" }, { id: "warning", text: this.lang.tree.warning, - iconCls: "icon-warning" + iconCls: "iconfont tr-icon-warning" }] }, { id: "servers", text: this.lang.tree.servers, state: "closed", - iconCls: "icon-servers", + iconCls: "iconfont tr-icon-servers", children: [{ id: "servers-loading", text: this.lang.tree.status.loading, @@ -454,6 +454,7 @@ var system = { }, { id: "folders", text: this.lang.tree.folders, + iconCls: "iconfont tr-icon-folder", children: [{ id: "folders-loading", text: this.lang.tree.status.loading, @@ -463,44 +464,56 @@ var system = { id: "statistics", text: this.lang.tree.statistics.title, state: "closed", - iconCls: "icon-chart", + iconCls: "iconfont tr-icon-shuju", children: [{ id: "cumulative-stats", text: this.lang.tree.statistics.cumulative, + iconCls: "iconfont tr-icon-folder", children: [{ id: "uploadedBytes", - text: this.lang.tree.statistics.uploadedBytes + text: this.lang.tree.statistics.uploadedBytes, + iconCls: "iconfont tr-icon-empty" }, { id: "downloadedBytes", - text: this.lang.tree.statistics.downloadedBytes + text: this.lang.tree.statistics.downloadedBytes, + iconCls: "iconfont tr-icon-empty" }, { id: "filesAdded", - text: this.lang.tree.statistics.filesAdded + text: this.lang.tree.statistics.filesAdded, + iconCls: "iconfont tr-icon-empty" }, { id: "sessionCount", - text: this.lang.tree.statistics.sessionCount + text: this.lang.tree.statistics.sessionCount, + iconCls: "iconfont tr-icon-empty" }, { id: "secondsActive", - text: this.lang.tree.statistics.secondsActive + text: this.lang.tree.statistics.secondsActive, + iconCls: "iconfont tr-icon-empty" }] }, { id: "current-stats", text: this.lang.tree.statistics.current, + iconCls: "iconfont tr-icon-folder", children: [{ id: "current-uploadedBytes", - text: this.lang.tree.statistics.uploadedBytes + text: this.lang.tree.statistics.uploadedBytes, + iconCls: "iconfont tr-icon-empty" }, { id: "current-downloadedBytes", - text: this.lang.tree.statistics.downloadedBytes + text: this.lang.tree.statistics.downloadedBytes, + iconCls: "iconfont tr-icon-empty" }, { id: "current-filesAdded", - text: this.lang.tree.statistics.filesAdded + text: this.lang.tree.statistics.filesAdded, + iconCls: "iconfont tr-icon-empty" }, { id: "current-sessionCount", - text: this.lang.tree.statistics.sessionCount + text: this.lang.tree.statistics.sessionCount, + iconCls: "iconfont tr-icon-empty" }, { id: "current-secondsActive", - text: this.lang.tree.statistics.secondsActive + text: this.lang.tree.statistics.secondsActive, + iconCls: "iconfont tr-icon-empty" }] }] } @@ -1145,7 +1158,7 @@ var system = { var button = $(this); var options = button.linkbutton("options"); var enabled = false; - if (options.iconCls == "icon-alt-speed-false") { + if (options.iconCls == "iconfont tr-icon-rocket") { enabled = true; } transmission.exec({ @@ -1157,7 +1170,7 @@ var system = { if (data.result == "success") { system.serverConfig["alt-speed-enabled"] = enabled; button.linkbutton({ - iconCls: "icon-alt-speed-" + enabled.toString() + iconCls: "iconfont tr-icon-" + (enabled?"woniu":"rocket")//"icon-alt-speed-" + enabled.toString() }); if (enabled) { $("#status_alt_speed").show(); @@ -1238,12 +1251,12 @@ var system = { ", WEB Control: " + system.version + "(" + system.codeupdate + ")"); if (result["alt-speed-enabled"] == true) { system.panel.toolbar.find("#toolbar_alt_speed").linkbutton({ - iconCls: "icon-alt-speed-true" + iconCls: "iconfont tr-icon-woniu" }); $("#status_alt_speed").show(); } else { system.panel.toolbar.find("#toolbar_alt_speed").linkbutton({ - iconCls: "icon-alt-speed-false" + iconCls: "iconfont tr-icon-rocket" }); $("#status_alt_speed").hide(); } @@ -1312,40 +1325,62 @@ var system = { // refresh the tree resetTorrentInfos: function (oldInfos) { var currentTorrentId = this.currentTorrentId; - var parentNode = this.panel.left.tree("find", "servers"); - if (parentNode) { - var parentNode_collapsed = parentNode.state + // 获取服务器分布主节点 + var serversNode = this.panel.left.tree("find", "servers"); + if (serversNode) { + var serversNode_collapsed = serversNode.state; this.removeTreeNode("servers-loading"); } else { this.appendTreeNode(null, [{ id: "servers", text: this.lang.tree.servers, state: "closed", - iconCls: "icon-servers" + iconCls: "iconfont tr-icon-servers" }]); - parentNode = this.panel.left.tree("find", "servers"); + serversNode = this.panel.left.tree("find", "servers"); } var datas = new Array(); + var BTServersNode = this.panel.left.tree("find", "btservers"); + // 加载服务器列表 for (var index in transmission.trackers) { var tracker = transmission.trackers[index]; + if (tracker.isBT) { + // 是否显示BT服务器 + if (!system.config.showBTServers) { + continue; + } + if (!BTServersNode) { + this.appendTreeNode(serversNode, [{ + id: "btservers", + text: "BT", + state: "open", + iconCls: "iconfont tr-icon-bt" + }]); + BTServersNode = this.panel.left.tree("find", "btservers"); + } + } var node = system.panel.left.tree("find", tracker.nodeid); var text = tracker.name + this.showNodeMoreInfos(tracker.count, tracker.size); if (node) { - system.updateTreeNodeText(tracker.nodeid, text, (tracker.connected ? "icon-server" : "icon-server-error")); + system.updateTreeNodeText(tracker.nodeid, text, (tracker.connected ? "iconfont tr-icon-server" : "iconfont tr-icon-server-error")); } else { - system.appendTreeNode(parentNode, [{ + system.appendTreeNode((tracker.isBT? BTServersNode: serversNode), [{ id: tracker.nodeid, text: text, - iconCls: (tracker.connected ? "icon-server" : "icon-server-error") + iconCls: (tracker.connected ? "iconfont tr-icon-server" : "iconfont tr-icon-server-error") }]); } oldInfos.trackers[tracker.nodeid] = null; } // Collapse the node if it was before - if (parentNode_collapsed == "closed") { - this.panel.left.tree("collapse", parentNode.target); + if (serversNode_collapsed == "closed") { + this.panel.left.tree("collapse", serversNode.target); + } + + if (system.config.showBTServers) { + this.panel.left.tree("collapse", BTServersNode.target); } // Delete the server that no longer exists @@ -1380,7 +1415,7 @@ var system = { system.appendTreeNode(node, [{ id: "seedwait", text: text, - iconCls: "icon-wait" + iconCls: "iconfont tr-icon-wait" }]); } } else { @@ -1404,7 +1439,7 @@ var system = { system.appendTreeNode(node, [{ id: "checkwait", text: text, - iconCls: "icon-wait" + iconCls: "iconfont tr-icon-wait" }]); } } else { @@ -1428,7 +1463,7 @@ var system = { system.appendTreeNode(node, [{ id: "downloadwait", text: text, - iconCls: "icon-wait" + iconCls: "iconfont tr-icon-wait" }]); } } else { @@ -1528,9 +1563,9 @@ var system = { $("#status_uploadspeed").html(formatSize(data["uploadSpeed"], false, "speed")); system.serverSessionStats = data; if (data["torrentCount"] == 0) { - var parentNode = system.panel.left.tree("find", "servers"); - if (parentNode) { - system.panel.left.tree('remove', parentNode.target); + var serversNode = system.panel.left.tree("find", "servers"); + if (serversNode) { + system.panel.left.tree('remove', serversNode.target); } system.updateTreeNodeText("torrent-all", system.lang.tree.all); } @@ -2016,7 +2051,7 @@ var system = { this.appendTreeNode("torrent-all", [{ id: "search-result", text: text, - iconCls: "icon-search" + iconCls: "iconfont tr-icon-search" }]); node = this.panel.left.tree("find", "search-result"); } else { @@ -2417,7 +2452,8 @@ var system = { if (!node) { this.appendTreeNode(parentkey, [{ id: key, - text: text + text: text, + iconCls: "iconfont tr-icon-file" }]); if (parentkey != rootkey) { node = this.panel.left.tree("find", parentkey); diff --git a/src/tr-web-control/script/transmission.torrents.js b/src/tr-web-control/script/transmission.torrents.js index bb01c12..79f8bce 100644 --- a/src/tr-web-control/script/transmission.torrents.js +++ b/src/tr-web-control/script/transmission.torrents.js @@ -254,7 +254,8 @@ transmission.torrents = { count: 0, torrents: new Array(), size: 0, - connected: true + connected: true, + isBT: (trackerStats.length>1) }; tracker = transmission.trackers[id]; } diff --git a/src/tr-web-control/template/dialog-about.html b/src/tr-web-control/template/dialog-about.html index 630d5cf..cec3250 100644 --- a/src/tr-web-control/template/dialog-about.html +++ b/src/tr-web-control/template/dialog-about.html @@ -1,3 +1,15 @@ +
@@ -5,10 +17,13 @@
Transmission
Web Control
Copyright © 2012-2018 栽培者
-
+
+ +
+