fixed issues #37

更新min文件
This commit is contained in:
栽培者 2017-06-07 08:55:44 +08:00
parent 4fa7f61c87
commit e02c107d49
10 changed files with 163 additions and 197 deletions

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
*.tmp
*.bkp
*.vscode
*.bat
node_modules
package.json
Gruntfile.js

View File

@ -9,26 +9,26 @@
<link rel='shortcut icon' href='favicon.ico' type='image/x-icon'/ >
<title>Transmission Web Control</title>
<!-- 样式表 -->
<link rel="stylesheet" type="text/css" href="tr-web-control/style/base.css?v=20170522" />
<link rel="stylesheet" type="text/css" href="tr-web-control/script/easyui/themes/default/easyui.css?v=20170522"/>
<link rel="stylesheet" type="text/css" href="tr-web-control/script/easyui/themes/icon.css?v=20170522"/>
<link rel="stylesheet" type="text/css" href="tr-web-control/style/base.css?v=20170607" />
<link rel="stylesheet" type="text/css" href="tr-web-control/script/easyui/themes/default/easyui.css?v=20170607"/>
<link rel="stylesheet" type="text/css" href="tr-web-control/script/easyui/themes/icon.css?v=20170607"/>
<!-- 基础类库 -->
<script type="text/javascript" src="tr-web-control/script/jquery/jquery-1.12.4.min.js"></script>
<script type="text/javascript" src="tr-web-control/script/jquery/jquery.form.js"></script>
<script type="text/javascript" src="tr-web-control/script/jquery/json2.min.js"></script>
<script type="text/javascript" src="tr-web-control/script/jquery/Base64.js"></script>
<script type="text/javascript" src="tr-web-control/script/easyui/jquery.easyui.min.js?v=20170522"></script>
<script type="text/javascript" src="tr-web-control/script/easyui/jquery.easyui.min.js?v=20170607"></script>
<script type="text/javascript" src="tr-web-control/script/easyui/plugins/jquery.datagrid.drophead.js"></script>
<!-- -->
<!-- 系统类库 -->
<script type="text/javascript" src="tr-web-control/script/min/public.min.js?v=20170522"></script>
<script type="text/javascript" src="tr-web-control/script/min/cookies.min.js?v=20170522"></script>
<script type="text/javascript" src="tr-web-control/script/min/clientDevice.min.js?v=20170522"></script>
<script type="text/javascript" src="tr-web-control/script/min/transmission.min.js?v=20170522"></script>
<script type="text/javascript" src="tr-web-control/script/min/transmission.torrents.min.js?v=20170522"></script>
<script type="text/javascript" src="tr-web-control/script/min/system.min.js?v=20170522"></script>
<script type="text/javascript" src="tr-web-control/config.js?v=20170522"></script>
<script type="text/javascript" src="tr-web-control/plugin.js?v=20170522"></script>
<script type="text/javascript" src="tr-web-control/script/min/public.min.js?v=20170607"></script>
<script type="text/javascript" src="tr-web-control/script/min/cookies.min.js?v=20170607"></script>
<script type="text/javascript" src="tr-web-control/script/min/clientDevice.min.js?v=20170607"></script>
<script type="text/javascript" src="tr-web-control/script/min/transmission.min.js?v=20170607"></script>
<script type="text/javascript" src="tr-web-control/script/min/transmission.torrents.min.js?v=20170607"></script>
<script type="text/javascript" src="tr-web-control/script/min/system.min.js?v=20170607"></script>
<script type="text/javascript" src="tr-web-control/config.js?v=20170607"></script>
<script type="text/javascript" src="tr-web-control/plugin.js?v=20170607"></script>
</head>
<style type="text/css">
.tree-title {

View File

@ -1,16 +1,4 @@
var clientDevice=function(){var e={ie:0,gecko:0,webkit:0,khtml:0,opera:0,ver:null},i={ie:0,firefox:0,konq:0,opera:0,chrome:0,safari:0,ver:null},r={win:!1,mac:!1,xll:!1,iPhone:!1,iPod:!1,iPad:!1,android:!1,nokiaN:!1,winMobile:!1,macMobile:!1,wii:!1,ps:!1},o=navigator.userAgent
if(window.opera)e.ver=i.ver=window.opera.version(),e.opera=i.opera=parseFloat(e.ver)
else if(/AppleWebKit\/(\S+)/.test(o))if(e.ver=RegExp.$1,e.webkit=parseFloat(e.ver),/Chrome\/(\S+)/.test(o))i.ver=RegExp.$1,i.chrome=parseFloat(i.ver)
else if(/Version\/(\S+)/.test(o))i.ver=RegExp.$1,i.safari=parseFloat(i.ver)
else{var a=1
a=e.webkit<100?1:e.webkit<312?1.2:e.webkit<412?1.3:2,i.safari=i.ver=a}else/KHTML\/(\S+)/.test(o)||/Konquersor\/([^;]+)/.test(o)?(e.ver=i.ver=RegExp.$1,e.khtml=i.kong=paresFloat(e.ver)):/rv:([^\)]+)\) Gecko\/\d{8}/.test(o)?(e.ver=RegExp.$1,e.gecko=parseFloat(e.ver),/Firefox\/(\S+)/.test(o)&&(i.ver=RegExp.$1,i.firefox=parseFloat(i.ver))):/MSIE([^;]+)/.test(o)&&(i.ver=RegExp.$1,i.firefox=parseFloat(i.ver))
i.ie=e.ie,i.opera=e.opera
var t=navigator.platform
if(r.win=0==t.indexOf("Win"),r.mac=0==t.indexOf("Mac"),r.x11="X11"==t||0==t.indexOf("Linux"),r.win&&/Win(?:doms)?([^do]{2})\s?(\d+\.\d+)?/.test(o))if("NT"==RegExp.$1)switch(RegExp.$2){case"5.0":r.win="2000"
break
case"5.1":r.win="XP"
break
case"6.0":r.win="Vista"
break
default:r.win="NT"}else RegExp.$1?r.win="ME":r.win=RegExp.$1
return r.iPhone=o.indexOf("iPhone")>-1,r.iPod=o.indexOf("iPod")>-1,r.iPad=o.indexOf("iPad")>-1,r.android=o.indexOf("Android")>-1,r.nokiaN=o.indexOf("NokiaN")>-1,r.winMobile="CE"==r.win,r.macMobile=r.iPhone||r.iPod||r.iPad,r.wii=o.indexOf("Wii")>-1,r.ps=/playstation/i.test(o),{engine:e,browser:i,system:r}}();(clientDevice.system.iphone||clientDevice.system.ipod||clientDevice.system.nokiaN||clientDevice.system.winMobile||clientDevice.system.macMobile||clientDevice.system.android)&&"computer"!=location.search.getQueryString("devicetype")&&(location.href="index.mobile.html")
var clientDevice=function(){var c={ie:0,gecko:0,webkit:0,khtml:0,opera:0,ver:null},b={ie:0,firefox:0,konq:0,opera:0,chrome:0,safari:0,ver:null},a={win:false,mac:false,xll:false,iPhone:false,iPod:false,iPad:false,android:false,nokiaN:false,winMobile:false,macMobile:false,wii:false,ps:false},d=navigator.userAgent;if(window.opera){c.ver=b.ver=window.opera.version();c.opera=b.opera=parseFloat(c.ver)}else if(/AppleWebKit\/(\S+)/.test(d)){c.ver=RegExp.$1;c.webkit=parseFloat(c.ver);if(/Chrome\/(\S+)/.test(d)){b.ver=
RegExp.$1;b.chrome=parseFloat(b.ver)}else if(/Version\/(\S+)/.test(d)){b.ver=RegExp.$1;b.safari=parseFloat(b.ver)}else{var e=1;e=c.webkit<100?1:c.webkit<312?1.2:c.webkit<412?1.3:2;b.safari=b.ver=e}}else if(/KHTML\/(\S+)/.test(d)||/Konquersor\/([^;]+)/.test(d)){c.ver=b.ver=RegExp.$1;c.khtml=b.kong=paresFloat(c.ver)}else if(/rv:([^\)]+)\) Gecko\/\d{8}/.test(d)){c.ver=RegExp.$1;c.gecko=parseFloat(c.ver);if(/Firefox\/(\S+)/.test(d)){b.ver=RegExp.$1;b.firefox=parseFloat(b.ver)}}else if(/MSIE([^;]+)/.test(d)){b.ver=
RegExp.$1;b.firefox=parseFloat(b.ver)}b.ie=c.ie;b.opera=c.opera;e=navigator.platform;a.win=e.indexOf("Win")==0;a.mac=e.indexOf("Mac")==0;a.x11=e=="X11"||e.indexOf("Linux")==0;if(a.win)if(/Win(?:doms)?([^do]{2})\s?(\d+\.\d+)?/.test(d))if(RegExp.$1=="NT")switch(RegExp.$2){case "5.0":a.win="2000";break;case "5.1":a.win="XP";break;case "6.0":a.win="Vista";break;default:a.win="NT"}else a.win=RegExp.$1?"ME":RegExp.$1;a.iPhone=d.indexOf("iPhone")>-1;a.iPod=d.indexOf("iPod")>-1;a.iPad=d.indexOf("iPad")>-1;
a.android=d.indexOf("Android")>-1;a.nokiaN=d.indexOf("NokiaN")>-1;a.winMobile=a.win=="CE";a.macMobile=a.iPhone||a.iPod||a.iPad;a.wii=d.indexOf("Wii")>-1;a.ps=/playstation/i.test(d);return{engine:c,browser:b,system:a}}();if((clientDevice.system.iphone||clientDevice.system.ipod||clientDevice.system.nokiaN||clientDevice.system.winMobile||clientDevice.system.macMobile||clientDevice.system.android)&&location.search.getQueryString("devicetype")!="computer")location.href="index.mobile.html";

