fix: 修复校验进度条无法正常显示的Bug

closes #458
This commit is contained in:
栽培者 2020-09-14 20:41:43 +08:00
parent 03f3fff082
commit d7a947064c
3 changed files with 153 additions and 30 deletions

View File

@ -9,14 +9,14 @@
<link rel='shortcut icon' href='favicon.ico' type='image/x-icon' />
<title>Transmission Web Control</title>
<!-- Style sheet -->
<link rel="stylesheet" type="text/css" href="tr-web-control/style/before-easyui.css?v=20200913" />
<link rel="stylesheet" type="text/css" href="tr-web-control/style/before-easyui.css?v=20200914" />
<link id="styleEasyui" rel="stylesheet" type="text/css"
href="tr-web-control/script/easyui/themes/default/easyui.css?v=20200913" />
href="tr-web-control/script/easyui/themes/default/easyui.css?v=20200914" />
<link rel="stylesheet" type="text/css" href="tr-web-control/script/plugins/jquery.webui-popover.css" />
<link rel="stylesheet" type="text/css" href="tr-web-control/style/base.css?v=20200913" />
<link rel="stylesheet" type="text/css" href="tr-web-control/script/easyui/themes/icon.css?v=20200913" />
<link rel="stylesheet" type="text/css" href="tr-web-control/style/icon.custom.css?v=20200913" />
<link rel="stylesheet" type="text/css" href="tr-web-control/style/iconfont/iconfont.css?v=20200913" />
<link rel="stylesheet" type="text/css" href="tr-web-control/style/base.css?v=20200914" />
<link rel="stylesheet" type="text/css" href="tr-web-control/script/easyui/themes/icon.css?v=20200914" />
<link rel="stylesheet" type="text/css" href="tr-web-control/style/icon.custom.css?v=20200914" />
<link rel="stylesheet" type="text/css" href="tr-web-control/style/iconfont/iconfont.css?v=20200914" />
<!-- <link rel="stylesheet" type="text/css" href="//at.alicdn.com/t/font_584244_g4d8d6qr58nnrk9.css"/> -->
<!-- Base class library -->
@ -24,20 +24,20 @@
<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=20200913"></script>
<script type="text/javascript" src="tr-web-control/script/easyui/jquery.easyui.min.js?v=20200914"></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/plugins/jquery.webui-popover.min.js"></script>
<!-- -->
<!-- System class library -->
<script type="text/javascript" src="tr-web-control/script/min/FileSaver.min.js?v=20200913"></script>
<script type="text/javascript" src="tr-web-control/script/min/FileSaver.min.js?v=20200914"></script>
<script type="text/javascript" src="tr-web-control/script/other/clipboard.min.js"></script>
<script type="text/javascript" src="tr-web-control/script/min/public.min.js?v=20200913"></script>
<script type="text/javascript" src="tr-web-control/script/other/ua-parser.min.js?v=20200913"></script>
<script type="text/javascript" src="tr-web-control/script/min/transmission.min.js?v=20200913"></script>
<script type="text/javascript" src="tr-web-control/script/min/transmission.torrents.min.js?v=20200913"></script>
<script type="text/javascript" src="tr-web-control/script/min/system.min.js?v=20200913"></script>
<script type="text/javascript" src="tr-web-control/config.js?v=20200913"></script>
<script type="text/javascript" src="tr-web-control/plugin.js?v=20200913"></script>
<script type="text/javascript" src="tr-web-control/script/min/public.min.js?v=20200914"></script>
<script type="text/javascript" src="tr-web-control/script/other/ua-parser.min.js?v=20200914"></script>
<script type="text/javascript" src="tr-web-control/script/min/transmission.min.js?v=20200914"></script>
<script type="text/javascript" src="tr-web-control/script/min/transmission.torrents.min.js?v=20200914"></script>
<script type="text/javascript" src="tr-web-control/script/min/system.min.js?v=20200914"></script>
<script type="text/javascript" src="tr-web-control/config.js?v=20200914"></script>
<script type="text/javascript" src="tr-web-control/plugin.js?v=20200914"></script>
<script type="text/javascript">
var nonpc = ["console", "mobile", "tablet", "smarttv", "wearable", "embedded"]
if ((nonpc.indexOf($.ua.device.type) != -1) && location.search.getQueryString("devicetype") != "computer") {

File diff suppressed because one or more lines are too long

View File

@ -1,14 +1,14 @@
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,activityDate",
status:"id,status,percentDone,trackerStats,leftUntilDone,rateDownload,rateUpload,rateDownload,rateUpload,peersGettingFromUs,peersSendingToUs,uploadRatio,uploadedEver,downloadedEver,error,errorString,doneDate,queuePosition,activityDate",config:"downloadLimit,downloadLimited,peer-limit,seedIdleLimit,seedIdleMode,seedRatioLimit,seedRatioMode,uploadLimit,uploadLimited"},datas:{},recently:null,removed:null,isRecentlyActive:false,newIds:[],btItems:[],getallids:function(b,d,c){var a=this.fields.base;if(this.loadSimpleInfo&&
this.all)a=this.fields.status;a=a.split(",");$.isArray(c)&&$.unique($.merge(a,c));c={fields:a};this.isRecentlyActive=false;if(this.all&&d==undefined){c.ids="recently-active";this.isRecentlyActive=true}else if(d)c.ids=d;if(!this.all)this.all={};transmission.exec({method:"torrent-get",arguments:c},function(f){if(f.result=="success"){transmission.torrents.newIds.length=0;transmission.torrents.loadSimpleInfo=true;transmission.torrents.recently=f.arguments.torrents;transmission.torrents.removed=f.arguments.removed;
transmission.torrents.splitid();b&&b(f.arguments.torrents)}else{transmission.torrents.datas=null;b&&b(null)}})},splitid:function(){this.downloading=[];this.puased=[];this.actively=[];this.error=[];this.warning=[];this.btItems=[];transmission.downloadDirs=[];var b=transmission._status;this.status={};transmission.trackers={};this.totalSize=0;this.folders={};this.count=0;var d=new Base64,c;for(c in this.recently){var a=this.recently[c];this.datas[a.id]=a}var f=[];for(c in this.removed){a=this.removed[c];
f.push(a)}for(c in this.datas){a=this.datas[c];if(!a)return;if($.inArray(a.id,f)!=-1&&f.length>0){if(this.all[a.id]){this.all[a.id]=null;delete this.all[a.id]}this.datas[c]=null;delete this.datas[c]}else{this.isRecentlyActive&&!this.all[a.id]&&this.newIds.push(a.id);a=$.extend(this.all[a.id],a);if(a.uploadedEver==0&&a.downloadedEver==0)a.uploadRatio=-1;a.uploadRatio=parseFloat(a.uploadRatio);a.infoIsLoading=false;var e=this.status[a.status];this.addTracker(a);if(!e){this.status[a.status]=[];e=this.status[a.status]}this.totalSize+=
a.totalSize;a.remainingTime=a.rateDownload>0&&a.leftUntilDone>0?Math.floor(a.leftUntilDone/a.rateDownload*1E3):a.rateDownload==0&&a.leftUntilDone==0&&a.totalSize!=0?0:31536E8;e.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){e=
a.downloadDir.replace(/\\/g,"/").split("/");var h="folders-",i;for(i in e){var g=e[i];if(g!=""){g=d.encode(g);h+=g.replace(/[+|\/|=]/g,"0");(g=this.folders[h])||(g={count:0,torrents:[],size:0,nodeid:h});g.torrents.push(a);g.count++;g.size+=a.totalSize;this.folders[h]=g}}}this.count++}}transmission.downloadDirs=transmission.downloadDirs.sort();this.newIds.length>0&&this.getallids(null,this.newIds)},addTracker:function(b){var d=b.trackerStats,c=[];b.leecherCount=0;b.seederCount=0;if(d.length>0){var a=
[],f;for(f in d){var e=d[f],h=e.lastAnnounceResult.toLowerCase(),i=e.host.getHostName().split(".");$.inArray(i[0],"www,tracker".split(","))!=-1&&i.shift();i=i.join(".");var g="tracker-"+i.replace(/\./g,"-"),j=transmission.trackers[g];if(!j){transmission.trackers[g]={count:0,torrents:[],size:0,connected:true,isBT:d.length>5};j=transmission.trackers[g]}j.name=i;j.nodeid=g;j.host=e.host;if(!e.lastAnnounceSucceeded&&e.announceState!=transmission._trackerStatus.inactive){a.push(e.lastAnnounceResult);if(h==
"could not connect to tracker")j.connected=false}if(j.torrents.indexOf(b)==-1){j.torrents.push(b);j.count++;j.size+=b.totalSize}b.leecherCount+=e.leecherCount;b.seederCount+=e.seederCount;c.indexOf(i)==-1&&c.push(i)}d.length>5&&this.btItems.push(b);if(a.length==d.length){b.warning=a.join(";");if(b.nextAnnounceTime){if(b.nextAnnounceTime>e.nextAnnounceTime)b.nextAnnounceTime=e.nextAnnounceTime}else b.nextAnnounceTime=e.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=c.join(";")}},getPeers:function(b){transmission.exec({method:"torrent-get",arguments:{fields:"peers,peersFrom".split(","),ids:b}},function(d){console.log("data:",d)})},getMoreInfos:function(b,d,c){transmission.exec({method:"torrent-get",arguments:{fields:b.split(","),ids:d}},function(a){if(a.result=="success")c&&c(a.arguments.torrents);else c&&c(null)})},search:function(b,
d){if(!b)return null;if(!d)d=this.all;var c=[];$.each(d,function(a){d[a].name.toLowerCase().indexOf(b.toLowerCase())!=-1&&c.push(d[a])});return this.searchResult=c},getFiles:function(b,d){transmission.exec({method:"torrent-get",arguments:{fields:"files,fileStats".split(","),ids:b}},function(c){if(c.result=="success")d&&d(c.arguments.torrents);else d&&d(null)})},getConfig:function(b,d){this.getMoreInfos(this.fields.config,b,d)},getErrorIds:function(b,d){var c=[],a=new Date;if(d==true)a=a.getTime()/
1E3;for(var f in this.error){var e=this.error[f];if(!($.inArray(e.id,b)!=-1&&b.length>0)){if(d==true)if(a<e.nextAnnounceTime)continue;e.status!=transmission._status.stopped&&c.push(e.id)}}for(f in this.warning){e=this.warning[f];if(!($.inArray(e.id,b)!=-1&&b.length>0)){if(d==true)if(a<e.nextAnnounceTime)continue;c.push(e.id)}}return c},searchAndReplaceTrackers:function(b,d,c){if(b&&d){var a={},f=0,e;for(e in this.all){var h=this.all[e];if(!h)return;var i=h.trackerStats,g;for(g in i)if(i[g].announce==
b){a[g]||(a[g]={ids:[],tracker:d});a[g].ids.push(h.id);f++}}f==0&&c&&c(null,0);for(e in a)transmission.exec({method:"torrent-set",arguments:{ids:a[e].ids,trackerReplace:[parseInt(e),a[e].tracker]}},function(j,k){if(j.result=="success")c&&c(k,f);else c&&c(null)},a[e].ids)}},getMagnetLink:function(b,d){var c="";if(b.constructor.name!="Array")b=[b];if(b.length==0)d&&d(c);else{var a=[],f;for(f in b){f=b[f];if(this.all[f])if(this.all[f].magnetLink)c+=this.all[f].magnetLink+"\n";else a.push(f)}if(a.length==
0)d&&d(c.trim());else transmission.exec({method:"torrent-get",arguments:{fields:["id","magnetLink"],ids:a}},function(e){if(e.result=="success"){for(var h in e.arguments.torrents){h=e.arguments.torrents[h];transmission.torrents.all[h.id].magnetLink=h.magnetLink;c+=h.magnetLink+"\n"}d&&d(c.trim())}})}}};
transmission.torrents={all:null,puased:null,downloading:null,actively:null,searchResult:null,error:null,warning:null,folders:{},status:{},count:0,totalSize:0,loadSimpleInfo:!1,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,activityDate",
status:"id,name,status,totalSize,percentDone,trackerStats,leftUntilDone,rateDownload,rateUpload,recheckProgress,rateDownload,rateUpload,peersGettingFromUs,peersSendingToUs,uploadRatio,uploadedEver,downloadedEver,error,errorString,doneDate,queuePosition,activityDate",config:"downloadLimit,downloadLimited,peer-limit,seedIdleLimit,seedIdleMode,seedRatioLimit,seedRatioMode,uploadLimit,uploadLimited"},datas:{},recently:null,removed:null,isRecentlyActive:!1,newIds:[],btItems:[],getallids:function(b,d,c){var a=
this.fields.base;this.loadSimpleInfo&&this.all&&(a=this.fields.status);a=a.split(",");$.isArray(c)&&$.unique($.merge(a,c));c={fields:a};this.isRecentlyActive=!1;this.all&&void 0==d?(c.ids="recently-active",this.isRecentlyActive=!0):d&&(c.ids=d);this.all||(this.all={});transmission.exec({method:"torrent-get",arguments:c},function(a){"success"==a.result?(transmission.torrents.newIds.length=0,transmission.torrents.loadSimpleInfo=!0,transmission.torrents.recently=a.arguments.torrents,transmission.torrents.removed=
a.arguments.removed,transmission.torrents.splitid(),b&&b(a.arguments.torrents)):(transmission.torrents.datas=null,b&&b(null))})},splitid:function(){this.downloading=[];this.puased=[];this.actively=[];this.error=[];this.warning=[];this.btItems=[];transmission.downloadDirs=[];var b=transmission._status;this.status={};transmission.trackers={};this.totalSize=0;this.folders={};this.count=0;var d=new Base64,c;for(c in this.recently){var a=this.recently[c];this.datas[a.id]=a}var f=[];for(c in this.removed)a=
this.removed[c],f.push(a);for(c in this.datas){a=this.datas[c];if(!a)return;if(-1!=$.inArray(a.id,f)&&0<f.length)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);0==a.uploadedEver&&0==a.downloadedEver&&(a.uploadRatio=-1);a.uploadRatio=parseFloat(a.uploadRatio);a.infoIsLoading=!1;var e=this.status[a.status];this.addTracker(a);e||(this.status[a.status]=
[],e=this.status[a.status]);this.totalSize+=a.totalSize;a.remainingTime=0<a.rateDownload&&0<a.leftUntilDone?Math.floor(a.leftUntilDone/a.rateDownload*1E3):0==a.rateDownload&&0==a.leftUntilDone&&0!=a.totalSize?0:31536E8;e.push(a);0!=a.error&&this.error.push(a);(0<a.rateUpload||0<a.rateDownload)&&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;-1==$.inArray(a.downloadDir,transmission.downloadDirs)&&transmission.downloadDirs.push(a.downloadDir);
if(transmission.options.getFolders&&a.downloadDir){e=a.downloadDir.replace(/\\/g,"/").split("/");var l="folders-",h;for(h in e){var g=e[h];""!=g&&(g=d.encode(g),l+=g.replace(/[+|\/|=]/g,"0"),(g=this.folders[l])||(g={count:0,torrents:[],size:0,nodeid:l}),g.torrents.push(a),g.count++,g.size+=a.totalSize,this.folders[l]=g)}}this.count++}}transmission.downloadDirs=transmission.downloadDirs.sort();0<this.newIds.length&&this.getallids(null,this.newIds)},addTracker:function(b){var d=b.trackerStats,c=[];
b.leecherCount=0;b.seederCount=0;if(0<d.length){var a=[],f;for(f in d){var e=d[f],l=e.lastAnnounceResult.toLowerCase(),h=e.host.getHostName().split(".");-1!=$.inArray(h[0],["www","tracker"])&&h.shift();h=h.join(".");var g="tracker-"+h.replace(/\./g,"-"),k=transmission.trackers[g];k||(transmission.trackers[g]={count:0,torrents:[],size:0,connected:!0,isBT:5<d.length},k=transmission.trackers[g]);k.name=h;k.nodeid=g;k.host=e.host;e.lastAnnounceSucceeded||e.announceState==transmission._trackerStatus.inactive||
(a.push(e.lastAnnounceResult),"could not connect to tracker"==l&&(k.connected=!1));-1==k.torrents.indexOf(b)&&(k.torrents.push(b),k.count++,k.size+=b.totalSize);b.leecherCount+=e.leecherCount;b.seederCount+=e.seederCount;-1==c.indexOf(h)&&c.push(h)}5<d.length&&this.btItems.push(b);a.length==d.length&&(""==a.join(";").replace(/;/g,"")?b.warning="":b.warning=a.join(";"),b.nextAnnounceTime?b.nextAnnounceTime>e.nextAnnounceTime&&(b.nextAnnounceTime=e.nextAnnounceTime):b.nextAnnounceTime=e.nextAnnounceTime,
this.warning.push(b));0>b.leecherCount&&(b.leecherCount=0);0>b.seederCount&&(b.seederCount=0);b.leecher=b.leecherCount+" ("+b.peersGettingFromUs+")";b.seeder=b.seederCount+" ("+b.peersSendingToUs+")";b.trackers=c.join(";")}},getPeers:function(b){transmission.exec({method:"torrent-get",arguments:{fields:["peers","peersFrom"],ids:b}},function(b){console.log("data:",b)})},getMoreInfos:function(b,d,c){transmission.exec({method:"torrent-get",arguments:{fields:b.split(","),ids:d}},function(a){"success"==
a.result?c&&c(a.arguments.torrents):c&&c(null)})},search:function(b,d){if(!b)return null;d||(d=this.all);var c=[];$.each(d,function(a,f){-1!=d[a].name.toLowerCase().indexOf(b.toLowerCase())&&c.push(d[a])});return this.searchResult=c},getFiles:function(b,d){transmission.exec({method:"torrent-get",arguments:{fields:["files","fileStats"],ids:b}},function(b){"success"==b.result?d&&d(b.arguments.torrents):d&&d(null)})},getConfig:function(b,d){this.getMoreInfos(this.fields.config,b,d)},getErrorIds:function(b,
d){var c=[],a=new Date;1==d&&(a=a.getTime()/1E3);for(var f in this.error){var e=this.error[f];-1!=$.inArray(e.id,b)&&0<b.length||1==d&&a<e.nextAnnounceTime||e.status!=transmission._status.stopped&&c.push(e.id)}for(f in this.warning)e=this.warning[f],-1!=$.inArray(e.id,b)&&0<b.length||1==d&&a<e.nextAnnounceTime||c.push(e.id);return c},searchAndReplaceTrackers:function(b,d,c){if(b&&d){var a={},f=0,e;for(e in this.all){var l=this.all[e];if(!l)return;var h=l.trackerStats,g;for(g in h)h[g].announce==b&&
(a[g]||(a[g]={ids:[],tracker:d}),a[g].ids.push(l.id),f++)}0==f&&c&&c(null,0);for(e in a)transmission.exec({method:"torrent-set",arguments:{ids:a[e].ids,trackerReplace:[parseInt(e),a[e].tracker]}},function(a,b){"success"==a.result?c&&c(b,f):c&&c(null)},a[e].ids)}},getMagnetLink:function(b,d){var c="";"Array"!=b.constructor.name&&(b=[b]);if(0==b.length)d&&d(c);else{var a=[];for(f in b){var f=b[f];this.all[f]&&(this.all[f].magnetLink?c+=this.all[f].magnetLink+"\n":a.push(f))}0==a.length?d&&d(c.trim()):
transmission.exec({method:"torrent-get",arguments:{fields:["id","magnetLink"],ids:a}},function(a){if("success"==a.result){for(var b in a.arguments.torrents)b=a.arguments.torrents[b],transmission.torrents.all[b.id].magnetLink=b.magnetLink,c+=b.magnetLink+"\n";d&&d(c.trim())}})}}};