Merge pull request #195 from ronggang/issue-174

Fixed #174
This commit is contained in:
栽培者 2018-04-03 10:58:42 +08:00 committed by GitHub
commit fefe176867
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 19 deletions

View File

@ -88,12 +88,12 @@ b[0]);system.currentTorrentId!=0&&$.each(b[0],function(c,d){var e=false,f=false,
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");
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"});system.loadCount==0&&system.initUIStatus();system.loadCount++})},appendFolder:function(a){if(a){var b="folders";a=a.replace(/\\/g,"/").split("/");var c="folders-",d;for(d in a){var e=a[d];if(e!=""){var f=this.B64.encode(e);
c+=f.replace(/[+|\/|=]/g,"0");f=this.panel.left.tree("find",c);var g=transmission.torrents.folders[c];e=e+this.showNodeMoreInfos(g.count,g.size);if(f)this.updateTreeNodeText(c,e);else{this.appendTreeNode(b,[{id:c,text:e,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'<a href="'+b+'" target="_blank">'+b+"</a>"})},
readConfig:function(){this.readUserConfig();var a=this.getStorageData(this.configHead+".system");if(a)this.config=$.extend(true,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,d){if(window.FileReader){var e=$("input[id='"+a+"']")[0].files;$.each(e,function(f,g){transmission.addTorrentFromFile(g,b,c,d,e.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.update){$("#area-update-infos").show();$("#msg-updateInfos").html(a.update+" -> "+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,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"))})});
c+=f.replace(/[+|\/|=]/g,"0");f=this.panel.left.tree("find",c);var g=transmission.torrents.folders[c];if(g){e=e+this.showNodeMoreInfos(g.count,g.size);if(f)this.updateTreeNodeText(c,e);else{this.appendTreeNode(b,[{id:c,text:e,iconCls:"iconfont tr-icon-file"}]);if(b!="folders"){f=this.panel.left.tree("find",b);this.panel.left.tree("collapse",f.target)}}b=c}else{this.debug("appendFolder:key",c);this.debug("appendFolder:name",e);this.debug("appendFolder:node",f)}}}}},replaceURI:function(a){return a.replace(/(http|https|ftp):\/\/([^/:]+)(:\d*)?([^# ]*)/ig,
function(b){return'<a href="'+b+'" target="_blank">'+b+"</a>"})},readConfig:function(){this.readUserConfig();var a=this.getStorageData(this.configHead+".system");if(a)this.config=$.extend(true,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,d){if(window.FileReader){var e=$("input[id='"+a+"']")[0].files;$.each(e,function(f,g){transmission.addTorrentFromFile(g,b,c,d,e.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.update){$("#area-update-infos").show();$("#msg-updateInfos").html(a.update+" -> "+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,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(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};

View File

@ -2606,6 +2606,7 @@ var system = {
key += _key.replace(/[+|\/|=]/g,"0");
var node = this.panel.left.tree("find", key);
var folderinfos = transmission.torrents.folders[key];
if (folderinfos) {
var text = name + this.showNodeMoreInfos(folderinfos.count, folderinfos.size);
if (!node) {
@ -2622,6 +2623,11 @@ var system = {
this.updateTreeNodeText(key, text);
}
parentkey = key;
} else {
this.debug("appendFolder:key", key);
this.debug("appendFolder:name", name);
this.debug("appendFolder:node", node);
}
}
},
replaceURI: function (text) {