View File

@ -1,16 +1,2 @@
var cookies={get:function(e,t){for(var r,i,n,s,a=document.cookie.split("; "),o=a.length,c=0;c<o;c++)if(a[c].indexOf("&")>0){if(n=a[c].split("="),e==n[0]){a[c]=a[c].substr(e.length+1),s=a[c].split("&"),r=s.length
for(var u={},f=0;f<r;f++){i=s[f].split("=")
var l=JSON.parse(i[1])
switch(l){case"true":u[i[0]]=!0
break
case"false":u[i[0]]=!1
break
default:u[i[0]]=l}if(t==i[0])return l}return u}}else if(i=a[c].split("="),e==i[0])return unescape(i[1])
return null},set:function(e,t,r){var i=new Date
void 0==r&&(r=0),i.setDate(i.getDate()+r)
var n=t
switch(typeof t){case"object":case"function":var s=new Array
for(var a in t)s.push(a+"="+JSON.stringify(t[a]))
n=s.join("&")
break
default:n=JSON.stringify(t)}document.cookie=e+"="+n+(0==r?"":"; expires="+i.toGMTString())},remove:function(e){this.set(e,"",-1)},all:function(){return document.cookie}}
var cookies={get:function(e,f){for(var c=document.cookie.split("; "),d=c.length,a,b=0;b<d;b++)if(c[b].indexOf("&")>0){a=c[b].split("=");if(e==a[0]){c[b]=c[b].substr(e.length+1);d=c[b].split("&");c=d.length;b={};for(var g=0;g<c;g++){a=d[g].split("=");var h=JSON.parse(a[1]);switch(h){case "true":b[a[0]]=true;break;case "false":b[a[0]]=false;break;default:b[a[0]]=h}if(f==a[0])return h}return b}}else{a=c[b].split("=");if(e==a[0])return unescape(a[1])}return null},set:function(e,f,c){var d=new Date;if(c==
undefined)c=0;d.setDate(d.getDate()+c);var a=f;switch(typeof f){case "object":case "function":a=[];for(var b in f)a.push(b+"="+JSON.stringify(f[b]));a=a.join("&");break;default:a=JSON.stringify(f)}document.cookie=e+"="+a+(c==0?"":"; expires="+d.toGMTString())},remove:function(e){this.set(e,"",-1)},all:function(){return document.cookie}};

View File

