mirror of
https://github.com/ronggang/transmission-web-control.git
synced 2025-04-12 18:30:55 +00:00
parent
d6fee50d20
commit
5016179e9e
117
src/tr-web-control/script/min/system.min.js
vendored
117
src/tr-web-control/script/min/system.min.js
vendored
|
@ -1,4 +1,4 @@
|
|||
var system={version:"1.5.1 update-1",rootPath:"tr-web-control/",codeupdate:"20180329",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,theme:"default",showBTServers:false,ui:{status:{tree:{},layout:{main:{},body:{},left:{}},panel:{}}}},storageKeys:{dictionary:{folders:"dictionary.folders"}},dictionary:{folders:null},
|
||||
var system={version:"1.5.1 update-2",rootPath:"tr-web-control/",codeupdate:"20180330",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,theme:"default",showBTServers:false,ui:{status:{tree:{},layout:{main:{},body:{},left:{}},panel:{}}}},storageKeys:{dictionary:{folders:"dictionary.folders"}},dictionary:{folders:null},
|
||||
checkUpdateScript:"https://raw.githubusercontent.com/ronggang/twc-release/master/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").hide(),body:$("#m_body"),layout_body:$("#layout_body"),layout_left:$("#layout_left"),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?
|
||||
|
@ -27,62 +27,62 @@ true)},onSelect:function(i,j){c!=-1&&system.control.torrentlist.datagrid("unsele
|
|||
i;system.userConfig.torrentList.sortOrder=j;system.saveUserConfig()},onRowContextMenu:function(i,j){system.checkedRows.length==0&&system.control.torrentlist.datagrid("checkRow",j);i.preventDefault();system.showContextMenu("torrent-list",i)},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(i){i.preventDefault();b||a();b.menu("show",{left:i.pageX,top:i.pageY})}})},"json")},resetTorrentListFieldsUserConfig:function(a){var b={};$.each(this.userConfig.torrentList.fields,function(c,d){b[d.field]=d});this.userConfig.torrentList.fields=[];$.each(a,function(c,d){var e=$.extend({},b[d.field]);e.width=d.width;e.hidden=d.hidden;system.userConfig.torrentList.fields.push(e)})},showContextMenu:function(a,b){var c=this.contextMenus[a];if(c)c.empty();
|
||||
else{c=$("<div/>").attr("class","easyui-menu").css({"min-width":"180px"}).appendTo(this.panel.main);this.contextMenus[a]=c;c.menu()}var d=null;switch(a){case "torrent-list":d=["start","pause","-","rename","remove","recheck","-","morepeers","changeDownloadDir","copyPath","-","menu-queue-move-top","menu-queue-move-up","menu-queue-move-down","menu-queue-move-bottom"];var e=this.panel.toolbar,f;for(f in d){var g=d[f];if(g=="-")$("<div class='menu-sep'></div>").appendTo(c);else{var h=e.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:e.find("#toolbar_queue").linkbutton("options").disabled,onclick:function(){$("#"+$(this).attr("id")).click()}})}h=null}}}c.menu("show",
|
||||
{left:b.pageX,top:b.pageY});d=c=null},checkTorrentRow:function(a,b){this.checkedRows=this.control.torrentlist.datagrid("getChecked");this.showCheckedInStatus();if(a=="all"){if(this.control.torrentlist.datagrid("getRows").length!=0){$("#toolbar_start, #toolbar_pause, #toolbar_remove, #toolbar_recheck, #toolbar_changeDownloadDir,#toolbar_morepeers,#toolbar_copyPath",this.panel.toolbar).linkbutton({disabled:b});$("#toolbar_rename, #toolbar_morepeers",this.panel.toolbar).linkbutton({disabled:true});this.panel.toolbar.find("#toolbar_queue").menubutton("disable")}}else if(this.checkedRows.length==
|
||||
0){$("#toolbar_start, #toolbar_pause, #toolbar_rename, #toolbar_remove, #toolbar_recheck, #toolbar_changeDownloadDir,#toolbar_morepeers,#toolbar_copyPath",this.panel.toolbar).linkbutton({disabled:true});this.panel.toolbar.find("#toolbar_queue").menubutton("disable")}else if(this.checkedRows.length==1){$("#toolbar_remove, #toolbar_rename, #toolbar_changeDownloadDir,#toolbar_copyPath",this.panel.toolbar).linkbutton({disabled:false});this.panel.toolbar.find("#toolbar_queue").menubutton("enable");switch(transmission.torrents.all[b.id].status){case transmission._status.stopped:this.panel.toolbar.find("#toolbar_start, #toolbar_recheck").linkbutton({disabled:false});
|
||||
this.panel.toolbar.find("#toolbar_pause, #toolbar_morepeers").linkbutton({disabled:true});break;case transmission._status.check:case transmission._status.checkwait:this.panel.toolbar.find("#toolbar_start, #toolbar_pause, #toolbar_recheck, #toolbar_morepeers").linkbutton({disabled:true});break;default:this.panel.toolbar.find("#toolbar_start, #toolbar_recheck").linkbutton({disabled:true});this.panel.toolbar.find("#toolbar_pause, #toolbar_morepeers").linkbutton({disabled:false})}}else{$("#toolbar_start, #toolbar_pause, #toolbar_remove, #toolbar_recheck, #toolbar_changeDownloadDir,#toolbar_copyPath",
|
||||
this.panel.toolbar).linkbutton({disabled:false});$("#toolbar_rename, #toolbar_morepeers",this.panel.toolbar).linkbutton({disabled:true});this.panel.toolbar.find("#toolbar_queue").menubutton("disable")}},showCheckedInStatus:function(){if(this.checkedRows.length>0){this.panel.status_text.empty();this.showStatus(undefined,0);var a=[],b=this.lang.system.status.checked.replace("%n",this.checkedRows.length),c=[];$("<div style='padding: 5px;'/>").html(b).appendTo(this.panel.status_text);for(b=0;b<this.checkedRows.length;b++){var d=
|
||||
this.checkedRows[b];a.push({value:b,text:b+1+". "+d.name});$.inArray(d.downloadDir,c)===-1&&c.push(d.downloadDir)}$("<div/>").appendTo(this.panel.status_text).datalist({data:a});$(".datalist>.panel-body",this.panel.status_text).css({border:0});$("#button-cancel-checked").show();$("#clipboard-source").val(c.join("\n"))}else{$("#button-cancel-checked").hide();this.panel.status_text.empty();$("#clipboard-source").val("")}},initToolbar:function(){this.panel.toolbar.find("#toolbar_label_reload_time").html(this.lang.toolbar["reload-time"]);
|
||||
this.panel.toolbar.find("#toolbar_label_reload_time_unit").html(this.lang.toolbar["reload-time-unit"]);this.panel.toolbar.find("#toolbar_reload_time").numberspinner({value:this.config.reloadStep/1E3,min:3,disabled:!this.config.autoReload,onChange:function(){var a=this.value;if($.isNumeric(a)){system.config.reloadStep=a*1E3;system.saveConfig()}}});this.panel.toolbar.find("#toolbar_autoreload").linkbutton({text:this.config.autoReload?this.lang.toolbar["autoreload-enabled"]:this.lang.toolbar["autoreload-disabled"],
|
||||
iconCls:this.config.autoReload?"icon-enabled":"icon-disabled"}).attr("title",this.config.autoReload?this.lang.toolbar.tip["autoreload-disabled"]:this.lang.toolbar.tip["autoreload-enabled"]).click(function(){if(system.config.autoReload){system.config.autoReload=false;clearTimeout(system.autoReloadTimer);system.panel.toolbar.find("#toolbar_reload_time").numberspinner("disable")}else{system.config.autoReload=true;system.reloadData();system.panel.toolbar.find("#toolbar_reload_time").numberspinner("enable")}system.saveConfig();
|
||||
$(this).linkbutton({text:system.config.autoReload?system.lang.toolbar["autoreload-enabled"]:system.lang.toolbar["autoreload-disabled"],iconCls:system.config.autoReload?"icon-enabled":"icon-disabled"}).attr("title",system.config.autoReload?system.lang.toolbar.tip["autoreload-disabled"]:system.lang.toolbar.tip["autoreload-enabled"])});this.panel.toolbar.find("#toolbar_add_torrents").linkbutton({text:this.lang.toolbar["add-torrent"],disabled:false}).attr("title",this.lang.toolbar.tip["add-torrent"]).click(function(){system.openDialogFromTemplate({id:"dialog-torrent-add",
|
||||
options:{title:system.lang.toolbar["add-torrent"],width:620,height:400,resizable:true}})});this.panel.toolbar.find("#toolbar_start_all").linkbutton({disabled:false}).attr("title",this.lang.toolbar.tip["start-all"]).click(function(){var a=$(this),b=a.linkbutton("options").iconCls;a.linkbutton({disabled:true,iconCls:"icon-loading"});transmission.exec({method:"torrent-start"},function(){a.linkbutton({iconCls:b,disabled:false});a=null})});this.panel.toolbar.find("#toolbar_pause_all").linkbutton({disabled:false}).attr("title",
|
||||
this.lang.toolbar.tip["pause-all"]).click(function(){var a=$(this),b=a.linkbutton("options").iconCls;a.linkbutton({disabled:true,iconCls:"icon-loading"});transmission.exec({method:"torrent-stop"},function(){a.linkbutton({iconCls:b,disabled:false});a=null})});this.panel.toolbar.find("#toolbar_start").linkbutton({disabled:true}).attr("title",this.lang.toolbar.tip.start).click(function(){system.changeSelectedTorrentStatus("start",$(this))});this.panel.toolbar.find("#toolbar_pause").linkbutton({disabled:true}).attr("title",
|
||||
this.lang.toolbar.tip.pause).click(function(){system.changeSelectedTorrentStatus("stop",$(this))});this.panel.toolbar.find("#toolbar_recheck").linkbutton({disabled:true}).attr("title",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==
|
||||
"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:680,height:450,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"]});this.panel.toolbar.find("#toolbar_copyPath").linkbutton().attr("title",this.lang.toolbar.tip["copy-path-to-clipboard"])},
|
||||
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();setTimeout(function(){system.initUIStatus()},
|
||||
300)})},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(d){var e=[],f;for(f in d)e.push(d[f].id);d=transmission.torrents.getErrorIds(e,true);
|
||||
d.length>0?transmission.torrents.getallids(function(){system.resetTorrentInfos(c)},d):system.resetTorrentInfos(c)},a,b)}},resetTorrentInfos:function(a){var b=this.currentTorrentId,c=this.panel.left.tree("find","servers");if(c){var d=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 e=this.panel.left.tree("find","btservers"),f=e?e.state:
|
||||
"close",g;for(g in transmission.trackers){var h=transmission.trackers[g];if(h.isBT){if(!system.config.showBTServers)continue;if(!e){this.appendTreeNode(c,[{id:"btservers",text:"BT",state:"open",iconCls:"iconfont tr-icon-bt"}]);e=this.panel.left.tree("find","btservers")}}var i=system.panel.left.tree("find",h.nodeid),j=h.name+this.showNodeMoreInfos(h.count,h.size);i?system.updateTreeNodeText(h.nodeid,j,h.connected?"iconfont tr-icon-server":"iconfont tr-icon-server-error"):system.appendTreeNode(h.isBT?
|
||||
e:c,[{id:h.nodeid,text:j,iconCls:h.connected?"iconfont tr-icon-server":"iconfont tr-icon-server-error"}]);a.trackers[h.nodeid]=null}d=="closed"&&this.panel.left.tree("collapse",c.target);system.config.showBTServers&&e&&f=="closed"&&this.panel.left.tree("collapse",e.target);for(g in a.trackers)(h=a.trackers[g])&&system.removeTreeNode(h.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]){i=system.panel.left.tree("find","sending");c=system.panel.left.tree("getChildren",i.target);j=system.lang.tree.wait+
|
||||
this.showNodeMoreInfos(transmission.torrents.status[transmission._status.seedwait].length);c.length>0?system.updateTreeNodeText(c[0].id,j):system.appendTreeNode(i,[{id:"seedwait",text:j,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]){i=system.panel.left.tree("find","check");c=system.panel.left.tree("getChildren",i.target);j=system.lang.tree.wait+this.showNodeMoreInfos(transmission.torrents.status[transmission._status.checkwait].length);c.length>0?system.updateTreeNodeText(c[0].id,j):system.appendTreeNode(i,[{id:"checkwait",text:j,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]){i=system.panel.left.tree("find","downloading");c=system.panel.left.tree("getChildren",i.target);j=system.lang.tree.wait+this.showNodeMoreInfos(transmission.torrents.status[transmission._status.downloadwait].length);
|
||||
c.length>0?system.updateTreeNodeText(c[0].id,j):system.appendTreeNode(i,[{id:"downloadwait",text:j,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));
|
||||
i=system.panel.left.tree("getSelected");if(i!=null){j=system.control.torrentlist.datagrid("options").pageNumber;system.loadTorrentToList({node:i,page:j})}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(l,k){switch(k){case "uploadedBytes":case "downloadedBytes":system.updateTreeNodeText(k,system.lang.tree.statistics[k]+formatSize(system.serverSessionStats["cumulative-stats"][k]));system.updateTreeNodeText("current-"+k,system.lang.tree.statistics[k]+formatSize(system.serverSessionStats["current-stats"][k]));break;case "secondsActive":system.updateTreeNodeText(k,system.lang.tree.statistics[k]+getTotalTime(system.serverSessionStats["cumulative-stats"][k]*
|
||||
1E3));system.updateTreeNodeText("current-"+k,system.lang.tree.statistics[k]+getTotalTime(system.serverSessionStats["current-stats"][k]*1E3));break;default:system.updateTreeNodeText(k,system.lang.tree.statistics[k]+system.serverSessionStats["cumulative-stats"][k]);system.updateTreeNodeText("current-"+k,system.lang.tree.statistics[k]+system.serverSessionStats["current-stats"][k])}});for(g in transmission.torrents.folders)a.folders[transmission.torrents.folders[g].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=" <span class='nav-torrents-number'>("+a+")</span>";if(b>0)c+="<span class='nav-total-size'>["+formatSize(b)+"]</span>";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:""},d=this.panel.left.data("currentNodeId");if(d!=a.node.id){this.control.torrentlist.datagrid("uncheckAll");this.control.torrentlist.datagrid({pageNumber:1});d=a.node.id}this.panel.left.data("currentNodeId",d);switch(c.id){case "servers":case "btservers":b=a.node.id=="btservers"?transmission.torrents.btItems: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;case "btservers":b=transmission.torrents.btItems;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 e in b){if(!b[e])return;c=this.lang.torrent["status-text"][b[e].status];parseFloat(b[e].percentDone*100).toFixed(2);c==transmission._status.check&&parseFloat(b[e].recheckProgress*100).toFixed(2);if(b[e].error!=0)c="<span class='text-status-error'>"+c+"</span>";else if(b[e].warning)c=
|
||||
"<span class='text-status-warning' title='"+b[e].warning+"'>"+c+"</span>";d={};d=$.extend(d,b[e]);d.status=c;d.statusCode=b[e].status;d.completeSize=Math.max(0,b[e].totalSize-b[e].leftUntilDone);d.leecherCount=b[e].leecher;d.seederCount=b[e].seeder;a.push(d)}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"),
|
||||
d=null;if(c.sortName){d=c.sortName;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:d,sortOrder:c.sortOrder}).datagrid("loadData",a);else{this.control.torrentlist.datagrid("getData").originalRows=a;d=(c.pageNumber-1)*parseInt(c.pageSize);c=d+parseInt(c.pageSize);a=a.slice(d,c);c={};d={};for(var e in transmission.torrents.recently){var f=
|
||||
transmission.torrents.recently[e];c[f.id]=true}for(e in a){f=a[e];d[f.id]=f}var g={};for(e=b.length-1;e>=0;e--){f=b[e];var h=d[f.id];if(h)if(c[f.id]){this.control.torrentlist.datagrid("updateRow",{index:e,row:h});g[f.id]=f}else if(transmission.torrents.removed)if(transmission.torrents.removed.length>0&&$.inArray(f.id,transmission.torrents.removed)!=-1)this.control.torrentlist.datagrid("deleteRow",e);else g[f.id]=f;else g[f.id]=f;else this.control.torrentlist.datagrid("deleteRow",e)}for(e in a){f=
|
||||
a[e];g[f.id]||this.control.torrentlist.datagrid("appendRow",f)}}}},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'<span class="'+b+'" title="'+c+'">'+a.name+"</span>"},getTorrentProgressBar:function(a,b){a+="%";var c="",d=0;d=typeof b=="object"?b.status:b;switch(d){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'<div class="torrent-progress" title="'+a+'"><div class="torrent-progress-text">'+a+'</div><div class="torrent-progress-bar '+c+'" style="width:'+a+';"></div></div>'},
|
||||
addTorrentsToServer:function(a,b,c,d){var e=b-a.length,f=a.shift();if(f){this.showStatus(this.lang.system.status.queue+(e+1)+"/"+b+"<br/>"+f,0);transmission.addTorrentFromUrl(f,d,c,function(){system.addTorrentsToServer(a,b,c,d)})}else{this.showStatus(this.lang.system.status.queuefinish);this.getServerStatus()}},changeSelectedTorrentStatus:function(a,b,c){var d=this.control.torrentlist.datagrid("getChecked"),e=[];a||(a="start");for(var f in d)e.push(d[f].id);c||(c="torrent-"+a);if(e.length>0){if(b){var g=
|
||||
b.linkbutton("options").iconCls;b.linkbutton({disabled:true,iconCls:"icon-loading"})}transmission.exec({method:c,arguments:{ids:e}},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(d){b.infoIsLoading=false;if(d!=null){jQuery.extend(b,d[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 d=c.datagrid("getRows"),e=c.datagrid("options"),f=null;if(e.sortName){f=e.sortName;b=b.sort(arrayObjectSort(f,e.sortOrder))}if(d.length==0||b.length!=c.datagrid("getData").total&&b.length>e.pageSize)c.datagrid({loadFilter:pagerFilter,pageNumber:1,sortName:f,sortOrder:e.sortOrder}).datagrid("loadData",b);else{c.datagrid("getData").originalRows=b;f=(e.pageNumber-1)*parseInt(e.pageSize);
|
||||
e=f+parseInt(e.pageSize);b=b.slice(f,e);e={};for(var g in b){f=b[g];e[f[a]]=f}for(g=d.length-1;g>=0;g--){f=d[g];(b=e[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 "remainingTime":c=c>=31536E8?"∞":getTotalTime(c);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,d=[],e=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);d.push({name:g.name==a.name?g.name:g.name.substr(e),index:f,bytesCompleted:h.bytesCompleted,percentDone:system.getTorrentProgressBar(i,transmission._status.download),length:g.length,wanted:system.lang.torrent.attribute.status[h.wanted],priority:'<span class="iconlabel icon-flag-'+h.priority+'">'+system.lang.torrent.attribute.priority[h.priority]+"</span>"})}this.updateCurrentPageDatas("index",d,system.panel.attribute.find("#torrent-files-table"))},
|
||||
fillTorrentServerList:function(a){var b=a.trackerStats,c=[],d;for(d in b){var e=b[d],f={},g;for(g in e)switch(g){case "lastAnnounceTime":case "nextAnnounceTime":f[g]=formatLongTime(e[g]);break;case "lastAnnounceSucceeded":case "lastAnnounceTimedOut":f[g]=system.lang.torrent.attribute.status[e[g]];break;default:f[g]=e[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 d=a[c],e={},f;for(f in d)e[f]=d[f];d=parseFloat(d.progress*100).toFixed(2);e.progress=system.getTorrentProgressBar(d,transmission._status.download);b.push(e)}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],
|
||||
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:e.find("#toolbar_queue").linkbutton("options").disabled,onclick:function(){$("#"+$(this).attr("id")).click()}})}h=null}}d=
|
||||
$("#copyPath",c);d.attr({"data-clipboard-action":"copy","data-clipboard-target":"#clipboard-source"});new ClipboardJS(d.get(0))}c.menu("show",{left:b.pageX,top:b.pageY});d=c=null},checkTorrentRow:function(a,b){this.checkedRows=this.control.torrentlist.datagrid("getChecked");this.showCheckedInStatus();if(a=="all"){if(this.control.torrentlist.datagrid("getRows").length!=0){$("#toolbar_start, #toolbar_pause, #toolbar_remove, #toolbar_recheck, #toolbar_changeDownloadDir,#toolbar_morepeers,#toolbar_copyPath",
|
||||
this.panel.toolbar).linkbutton({disabled:b});$("#toolbar_rename, #toolbar_morepeers",this.panel.toolbar).linkbutton({disabled:true});this.panel.toolbar.find("#toolbar_queue").menubutton("disable")}}else if(this.checkedRows.length==0){$("#toolbar_start, #toolbar_pause, #toolbar_rename, #toolbar_remove, #toolbar_recheck, #toolbar_changeDownloadDir,#toolbar_morepeers,#toolbar_copyPath",this.panel.toolbar).linkbutton({disabled:true});this.panel.toolbar.find("#toolbar_queue").menubutton("disable")}else if(this.checkedRows.length==
|
||||
1){$("#toolbar_remove, #toolbar_rename, #toolbar_changeDownloadDir,#toolbar_copyPath",this.panel.toolbar).linkbutton({disabled:false});this.panel.toolbar.find("#toolbar_queue").menubutton("enable");switch(transmission.torrents.all[b.id].status){case transmission._status.stopped:this.panel.toolbar.find("#toolbar_start, #toolbar_recheck").linkbutton({disabled:false});this.panel.toolbar.find("#toolbar_pause, #toolbar_morepeers").linkbutton({disabled:true});break;case transmission._status.check:case transmission._status.checkwait:this.panel.toolbar.find("#toolbar_start, #toolbar_pause, #toolbar_recheck, #toolbar_morepeers").linkbutton({disabled:true});
|
||||
break;default:this.panel.toolbar.find("#toolbar_start, #toolbar_recheck").linkbutton({disabled:true});this.panel.toolbar.find("#toolbar_pause, #toolbar_morepeers").linkbutton({disabled:false})}}else{$("#toolbar_start, #toolbar_pause, #toolbar_remove, #toolbar_recheck, #toolbar_changeDownloadDir,#toolbar_copyPath",this.panel.toolbar).linkbutton({disabled:false});$("#toolbar_rename, #toolbar_morepeers",this.panel.toolbar).linkbutton({disabled:true});this.panel.toolbar.find("#toolbar_queue").menubutton("disable")}},
|
||||
showCheckedInStatus:function(){if(this.checkedRows.length>0){this.panel.status_text.empty();this.showStatus(undefined,0);var a=[],b=this.lang.system.status.checked.replace("%n",this.checkedRows.length),c=[];$("<div style='padding: 5px;'/>").html(b).appendTo(this.panel.status_text);for(b=0;b<this.checkedRows.length;b++){var d=this.checkedRows[b];a.push({value:b,text:b+1+". "+d.name});$.inArray(d.downloadDir,c)===-1&&c.push(d.downloadDir)}$("<div/>").appendTo(this.panel.status_text).datalist({data:a});
|
||||
$(".datalist>.panel-body",this.panel.status_text).css({border:0});$("#button-cancel-checked").show();$("#clipboard-source").val(c.join("\n"))}else{$("#button-cancel-checked").hide();this.panel.status_text.empty();$("#clipboard-source").val("")}},initToolbar:function(){this.panel.toolbar.find("#toolbar_label_reload_time").html(this.lang.toolbar["reload-time"]);this.panel.toolbar.find("#toolbar_label_reload_time_unit").html(this.lang.toolbar["reload-time-unit"]);this.panel.toolbar.find("#toolbar_reload_time").numberspinner({value:this.config.reloadStep/
|
||||
1E3,min:3,disabled:!this.config.autoReload,onChange:function(){var a=this.value;if($.isNumeric(a)){system.config.reloadStep=a*1E3;system.saveConfig()}}});this.panel.toolbar.find("#toolbar_autoreload").linkbutton({text:this.config.autoReload?this.lang.toolbar["autoreload-enabled"]:this.lang.toolbar["autoreload-disabled"],iconCls:this.config.autoReload?"icon-enabled":"icon-disabled"}).attr("title",this.config.autoReload?this.lang.toolbar.tip["autoreload-disabled"]:this.lang.toolbar.tip["autoreload-enabled"]).click(function(){if(system.config.autoReload){system.config.autoReload=
|
||||
false;clearTimeout(system.autoReloadTimer);system.panel.toolbar.find("#toolbar_reload_time").numberspinner("disable")}else{system.config.autoReload=true;system.reloadData();system.panel.toolbar.find("#toolbar_reload_time").numberspinner("enable")}system.saveConfig();$(this).linkbutton({text:system.config.autoReload?system.lang.toolbar["autoreload-enabled"]:system.lang.toolbar["autoreload-disabled"],iconCls:system.config.autoReload?"icon-enabled":"icon-disabled"}).attr("title",system.config.autoReload?
|
||||
system.lang.toolbar.tip["autoreload-disabled"]:system.lang.toolbar.tip["autoreload-enabled"])});this.panel.toolbar.find("#toolbar_add_torrents").linkbutton({text:this.lang.toolbar["add-torrent"],disabled:false}).attr("title",this.lang.toolbar.tip["add-torrent"]).click(function(){system.openDialogFromTemplate({id:"dialog-torrent-add",options:{title:system.lang.toolbar["add-torrent"],width:620,height:400,resizable:true}})});this.panel.toolbar.find("#toolbar_start_all").linkbutton({disabled:false}).attr("title",
|
||||
this.lang.toolbar.tip["start-all"]).click(function(){var a=$(this),b=a.linkbutton("options").iconCls;a.linkbutton({disabled:true,iconCls:"icon-loading"});transmission.exec({method:"torrent-start"},function(){a.linkbutton({iconCls:b,disabled:false});a=null})});this.panel.toolbar.find("#toolbar_pause_all").linkbutton({disabled:false}).attr("title",this.lang.toolbar.tip["pause-all"]).click(function(){var a=$(this),b=a.linkbutton("options").iconCls;a.linkbutton({disabled:true,iconCls:"icon-loading"});
|
||||
transmission.exec({method:"torrent-stop"},function(){a.linkbutton({iconCls:b,disabled:false});a=null})});this.panel.toolbar.find("#toolbar_start").linkbutton({disabled:true}).attr("title",this.lang.toolbar.tip.start).click(function(){system.changeSelectedTorrentStatus("start",$(this))});this.panel.toolbar.find("#toolbar_pause").linkbutton({disabled:true}).attr("title",this.lang.toolbar.tip.pause).click(function(){system.changeSelectedTorrentStatus("stop",$(this))});this.panel.toolbar.find("#toolbar_recheck").linkbutton({disabled:true}).attr("title",
|
||||
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=="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:680,height:450,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"]});this.panel.toolbar.find("#toolbar_copyPath").linkbutton().attr("title",this.lang.toolbar.tip["copy-path-to-clipboard"])},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();setTimeout(function(){system.initUIStatus()},300)})},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(d){var e=[],f;for(f in d)e.push(d[f].id);d=transmission.torrents.getErrorIds(e,true);d.length>0?transmission.torrents.getallids(function(){system.resetTorrentInfos(c)},d):system.resetTorrentInfos(c)},a,b)}},resetTorrentInfos:function(a){var b=this.currentTorrentId,c=this.panel.left.tree("find","servers");if(c){var d=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 e=this.panel.left.tree("find","btservers"),f=e?e.state:"close",g;for(g in transmission.trackers){var h=transmission.trackers[g];if(h.isBT){if(!system.config.showBTServers)continue;if(!e){this.appendTreeNode(c,[{id:"btservers",text:"BT",state:"open",iconCls:"iconfont tr-icon-bt"}]);e=this.panel.left.tree("find","btservers")}}var i=system.panel.left.tree("find",
|
||||
h.nodeid),j=h.name+this.showNodeMoreInfos(h.count,h.size);i?system.updateTreeNodeText(h.nodeid,j,h.connected?"iconfont tr-icon-server":"iconfont tr-icon-server-error"):system.appendTreeNode(h.isBT?e:c,[{id:h.nodeid,text:j,iconCls:h.connected?"iconfont tr-icon-server":"iconfont tr-icon-server-error"}]);a.trackers[h.nodeid]=null}d=="closed"&&this.panel.left.tree("collapse",c.target);system.config.showBTServers&&e&&f=="closed"&&this.panel.left.tree("collapse",e.target);for(g in a.trackers)(h=a.trackers[g])&&
|
||||
system.removeTreeNode(h.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]){i=system.panel.left.tree("find","sending");c=system.panel.left.tree("getChildren",i.target);j=system.lang.tree.wait+this.showNodeMoreInfos(transmission.torrents.status[transmission._status.seedwait].length);c.length>0?system.updateTreeNodeText(c[0].id,j):system.appendTreeNode(i,[{id:"seedwait",text:j,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]){i=system.panel.left.tree("find","check");c=system.panel.left.tree("getChildren",i.target);j=system.lang.tree.wait+this.showNodeMoreInfos(transmission.torrents.status[transmission._status.checkwait].length);
|
||||
c.length>0?system.updateTreeNodeText(c[0].id,j):system.appendTreeNode(i,[{id:"checkwait",text:j,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]){i=
|
||||
system.panel.left.tree("find","downloading");c=system.panel.left.tree("getChildren",i.target);j=system.lang.tree.wait+this.showNodeMoreInfos(transmission.torrents.status[transmission._status.downloadwait].length);c.length>0?system.updateTreeNodeText(c[0].id,j):system.appendTreeNode(i,[{id:"downloadwait",text:j,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));i=system.panel.left.tree("getSelected");if(i!=null){j=system.control.torrentlist.datagrid("options").pageNumber;system.loadTorrentToList({node:i,page:j})}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(l,k){switch(k){case "uploadedBytes":case "downloadedBytes":system.updateTreeNodeText(k,system.lang.tree.statistics[k]+formatSize(system.serverSessionStats["cumulative-stats"][k]));system.updateTreeNodeText("current-"+
|
||||
k,system.lang.tree.statistics[k]+formatSize(system.serverSessionStats["current-stats"][k]));break;case "secondsActive":system.updateTreeNodeText(k,system.lang.tree.statistics[k]+getTotalTime(system.serverSessionStats["cumulative-stats"][k]*1E3));system.updateTreeNodeText("current-"+k,system.lang.tree.statistics[k]+getTotalTime(system.serverSessionStats["current-stats"][k]*1E3));break;default:system.updateTreeNodeText(k,system.lang.tree.statistics[k]+system.serverSessionStats["cumulative-stats"][k]);
|
||||
system.updateTreeNodeText("current-"+k,system.lang.tree.statistics[k]+system.serverSessionStats["current-stats"][k])}});for(g in transmission.torrents.folders)a.folders[transmission.torrents.folders[g].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=" <span class='nav-torrents-number'>("+a+")</span>";if(b>0)c+="<span class='nav-total-size'>["+
|
||||
formatSize(b)+"]</span>";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:""},d=this.panel.left.data("currentNodeId");if(d!=a.node.id){this.control.torrentlist.datagrid("uncheckAll");
|
||||
this.control.torrentlist.datagrid({pageNumber:1});d=a.node.id}this.panel.left.data("currentNodeId",d);switch(c.id){case "servers":case "btservers":b=a.node.id=="btservers"?transmission.torrents.btItems: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;case "btservers":b=transmission.torrents.btItems;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 e in b){if(!b[e])return;c=this.lang.torrent["status-text"][b[e].status];
|
||||
parseFloat(b[e].percentDone*100).toFixed(2);c==transmission._status.check&&parseFloat(b[e].recheckProgress*100).toFixed(2);if(b[e].error!=0)c="<span class='text-status-error'>"+c+"</span>";else if(b[e].warning)c="<span class='text-status-warning' title='"+b[e].warning+"'>"+c+"</span>";d={};d=$.extend(d,b[e]);d.status=c;d.statusCode=b[e].status;d.completeSize=Math.max(0,b[e].totalSize-b[e].leftUntilDone);d.leecherCount=b[e].leecher;d.seederCount=b[e].seeder;a.push(d)}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"),d=null;if(c.sortName){d=c.sortName;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:d,sortOrder:c.sortOrder}).datagrid("loadData",
|
||||
a);else{this.control.torrentlist.datagrid("getData").originalRows=a;d=(c.pageNumber-1)*parseInt(c.pageSize);c=d+parseInt(c.pageSize);a=a.slice(d,c);c={};d={};for(var e in transmission.torrents.recently){var f=transmission.torrents.recently[e];c[f.id]=true}for(e in a){f=a[e];d[f.id]=f}var g={};for(e=b.length-1;e>=0;e--){f=b[e];var h=d[f.id];if(h)if(c[f.id]){this.control.torrentlist.datagrid("updateRow",{index:e,row:h});g[f.id]=f}else if(transmission.torrents.removed)if(transmission.torrents.removed.length>
|
||||
0&&$.inArray(f.id,transmission.torrents.removed)!=-1)this.control.torrentlist.datagrid("deleteRow",e);else g[f.id]=f;else g[f.id]=f;else this.control.torrentlist.datagrid("deleteRow",e)}for(e in a){f=a[e];g[f.id]||this.control.torrentlist.datagrid("appendRow",f)}}}},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'<span class="'+b+'" title="'+c+'">'+a.name+
|
||||
"</span>"},getTorrentProgressBar:function(a,b){a+="%";var c="",d=0;d=typeof b=="object"?b.status:b;switch(d){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'<div class="torrent-progress" title="'+a+'"><div class="torrent-progress-text">'+a+'</div><div class="torrent-progress-bar '+c+'" style="width:'+a+';"></div></div>'},addTorrentsToServer:function(a,b,c,d){var e=b-a.length,f=a.shift();if(f){this.showStatus(this.lang.system.status.queue+(e+1)+"/"+b+"<br/>"+f,0);transmission.addTorrentFromUrl(f,d,c,function(){system.addTorrentsToServer(a,b,c,d)})}else{this.showStatus(this.lang.system.status.queuefinish);
|
||||
this.getServerStatus()}},changeSelectedTorrentStatus:function(a,b,c){var d=this.control.torrentlist.datagrid("getChecked"),e=[];a||(a="start");for(var f in d)e.push(d[f].id);c||(c="torrent-"+a);if(e.length>0){if(b){var g=b.linkbutton("options").iconCls;b.linkbutton({disabled:true,iconCls:"icon-loading"})}transmission.exec({method:c,arguments:{ids:e}},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(d){b.infoIsLoading=false;if(d!=null){jQuery.extend(b,d[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 d=c.datagrid("getRows"),e=c.datagrid("options"),f=null;if(e.sortName){f=e.sortName;b=b.sort(arrayObjectSort(f,e.sortOrder))}if(d.length==0||b.length!=c.datagrid("getData").total&&b.length>e.pageSize)c.datagrid({loadFilter:pagerFilter,
|
||||
pageNumber:1,sortName:f,sortOrder:e.sortOrder}).datagrid("loadData",b);else{c.datagrid("getData").originalRows=b;f=(e.pageNumber-1)*parseInt(e.pageSize);e=f+parseInt(e.pageSize);b=b.slice(f,e);e={};for(var g in b){f=b[g];e[f[a]]=f}for(g=d.length-1;g>=0;g--){f=d[g];(b=e[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 "remainingTime":c=c>=31536E8?"∞":getTotalTime(c);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,d=[],e=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);d.push({name:g.name==a.name?g.name:g.name.substr(e),index:f,bytesCompleted:h.bytesCompleted,percentDone:system.getTorrentProgressBar(i,transmission._status.download),length:g.length,wanted:system.lang.torrent.attribute.status[h.wanted],priority:'<span class="iconlabel icon-flag-'+h.priority+'">'+system.lang.torrent.attribute.priority[h.priority]+"</span>"})}this.updateCurrentPageDatas("index",
|
||||
d,system.panel.attribute.find("#torrent-files-table"))},fillTorrentServerList:function(a){var b=a.trackerStats,c=[],d;for(d in b){var e=b[d],f={},g;for(g in e)switch(g){case "lastAnnounceTime":case "nextAnnounceTime":f[g]=formatLongTime(e[g]);break;case "lastAnnounceSucceeded":case "lastAnnounceTimedOut":f[g]=system.lang.torrent.attribute.status[e[g]];break;default:f[g]=e[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 d=a[c],e={},f;for(f in d)e[f]=d[f];d=parseFloat(d.progress*100).toFixed(2);e.progress=system.getTorrentProgressBar(d,transmission._status.download);b.push(e)}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,d){var e=false,f=false,g=false;switch(c){case "seedIdleMode":case "seedRatioMode":if(d==0){f=false;e=true}g=true;case "downloadLimited":case "uploadLimited":if(d==true||d==1)f=true;system.panel.attribute.find("input[enabledof='"+c+"']").prop("disabled",!f);g&&system.panel.attribute.find("#"+c).prop("indeterminate",e).data("_tag",d);system.panel.attribute.find("#"+c).prop("checked",f);break;default:system.panel.attribute.find("#"+c).val(d);system.panel.attribute.find("#"+
|
||||
c).numberspinner("setValue",d)}})}})},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 d=parseFloat(b*100).toFixed(2);return system.getTorrentProgressBar(d,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'<span class="'+c+'">'+b+"</span>"};break;case "remainingTime":a.formatter=function(b){if(b>=31536E8)return"∞";return getTotalTime(b)}}},reloadData:function(){this.reloadSession();this.reloading=false;this.getServerStatus();this.reloading=false;this.reloadTorrentBaseInfos()},loadFolderList:function(a){this.removeTreeNode("folders-loading");
|
||||
|
@ -94,4 +94,5 @@ a.update){$("#area-update-infos").show();$("#msg-updateInfos").html(a.update+" -
|
|||
null){var b=a.id,c=a.options,d=a.datas,e=$("#"+b);if(e.length){e.dialog("open");d&&$.each(d,function(f,g){e.data(f,g)});e.dialog({content:system.templates[b]})}else{c=$.extend(true,{title:"",width:100,height:100,resizable:false,cache:true,content:"loading...",modal:true},c);$("<div/>").attr("id",b).appendTo(document.body).dialog(c);$.get(system.rootPath+"template/"+b+".html?time="+new Date,function(f){system.templates[b]=f;d&&$.each(d,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"),d=b.datagrid("getPager"),e=b.data("buttons");d.pagination({onSelectPage:function(g,h){c.pageNumber=g;c.pageSize=h;d.pagination("refresh",{pageNumber:g,pageSize:h});b.datagrid("loadData",a)},buttons:e});if(!a.originalRows)a.originalRows=a.rows;e=(c.pageNumber-1)*parseInt(c.pageSize);var f=e+parseInt(c.pageSize);a.rows=a.originalRows.slice(e,f);return a};
|
||||
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"),d=b.datagrid("getPager"),e=b.data("buttons");d.pagination({onSelectPage:function(h,i){c.pageNumber=h;c.pageSize=i;d.pagination("refresh",{pageNumber:h,pageSize:i});b.datagrid("loadData",a)},buttons:e});if(!a.originalRows)a.originalRows=a.rows;var f=(c.pageNumber-1)*parseInt(c.pageSize),g=f+parseInt(c.pageSize);a.rows=a.originalRows.slice(f,g);if(e&&e.length)for(f=
|
||||
0;f<e.length;f++){g=e[f];g.id&&g.title&&$("#"+g.id,d).attr("title",g.title)}return a};
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
// Current system global object
|
||||
var system = {
|
||||
version: "1.5.1 update-1",
|
||||
version: "1.5.1 update-2",
|
||||
rootPath: "tr-web-control/",
|
||||
codeupdate: "20180329",
|
||||
codeupdate: "20180330",
|
||||
configHead: "transmission-web-control",
|
||||
// default config, can be customized in config.js
|
||||
config: {
|
||||
|
@ -888,6 +888,14 @@ var system = {
|
|||
menu = null;
|
||||
}
|
||||
}
|
||||
// 设置剪切板组件,因为直接调用 click 不能执行相关操作
|
||||
var btn = $('#copyPath', parent);
|
||||
btn.attr({
|
||||
"data-clipboard-action": "copy",
|
||||
"data-clipboard-target": "#clipboard-source"
|
||||
});
|
||||
var clipboard = new ClipboardJS(btn.get(0));
|
||||
|
||||
break;
|
||||
}
|
||||
parent.menu("show", {
|
||||
|
@ -2816,5 +2824,15 @@ function pagerFilter(data) {
|
|||
var start = (opts.pageNumber - 1) * parseInt(opts.pageSize);
|
||||
var end = start + parseInt(opts.pageSize);
|
||||
data.rows = (data.originalRows.slice(start, end));
|
||||
|
||||
if (buttons && buttons.length) {
|
||||
for (var i=0;i<buttons.length;i++) {
|
||||
var button = buttons[i];
|
||||
if (button.id && button.title) {
|
||||
$("#"+button.id, pager).attr("title", button.title);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
|
@ -11,7 +11,8 @@
|
|||
<td class="title"><span id="torrent-attribute-label-downloadDir"></span></td>
|
||||
<td colspan="3">
|
||||
<span id="torrent-attribute-value-downloadDir"></span>
|
||||
<a id="torrent-attribute-config-button-changeDownloadDir" class="easyui-linkbutton" data-options="iconCls:'icon-folder-change',plain:true" href="javascript:void(0);"></a>
|
||||
<a id="torrent-attribute-config-button-changeDownloadDir" class="easyui-linkbutton" data-options="iconCls:'iconfont tr-icon-folder-change',plain:true" href="javascript:void(0);" system-tip-lang="toolbar.tip['change-download-dir']"></a>
|
||||
<a id="torrent-attribute-config-button-copyPath" class="easyui-linkbutton" data-options="iconCls:'iconfont tr-icon-clippy',plain:true" href="javascript:void(0);" data-clipboard-action="copy" data-clipboard-target="#torrent-attribute-value-downloadDir" system-tip-lang="toolbar.tip['copy-path-to-clipboard']"></a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -124,6 +125,9 @@
|
|||
<script type="text/javascript">
|
||||
(function(thisLayout){
|
||||
var labels = system.lang.torrent.attribute.label;
|
||||
system.resetLangText(thisLayout);
|
||||
var clipboard = new ClipboardJS('#torrent-attribute-config-button-copyPath');
|
||||
|
||||
$.each(labels, function(key, item){
|
||||
thisLayout.find("#torrent-attribute-label-"+key).html(item);
|
||||
});
|
||||
|
@ -241,18 +245,21 @@
|
|||
var buttons = [{
|
||||
id:"pager-button-allow",
|
||||
iconCls:'icon-allow',
|
||||
title: system.lang.torrent.attribute["tip"]["button-deny"],
|
||||
handler:function(){
|
||||
changeSelectedFilesWanted(true,$(this));
|
||||
}
|
||||
},'-',{
|
||||
id:"pager-button-deny",
|
||||
iconCls:'icon-deny',
|
||||
title: system.lang.torrent.attribute["tip"]["button-allow"],
|
||||
handler:function(){
|
||||
changeSelectedFilesWanted(false,$(this));
|
||||
}
|
||||
},'-',{
|
||||
id:"pager-button-priority",
|
||||
iconCls:'icon-flag-edit',
|
||||
title: system.lang.torrent.attribute["tip"]["button-priority"],
|
||||
handler:function(){
|
||||
priorityMenu.menu("show",$(this).offset());
|
||||
}
|
||||
|
@ -286,9 +293,9 @@
|
|||
buttons:buttons
|
||||
});
|
||||
|
||||
pager.find("#pager-button-allow").attr({"title":system.lang.torrent.attribute["tip"]["button-allow"],"alt":system.lang.torrent.attribute["tip"]["button-allow"]});
|
||||
pager.find("#pager-button-deny").attr({"title":system.lang.torrent.attribute["tip"]["button-deny"],"alt":system.lang.torrent.attribute["tip"]["button-deny"]});
|
||||
pager.find("#pager-button-priority").attr({"title":system.lang.torrent.attribute["tip"]["button-priority"],"alt":system.lang.torrent.attribute["tip"]["button-priority"]});
|
||||
// pager.find("#pager-button-allow").attr({"title":system.lang.torrent.attribute["tip"]["button-allow"],"alt":system.lang.torrent.attribute["tip"]["button-allow"]});
|
||||
// pager.find("#pager-button-deny").attr({"title":system.lang.torrent.attribute["tip"]["button-deny"],"alt":system.lang.torrent.attribute["tip"]["button-deny"]});
|
||||
// pager.find("#pager-button-priority").attr({"title":system.lang.torrent.attribute["tip"]["button-priority"],"alt":system.lang.torrent.attribute["tip"]["button-priority"]});
|
||||
},"json");
|
||||
|
||||
// 设置已选中的文件是否下载
|
||||
|
@ -406,18 +413,21 @@
|
|||
var buttons = [{
|
||||
id:"pager-button-trackerAdd",
|
||||
iconCls:'icon-tracker-add',
|
||||
title: system.lang.torrent.attribute["tip"]["button-tracker-add"],
|
||||
handler:function(){
|
||||
addTracker();
|
||||
}
|
||||
},'-',{
|
||||
id:"pager-button-trackerReplace",
|
||||
iconCls:'icon-tracker-edit',
|
||||
title: system.lang.torrent.attribute["tip"]["button-tracker-edit"],
|
||||
handler:function(){
|
||||
changeSelectedTracker($(this));
|
||||
}
|
||||
},'-',{
|
||||
id:"pager-button-trackerRemove",
|
||||
iconCls:'icon-tracker-remove',
|
||||
title: system.lang.torrent.attribute["tip"]["button-tracker-remove"],
|
||||
handler:function(){
|
||||
var tracker = serverlist.datagrid("getSelected");
|
||||
if (tracker)
|
||||
|
@ -553,8 +563,8 @@
|
|||
|
||||
$("<div/>").attr("id","dialog-torrent-changeDownloadDir").appendTo(document.body).dialog({
|
||||
title: system.lang.dialog["torrent-changeDownloadDir"].title,
|
||||
width: 520,
|
||||
height: 180,
|
||||
width: 600,
|
||||
height: 200,
|
||||
resizable: false,
|
||||
cache: true,
|
||||
content:"loading...",
|
||||
|
|
Loading…
Reference in New Issue
Block a user