diff --git a/src/tr-web-control/script/min/public.min.js b/src/tr-web-control/script/min/public.min.js index 4bc33d5..8969dd3 100644 --- a/src/tr-web-control/script/min/public.min.js +++ b/src/tr-web-control/script/min/public.min.js @@ -1,13 +1,10 @@ -String.prototype.getQueryString=function(name,split){if(split==undefined)split="\x26";var reg=new RegExp("(^|"+split+"|\\?)"+name+"\x3d([^"+split+"]*)("+split+"|$)"),r;if(r=this.match(reg))return unescape(r[2]);return null};String.prototype.right=function(len){return this.substr(-len)}; -Number.prototype.formatNumber=function(f){this.fStr=function(n,f,p){if(n==""||n==undefined)if(f==""||f==undefined)return"";else return f;var fc=s=r="",pos;if(!p){n=n.split("").reverse().join("");f=f.split("").reverse().join("")}for(var i=j=0;i1?this.fStr(n[0],f[0])+"."+this.fStr(n[1],f[1],1):this.fStr(n[0],f[0])}; -function getLocalTime(time){return(new Date(parseInt(time)*1E3)).toLocaleString().replace(/\u5e74|\u6708/g,"-").replace(/\u65e5/g," ")}function formatLongTime(time,formatString){var now=new Date(parseInt(time)*1E3);return formatDate(now)} -function formatDate(formatDate,formatString){if(!formatString)formatString="yyyy-mm-dd hh:nn:ss";if(formatDate instanceof Date){var months=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");var yyyy=formatDate.getFullYear();var yy=yyyy.toString().substring(2);var m=formatDate.getMonth()+1;var mm=m<10?"0"+m:m;var mmm=months[m];var d=formatDate.getDate();var dd=d<10?"0"+d:d;var h=formatDate.getHours();var hh=h<10?"0"+h:h;var n=formatDate.getMinutes();var nn=n<10?"0"+ -n:n;var s=formatDate.getSeconds();var ss=s<10?"0"+s:s;formatString=formatString.replace(/yyyy/i,yyyy);formatString=formatString.replace(/yy/i,yy);formatString=formatString.replace(/mmm/i,mmm);formatString=formatString.replace(/mm/i,mm);formatString=formatString.replace(/m/i,m);formatString=formatString.replace(/dd/i,dd);formatString=formatString.replace(/d/i,d);formatString=formatString.replace(/hh/i,hh);formatString=formatString.replace(/h/i,h);formatString=formatString.replace(/nn/i,nn);formatString= -formatString.replace(/n/i,n);formatString=formatString.replace(/ss/i,ss);formatString=formatString.replace(/s/i,s);return formatString}else return""} -function formatSize(bytes,zeroToEmpty,type){if(bytes==0)if(zeroToEmpty==true)return"";else if(type=="speed")return"0.00 KB/s";else return"0.00";var r="";var u="KB";if(bytes<1E3*1024){r=bytes/1024;u="KB"}else if(bytes<1E3*1048576){r=bytes/1048576;u="MB"}else if(bytes<1E3*1073741824){r=bytes/1073741824;u="GB"}else if(bytes<1E3*1099511627776){r=bytes/1099511627776;u="TB"}else{r=bytes/0x4000000000000;u="PB"}if(type=="speed")u+="/s";return r.formatNumber("###,###,###,###.00 ")+u} -function getHoursFromMinutes(minutes){return("00"+parseInt(minutes/60,10)).right(2)+":"+("00"+minutes%60).right(2)}function getMinutesFromHours(hours){return parseInt(hours.split(":")[0],10)*60+parseInt(hours.split(":")[1],10)} -function getTotalTime(time,format){if(!format)format="%dd %hh %mm %ss ";var days=Math.floor(time/(24*3600*1E3));var leave1=time%(24*3600*1E3);var hours=Math.floor(leave1/(3600*1E3));var leave2=leave1%(3600*1E3);var minutes=Math.floor(leave2/(60*1E3));var leave3=leave2%(60*1E3);var seconds=Math.round(leave3/1E3);var result=format;if(days==0)result=result.replace(/(%d+\s)/,"");else result=result.replace("%d",days);if(hours==0)result=result.replace(/(%h+\s)/,"");else result=result.replace("%h",hours); -if(minutes==0)result=result.replace(/(%m+\s)/,"");else result=result.replace("%m",minutes);if(seconds==0)result=result.replace(/(%s+\s)/,"");else result=result.replace("%s",seconds);return result}function arrayObjectSort(field,sortOrder){return function(object1,object2){var value1=object1[field];var value2=object2[field];if(value1value2)if(sortOrder=="desc")return-1;else return 1;else return 0}} -function timedChunk(items,process,context,delay,callback){var todo=items.concat();if(delay==undefined)delay=25;setTimeout(function(){var start=+new Date;do process.call(context,todo.shift());while(todo.length>0&&+new Date-start<100);if(todo.length>0)setTimeout(arguments.callee,delay);else if(callback)callback(items)},delay)} -(function($){$.fn.fadeInAndOut=function(speed,easing,fn){var options={speed:speed,easing:easing,fn:fn};$.extend(options,$.fn.fadeInAndOut.defaults);this.fadeIn(options.speed).delay(options.speed).fadeOut(options.speed,options.easing,options.fn)};$.fn.fadeInAndOut.defaults={speed:1E3,easing:"swing",fn:null}})(jQuery);function uniq(a){var seen={};return a.filter(function(item){return seen.hasOwnProperty(item)?false:seen[item]=true})}; +String.prototype.getQueryString=function(b,a){if(a==undefined)a="&";var d;if(d=this.match(RegExp("(^|"+a+"|\\?)"+b+"=([^"+a+"]*)("+a+"|$)")))return unescape(d[2]);return null};String.prototype.right=function(b){return this.substr(-b)};String.prototype.getHostName=function(){var b=this,a=this.match(/^\w+\:\/\/([^\/]*).*/);if(typeof a!="undefined"&&null!=a){b=a[1];if(b.indexOf(":")!=-1)b=b.split(":")[0]}return b}; +Number.prototype.formatNumber=function(b){this.fStr=function(d,c,g){if(d==""||d==undefined)return c==""||c==undefined?"":c;var e=s=r="",f;if(!g){d=d.split("").reverse().join("");c=c.split("").reverse().join("")}for(var h=j=0;h1?this.fStr(a[0],b[0])+"."+this.fStr(a[1],b[1],1):this.fStr(a[0],b[0])}; +function getLocalTime(b){return(new Date(parseInt(b)*1E3)).toLocaleString().replace(/年|月/g,"-").replace(/日/g," ")}function formatLongTime(b){b=new Date(parseInt(b)*1E3);return formatDate(b)} +function formatDate(b,a){a||(a="yyyy-mm-dd hh:nn:ss");if(b instanceof Date){var d=b.getFullYear(),c=d.toString().substring(2),g=b.getMonth()+1,e=g<10?"0"+g:g,f=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][g],h=b.getDate(),m=h<10?"0"+h:h,i=b.getHours(),n=i<10?"0"+i:i,k=b.getMinutes(),o=k<10?"0"+k:k,l=b.getSeconds(),p=l<10?"0"+l:l;a=a.replace(/yyyy/i,d);a=a.replace(/yy/i,c);a=a.replace(/mmm/i,f);a=a.replace(/mm/i,e);a=a.replace(/m/i,g);a=a.replace(/dd/i,m);a=a.replace(/d/i, +h);a=a.replace(/hh/i,n);a=a.replace(/h/i,i);a=a.replace(/nn/i,o);a=a.replace(/n/i,k);a=a.replace(/ss/i,p);return a=a.replace(/s/i,l)}else return""} +function formatSize(b,a,d){if(b==0)return a==true?"":d=="speed"?"0.00 KB/s":"0.00";a="";var c="KB";if(b<1024E3){a=b/1024;c="KB"}else if(b<1048576E3){a=b/1048576;c="MB"}else if(b<1073741824E3){a=b/1073741824;c="GB"}else if(b<1099511627776E3){a=b/1099511627776;c="TB"}else{a=b/1125899906842624;c="PB"}if(d=="speed")c+="/s";return a.formatNumber("###,###,###,###.00 ")+c}function getHoursFromMinutes(b){return("00"+parseInt(b/60,10)).right(2)+":"+("00"+b%60).right(2)} +function getMinutesFromHours(b){return parseInt(b.split(":")[0],10)*60+parseInt(b.split(":")[1],10)}function getTotalTime(b,a){a||(a="%dd %hh %mm %ss ");var d=Math.floor(b/864E5),c=b%864E5,g=Math.floor(c/36E5),e=c%36E5;c=Math.floor(e/6E4);e=Math.round(e%6E4/1E3);var f=a;f=d==0?f.replace(/(%d+\s)/,""):f.replace("%d",d);f=g==0?f.replace(/(%h+\s)/,""):f.replace("%h",g);f=c==0?f.replace(/(%m+\s)/,""):f.replace("%m",c);return f=e==0?f.replace(/(%s+\s)/,""):f.replace("%s",e)} +function arrayObjectSort(b,a){return function(d,c){var g=d[b],e=c[b];return ge?a=="desc"?-1:1:0}}function timedChunk(b,a,d,c,g){var e=b.concat();if(c==undefined)c=25;setTimeout(function(){var f=+new Date;do a.call(d,e.shift());while(e.length>0&&+new Date-f<100);if(e.length>0)setTimeout(arguments.callee,c);else g&&g(b)},c)} +(function(b){b.fn.fadeInAndOut=function(a,d,c){a={speed:a,easing:d,fn:c};b.extend(a,b.fn.fadeInAndOut.defaults);this.fadeIn(a.speed).delay(a.speed).fadeOut(a.speed,a.easing,a.fn)};b.fn.fadeInAndOut.defaults={speed:1E3,easing:"swing",fn:null}})(jQuery);function uniq(b){var a={};return b.filter(function(d){return a.hasOwnProperty(d)?false:a[d]=true})}; diff --git a/src/tr-web-control/script/min/system.min.js b/src/tr-web-control/script/min/system.min.js index 4549faa..a976c6c 100644 --- a/src/tr-web-control/script/min/system.min.js +++ b/src/tr-web-control/script/min/system.min.js @@ -71,17 +71,17 @@ else{b.completeSize=b.totalSize-b.leftUntilDone;b.moreInfosTag=true;system.fillT []);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.trackers,c=a.trackerStats,e= -[],d;for(d in b){var f=c[d],g={},h;for(h in f)switch(h){case "lastAnnounceTime":case "nextAnnounceTime":g[h]=formatLongTime(f[h]);break;case "lastAnnounceSucceeded":case "lastAnnounceTimedOut":g[h]=system.lang.torrent.attribute.status[f[h]];break;default:g[h]=f[h]}e.push(g)}transmission.torrents.addTracker(a);this.updateCurrentPageDatas("id",e,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();this.checkTorrentRow("all",false)},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){$("#styleEasyui").attr("href","tr-web-control/script/easyui/themes/"+a+"/easyui.css");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"))})}); +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();this.checkTorrentRow("all",false)},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){$("#styleEasyui").attr("href", +"tr-web-control/script/easyui/themes/"+a+"/easyui.css");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 948bac1..f057fb3 100644 --- a/src/tr-web-control/script/min/transmission.torrents.min.js +++ b/src/tr-web-control/script/min/transmission.torrents.min.js @@ -1,17 +1,13 @@ -transmission.torrents={all:null,puased:null,downloading:null,actively:null,searchResult:null,error:null,warning:null,folders:{},status:{},count:0,totalSize:0,loadSimpleInfo:false,activeTorrentCount:0,pausedTorrentCount:0,fields:{base:"id,name,status,hashString,totalSize,percentDone,addedDate,trackerStats,leftUntilDone,rateDownload,rateUpload,recheckProgress"+",rateDownload,rateUpload,peersGettingFromUs,peersSendingToUs,uploadRatio,uploadedEver,downloadedEver,downloadDir,error,errorString,doneDate,queuePosition", -status:"id,status,percentDone,trackerStats,leftUntilDone,rateDownload,rateUpload"+",rateDownload,rateUpload,peersGettingFromUs,peersSendingToUs,uploadRatio,uploadedEver,downloadedEver,error,errorString,doneDate,queuePosition",config:"downloadLimit,downloadLimited,peer-limit,seedIdleLimit,seedIdleMode,seedRatioLimit,seedRatioMode,uploadLimit,uploadLimited"},datas:{},recently:null,removed:null,isRecentlyActive:false,newIds:new Array,getallids:function(callback,ids,moreFields){var tmp=this.fields.base; -if(this.loadSimpleInfo&&this.all)tmp=this.fields.status;var fields=tmp.split(",");if($.isArray(moreFields))$.unique($.merge(fields,moreFields));var arguments={fields:fields};this.isRecentlyActive=false;if(this.all&&ids==undefined){arguments["ids"]="recently-active";this.isRecentlyActive=true}else if(ids)arguments["ids"]=ids;if(!this.all)this.all={};transmission.exec({method:"torrent-get",arguments:arguments},function(data){if(data.result=="success"){transmission.torrents.newIds.length=0;transmission.torrents.loadSimpleInfo= -true;transmission.torrents.recently=data.arguments.torrents;transmission.torrents.removed=data.arguments.removed;transmission.torrents.splitid();if(callback)callback(data.arguments.torrents)}else{transmission.torrents.datas=null;if(callback)callback(null)}})},splitid:function(){this.downloading=new Array;this.puased=new Array;this.actively=new Array;this.error=new Array;this.warning=new Array;transmission.downloadDirs=new Array;var _Status=transmission._status;this.status={};transmission.trackers= -{};this.totalSize=0;this.folders={};this.count=0;var B64=new Base64;for(var index in this.recently){var item=this.recently[index];this.datas[item.id]=item}var removed=new Array;for(var index in this.removed){var item=this.removed[index];removed.push(item)}for(var index in this.datas){var item=this.datas[index];if(!item)return;if($.inArray(item.id,removed)!=-1&&removed.length>0){if(this.all[item.id]){this.all[item.id]=null;delete this.all[item.id]}this.datas[index]=null;delete this.datas[index];continue}if(this.isRecentlyActive&& -!this.all[item.id])this.newIds.push(item.id);item=$.extend(this.all[item.id],item);if(item.uploadedEver==0&&item.downloadedEver==0)item.uploadRatio="\u221e";item.infoIsLoading=false;var type=this.status[item.status];this.addTracker(item);if(!type){this.status[item.status]=new Array;type=this.status[item.status]}this.totalSize+=item.totalSize;if(item.rateDownload>0&&item.leftUntilDone>0){item["remainingTime"]=getTotalTime(item.leftUntilDone/item.rateDownload*1E3);item["remainingTimeRaw"]=Math.floor(item.leftUntilDone/ -item.rateDownload*1E3)}else if(item.rateDownload==0&&item.leftUntilDone==0&&item.totalSize!=0){item["remainingTime"]=0;item["remainingTimeRaw"]=0}else{item["remainingTime"]="\u221e";item["remainingTimeRaw"]=31536E8}type.push(item);if(item.error!=0)this.error.push(item);if(item.rateUpload>0||item.rateDownload>0)this.actively.push(item);switch(item.status){case _Status.stopped:this.puased.push(item);break;case _Status.download:this.downloading.push(item);break}this.all[item.id]=item;if($.inArray(item.downloadDir, -transmission.downloadDirs)==-1)transmission.downloadDirs.push(item.downloadDir);if(transmission.options.getFolders)if(item.downloadDir){var folder=item.downloadDir.split("/");var folderkey="folders-";for(var i in folder){var text=folder[i];if(text=="")continue;folderkey+=B64.encode(text);var node=this.folders[folderkey];if(!node)node={count:0,torrents:new Array,size:0,nodeid:folderkey};node.torrents.push(item);node.count++;node.size+=item.totalSize;this.folders[folderkey]=node}}this.count++}transmission.downloadDirs= -transmission.downloadDirs.sort();if(this.newIds.length>0)this.getallids(null,this.newIds)},addTracker:function(item){var trackerStats=item.trackerStats;var haveWarning=false;var trackers=[];item.leecherCount=0;item.seederCount=0;if(trackerStats.length>0){for(var index in trackerStats){var trackerInfo=trackerStats[index];var lastResult=trackerInfo.lastAnnounceResult.toLowerCase();var trackerUrl=trackerInfo.host.replace("http://","").replace("https://","").split(":")[0].split(".");if($.inArray(trackerUrl[0], -"www,tracker".split(","))!=-1)trackerUrl.shift();var name=trackerUrl.join(".");var id="tracker-"+name.replace(/\./g,"-");var tracker=transmission.trackers[id];if(!tracker){transmission.trackers[id]={count:0,torrents:new Array,size:0,connected:true};tracker=transmission.trackers[id]}tracker["name"]=name;tracker["nodeid"]=id;tracker["host"]=trackerInfo.host;if(!trackerInfo.lastAnnounceSucceeded&&trackerInfo.announceState!=transmission._trackerStatus.inactive){haveWarning=true;item["warning"]=trackerInfo.lastAnnounceResult; -if(lastResult=="could not connect to tracker")tracker.connected=false}tracker.torrents.push(item);tracker.count++;tracker.size+=item.totalSize;item.leecherCount+=trackerInfo.leecherCount;item.seederCount+=trackerInfo.seederCount;trackers.push(name)}if(haveWarning){if(!item["nextAnnounceTime"])item["nextAnnounceTime"]=trackerInfo.nextAnnounceTime;else if(item["nextAnnounceTime"]>trackerInfo.nextAnnounceTime)item["nextAnnounceTime"]=trackerInfo.nextAnnounceTime;this.warning.push(item)}if(item.leecherCount< -0)item.leecherCount=0;if(item.seederCount<0)item.seederCount=0;item.leecher=item.leecherCount+" ("+item.peersGettingFromUs+")";item.seeder=item.seederCount+" ("+item.peersSendingToUs+")";item.trackers=trackers.join(";")}},getPeers:function(ids){transmission.exec({method:"torrent-get",arguments:{fields:"peers,peersFrom".split(","),ids:ids}},function(data){console.log("data:",data)})},getMoreInfos:function(fields,ids,callback){transmission.exec({method:"torrent-get",arguments:{fields:fields.split(","), -ids:ids}},function(data){if(data.result=="success"){if(callback)callback(data.arguments.torrents)}else if(callback)callback(null)})},search:function(key,source){if(!key)return null;if(!source)source=this.all;var arrReturn=new Array;$.each(source,function(item,i){if(source[item].name.toLowerCase().indexOf(key.toLowerCase())!=-1)arrReturn.push(source[item])});this.searchResult=arrReturn;return arrReturn},getFiles:function(id,callback){transmission.exec({method:"torrent-get",arguments:{fields:"files,fileStats".split(","), -ids:id}},function(data){if(data.result=="success"){if(callback)callback(data.arguments.torrents)}else if(callback)callback(null)})},getConfig:function(id,callback){this.getMoreInfos(this.fields.config,id,callback)},getErrorIds:function(ignore,needUpdateOnly){var result=new Array;var now=new Date;if(needUpdateOnly==true)now=now.getTime()/1E3;for(var index in this.error){var item=this.error[index];if($.inArray(item.id,ignore)!=-1&&ignore.length>0)continue;if(needUpdateOnly==true)if(now0)continue;if(needUpdateOnly==true)if(now0){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&& +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=[], +a=new Date;if(e==true)a=a.getTime()/1E3;for(var g in this.error){var d=this.error[g];if(!($.inArray(d.id,b)!=-1&&b.length>0)){if(e==true)if(a0)){if(e==true)if(a