@ -1,39 +1,10 @@
// Get "query string"
//公用函数定义
//格式化数字
// 根据分钟获取小时
// 根据小时获取分钟
// Get the cumulative time
// Array object sort extension
// Generic time - sharing processing functions
// jQuery Extended
// returns only unique values
function getLocalTime(e){return new Date(1e3*parseInt(e)).toLocaleString().replace(/年|月/g,"-").replace(/日/g," ")}function formatLongTime(e,r){var t=new Date(1e3*parseInt(e))
return formatDate(t)}function formatDate(e,r){if(r||(r="yyyy-mm-dd hh:nn:ss"),e instanceof Date){var t=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"),n=e.getFullYear(),a=n.toString().substring(2),s=e.getMonth()+1,i=s<10?"0"+s:s,u=t[s],o=e.getDate(),c=o<10?"0"+o:o,l=e.getHours(),f=l<10?"0"+l:l,p=e.getMinutes(),h=p<10?"0"+p:p,d=e.getSeconds(),g=d<10?"0"+d:d
return r=r.replace(/yyyy/i,n),r=r.replace(/yy/i,a),r=r.replace(/mmm/i,u),r=r.replace(/mm/i,i),r=r.replace(/m/i,s),r=r.replace(/dd/i,c),r=r.replace(/d/i,o),r=r.replace(/hh/i,f),r=r.replace(/h/i,l),r=r.replace(/nn/i,h),r=r.replace(/n/i,p),r=r.replace(/ss/i,g),r=r.replace(/s/i,d)}return""}function formatSize(e,r,t){if(0==e)return 1==r?"":"speed"==t?"0.00 KB/s":"0.00"
var n="",a="KB"
return e<1024e3?(n=e/1024,a="KB"):e<1048576e3?(n=e/1048576,a="MB"):e<0xfa00000000?(n=e/1073741824,a="GB"):e<0x3e80000000000?(n=e/1099511627776,a="TB"):(n=e/0x4000000000000,a="PB"),"speed"==t&&(a+="/s"),n.formatNumber("###,###,###,###.00 ")+a}function getHoursFromMinutes(e){return("00"+parseInt(e/60,10)).right(2)+":"+("00"+e%60).right(2)}function getMinutesFromHours(e){return 60*parseInt(e.split(":")[0],10)+parseInt(e.split(":")[1],10)}function getTotalTime(e,r){r||(r="%dd %hh %mm %ss ")
var t=Math.floor(e/864e5),n=e%864e5,a=Math.floor(n/36e5),s=n%36e5,i=Math.floor(s/6e4),u=s%6e4,o=Math.round(u/1e3),c=r
return c=0==t?c.replace(/(%d+\s)/,""):c.replace("%d",t),c=0==a?c.replace(/(%h+\s)/,""):c.replace("%h",a),c=0==i?c.replace(/(%m+\s)/,""):c.replace("%m",i),c=0==o?c.replace(/(%s+\s)/,""):c.replace("%s",o)}function arrayObjectSort(e,r){return function(t,n){var a=t[e],s=n[e]
return a<s?"desc"==r?1:-1:a>s?"desc"==r?-1:1:0}}function timedChunk(e,r,t,n,a){var s=e.concat()
void 0==n&&(n=25),setTimeout(function(){var i=+new Date
do r.call(t,s.shift())
while(s.length>0&&+new Date-i<100)
s.length>0?setTimeout(arguments.callee,n):a&&a(e)},n)}function uniq(e){var r={}
return e.filter(function(e){return!r.hasOwnProperty(e)&&(r[e]=!0)})}String.prototype.getQueryString=function(e,r){void 0==r&&(r="&")
var t,n=new RegExp("(^|"+r+"|\\?)"+e+"=([^"+r+"]*)("+r+"|$)")
return(t=this.match(n))?unescape(t[2]):null},String.prototype.right=function(e){return this.substr(-e)},Number.prototype.formatNumber=function(e){this.fStr=function(e,t,n){if(""==e||void 0==e)return""==t||void 0==t?"":t
var a,i=s=r=""
n||(e=e.split("").reverse().join(""),t=t.split("").reverse().join(""))
for(var u=j=0;u<t.length;u++,j++)if(s=e.charAt(j),void 0!=s)switch(i=t.charAt(u)){case"#":r+=s,a=u
break
case"0":r=s||s==i?r+s:r+0,a=u
break
case".":r+=s==i?s:(j--,i)
break
case",":r+=s==i?s:(j--,i)
break
default:r+=i,j--}return j!=e.length&&"0"!=t.charAt(t.length-1)&&a!=t.length&&"0"!=t.charAt(a)&&(r=r.substr(0,a+1)+e.substr(j)+r.substr(a+1)),r=(n?r:r.split("").reverse().join("")).replace(/(^,)|(,$)|(,,+)/g,""),","==r.substr(0,1)&&(r=r.substr(1)),"-,"==r.substr(0,2)&&(r="-"+r.substr(2)),r}
var t=this.toString()
return 0==t.length?"":void 0==e?this:(e=e.split("."),t=t.split("."),e.length>1?this.fStr(t[0],e[0])+"."+this.fStr(t[1],e[1],1):this.fStr(t[0],e[0]))},function(e){e.fn.fadeInAndOut=function(r,t,n){var a={speed:r,easing:t,fn:n}
e.extend(a,e.fn.fadeInAndOut.defaults),this.fadeIn(a.speed).delay(a.speed).fadeOut(a.speed,a.easing,a.fn)},e.fn.fadeInAndOut.defaults={speed:1e3,easing:"swing",fn:null}}(jQuery)
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)};
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;h<c.length;h++,j++){s=d.charAt(j);if(s!=undefined){e=c.charAt(h);switch(e){case "#":r+=s;f=h;break;case "0":r=s||s==e?r+s:r+0;f=h;break;case ".":r+=s==e?s:(j--,e);break;case ",":r+=s==e?s:(j--,e);break;default:r+=e;j--}}}if(j!=d.length&&c.charAt(c.length-1)!="0"&&f!=c.length&&
c.charAt(f)!="0")r=r.substr(0,f+1)+d.substr(j)+r.substr(f+1);r=(g?r:r.split("").reverse().join("")).replace(/(^,)|(,$)|(,,+)/g,"");if(r.substr(0,1)==",")r=r.substr(1);if(r.substr(0,2)=="-,")r="-"+r.substr(2);return r};var a=this.toString();if(a.length==0)return"";if(b==undefined)return this;b=b.split(".");a=a.split(".");return b.length>1?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 g<e?a=="desc"?1:-1:g>e?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})};

File diff suppressed because one or more lines are too long

View File

@ -1,86 +1,27 @@
/*
移动版
*/
var system={version:"1.0 Beta",rootPath:"tr-web-control/",codeupdate:"20141010",config:{autoReload:!0,reloadStep:5e3,pageSize:30,defaultSelectNode:null},lang:null,reloading:!1,autoReloadTimer:null,downloadDir:"",islocal:!1,B64:new Base64,currentTorrentId:0,currentContentPage:"home",currentContentConfig:null,control:{tree:null,torrentlist:null},serverConfig:null,serverSessionStats:null,torrentListChecked:!1,debug:function(t,e){window.console&&window.console.log&&window.console.log(t,e)},setlang:function(t,e){t||(t=this.config.defaultLang?this.config.defaultLang:navigator.language||navigator.browserLanguage),t||(t="zh-CN"),t.indexOf("-")!=-1&&(t=t.split("-")[0].toLocaleLowerCase()+"-"+t.split("-")[1].toLocaleUpperCase()),this.languages[t]||(t="en"),$.getScript(system.rootPath+"lang/"+t+".js",function(){system.lang=$.extend(!0,system.defaultLang,system.lang),system.resetLangText(),e&&e()})},resetLangText:function(){var items=$("*[system-lang]")
$.each(items,function(key,item){var name=$(item).attr("system-lang")
$(item).html(eval("system.lang."+name))})},init:function(t,e){this.readConfig(),transmission.options.getFolders=!1,null==this.lang?this.setlang(t,function(){system.initdata()}):this.initdata()},initdata:function(){$(document).attr("title",this.lang.system.title+" "+this.version),this.control.torrentlist=$("#torrent-list"),this.connect()},readConfig:function(){var t=cookies.get("transmission-web-control")
$.isPlainObject(t)&&(this.config=$.extend(this.config,t))},saveConfig:function(){cookies.set("transmission-web-control",this.config,100)},connect:function(){transmission.on.torrentCountChange=function(){system.reloadTorrentBaseInfos()},transmission.on.postError=function(){},transmission.init({islocal:!0},function(){system.reloadSession(!0),system.getServerStatus()})},reloadSession:function(t){transmission.getSession(function(t){system.serverConfig=t,1==t["alt-speed-enabled"]?$("#status_alt_speed").show():$("#status_alt_speed").hide(),system.downloadDir=t["download-dir"],parseInt(system.serverConfig["rpc-version"])>=15?transmission.getFreeSpace(system.downloadDir,function(t){system.serverConfig["download-dir-free-space"]=t.arguments["size-bytes"],system.showFreeSpace(t.arguments["size-bytes"])}):system.showFreeSpace(system.serverConfig["download-dir-free-space"])})},showFreeSpace:function(t){var e=t
e=e==-1?system.lang.public["text-unknown"]:formatSize(e),$("#status_freespace").text(e)},getServerStatus:function(){this.reloading||(clearTimeout(this.autoReloadTimer),this.reloading=!0,transmission.getStatus(function(t){system.reloading=!1,$("#status_downloadspeed").html(formatSize(t.downloadSpeed,!1,"speed")),$("#status_uploadspeed").html(formatSize(t.uploadSpeed,!1,"speed")),system.serverSessionStats=t}))},reloadTorrentBaseInfos:function(t){if(!this.reloading){clearTimeout(this.autoReloadTimer),this.reloading=!0
var e={trackers:transmission.trackers,folders:transmission.torrents.folders}
transmission.torrents.getallids(function(t){var s=new Array
for(var n in t){var r=t[n]
s.push(r.id)}var a=transmission.torrents.getErrorIds(s,!0)
a.length>0?transmission.torrents.getallids(function(){system.resetTorrentInfos(e)},a):system.resetTorrentInfos(e)},t)}},resetTorrentInfos:function(t){this.currentTorrentId
if(transmission.torrents.status[transmission._status.stopped]?this.updateCount("paused",transmission.torrents.status[transmission._status.stopped].length):this.updateCount("paused",0),transmission.torrents.status[transmission._status.seed]?this.updateCount("sending",transmission.torrents.status[transmission._status.seed].length):this.updateCount("sending",0),transmission.torrents.status[transmission._status.check]?this.updateCount("check",transmission.torrents.status[transmission._status.check].length):this.updateCount("check",0),transmission.torrents.status[transmission._status.download]?this.updateCount("downloading",transmission.torrents.status[transmission._status.download].length):this.updateCount("downloading",0),this.updateCount("actively",transmission.torrents.actively.length),this.updateCount("error",transmission.torrents.error.length),this.updateCount("warning",transmission.torrents.warning.length),system.reloading=!1,system.config.autoReload&&(system.autoReloadTimer=setTimeout(function(){system.reloadData()},system.config.reloadStep)),this.updateCount("all",transmission.torrents.count),"torrent-list"==this.currentContentPage){var e=this.currentContentConfig
e.reload=!0,this.showContent(e)}},updateCount:function(t,e){var s=$("#count-"+t)
s.text(e),0==e?s.hide():s.show()},reloadData:function(){this.reloadSession(),this.reloading=!1,this.getServerStatus(),this.reloading=!1,this.reloadTorrentBaseInfos()},showContent:function(t){var e={page:"",type:"",data:"",title:this.lang.system.title,reload:!1,callback:null},s=null
if("string"==typeof t?(e.page=t,s=e):s=jQuery.extend(e,t),s.page!=this.currentContentPage||s.reload){switch($("#content-"+s.page).show(),s.page!=this.currentContentPage&&($("#content-"+this.currentContentPage).hide(),this.control.torrentlist.find("input:checked").prop("checked",!1).checkboxradio("refresh"),this.torrentListChecked=!1),$("#torrent-page-bar").hide(),this.torrentListChecked||$("#torrent-toolbar").hide(),this.currentContentPage=s.page,s.type){case"torrent-list":s.title=this.lang.tree[s.data],this.loadTorrentToList({target:s.data})}$("#page-title").text(s.title),s.reload=!1,this.currentContentConfig=s,s.callback&&s.callback()}},getTorrentFromType:function(t){var e=null
switch(t){case"torrent-all":case"all":case"servers":e=transmission.torrents.all
break
case"paused":e=transmission.torrents.status[transmission._status.stopped]
break
case"sending":e=transmission.torrents.status[transmission._status.seed]
break
case"seedwait":e=transmission.torrents.status[transmission._status.seedwait]
break
case"check":e=transmission.torrents.status[transmission._status.check]
break
case"checkwait":e=transmission.torrents.status[transmission._status.checkwait]
break
case"downloading":e=transmission.torrents.status[transmission._status.download]
break
case"downloadwait":e=transmission.torrents.status[transmission._status.downloadwait]
break
case"actively":e=transmission.torrents.actively
break
case"error":e=transmission.torrents.error
break
case"warning":e=transmission.torrents.warning
break
case"search-result":e=transmission.torrents.searchResult}return e},loadTorrentToList:function(t){if(!this.torrentListChecked&&transmission.torrents.all){var e={node:null,page:1,target:"all"}
if(jQuery.extend(e,t),t.target){var s=this.getTorrentFromType(t.target)
this.config.defaultSelectNode=t.target,this.saveConfig()
var n=new Array
this.control.torrentlist.empty()
for(var r in s)if(s[r]){var a=parseFloat(100*s[r].percentDone).toFixed(2),o=this.lang.torrent["status-text"][s[r].status]
0!=s[r].error?o="<span class='text-status-error'>"+o+"</span>":s[r].warning&&(o="<span class='text-status-warning' title='"+s[r].warning+"'>"+o+"</span>")
var i={id:s[r].id,name:this.getTorrentNameBar(s[r]),totalSize:s[r].totalSize,percentDone:this.getTorrentProgressBar(a,s[r]),percentDoneNumber:a,status:o,addedDate:formatLongTime(s[r].addedDate),completeSize:s[r].totalSize-s[r].leftUntilDone,rateDownload:s[r].rateDownload,rateUpload:s[r].rateUpload,leecherCount:s[r].leecher,seederCount:s[r].seeder,uploadRatio:s[r].uploadRatio,uploadedEver:s[r].uploadedEver}
n.push(i)}if(0==n.length)return void setTimeout(function(){system.showContent("home")},100)
null==this.torrentPager.onGotoPage&&(this.torrentPager.onGotoPage=function(t){system.control.torrentlist.empty(),$("#torrent-toolbar").hide()
for(var e in t)system.appendTorrentToList(t[e])
$(system.control.torrentlist).listview("refresh").find("input[type='checkbox']").click(function(){system.changeTorrentToolbar(this,i),system.torrentListChecked?system.control.torrentlist.find("a[name='torrent']").css("marginLeft","0px"):system.control.torrentlist.find("a[name='torrent']").css("marginLeft","-35px")}).checkboxradio()}),this.torrentPager.setDatas(n,t.target)}}},appendTorrentToList:function(t){var e={id:t.id,name:t.name,rateDownload:formatSize(t.rateDownload,!1,"speed"),rateUpload:formatSize(t.rateUpload,!1,"speed"),completeSize:formatSize(t.completeSize),totalSize:formatSize(t.totalSize),percentDone:t.percentDone},s="<li id='li-torrent-$id$' torrentid='$id$' style='padding:0px;'><a name='torrent' style='padding:0px;margin-left:-35px;'><label data-corners='false' style='margin:0px;border:0px;padding:0px;'><input type='checkbox' id='torrent-$id$'/><label for='torrent-$id$'><h3 style='margin:0px;'>$name$</h3><div style='padding:0px 10px 5px 0px;'>$percentDone$</div><p class='torrent-list-infos'>↓$rateDownload$ ↑$rateUpload$|$completeSize$/$totalSize$</p></label></label></a><a class='more'></a>"
s=s.replace(/\$([^\$]*)\$/g,function(t,s){return e[s]})
var n=$(s)
n.on("swiperight",function(t){system.control.torrentlist.find("a[name='torrent']").css("marginLeft","0px")}),n.on("swipeleft",function(t){system.control.torrentlist.find("a[name='torrent']").css("marginLeft","-35px")}),n.appendTo(this.control.torrentlist)},getTorrentNameBar:function(t){var e="",s=t.name
switch(t.status){case transmission._status.stopped:e="iconlabel icon-pause-small"
break
case transmission._status.check:e="iconlabel icon-checking"
break
case transmission._status.download:e="iconlabel icon-down"
break
case transmission._status.seed:e="iconlabel icon-up"
break
case transmission._status.seedwait:case transmission._status.downloadwait:case transmission._status.checkwait:e="iconlabel icon-wait"}return t.warning&&(e="iconlabel icon-warning-type1",s+="\n\n"+this.lang.public["text-info"]+": "+t.warning),0!=t.error&&(e="iconlabel icon-exclamation",s+="\n\n"+this.lang.public["text-info"]+": "+t.errorString),'<span class="'+e+'" title="'+s+'">'+t.name+"</span>"},getTorrentProgressBar:function(t,e){t+="%"
var s=""
switch(e.status){case transmission._status.stopped:s="torrent-progress-stop"
break
case transmission._status.checkwait:case transmission._status.check:s="torrent-progress-check"
break
case transmission._status.downloadwait:case transmission._status.download:s="torrent-progress-download"
break
case transmission._status.seedwait:case transmission._status.seed:s="torrent-progress-seed"}return e.warning&&(s="torrent-progress-warning"),0!=e.error&&(s="torrent-progress-error"),'<div class="torrent-progress" title="'+t+'"><div class="torrent-progress-text">'+t+'</div><div class="torrent-progress-bar '+s+'" style="width:'+t+';"></div></div>'},changeTorrentToolbar:function(t,e){var s=this.control.torrentlist.find("input:checked")
$("#torrent-checked-count").html(s.length),s.length>0?(this.torrentListChecked=!0,$("#torrent-toolbar").show()):(this.torrentListChecked=!1,$("#torrent-toolbar").hide()),e&&(this.currentTorrentId=e.id)},torrentPager:{datas:null,pageSize:30,pageNumber:0,pageCount:0,count:0,onGotoPage:null,currentDatas:null,pageBar:null,controls:{prev:null,next:null,number:null},head:"",init:function(t){this.pageBar=$("#torrent-page-bar"),this.controls.next=this.pageBar.find("#page-next"),this.controls.next.click(function(){system.torrentPager.gotoPage("next")}),this.controls.prev=this.pageBar.find("#page-prev"),this.controls.prev.click(function(){system.torrentPager.gotoPage("prev")}),this.controls.number=this.pageBar.find("#page-number"),t&&this.setDatas(t)},setDatas:function(t,e){this.datas||this.init(),this.datas=t,this.pageBar.show(),this.count=this.datas.length,this.pageCount=parseInt(this.count/this.pageSize),this.count%this.pageSize>0&&this.pageCount++,1==this.pageCount&&this.pageBar.hide(),this.head==e?this.gotoPage():this.gotoPage(1),this.head=e},gotoPage:function(t){if("number"==typeof t)this.pageNumber=t
else switch(t){case"next":this.pageNumber++
break
case"prev":this.pageNumber--}this.pageNumber>this.pageCount&&(this.pageNumber=this.pageCount),this.pageNumber<1&&(this.pageNumber=1)
var e=(this.pageNumber-1)*parseInt(this.pageSize),s=e+parseInt(this.pageSize)
this.currentDatas=this.datas.slice(e,s),this.controls.number.text(this.pageNumber+"/"+this.pageCount),this.pageNumber>1?this.controls.prev.show():this.controls.prev.hide(),this.pageNumber<this.pageCount?this.controls.next.show():this.controls.next.hide(),this.onGotoPage&&this.onGotoPage(this.currentDatas)}},changeSelectedTorrentStatus:function(t,e,s){var n=this.control.torrentlist.find("input:checked"),r=new Array
t||(t="start")
for(var a=0;a<n.length;a++)r.push(parseInt(n[a].id.replace("torrent-","")))
if(r.length>0){var arguments={ids:r}
switch(t){case"remove":arguments["delete-local-data"]=s.removeData
break
case"verify":if(1==r.length){var o=transmission.torrents.all[r[0]]
if(o.percentDone>0&&0==confirm(system.lang.toolbar.tip["recheck-confirm"]))return}else if(0==confirm(system.lang.toolbar.tip["recheck-confirm"]))return}e=$(e),e.attr("disabled",!0),transmission.exec({method:"torrent-"+t,arguments:arguments},function(t){e.attr("disabled",!1),system.reloadTorrentBaseInfos()}),this.torrentListChecked=!1}},addTorrentsToServer:function(t,e,s,n,r){var a=e-t.length,o=t.shift()
return o?(this.showStatus(this.lang.system.status.queue,e-a+1),void transmission.addTorrentFromUrl(o,n,s,function(a){system.addTorrentsToServer(t,e,s,n,r)})):(this.showStatus(this.lang.system.status.queuefinish),this.getServerStatus(),void(r&&r()))},showStatus:function(t,e){return t?($("#status").show(),$("#status-msg").html(t),void($.isNumeric(e)?$("#status-count").html(e).show():$("#status-count").hide())):void $("#status").hide()}}
$(document).ready(function(){$.getScript(system.rootPath+"lang/default.js"),$.getScript(system.rootPath+"lang/_languages.js",function(){system.init(location.search.getQueryString("lang"))})})
var system={version:"1.1 Beta",rootPath:"tr-web-control/",codeupdate:"20170317",config:{autoReload:true,reloadStep:5E3,pageSize:30,defaultSelectNode:null},lang:null,reloading:false,autoReloadTimer:null,downloadDir:"",islocal:false,B64:new Base64,currentTorrentId:0,currentContentPage:"home",currentContentConfig:null,control:{tree:null,torrentlist:null},serverConfig:null,serverSessionStats:null,torrentListChecked:false,debug:function(a,b){window.console&&window.console.log&&window.console.log(a,b)},
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();b&&b()})},resetLangText:function(){var a=$("*[system-lang]");$.each(a,function(b,c){var d=$(c).attr("system-lang");
$(c).html(eval("system.lang."+d))})},init:function(a){this.readConfig();transmission.options.getFolders=false;this.lang==null?this.setlang(a,function(){system.initdata()}):this.initdata()},initdata:function(){$(document).attr("title",this.lang.system.title+" "+this.version);this.control.torrentlist=$("#torrent-list");this.connect()},readConfig:function(){var a=cookies.get("transmission-web-control");if($.isPlainObject(a))this.config=$.extend(this.config,a)},saveConfig:function(){cookies.set("transmission-web-control",
this.config,100)},connect:function(){transmission.on.torrentCountChange=function(){system.reloadTorrentBaseInfos()};transmission.on.postError=function(){};transmission.init({islocal:true},function(){system.reloadSession(true);system.getServerStatus()})},reloadSession:function(){transmission.getSession(function(a){system.serverConfig=a;a["alt-speed-enabled"]==true?$("#status_alt_speed").show():$("#status_alt_speed").hide();system.downloadDir=a["download-dir"];parseInt(system.serverConfig["rpc-version"])>=
15?transmission.getFreeSpace(system.downloadDir,function(b){system.serverConfig["download-dir-free-space"]=b.arguments["size-bytes"];system.showFreeSpace(b.arguments["size-bytes"])}):system.showFreeSpace(system.serverConfig["download-dir-free-space"])})},showFreeSpace:function(a){a=a;a=a==-1?system.lang["public"]["text-unknown"]:formatSize(a);$("#status_freespace").text(a)},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})}},reloadTorrentBaseInfos:function(a){if(!this.reloading){clearTimeout(this.autoReloadTimer);this.reloading=true;var b={trackers:transmission.trackers,folders:transmission.torrents.folders};transmission.torrents.getallids(function(c){var d=[],e;for(e in c)d.push(c[e].id);c=transmission.torrents.getErrorIds(d,true);c.length>
0?transmission.torrents.getallids(function(){system.resetTorrentInfos(b)},c):system.resetTorrentInfos(b)},a)}},resetTorrentInfos:function(){transmission.torrents.status[transmission._status.stopped]?this.updateCount("paused",transmission.torrents.status[transmission._status.stopped].length):this.updateCount("paused",0);transmission.torrents.status[transmission._status.seed]?this.updateCount("sending",transmission.torrents.status[transmission._status.seed].length):this.updateCount("sending",0);transmission.torrents.status[transmission._status.check]?
this.updateCount("check",transmission.torrents.status[transmission._status.check].length):this.updateCount("check",0);transmission.torrents.status[transmission._status.download]?this.updateCount("downloading",transmission.torrents.status[transmission._status.download].length):this.updateCount("downloading",0);this.updateCount("actively",transmission.torrents.actively.length);this.updateCount("error",transmission.torrents.error.length);this.updateCount("warning",transmission.torrents.warning.length);
system.reloading=false;if(system.config.autoReload)system.autoReloadTimer=setTimeout(function(){system.reloadData()},system.config.reloadStep);this.updateCount("all",transmission.torrents.count);if(this.currentContentPage=="torrent-list"){var a=this.currentContentConfig;a.reload=true;this.showContent(a)}},updateCount:function(a,b){var c=$("#count-"+a);c.text(b);b==0?c.hide():c.show()},reloadData:function(){this.reloadSession();this.reloading=false;this.getServerStatus();this.reloading=false;this.reloadTorrentBaseInfos()},
showContent:function(a){var b={page:"",type:"",data:"",title:this.lang.system.title,reload:false,callback:null},c=null;if(typeof a=="string"){b.page=a;c=b}else c=jQuery.extend(b,a);if(!(c.page==this.currentContentPage&&!c.reload)){$("#content-"+c.page).show();if(c.page!=this.currentContentPage){$("#content-"+this.currentContentPage).hide();this.control.torrentlist.find("input:checked").prop("checked",false).checkboxradio("refresh");this.torrentListChecked=false}$("#torrent-page-bar").hide();this.torrentListChecked||
$("#torrent-toolbar").hide();this.currentContentPage=c.page;switch(c.type){case "torrent-list":c.title=this.lang.tree[c.data];this.loadTorrentToList({target:c.data})}$("#page-title").text(c.title);c.reload=false;this.currentContentConfig=c;c.callback&&c.callback()}},getTorrentFromType:function(a){var b=null;switch(a){case "torrent-all":case "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}return b},loadTorrentToList:function(a){if(!this.torrentListChecked)if(transmission.torrents.all){jQuery.extend({node:null,page:1,target:"all"},a);if(a.target){var b=this.getTorrentFromType(a.target);this.config.defaultSelectNode=a.target;this.saveConfig();var c=[];this.control.torrentlist.empty();for(var d in b)if(b[d]){var e=parseFloat(b[d].percentDone*
100).toFixed(2),f=this.lang.torrent["status-text"][b[d].status];if(b[d].error!=0)f="<span class='text-status-error'>"+f+"</span>";else if(b[d].warning)f="<span class='text-status-warning' title='"+b[d].warning+"'>"+f+"</span>";var g={id:b[d].id,name:this.getTorrentNameBar(b[d]),totalSize:b[d].totalSize,percentDone:this.getTorrentProgressBar(e,b[d]),percentDoneNumber:e,status:f,addedDate:formatLongTime(b[d].addedDate),completeSize:b[d].totalSize-b[d].leftUntilDone,rateDownload:b[d].rateDownload,rateUpload:b[d].rateUpload,
leecherCount:b[d].leecher,seederCount:b[d].seeder,uploadRatio:b[d].uploadRatio,uploadedEver:b[d].uploadedEver};c.push(g)}if(c.length==0)setTimeout(function(){system.showContent("home")},100);else{if(this.torrentPager.onGotoPage==null)this.torrentPager.onGotoPage=function(h){system.control.torrentlist.empty();$("#torrent-toolbar").hide();for(var i in h)system.appendTorrentToList(h[i]);$(system.control.torrentlist).listview("refresh").find("input[type='checkbox']").click(function(){system.changeTorrentToolbar(this,
g);system.torrentListChecked?system.control.torrentlist.find("a[name='torrent']").css("marginLeft","0px"):system.control.torrentlist.find("a[name='torrent']").css("marginLeft","-35px")}).checkboxradio()};this.torrentPager.setDatas(c,a.target)}}}},appendTorrentToList:function(a){var b={id:a.id,name:a.name,rateDownload:formatSize(a.rateDownload,false,"speed"),rateUpload:formatSize(a.rateUpload,false,"speed"),completeSize:formatSize(a.completeSize),totalSize:formatSize(a.totalSize),percentDone:a.percentDone};
a="<li id='li-torrent-$id$' torrentid='$id$' style='padding:0px;'><a name='torrent' style='padding:0px;margin-left:-35px;'><label data-corners='false' style='margin:0px;border:0px;padding:0px;'><input type='checkbox' id='torrent-$id$'/><label for='torrent-$id$'><h3 style='margin:0px;'>$name$</h3><div style='padding:0px 10px 5px 0px;'>$percentDone$</div><p class='torrent-list-infos'>↓$rateDownload$ ↑$rateUpload$|$completeSize$/$totalSize$</p></label></label></a><a class='more'></a>";a=a.replace(/\$([^\$]*)\$/g,
function(c,d){return b[d]});a=$(a);a.on("swiperight",function(){system.control.torrentlist.find("a[name='torrent']").css("marginLeft","0px")});a.on("swipeleft",function(){system.control.torrentlist.find("a[name='torrent']").css("marginLeft","-35px")});a.appendTo(this.control.torrentlist)},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"}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="";switch(b.status){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(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>'},changeTorrentToolbar:function(a,b){var c=this.control.torrentlist.find("input:checked");$("#torrent-checked-count").html(c.length);if(c.length>0){this.torrentListChecked=true;$("#torrent-toolbar").show()}else{this.torrentListChecked=false;$("#torrent-toolbar").hide()}if(b)this.currentTorrentId=b.id},torrentPager:{datas:null,pageSize:30,pageNumber:0,pageCount:0,count:0,onGotoPage:null,
currentDatas:null,pageBar:null,controls:{prev:null,next:null,number:null},head:"",init:function(a){this.pageBar=$("#torrent-page-bar");this.controls.next=this.pageBar.find("#page-next");this.controls.next.click(function(){system.torrentPager.gotoPage("next")});this.controls.prev=this.pageBar.find("#page-prev");this.controls.prev.click(function(){system.torrentPager.gotoPage("prev")});this.controls.number=this.pageBar.find("#page-number");a&&this.setDatas(a)},setDatas:function(a,b){this.datas||this.init();
this.datas=a;this.pageBar.show();this.count=this.datas.length;this.pageCount=parseInt(this.count/this.pageSize);this.count%this.pageSize>0&&this.pageCount++;this.pageCount==1&&this.pageBar.hide();this.head==b?this.gotoPage():this.gotoPage(1);this.head=b},gotoPage:function(a){if(typeof a=="number")this.pageNumber=a;else switch(a){case "next":this.pageNumber++;break;case "prev":this.pageNumber--}if(this.pageNumber>this.pageCount)this.pageNumber=this.pageCount;if(this.pageNumber<1)this.pageNumber=1;
a=(this.pageNumber-1)*parseInt(this.pageSize);var b=a+parseInt(this.pageSize);this.currentDatas=this.datas.slice(a,b);this.controls.number.text(this.pageNumber+"/"+this.pageCount);this.pageNumber>1?this.controls.prev.show():this.controls.prev.hide();this.pageNumber<this.pageCount?this.controls.next.show():this.controls.next.hide();this.onGotoPage&&this.onGotoPage(this.currentDatas)}},changeSelectedTorrentStatus:function(a,b,c){var d=this.control.torrentlist.find("input:checked"),e=[];a||(a="start");
for(var f=0;f<d.length;f++)e.push(parseInt(d[f].id.replace("torrent-","")));if(e.length>0){arguments={ids:e};switch(a){case "remove":arguments["delete-local-data"]=c.removeData;break;case "verify":if(e.length==1){if(transmission.torrents.all[e[0]].percentDone>0)if(confirm(system.lang.toolbar.tip["recheck-confirm"])==false)return}else if(confirm(system.lang.toolbar.tip["recheck-confirm"])==false)return}b=$(b);b.attr("disabled",true);transmission.exec({method:"torrent-"+a,arguments:arguments},function(){b.attr("disabled",
false);system.reloadTorrentBaseInfos()});this.torrentListChecked=false}},addTorrentsToServer:function(a,b,c,d,e){var f=b-a.length,g=a.shift();if(g){this.showStatus(this.lang.system.status.queue,b-f+1);transmission.addTorrentFromUrl(g,d,c,function(){system.addTorrentsToServer(a,b,c,d,e)})}else{this.showStatus(this.lang.system.status.queuefinish);this.getServerStatus();e&&e()}},showStatus:function(a,b){if(a){$("#status").show();$("#status-msg").html(a);$.isNumeric(b)?$("#status-count").html(b).show():
$("#status-count").hide()}else $("#status").hide()}};$(document).ready(function(){$.getScript(system.rootPath+"lang/default.js");$.getScript(system.rootPath+"lang/_languages.js",function(){system.init(location.search.getQueryString("lang"))})});

View File

@ -1,20 +1,8 @@
// transmission RPC 操作类
// 栽培者
var transmission={SessionId:"",isInitialized:!1,host:"",port:"9091",path:"/transmission/rpc",rpcpath:"../rpc",fullpath:"",on:{torrentCountChange:null,postError:null},username:"",password:"",_status:{stopped:0,checkwait:1,check:2,downloadwait:3,download:4,seedwait:5,seed:6,actively:101},options:{getFolders:!0,getTarckers:!0},headers:{},trackers:{},islocal:!1,downloadDirs:new Array,getSessionId:function(t,e){var s={type:"POST",url:this.fullpath,error:function(s,n,r){var o=""
409===s.status&&(o=s.getResponseHeader("X-Transmission-Session-Id"))&&(t.isInitialized=!0,t.SessionId=o,t.headers["X-Transmission-Session-Id"]=o,e&&e())},headers:this.headers}
jQuery.ajax(s)},init:function(t,e){jQuery.extend(this,t),this.username&&this.password&&(this.headers.Authorization="Basic "+(new Base64).encode(this.username+":"+this.password)),this.fullpath=this.rpcpath,this.getSessionId(this,e)},exec:function(t,e,s){if(!this.isInitialized)return!1
var n={method:"",arguments:{},tag:""}
jQuery.extend(n,t)
var r={type:"POST",url:this.fullpath,dataType:"json",data:JSON.stringify(n),success:function(t,n){e&&e(t,s)},error:function(t,e,s){var n=""
409===t.status&&(n=t.getResponseHeader("X-Transmission-Session-Id"))?(transmission.SessionId=n,transmission.headers["X-Transmission-Session-Id"]=n,jQuery.ajax(r)):transmission.on.postError&&transmission.on.postError(t)},headers:this.headers}
jQuery.ajax(r)},getStatus:function(t){this.exec({method:"session-stats"},function(e){"success"==e.result&&(t&&t(e.arguments),transmission.torrents.count==e.arguments.torrentCount&&transmission.torrents.activeTorrentCount==e.arguments.activeTorrentCount&&transmission.torrents.pausedTorrentCount==e.arguments.pausedTorrentCount||(transmission.torrents.count=e.arguments.torrentCount,transmission.torrents.activeTorrentCount=e.arguments.activeTorrentCount,transmission.torrents.pausedTorrentCount=e.arguments.pausedTorrentCount,transmission._onTorrentCountChange()))})},getSession:function(t){this.exec({method:"session-get"},function(e){"success"==e.result&&t&&t(e.arguments)})},addTorrentFromUrl:function(t,e,s,n){t.match(/^[0-9a-f]{40}$/i)&&(t="magnet:?xt=urn:btih:"+t)
var r={method:"torrent-add",arguments:{filename:t,paused:!s}}
e&&(r.arguments["download-dir"]=e),this.exec(r,function(t){switch(t.result){case"success":n&&(t.arguments["torrent-added"]?n(t.arguments["torrent-added"]):t.arguments["torrent-duplicate"]&&n({status:"duplicate",torrent:t.arguments["torrent-duplicate"]}))
break
case"duplicate torrent":default:n&&n(t.result)}})},addTorrentFromFile:function(t,e,s,n,r){var o=new FileReader
o.onload=function(t){var o=t.target.result,a="base64,",i=o.indexOf(a)
if(i!=-1){var u=o.substring(i+a.length)
transmission.exec({method:"torrent-add",arguments:{metainfo:u,"download-dir":e,paused:s}},function(t){switch(t.result){case"success":n&&n(t.arguments["torrent-added"],r)
break
case"duplicate torrent":n&&n("duplicate")}})}},o.readAsDataURL(t)},_onTorrentCountChange:function(){this.torrents.loadSimpleInfo=!1,this.on.torrentCountChange&&this.on.torrentCountChange()},removeTorrent:function(t,e,s){this.exec({method:"torrent-remove",arguments:{ids:t,"delete-local-data":e}},function(t){s&&s(t.result)})},getFreeSpace:function(t,e){this.exec({method:"free-space",arguments:{path:t}},function(t){e&&e(t)})},updateBlocklist:function(t){this.exec({method:"blocklist-update"},function(e){t&&t(e.result)})},renameTorrent:function(t,e,s,n){var r=this.torrents.all[t]
return!!r&&void this.exec({method:"torrent-rename-path",arguments:{ids:[t],path:e||r.name,name:s}},function(t){n&&n(t)})},closeSession:function(t){this.exec({method:"session-close"},function(e){t&&t(e)})}}
var transmission={SessionId:"",isInitialized:false,host:"",port:"9091",path:"/transmission/rpc",rpcpath:"../rpc",fullpath:"",on:{torrentCountChange:null,postError:null},username:"",password:"",_status:{stopped:0,checkwait:1,check:2,downloadwait:3,download:4,seedwait:5,seed:6,actively:101},_trackerStatus:{inactive:0,waiting:1,queued:2,active:3},options:{getFolders:true,getTarckers:true},headers:{},trackers:{},islocal:false,downloadDirs:[],getSessionId:function(a,b){jQuery.ajax({type:"POST",url:this.fullpath,
error:function(d){var c="";if(d.status===409&&(c=d.getResponseHeader("X-Transmission-Session-Id"))){a.isInitialized=true;a.SessionId=c;a.headers["X-Transmission-Session-Id"]=c;b&&b()}},headers:this.headers})},init:function(a,b){jQuery.extend(this,a);if(this.username&&this.password)this.headers.Authorization="Basic "+(new Base64).encode(this.username+":"+this.password);this.fullpath=this.rpcpath;this.getSessionId(this,b)},exec:function(a,b,d){if(!this.isInitialized)return false;var c={method:"",arguments:{},
tag:""};jQuery.extend(c,a);var e={type:"POST",url:this.fullpath,dataType:"json",data:JSON.stringify(c),success:function(f){b&&b(f,d)},error:function(f){var g="";if(f.status===409&&(g=f.getResponseHeader("X-Transmission-Session-Id"))){transmission.SessionId=g;transmission.headers["X-Transmission-Session-Id"]=g;jQuery.ajax(e)}else transmission.on.postError&&transmission.on.postError(f)},headers:this.headers};jQuery.ajax(e)},getStatus:function(a){this.exec({method:"session-stats"},function(b){if(b.result==
"success"){a&&a(b.arguments);if(transmission.torrents.count!=b.arguments.torrentCount||transmission.torrents.activeTorrentCount!=b.arguments.activeTorrentCount||transmission.torrents.pausedTorrentCount!=b.arguments.pausedTorrentCount){transmission.torrents.count=b.arguments.torrentCount;transmission.torrents.activeTorrentCount=b.arguments.activeTorrentCount;transmission.torrents.pausedTorrentCount=b.arguments.pausedTorrentCount;transmission._onTorrentCountChange()}}})},getSession:function(a){this.exec({method:"session-get"},
function(b){b.result=="success"&&a&&a(b.arguments)})},addTorrentFromUrl:function(a,b,d,c){if(a.match(/^[0-9a-f]{40}$/i))a="magnet:?xt=urn:btih:"+a;a={method:"torrent-add",arguments:{filename:a,paused:!d}};if(b)a.arguments["download-dir"]=b;this.exec(a,function(e){switch(e.result){case "success":if(c)if(e.arguments["torrent-added"])c(e.arguments["torrent-added"]);else e.arguments["torrent-duplicate"]&&c({status:"duplicate",torrent:e.arguments["torrent-duplicate"]});break;default:c&&c(e.result)}})},
addTorrentFromFile:function(a,b,d,c,e){var f=new FileReader;f.onload=function(g){g=g.target.result;var h=g.indexOf("base64,");if(h!=-1){g=g.substring(h+7);transmission.exec({method:"torrent-add",arguments:{metainfo:g,"download-dir":b,paused:d}},function(i){switch(i.result){case "success":c&&c(i.arguments["torrent-added"],e);break;case "duplicate torrent":c&&c("duplicate")}})}};f.readAsDataURL(a)},_onTorrentCountChange:function(){this.torrents.loadSimpleInfo=false;this.on.torrentCountChange&&this.on.torrentCountChange()},
removeTorrent:function(a,b,d){this.exec({method:"torrent-remove",arguments:{ids:a,"delete-local-data":b}},function(c){d&&d(c.result)})},getFreeSpace:function(a,b){this.exec({method:"free-space",arguments:{path:a}},function(d){b&&b(d)})},updateBlocklist:function(a){this.exec({method:"blocklist-update"},function(b){a&&a(b.result)})},renameTorrent:function(a,b,d,c){var e=this.torrents.all[a];if(!e)return false;this.exec({method:"torrent-rename-path",arguments:{ids:[a],path:b||e.name,name:d}},function(f){c&&
c(f)})},closeSession:function(a){this.exec({method:"session-close"},function(b){a&&a(b)})}};

File diff suppressed because one or more lines are too long

View File

@ -261,7 +261,7 @@ transmission.torrents = {
tracker["host"] = trackerInfo.host;
// 判断当前tracker状态
if (trackerInfo.lastAnnounceSucceeded && trackerInfo.announceState != transmission._trackerStatus.inactive) {
if (!trackerInfo.lastAnnounceSucceeded && trackerInfo.announceState != transmission._trackerStatus.inactive) {
haveWarning = true;
item["warning"] = trackerInfo.lastAnnounceResult;