调整检查更新内容的方式

This commit is contained in:
ronggang 2018-04-20 17:23:02 +08:00
parent e4cc1da9f3
commit 2de2502f2e
6 changed files with 98 additions and 60 deletions

View File

@ -49,9 +49,9 @@
<div class="easyui-layout" data-options="fit:true">
<div id="m_title_layout" data-options="region:'center'" border="0">
<img id="logo" src="tr-web-control/logo.png"/><span id="m_title" style="padding:10px;display:none;"></span>
<span id="area-update-infos" style="display:none;padding: 18px;position: absolute;background-color: #ffe48c;">
<span id="area-update-infos" style="display:none;padding: 13px;position: absolute;background-color: #ffe48c;">
<span id="msg-updateInfos" style="color:#ff3232;"></span>
<a id="button-download-update" href="https://github.com/ronggang/transmission-web-control/releases" system-lang="public['text-have-update']" target="_blank"></a>
<a id="button-download-update" href="" class="easyui-linkbutton" data-options="iconCls:'iconfont tr-icon-help'"><span system-lang="public['text-have-update']"></span></a>
</span>
<div style="float:right;padding:13px;">
<span>Theme: </span>

View File

@ -427,6 +427,8 @@ system.defaultLang = {
"text-download-update":"Download this update",
"text-have-update":"An update is available",
"text-on":"ON",
"text-off":"OFF"
"text-off":"OFF",
"text-how-to-update":"How to update?",
"text-ignore-this-version": "Ignore this version"
}
};

View File

@ -427,6 +427,8 @@ system.lang = {
"text-download-update":"Download this update",
"text-have-update":"An update is available",
"text-on":"ON",
"text-off":"OFF"
"text-off":"OFF",
"text-how-to-update":"How to update?",
"text-ignore-this-version": "Ignore this version"
}
};

View File

@ -425,8 +425,10 @@ system.lang = {
"text-confirm": "确认要这样做吗?",
"text-browsers-not-support-features": "当前浏览器不支持该功能!",
"text-download-update": "下载这个更新",
"text-have-update": "有可用的更新",
"text-have-update": "点击查看更新内容",
"text-on": "开",
"text-off": "关"
"text-off": "关",
"text-how-to-update": "如何更新?",
"text-ignore-this-version": "忽略这个版本"
}
};

View File

@ -1,12 +1,12 @@
var system={version:"1.6.0 alpha",rootPath:"tr-web-control/",codeupdate:"20180418",configHead:"transmission-web-control",config:{autoReload:true,reloadStep:5E3,pageSize:30,pagination:true,pageList:[10,20,30,40,50,100,150,200,250,300],defaultSelectNode:null,autoExpandAttribute:false,defaultLang:"",foldersShow:false,theme:"default",showBTServers:false,ui:{status:{tree:{},layout:{main:{},body:{},left:{}},panel:{},size:{nav:{},attribute:{}}}},hideSubfolders:false,simpleCheckMode:false,nav:{servers:true,
folders:true,statistics:true,labels:false},labels:[],labelMaps:{}},storageKeys:{dictionary:{folders:"dictionary.folders"}},dictionary:{folders:null},checkUpdateScript:"https://raw.githubusercontent.com/ronggang/twc-release/master/update.json",contextMenus:{},panel:null,lang:null,reloading:false,autoReloadTimer:null,downloadDir:"",islocal:false,B64:new Base64,currentTorrentId:0,control:{tree:null,torrentlist:null},userConfig:{torrentList:{fields:[],sortName:null,sortOrder:"asc"}},serverConfig:null,
serverSessionStats:null,templates:{},checkedRows:[],uiIsInitialized:false,popoverCount:0,setlang:function(a,b){a||(a=this.config.defaultLang?this.config.defaultLang:navigator.language||navigator.browserLanguage);a||(a="zh-CN");if(a.indexOf("-")!=-1)a=a.split("-")[0].toLocaleLowerCase()+"-"+a.split("-")[1].toLocaleUpperCase();this.languages[a]||(a="en");$.getScript(system.rootPath+"lang/"+a+".js",function(){system.lang=$.extend(true,system.defaultLang,system.lang);system.resetLangText();$.getScript(system.rootPath+
"script/easyui/locale/easyui-lang-"+a.replace("-","_")+".js").done(function(){b&&b()}).fail(function(){$.getScript(system.rootPath+"script/easyui/locale/easyui-lang-en.js",function(){b&&b()})})})},init:function(a,b){this.readConfig();this.lastUIStatus=JSON.parse(JSON.stringify(this.config.ui.status));this.islocal=b==1?true:false;this.panel={main:$("#main"),top:$("#m_top"),toolbar:$("#m_toolbar"),left_layout:$("#m_left_layout"),left:$("#m_left"),body:$("#m_body"),layout_body:$("#layout_body"),layout_left:$("#layout_left"),
list:$("#m_list"),attribute:$("#m_attribute"),bottom:$("#m_bottom"),title:$("#m_title"),status:$("#m_status"),statusbar:$("#m_statusbar"),status_text:$("#status_text"),droparea:$("#dropArea")};this.lang==null?this.setlang(a,function(){system.initdata()}):this.initdata();this.initThemes();this.clipboard=new ClipboardJS("#toolbar_copyPath")},resetLangText:function(a){a||(a=$);var b=a.find("*[system-lang]");$.each(b,function(c,d){var e=$(d).attr("system-lang");e.substr(0,1)=="["?$(d).html(eval("system.lang"+
e)):$(d).html(eval("system.lang."+e))});b=a.find("*[system-tip-lang]");$.each(b,function(c,d){var e=$(d).attr("system-tip-lang");e.substr(0,1)=="["?$(d).attr("title",eval("system.lang"+e)):$(d).attr("title",eval("system.lang."+e))})},initdata:function(){$(document).attr("title",this.lang.system.title+" "+this.version);$.fn.switchbutton.defaults.onText=this.lang["public"]["text-on"];$.fn.switchbutton.defaults.offText=this.lang["public"]["text-off"];var a=[],b="<span>"+this.lang.title.left+"</span>";
if(a.length>1){b+=a.join("");this.panel.left_layout.panel("setTitle",b);for(var c in this.lang.tree.toolbar.nav){$("#tree-toolbar-nav-"+c).linkbutton();switch(c){case "folders":system.config.foldersShow?$("tree-toolbar-nav-"+c).linkbutton({iconCls:"icon-enabled"}).data("status",1):$("tree-toolbar-nav-"+c).linkbutton({iconCls:"icon-disabled"}).data("status",0)}}}else this.panel.left_layout.panel("setTitle",b);b="<span>"+this.lang.title.list+"</span>";a.length=0;if(a.length>1){b+=a.join("");this.panel.body.panel("setTitle",
b);for(c in this.lang["torrent-head"].buttons){$("#torrent-head-buttons-"+c).linkbutton();switch(c){case "autoExpandAttribute":system.config.autoExpandAttribute?$("#torrent-head-buttons-"+c).linkbutton({iconCls:"icon-enabled"}).data("status",1):$("#torrent-head-buttons-"+c).linkbutton({iconCls:"icon-disabled"}).data("status",0)}}}else this.panel.body.panel("setTitle",b);this.panel.status.panel("setTitle",this.lang.title.status);this.panel.attribute.panel({title:this.lang.title.attribute,onExpand:function(){system.currentTorrentId!=
0&&$(this).data("isload")?system.getTorrentInfos(system.currentTorrentId):system.clearTorrentAttribute()},onLoad:function(){if(!$(this).data("isload")){$(this).data("isload",true);system.currentTorrentId!=0&&setTimeout(function(){system.getTorrentInfos(system.currentTorrentId)},500)}}});$.each(this.languages,function(d,e){$("<option/>").text(e).val(d).attr("selected",d==system.lang.name?true:false).appendTo(system.panel.top.find("#lang"))});this.panel.top.find("#lang").change(function(){location.href=
var system={version:"1.6.0 alpha",rootPath:"tr-web-control/",codeupdate:"20180420",configHead:"transmission-web-control",config:{autoReload:true,reloadStep:5E3,pageSize:30,pagination:true,pageList:[10,20,30,40,50,100,150,200,250,300],defaultSelectNode:null,autoExpandAttribute:false,defaultLang:"",foldersShow:false,theme:"default",showBTServers:false,ui:{status:{tree:{},layout:{main:{},body:{},left:{}},panel:{},size:{nav:{},attribute:{}}}},hideSubfolders:false,simpleCheckMode:false,nav:{servers:true,
folders:true,statistics:true,labels:false},labels:[],labelMaps:{},ignoreVersion:[]},storageKeys:{dictionary:{folders:"dictionary.folders"}},dictionary:{folders:null},checkUpdateScript:"https://api.github.com/repos/ronggang/transmission-web-control/releases/latest",contextMenus:{},panel:null,lang:null,reloading:false,autoReloadTimer:null,downloadDir:"",islocal:false,B64:new Base64,currentTorrentId:0,control:{tree:null,torrentlist:null},userConfig:{torrentList:{fields:[],sortName:null,sortOrder:"asc"}},
serverConfig:null,serverSessionStats:null,templates:{},checkedRows:[],uiIsInitialized:false,popoverCount:0,setlang:function(a,b){a||(a=this.config.defaultLang?this.config.defaultLang:navigator.language||navigator.browserLanguage);a||(a="zh-CN");if(a.indexOf("-")!=-1)a=a.split("-")[0].toLocaleLowerCase()+"-"+a.split("-")[1].toLocaleUpperCase();this.languages[a]||(a="en");$.getScript(system.rootPath+"lang/"+a+".js",function(){system.lang=$.extend(true,system.defaultLang,system.lang);system.resetLangText();
$.getScript(system.rootPath+"script/easyui/locale/easyui-lang-"+a.replace("-","_")+".js").done(function(){b&&b()}).fail(function(){$.getScript(system.rootPath+"script/easyui/locale/easyui-lang-en.js",function(){b&&b()})})})},init:function(a,b){this.readConfig();this.lastUIStatus=JSON.parse(JSON.stringify(this.config.ui.status));this.islocal=b==1?true:false;this.panel={main:$("#main"),top:$("#m_top"),toolbar:$("#m_toolbar"),left_layout:$("#m_left_layout"),left:$("#m_left"),body:$("#m_body"),layout_body:$("#layout_body"),
layout_left:$("#layout_left"),list:$("#m_list"),attribute:$("#m_attribute"),bottom:$("#m_bottom"),title:$("#m_title"),status:$("#m_status"),statusbar:$("#m_statusbar"),status_text:$("#status_text"),droparea:$("#dropArea")};this.lang==null?this.setlang(a,function(){system.initdata()}):this.initdata();this.initThemes();this.clipboard=new ClipboardJS("#toolbar_copyPath")},resetLangText:function(a){a||(a=$);var b=a.find("*[system-lang]");$.each(b,function(c,d){var f=$(d).attr("system-lang");f.substr(0,
1)=="["?$(d).html(eval("system.lang"+f)):$(d).html(eval("system.lang."+f))});b=a.find("*[system-tip-lang]");$.each(b,function(c,d){var f=$(d).attr("system-tip-lang");f.substr(0,1)=="["?$(d).attr("title",eval("system.lang"+f)):$(d).attr("title",eval("system.lang."+f))})},initdata:function(){$(document).attr("title",this.lang.system.title+" "+this.version);$.fn.switchbutton.defaults.onText=this.lang["public"]["text-on"];$.fn.switchbutton.defaults.offText=this.lang["public"]["text-off"];var a=[],b="<span>"+
this.lang.title.left+"</span>";if(a.length>1){b+=a.join("");this.panel.left_layout.panel("setTitle",b);for(var c in this.lang.tree.toolbar.nav){$("#tree-toolbar-nav-"+c).linkbutton();switch(c){case "folders":system.config.foldersShow?$("tree-toolbar-nav-"+c).linkbutton({iconCls:"icon-enabled"}).data("status",1):$("tree-toolbar-nav-"+c).linkbutton({iconCls:"icon-disabled"}).data("status",0)}}}else this.panel.left_layout.panel("setTitle",b);b="<span>"+this.lang.title.list+"</span>";a.length=0;if(a.length>
1){b+=a.join("");this.panel.body.panel("setTitle",b);for(c in this.lang["torrent-head"].buttons){$("#torrent-head-buttons-"+c).linkbutton();switch(c){case "autoExpandAttribute":system.config.autoExpandAttribute?$("#torrent-head-buttons-"+c).linkbutton({iconCls:"icon-enabled"}).data("status",1):$("#torrent-head-buttons-"+c).linkbutton({iconCls:"icon-disabled"}).data("status",0)}}}else this.panel.body.panel("setTitle",b);this.panel.status.panel("setTitle",this.lang.title.status);this.panel.attribute.panel({title:this.lang.title.attribute,
onExpand:function(){system.currentTorrentId!=0&&$(this).data("isload")?system.getTorrentInfos(system.currentTorrentId):system.clearTorrentAttribute()},onLoad:function(){if(!$(this).data("isload")){$(this).data("isload",true);system.currentTorrentId!=0&&setTimeout(function(){system.getTorrentInfos(system.currentTorrentId)},500)}}});$.each(this.languages,function(d,f){$("<option/>").text(f).val(d).attr("selected",d==system.lang.name?true:false).appendTo(system.panel.top.find("#lang"))});this.panel.top.find("#lang").change(function(){location.href=
"?lang="+this.value});this.panel.toolbar.attr("class","panel-header");this.initTree();this.initToolbar();this.initStatusBar();this.initTorrentTable();this.connect();this.initEvent();this.checkUpdate()},initEvent:function(){$(window).resize(function(){$("#main").layout("resize")});this.panel.droparea[0].addEventListener("dragover",function(a){a.stopPropagation();a.preventDefault();system.debug("#dropArea.dragover")},false);this.panel.list[0].addEventListener("dragover",function(a){a.stopPropagation();
a.preventDefault();system.panel.droparea.show();system.debug("dragover")},false);this.panel.droparea[0].addEventListener("drop",function(a){a.stopPropagation();a.preventDefault();system.panel.droparea.hide();system.debug("drop.e.dataTransfer:",a.dataTransfer);system.checkDropFiles(a.dataTransfer.files)},false);this.panel.droparea[0].addEventListener("dragleave",function(a){a.stopPropagation();a.preventDefault();system.panel.droparea.hide();system.debug("dragleave")},false);$("#text-drop-title").html(this.lang["public"]["text-drop-title"]);
$("#button-cancel-checked").on("click",function(){system.control.torrentlist.datagrid("uncheckAll")});this.panel.left.tree({onExpand:function(a){system.config.ui.status.tree[a.id]=a.state;system.saveConfig()},onCollapse:function(a){system.config.ui.status.tree[a.id]=a.state;system.saveConfig()}});this.panel.layout_body.layout({onExpand:function(a){system.config.ui.status.layout.body[a]="open";system.saveConfig()},onCollapse:function(a){system.config.ui.status.layout.body[a]="closed";system.saveConfig()}});
@ -17,22 +17,22 @@ text:this.lang.tree.all+" ("+this.lang.tree.status.loading+")",children:[{id:"do
iconCls:"iconfont tr-icon-errors"},{id:"warning",text:this.lang.tree.warning,iconCls:"iconfont tr-icon-warning"}]}],b={servers:{id:"servers",text:this.lang.tree.servers,state:"closed",iconCls:"iconfont tr-icon-servers",children:[{id:"servers-loading",text:this.lang.tree.status.loading,iconCls:"tree-loading"}]},folders:{id:"folders",text:this.lang.tree.folders,iconCls:"iconfont tr-icon-folder",state:"closed",children:[{id:"folders-loading",text:this.lang.tree.status.loading,iconCls:"tree-loading"}]},
statistics:{id:"statistics",text:this.lang.tree.statistics.title,state:"closed",iconCls:"iconfont tr-icon-shuju",children:[{id:"cumulative-stats",text:this.lang.tree.statistics.cumulative,iconCls:"iconfont tr-icon-folder",children:[{id:"uploadedBytes",text:this.lang.tree.statistics.uploadedBytes,iconCls:"iconfont tr-icon-empty"},{id:"downloadedBytes",text:this.lang.tree.statistics.downloadedBytes,iconCls:"iconfont tr-icon-empty"},{id:"filesAdded",text:this.lang.tree.statistics.filesAdded,iconCls:"iconfont tr-icon-empty"},
{id:"sessionCount",text:this.lang.tree.statistics.sessionCount,iconCls:"iconfont tr-icon-empty"},{id:"secondsActive",text:this.lang.tree.statistics.secondsActive,iconCls:"iconfont tr-icon-empty"}]},{id:"current-stats",text:this.lang.tree.statistics.current,iconCls:"iconfont tr-icon-folder",children:[{id:"current-uploadedBytes",text:this.lang.tree.statistics.uploadedBytes,iconCls:"iconfont tr-icon-empty"},{id:"current-downloadedBytes",text:this.lang.tree.statistics.downloadedBytes,iconCls:"iconfont tr-icon-empty"},
{id:"current-filesAdded",text:this.lang.tree.statistics.filesAdded,iconCls:"iconfont tr-icon-empty"},{id:"current-sessionCount",text:this.lang.tree.statistics.sessionCount,iconCls:"iconfont tr-icon-empty"},{id:"current-secondsActive",text:this.lang.tree.statistics.secondsActive,iconCls:"iconfont tr-icon-empty"}]}]},labels:{id:"labels",text:this.lang.tree.labels,iconCls:"iconfont tr-icon-labels"}},c;for(c in this.config.nav){var d=this.config.nav[c],e=b[c];e&&d&&a.push(e)}this.panel.left.tree({data:a,
onSelect:function(f){system.loadTorrentToList({node:f})},lines:true})},initUIStatus:function(){if(!this.uiIsInitialized){system.uiIsInitialized=true;var a=this.lastUIStatus.tree,b;for(b in a){var c=this.panel.left.tree("find",b);if(c&&c.target)a[b]=="open"?this.panel.left.tree("expand",c.target):this.panel.left.tree("collapse",c.target)}if(this.config.defaultSelectNode){(c=this.panel.left.tree("find",this.config.defaultSelectNode))&&(this.config.foldersShow||this.config.defaultSelectNode.indexOf("folders")==
{id:"current-filesAdded",text:this.lang.tree.statistics.filesAdded,iconCls:"iconfont tr-icon-empty"},{id:"current-sessionCount",text:this.lang.tree.statistics.sessionCount,iconCls:"iconfont tr-icon-empty"},{id:"current-secondsActive",text:this.lang.tree.statistics.secondsActive,iconCls:"iconfont tr-icon-empty"}]}]},labels:{id:"labels",text:this.lang.tree.labels,iconCls:"iconfont tr-icon-labels"}},c;for(c in this.config.nav){var d=this.config.nav[c],f=b[c];f&&d&&a.push(f)}this.panel.left.tree({data:a,
onSelect:function(e){system.loadTorrentToList({node:e})},lines:true})},initUIStatus:function(){if(!this.uiIsInitialized){system.uiIsInitialized=true;var a=this.lastUIStatus.tree,b;for(b in a){var c=this.panel.left.tree("find",b);if(c&&c.target)a[b]=="open"?this.panel.left.tree("expand",c.target):this.panel.left.tree("collapse",c.target)}if(this.config.defaultSelectNode){(c=this.panel.left.tree("find",this.config.defaultSelectNode))&&(this.config.foldersShow||this.config.defaultSelectNode.indexOf("folders")==
-1)||(c=this.panel.left.tree("find","torrent-all"));this.panel.left.tree("select",c.target)}if(this.lastUIStatus.size.nav&&this.lastUIStatus.size.nav.width){this.panel.main.layout("panel","west").panel("resize",{width:this.lastUIStatus.size.nav.width+5});this.panel.main.layout("resize")}if(this.lastUIStatus.size.attribute&&this.lastUIStatus.size.attribute.height){this.panel.layout_body.layout("panel","south").panel("resize",{height:this.lastUIStatus.size.attribute.height});this.panel.layout_body.layout("resize")}a=
this.lastUIStatus.layout.body;for(b in a)a[b]=="open"?this.panel.layout_body.layout("expand",b):this.panel.layout_body.layout("collapse",b);a=this.lastUIStatus.layout.left;for(b in a)a[b]=="open"?this.panel.layout_left.layout("expand",b):this.panel.layout_left.layout("collapse",b);a=this.lastUIStatus.layout.main;for(b in a)a[b]=="open"?this.panel.main.layout("expand",b):this.panel.main.layout("collapse",b)}},initTorrentTable:function(){function a(){b&&$(b).remove();b=$("<div/>").appendTo("body");
b.menu({onClick:function(h){if(h.iconCls=="icon-ok"){system.control.torrentlist.datagrid("hideColumn",h.name);b.menu("setIcon",{target:h.target,iconCls:"icon-empty"})}else{system.control.torrentlist.datagrid("showColumn",h.name);b.menu("setIcon",{target:h.target,iconCls:"icon-ok"})}system.resetTorrentListFieldsUserConfig(system.control.torrentlist.datagrid("options").columns[0]);system.saveUserConfig()}});for(var d=system.control.torrentlist.datagrid("getColumnFields"),e=0;e<d.length;e++){var f=d[e],
g=system.control.torrentlist.datagrid("getColumnOption",f);if(g.allowCustom!=false&&g.allowCustom!="false")b.menu("appendItem",{text:g.title,name:f,iconCls:g.hidden?"icon-empty":"icon-ok"})}}this.control.torrentlist=$("<table/>").attr("class","torrent-list").appendTo(this.panel.list);var b=null,c=-1;$.get(system.rootPath+"template/torrent-fields.json?time="+new Date,function(d){d=d.fields;for(var e={},f=0;f<d.length;f++){var g=d[f];e[g.field]=g}if(system.userConfig.torrentList.fields.length!=0)d=
$.extend(d,system.userConfig.torrentList.fields);system.userConfig.torrentList.fields=d;for(var h in d){g=d[h];if((f=e[g.field])&&f.formatter)g.formatter=f.formatter;else g.formatter&&delete g.formatter;if(f&&f.sortable)g.sortable=f.sortable;else g.sortable&&delete g.sortable;g.title=system.lang.torrent.fields[g.field]||g.field;system.setFieldFormat(g)}system.control.torrentlist.datagrid({autoRowHeight:false,pagination:system.config.pagination,rownumbers:true,remoteSort:false,checkOnSelect:false,
b.menu({onClick:function(h){if(h.iconCls=="icon-ok"){system.control.torrentlist.datagrid("hideColumn",h.name);b.menu("setIcon",{target:h.target,iconCls:"icon-empty"})}else{system.control.torrentlist.datagrid("showColumn",h.name);b.menu("setIcon",{target:h.target,iconCls:"icon-ok"})}system.resetTorrentListFieldsUserConfig(system.control.torrentlist.datagrid("options").columns[0]);system.saveUserConfig()}});for(var d=system.control.torrentlist.datagrid("getColumnFields"),f=0;f<d.length;f++){var e=d[f],
g=system.control.torrentlist.datagrid("getColumnOption",e);if(g.allowCustom!=false&&g.allowCustom!="false")b.menu("appendItem",{text:g.title,name:e,iconCls:g.hidden?"icon-empty":"icon-ok"})}}this.control.torrentlist=$("<table/>").attr("class","torrent-list").appendTo(this.panel.list);var b=null,c=-1;$.get(system.rootPath+"template/torrent-fields.json?time="+new Date,function(d){d=d.fields;for(var f={},e=0;e<d.length;e++){var g=d[e];f[g.field]=g}if(system.userConfig.torrentList.fields.length!=0)d=
$.extend(d,system.userConfig.torrentList.fields);system.userConfig.torrentList.fields=d;for(var h in d){g=d[h];if((e=f[g.field])&&e.formatter)g.formatter=e.formatter;else g.formatter&&delete g.formatter;if(e&&e.sortable)g.sortable=e.sortable;else g.sortable&&delete g.sortable;g.title=system.lang.torrent.fields[g.field]||g.field;system.setFieldFormat(g)}system.control.torrentlist.datagrid({autoRowHeight:false,pagination:system.config.pagination,rownumbers:true,remoteSort:false,checkOnSelect:false,
pageSize:system.config.pageSize,pageList:system.config.pageList,idField:"id",fit:true,striped:true,sortName:system.userConfig.torrentList.sortName,sortOrder:system.userConfig.torrentList.sortOrder,drophead:true,columns:[d],onCheck:function(i,j){system.checkTorrentRow(i,j)},onUncheck:function(i,j){system.checkTorrentRow(i,j)},onCheckAll:function(){system.checkTorrentRow("all",false)},onUncheckAll:function(){system.checkTorrentRow("all",true)},onSelect:function(i,j){c!=-1&&system.control.torrentlist.datagrid("unselectRow",
c);system.getTorrentInfos(j.id);c=i},onUnselect:function(){system.currentTorrentId=0;c=-1},onBeforeLoad:function(){system.currentTorrentId=0},onSortColumn:function(i,j){var k=system.control.torrentlist.datagrid("getData").originalRows.sort(arrayObjectSort(i,j));system.control.torrentlist.datagrid("loadData",k);system.resetTorrentListFieldsUserConfig(system.control.torrentlist.datagrid("options").columns[0]);system.userConfig.torrentList.sortName=i;system.userConfig.torrentList.sortOrder=j;system.saveUserConfig()},
onRowContextMenu:function(i,j){system.config.simpleCheckMode&&system.control.torrentlist.datagrid("uncheckAll");system.checkedRows.length==0&&system.control.torrentlist.datagrid("checkRow",j);i.preventDefault();system.showContextMenu("torrent-list",i)},onHeadDrop:function(){system.resetTorrentListFieldsUserConfig(system.control.torrentlist.datagrid("options").columns[0]);system.saveUserConfig()},onResizeColumn:function(){system.resetTorrentListFieldsUserConfig(system.control.torrentlist.datagrid("options").columns[0]);
system.saveUserConfig()},onHeaderContextMenu:function(i){i.preventDefault();b||a();b.menu("show",{left:i.pageX,top:i.pageY})}})},"json");this.control.torrentlist.refresh=function(){system.control.torrentlist.datagrid("getPager").find(".pagination-load").click()}},resetTorrentListFieldsUserConfig:function(a){var b={};$.each(this.userConfig.torrentList.fields,function(c,d){b[d.field]=d});this.userConfig.torrentList.fields=[];$.each(a,function(c,d){var e=$.extend({},b[d.field]);e.width=d.width;e.hidden=
d.hidden;system.userConfig.torrentList.fields.push(e)})},showContextMenu:function(a,b){var c=this.contextMenus[a];if(c)c.empty();else{c=$("<div/>").attr("class","easyui-menu").css({"min-width":"180px"}).appendTo(this.panel.main);this.contextMenus[a]=c;c.menu()}var d=null;switch(a){case "torrent-list":d=["start","pause","-","rename","remove","recheck","-","morepeers","changeDownloadDir","copyPath","-","menu-queue-move-top","menu-queue-move-up","menu-queue-move-down","menu-queue-move-bottom","-","setLabels"];
var e=this.panel.toolbar,f;for(f in d){var g=d[f];if(g=="-")$("<div class='menu-sep'></div>").appendTo(c);else{var h=e.find("#toolbar_"+g);if(h.length>0)c.menu("appendItem",{text:h.attr("title"),id:g,iconCls:h.linkbutton("options").iconCls,disabled:h.linkbutton("options").disabled,onclick:function(){system.panel.toolbar.find("#toolbar_"+$(this).attr("id")).click()}});else{h=$("#"+g);if(h.length>0)c.menu("appendItem",{text:h.attr("title"),id:g,iconCls:h.attr("id").replace("menu-queue-move","iconfont tr-icon"),
disabled:e.find("#toolbar_queue").linkbutton("options").disabled,onclick:function(){$("#"+$(this).attr("id")).click()}});else(h=this.getContentMenuWithKey(g))&&c.menu("appendItem",h)}h=null}}d=$("#copyPath",c);d.attr({"data-clipboard-action":"copy","data-clipboard-target":"#clipboard-source"});new ClipboardJS(d.get(0))}c.menu("show",{left:b.pageX,top:b.pageY});d=c=null},getContentMenuWithKey:function(a){switch(a){case "setLabels":return{id:"setLabels",text:system.lang.menus.setLabels,iconCls:"iconfont tr-icon-labels",
disabled:this.checkedRows.length==0,onclick:function(){var b=system.checkedRows,c=[],d;for(d in b)c.push(b[d].hashString);c.length!=0&&system.openDialogFromTemplate({id:"dialog-torrent-setLabels",options:{title:system.lang.dialog["torrent-setLabels"].title,width:520,height:200},datas:{hashs:c}})}}}},formetTorrentLabels:function(a,b){var c=$("<div style='position: relative;'/>");if(a){if(typeof a=="string")a=a.split(",");for(var d=0;d<a.length;d++){var e=this.config.labels[a[d]];if(e)$("<span class='user-label'/>").html(e.name).css({"background-color":e.color,
color:getGrayLevel(e.color)>0.5?"#000":"#fff"}).appendTo(c)}}d=$("<button onclick='javascript:system.setTorrentLabels(this,\""+b+'");\' data-options="iconCls:\'iconfont tr-icon-labels\',plain:true" class="easyui-linkbutton user-label-set"/>').appendTo(c);d.linkbutton();d.find("span").first().attr({title:system.lang.dialog["torrent-setLabels"].title});return c.get(0).outerHTML},setTorrentLabels:function(a,b){system.openDialogFromTemplate({id:"dialog-torrent-setLabels",options:{title:system.lang.dialog["torrent-setLabels"].title,
system.saveUserConfig()},onHeaderContextMenu:function(i){i.preventDefault();b||a();b.menu("show",{left:i.pageX,top:i.pageY})}})},"json");this.control.torrentlist.refresh=function(){system.control.torrentlist.datagrid("getPager").find(".pagination-load").click()}},resetTorrentListFieldsUserConfig:function(a){var b={};$.each(this.userConfig.torrentList.fields,function(c,d){b[d.field]=d});this.userConfig.torrentList.fields=[];$.each(a,function(c,d){var f=$.extend({},b[d.field]);f.width=d.width;f.hidden=
d.hidden;system.userConfig.torrentList.fields.push(f)})},showContextMenu:function(a,b){var c=this.contextMenus[a];if(c)c.empty();else{c=$("<div/>").attr("class","easyui-menu").css({"min-width":"180px"}).appendTo(this.panel.main);this.contextMenus[a]=c;c.menu()}var d=null;switch(a){case "torrent-list":d=["start","pause","-","rename","remove","recheck","-","morepeers","changeDownloadDir","copyPath","-","menu-queue-move-top","menu-queue-move-up","menu-queue-move-down","menu-queue-move-bottom","-","setLabels"];
var f=this.panel.toolbar,e;for(e in d){var g=d[e];if(g=="-")$("<div class='menu-sep'></div>").appendTo(c);else{var h=f.find("#toolbar_"+g);if(h.length>0)c.menu("appendItem",{text:h.attr("title"),id:g,iconCls:h.linkbutton("options").iconCls,disabled:h.linkbutton("options").disabled,onclick:function(){system.panel.toolbar.find("#toolbar_"+$(this).attr("id")).click()}});else{h=$("#"+g);if(h.length>0)c.menu("appendItem",{text:h.attr("title"),id:g,iconCls:h.attr("id").replace("menu-queue-move","iconfont tr-icon"),
disabled:f.find("#toolbar_queue").linkbutton("options").disabled,onclick:function(){$("#"+$(this).attr("id")).click()}});else(h=this.getContentMenuWithKey(g))&&c.menu("appendItem",h)}h=null}}d=$("#copyPath",c);d.attr({"data-clipboard-action":"copy","data-clipboard-target":"#clipboard-source"});new ClipboardJS(d.get(0))}c.menu("show",{left:b.pageX,top:b.pageY});d=c=null},getContentMenuWithKey:function(a){switch(a){case "setLabels":return{id:"setLabels",text:system.lang.menus.setLabels,iconCls:"iconfont tr-icon-labels",
disabled:this.checkedRows.length==0,onclick:function(){var b=system.checkedRows,c=[],d;for(d in b)c.push(b[d].hashString);c.length!=0&&system.openDialogFromTemplate({id:"dialog-torrent-setLabels",options:{title:system.lang.dialog["torrent-setLabels"].title,width:520,height:200},datas:{hashs:c}})}}}},formetTorrentLabels:function(a,b){var c=$("<div style='position: relative;'/>");if(a){if(typeof a=="string")a=a.split(",");for(var d=0;d<a.length;d++){var f=this.config.labels[a[d]];if(f)$("<span class='user-label'/>").html(f.name).css({"background-color":f.color,
color:getGrayLevel(f.color)>0.5?"#000":"#fff"}).appendTo(c)}}d=$("<button onclick='javascript:system.setTorrentLabels(this,\""+b+'");\' data-options="iconCls:\'iconfont tr-icon-labels\',plain:true" class="easyui-linkbutton user-label-set"/>').appendTo(c);d.linkbutton();d.find("span").first().attr({title:system.lang.dialog["torrent-setLabels"].title});return c.get(0).outerHTML},setTorrentLabels:function(a,b){system.openDialogFromTemplate({id:"dialog-torrent-setLabels",options:{title:system.lang.dialog["torrent-setLabels"].title,
width:520,height:200},datas:{hashs:[b]},type:1,source:$(a)})},checkTorrentRow:function(a,b){this.checkedRows=this.control.torrentlist.datagrid("getChecked");this.showCheckedInStatus();if(a=="all"){if(this.control.torrentlist.datagrid("getRows").length!=0){$("#toolbar_start, #toolbar_pause, #toolbar_remove, #toolbar_recheck, #toolbar_changeDownloadDir,#toolbar_morepeers,#toolbar_copyPath",this.panel.toolbar).linkbutton({disabled:b});$("#toolbar_rename, #toolbar_morepeers",this.panel.toolbar).linkbutton({disabled:true});
this.panel.toolbar.find("#toolbar_queue").menubutton("disable")}}else if(this.checkedRows.length==0){$("#toolbar_start, #toolbar_pause, #toolbar_rename, #toolbar_remove, #toolbar_recheck, #toolbar_changeDownloadDir,#toolbar_morepeers,#toolbar_copyPath",this.panel.toolbar).linkbutton({disabled:true});this.panel.toolbar.find("#toolbar_queue").menubutton("disable")}else if(this.checkedRows.length==1){$("#toolbar_remove, #toolbar_rename, #toolbar_changeDownloadDir,#toolbar_copyPath",this.panel.toolbar).linkbutton({disabled:false});
this.panel.toolbar.find("#toolbar_queue").menubutton("enable");switch(transmission.torrents.all[b.id].status){case transmission._status.stopped:this.panel.toolbar.find("#toolbar_start, #toolbar_recheck").linkbutton({disabled:false});this.panel.toolbar.find("#toolbar_pause, #toolbar_morepeers").linkbutton({disabled:true});break;case transmission._status.check:case transmission._status.checkwait:this.panel.toolbar.find("#toolbar_start, #toolbar_pause, #toolbar_recheck, #toolbar_morepeers").linkbutton({disabled:true});
@ -53,7 +53,7 @@ this.panel.toolbar.find("#toolbar_search").searchbox({searcher:function(a){syste
0);transmission.on.torrentCountChange=function(){system.reloadTorrentBaseInfos()};transmission.on.postError=function(){};transmission.init({islocal:true},function(){system.reloadSession(true);system.getServerStatus()})},reloadSession:function(a){transmission.getSession(function(b){system.serverConfig=b;$("#status_version").html("Transmission "+system.lang.statusbar.version+b.version+", RPC: "+b["rpc-version"]+", WEB Control: "+system.version+"("+system.codeupdate+")");if(b["alt-speed-enabled"]==true){system.panel.toolbar.find("#toolbar_alt_speed").linkbutton({iconCls:"iconfont tr-icon-woniu"});
$("#status_alt_speed").show()}else{system.panel.toolbar.find("#toolbar_alt_speed").linkbutton({iconCls:"iconfont tr-icon-rocket"});$("#status_alt_speed").hide()}system.downloadDir=b["download-dir"];transmission.downloadDirs.length==0&&transmission.downloadDirs.push(system.downloadDir);parseInt(system.serverConfig["rpc-version"])>=15?transmission.getFreeSpace(system.downloadDir,function(c){system.serverConfig["download-dir-free-space"]=c.arguments["size-bytes"];system.showFreeSpace(c.arguments["size-bytes"])}):
system.showFreeSpace(system.serverConfig["download-dir-free-space"]);a&&system.showStatus(system.lang.system.status.connected)})},showFreeSpace:function(a){a=a;a=a==-1?system.lang["public"]["text-unknown"]:formatSize(a);$("#status_freespace").text(system.lang.dialog["system-config"]["download-dir-free-space"]+" "+a)},reloadTorrentBaseInfos:function(a,b){if(!this.reloading){clearTimeout(this.autoReloadTimer);this.reloading=true;var c={trackers:transmission.trackers,folders:transmission.torrents.folders};
transmission.torrents.getallids(function(d){var e=[],f;for(f in d)e.push(d[f].id);d=transmission.torrents.getErrorIds(e,true);d.length>0?transmission.torrents.getallids(function(){system.resetTorrentInfos(c)},d):system.resetTorrentInfos(c)},a,b)}},resetTorrentInfos:function(a){this.resetNavTorrentStatus();this.resetNavServers(a);this.resetNavStatistics();this.resetNavFolders(a);this.resetNavLabels();navigator.userAgent.indexOf("Firefox")>0&&system.panel.left.find("span.nav-total-size").css({"margin-top":"-19px"})},
transmission.torrents.getallids(function(d){var f=[],e;for(e in d)f.push(d[e].id);d=transmission.torrents.getErrorIds(f,true);d.length>0?transmission.torrents.getallids(function(){system.resetTorrentInfos(c)},d):system.resetTorrentInfos(c)},a,b)}},resetTorrentInfos:function(a){this.resetNavTorrentStatus();this.resetNavServers(a);this.resetNavStatistics();this.resetNavFolders(a);this.resetNavLabels();navigator.userAgent.indexOf("Firefox")>0&&system.panel.left.find("span.nav-total-size").css({"margin-top":"-19px"})},
resetNavTorrentStatus:function(){var a=this.currentTorrentId;transmission.torrents.status[transmission._status.stopped]?system.updateTreeNodeText("paused",system.lang.tree.paused+this.showNodeMoreInfos(transmission.torrents.status[transmission._status.stopped].length)):system.updateTreeNodeText("paused",system.lang.tree.paused);transmission.torrents.status[transmission._status.seed]?system.updateTreeNodeText("sending",system.lang.tree.sending+this.showNodeMoreInfos(transmission.torrents.status[transmission._status.seed].length)):
system.updateTreeNodeText("sending",system.lang.tree.sending);if(transmission.torrents.status[transmission._status.seedwait]){var b=system.panel.left.tree("find","sending"),c=system.panel.left.tree("getChildren",b.target),d=system.lang.tree.wait+this.showNodeMoreInfos(transmission.torrents.status[transmission._status.seedwait].length);c.length>0?system.updateTreeNodeText(c[0].id,d):system.appendTreeNode(b,[{id:"seedwait",text:d,iconCls:"iconfont tr-icon-wait"}])}else system.removeTreeNode("seedwait");
transmission.torrents.status[transmission._status.check]?system.updateTreeNodeText("check",system.lang.tree.check+this.showNodeMoreInfos(transmission.torrents.status[transmission._status.check].length)):system.updateTreeNodeText("check",system.lang.tree.check);if(transmission.torrents.status[transmission._status.checkwait]){b=system.panel.left.tree("find","check");c=system.panel.left.tree("getChildren",b.target);d=system.lang.tree.wait+this.showNodeMoreInfos(transmission.torrents.status[transmission._status.checkwait].length);
@ -61,8 +61,8 @@ c.length>0?system.updateTreeNodeText(c[0].id,d):system.appendTreeNode(b,[{id:"ch
system.panel.left.tree("find","downloading");c=system.panel.left.tree("getChildren",b.target);d=system.lang.tree.wait+this.showNodeMoreInfos(transmission.torrents.status[transmission._status.downloadwait].length);c.length>0?system.updateTreeNodeText(c[0].id,d):system.appendTreeNode(b,[{id:"downloadwait",text:d,iconCls:"iconfont tr-icon-wait"}])}else system.removeTreeNode("downloadwait");system.updateTreeNodeText("actively",system.lang.tree.actively+this.showNodeMoreInfos(transmission.torrents.actively.length));
system.updateTreeNodeText("error",system.lang.tree.error+this.showNodeMoreInfos(transmission.torrents.error.length));system.updateTreeNodeText("warning",system.lang.tree.warning+this.showNodeMoreInfos(transmission.torrents.warning.length));b=system.panel.left.tree("getSelected");if(b!=null){c=system.control.torrentlist.datagrid("options").pageNumber;system.loadTorrentToList({node:b,page:c})}a!=0&&system.control.torrentlist.datagrid("selectRecord",a);system.reloading=false;if(system.config.autoReload)system.autoReloadTimer=
setTimeout(function(){system.reloadData()},system.config.reloadStep);system.updateTreeNodeText("torrent-all",system.lang.tree.all+this.showNodeMoreInfos(transmission.torrents.count,transmission.torrents.totalSize))},resetNavServers:function(a){var b=this.panel.left.tree("find","servers");if(this.config.nav.servers){if(b){var c=b.state;this.removeTreeNode("servers-loading")}else{this.appendTreeNode(null,[{id:"servers",text:this.lang.tree.servers,state:"closed",iconCls:"iconfont tr-icon-servers"}]);
b=this.panel.left.tree("find","servers")}var d=this.panel.left.tree("find","btservers"),e=d?d.state:"close",f;for(f in transmission.trackers){var g=transmission.trackers[f];if(g.isBT){if(!system.config.showBTServers)continue;if(!d){this.appendTreeNode(b,[{id:"btservers",text:"BT",state:"open",iconCls:"iconfont tr-icon-bt"}]);d=this.panel.left.tree("find","btservers")}}var h=system.panel.left.tree("find",g.nodeid),i=g.name+this.showNodeMoreInfos(g.count,g.size);h?system.updateTreeNodeText(g.nodeid,
i,g.connected?"iconfont tr-icon-server":"iconfont tr-icon-server-error"):system.appendTreeNode(g.isBT?d:b,[{id:g.nodeid,text:i,iconCls:g.connected?"iconfont tr-icon-server":"iconfont tr-icon-server-error"}]);a.trackers[g.nodeid]=null}c=="closed"&&this.panel.left.tree("collapse",b.target);system.config.showBTServers&&d&&e=="closed"&&this.panel.left.tree("collapse",d.target);for(f in a.trackers)(g=a.trackers[f])&&system.removeTreeNode(g.nodeid)}else b&&this.panel.left.tree("remove",b.target)},resetNavStatistics:function(){if(this.config.nav.statistics){var a=
b=this.panel.left.tree("find","servers")}var d=this.panel.left.tree("find","btservers"),f=d?d.state:"close",e;for(e in transmission.trackers){var g=transmission.trackers[e];if(g.isBT){if(!system.config.showBTServers)continue;if(!d){this.appendTreeNode(b,[{id:"btservers",text:"BT",state:"open",iconCls:"iconfont tr-icon-bt"}]);d=this.panel.left.tree("find","btservers")}}var h=system.panel.left.tree("find",g.nodeid),i=g.name+this.showNodeMoreInfos(g.count,g.size);h?system.updateTreeNodeText(g.nodeid,
i,g.connected?"iconfont tr-icon-server":"iconfont tr-icon-server-error"):system.appendTreeNode(g.isBT?d:b,[{id:g.nodeid,text:i,iconCls:g.connected?"iconfont tr-icon-server":"iconfont tr-icon-server-error"}]);a.trackers[g.nodeid]=null}c=="closed"&&this.panel.left.tree("collapse",b.target);system.config.showBTServers&&d&&f=="closed"&&this.panel.left.tree("collapse",d.target);for(e in a.trackers)(g=a.trackers[e])&&system.removeTreeNode(g.nodeid)}else b&&this.panel.left.tree("remove",b.target)},resetNavStatistics:function(){if(this.config.nav.statistics){var a=
"uploadedBytes,downloadedBytes,filesAdded,sessionCount,secondsActive".split(",");$.each(a,function(b,c){switch(c){case "uploadedBytes":case "downloadedBytes":system.updateTreeNodeText(c,system.lang.tree.statistics[c]+" "+formatSize(system.serverSessionStats["cumulative-stats"][c]));system.updateTreeNodeText("current-"+c,system.lang.tree.statistics[c]+" "+formatSize(system.serverSessionStats["current-stats"][c]));break;case "secondsActive":system.updateTreeNodeText(c,system.lang.tree.statistics[c]+
" "+getTotalTime(system.serverSessionStats["cumulative-stats"][c]*1E3));system.updateTreeNodeText("current-"+c,system.lang.tree.statistics[c]+" "+getTotalTime(system.serverSessionStats["current-stats"][c]*1E3));break;default:system.updateTreeNodeText(c,system.lang.tree.statistics[c]+" "+system.serverSessionStats["cumulative-stats"][c]);system.updateTreeNodeText("current-"+c,system.lang.tree.statistics[c]+" "+system.serverSessionStats["current-stats"][c])}})}else(a=this.panel.left.tree("find","statistics"))&&
this.panel.left.tree("remove",a.target)},resetNavFolders:function(a){if(this.config.nav.folders){for(var b in transmission.torrents.folders)a.folders[transmission.torrents.folders[b].nodeid]=null;this.loadFolderList(a.folders)}else{this.initUIStatus();(a=this.panel.left.tree("find","folders"))&&this.panel.left.tree("remove",a.target)}},resetNavLabels:function(a){if(this.config.nav.labels){if(a){var b=this.panel.left.tree("getChildren",this.panel.left.tree("find","labels").target);for(a=0;a<b.length;a++)this.panel.left.tree("remove",
@ -72,38 +72,40 @@ false,"speed"));system.serverSessionStats=a;if(a.torrentCount==0){(a=system.pane
"south")})}},updateTreeNodeText:function(a,b,c){if(a=this.panel.left.tree("find",a)){b={target:a.target,text:b};if(c!=undefined)b.iconCls=c;this.panel.left.tree("update",b)}},appendTreeNode:function(a,b){var c=null;(c=typeof a=="string"?this.panel.left.tree("find",a):a)?this.panel.left.tree("append",{parent:c.target,data:b}):this.panel.left.tree("append",{data:b})},removeTreeNode:function(a){(a=this.panel.left.tree("find",a))&&this.panel.left.tree("remove",a.target)},loadTorrentToList:function(a){if(transmission.torrents.all){jQuery.extend({node:null,
page:1},a);if(a.node){var b=null,c=this.panel.left.tree("getParent",a.node.target)||{id:""},d=this.panel.left.data("currentNodeId");if(d!=a.node.id){this.control.torrentlist.datagrid("uncheckAll");this.control.torrentlist.datagrid({pageNumber:1});d=a.node.id}this.panel.left.data("currentNodeId",d);switch(c.id){case "servers":case "btservers":b=a.node.id=="btservers"?transmission.torrents.btItems:transmission.trackers[a.node.id].torrents;break;default:switch(a.node.id){case "torrent-all":case "servers":b=
transmission.torrents.all;break;case "paused":b=transmission.torrents.status[transmission._status.stopped];break;case "sending":b=transmission.torrents.status[transmission._status.seed];break;case "seedwait":b=transmission.torrents.status[transmission._status.seedwait];break;case "check":b=transmission.torrents.status[transmission._status.check];break;case "checkwait":b=transmission.torrents.status[transmission._status.checkwait];break;case "downloading":b=transmission.torrents.status[transmission._status.download];
break;case "downloadwait":b=transmission.torrents.status[transmission._status.downloadwait];break;case "actively":b=transmission.torrents.actively;break;case "error":b=transmission.torrents.error;break;case "warning":b=transmission.torrents.warning;break;case "search-result":b=transmission.torrents.searchResult;break;case "btservers":b=transmission.torrents.btItems;break;default:if(a.node.id.indexOf("folders-")!=-1){var e=transmission.torrents.folders[a.node.id];if(e)if(this.config.hideSubfolders){b=
[];for(var f=0;f<e.torrents.length;f++){c=e.torrents[f];c.downloadDir.replace(/[\\|\/]/g,"")==a.node.path&&b.push(c)}}else b=e.torrents}else if(a.node.id.indexOf("label-")!=-1){d=parseInt(a.node.labelIndex);b=[];for(e in transmission.torrents.all){var g=transmission.torrents.all[e];(c=this.config.labelMaps[g.hashString])&&$.inArray(d,c)!=-1&&b.push(g)}}}}if(this.config.defaultSelectNode!=a.node.id){this.control.torrentlist.datagrid("loadData",[]);this.config.defaultSelectNode=a.node.id;this.saveConfig()}a=
[];for(f in b){if(!b[f])return;c=this.lang.torrent["status-text"][b[f].status];parseFloat(b[f].percentDone*100).toFixed(2);c==transmission._status.check&&parseFloat(b[f].recheckProgress*100).toFixed(2);if(b[f].error!=0)c="<span class='text-status-error'>"+c+"</span>";else if(b[f].warning)c="<span class='text-status-warning' title='"+b[f].warning+"'>"+c+"</span>";e={};e=$.extend(e,b[f]);e.status=c;e.statusCode=b[f].status;e.completeSize=Math.max(0,b[f].totalSize-b[f].leftUntilDone);e.leecherCount=
b[f].leecher;e.seederCount=b[f].seeder;if(c=this.config.labelMaps[e.hashString])e.labels=c;a.push(e)}this.updateTorrentCurrentPageDatas(a)}}},updateTorrentCurrentPageDatas:function(a){var b=this.control.torrentlist.datagrid("getRows");if(a.length==0&&b.length>0)this.control.torrentlist.datagrid("loadData",[]);else{var c=this.control.torrentlist.datagrid("options"),d=null;if(c.sortName){d=c.sortName;a=a.sort(arrayObjectSort(d,c.sortOrder))}if(b.length==0||a.length!=this.control.torrentlist.datagrid("getData").total&&
a.length>c.pageSize)this.control.torrentlist.datagrid({loadFilter:pagerFilter,pageNumber:c.pageNumber,sortName:d,sortOrder:c.sortOrder}).datagrid("loadData",a);else{this.control.torrentlist.datagrid("getData").originalRows=a;d=(c.pageNumber-1)*parseInt(c.pageSize);c=d+parseInt(c.pageSize);a=a.slice(d,c);c={};d={};for(var e in transmission.torrents.recently){var f=transmission.torrents.recently[e];c[f.id]=true}for(e in a){f=a[e];d[f.id]=f}var g={};for(e=b.length-1;e>=0;e--){f=b[e];var h=d[f.id];if(h)if(c[f.id]){this.control.torrentlist.datagrid("updateRow",
{index:e,row:h});g[f.id]=f}else if(transmission.torrents.removed)if(transmission.torrents.removed.length>0&&$.inArray(f.id,transmission.torrents.removed)!=-1)this.control.torrentlist.datagrid("deleteRow",e);else g[f.id]=f;else g[f.id]=f;else this.control.torrentlist.datagrid("deleteRow",e)}for(e in a){f=a[e];g[f.id]||this.control.torrentlist.datagrid("appendRow",f)}}}},getTorrentNameBar:function(a){var b="",c=a.name;switch(a.status){case transmission._status.stopped:b="iconlabel icon-pause-small";
break;case "downloadwait":b=transmission.torrents.status[transmission._status.downloadwait];break;case "actively":b=transmission.torrents.actively;break;case "error":b=transmission.torrents.error;break;case "warning":b=transmission.torrents.warning;break;case "search-result":b=transmission.torrents.searchResult;break;case "btservers":b=transmission.torrents.btItems;break;default:if(a.node.id.indexOf("folders-")!=-1){var f=transmission.torrents.folders[a.node.id];if(f)if(this.config.hideSubfolders){b=
[];for(var e=0;e<f.torrents.length;e++){c=f.torrents[e];c.downloadDir.replace(/[\\|\/]/g,"")==a.node.path&&b.push(c)}}else b=f.torrents}else if(a.node.id.indexOf("label-")!=-1){d=parseInt(a.node.labelIndex);b=[];for(f in transmission.torrents.all){var g=transmission.torrents.all[f];(c=this.config.labelMaps[g.hashString])&&$.inArray(d,c)!=-1&&b.push(g)}}}}if(this.config.defaultSelectNode!=a.node.id){this.control.torrentlist.datagrid("loadData",[]);this.config.defaultSelectNode=a.node.id;this.saveConfig()}a=
[];for(e in b){if(!b[e])return;c=this.lang.torrent["status-text"][b[e].status];parseFloat(b[e].percentDone*100).toFixed(2);c==transmission._status.check&&parseFloat(b[e].recheckProgress*100).toFixed(2);if(b[e].error!=0)c="<span class='text-status-error'>"+c+"</span>";else if(b[e].warning)c="<span class='text-status-warning' title='"+b[e].warning+"'>"+c+"</span>";f={};f=$.extend(f,b[e]);f.status=c;f.statusCode=b[e].status;f.completeSize=Math.max(0,b[e].totalSize-b[e].leftUntilDone);f.leecherCount=
b[e].leecher;f.seederCount=b[e].seeder;if(c=this.config.labelMaps[f.hashString])f.labels=c;a.push(f)}this.updateTorrentCurrentPageDatas(a)}}},updateTorrentCurrentPageDatas:function(a){var b=this.control.torrentlist.datagrid("getRows");if(a.length==0&&b.length>0)this.control.torrentlist.datagrid("loadData",[]);else{var c=this.control.torrentlist.datagrid("options"),d=null;if(c.sortName){d=c.sortName;a=a.sort(arrayObjectSort(d,c.sortOrder))}if(b.length==0||a.length!=this.control.torrentlist.datagrid("getData").total&&
a.length>c.pageSize)this.control.torrentlist.datagrid({loadFilter:pagerFilter,pageNumber:c.pageNumber,sortName:d,sortOrder:c.sortOrder}).datagrid("loadData",a);else{this.control.torrentlist.datagrid("getData").originalRows=a;d=(c.pageNumber-1)*parseInt(c.pageSize);c=d+parseInt(c.pageSize);a=a.slice(d,c);c={};d={};for(var f in transmission.torrents.recently){var e=transmission.torrents.recently[f];c[e.id]=true}for(f in a){e=a[f];d[e.id]=e}var g={};for(f=b.length-1;f>=0;f--){e=b[f];var h=d[e.id];if(h)if(c[e.id]){this.control.torrentlist.datagrid("updateRow",
{index:f,row:h});g[e.id]=e}else if(transmission.torrents.removed)if(transmission.torrents.removed.length>0&&$.inArray(e.id,transmission.torrents.removed)!=-1)this.control.torrentlist.datagrid("deleteRow",f);else g[e.id]=e;else g[e.id]=e;else this.control.torrentlist.datagrid("deleteRow",f)}for(f in a){e=a[f];g[e.id]||this.control.torrentlist.datagrid("appendRow",e)}}}},getTorrentNameBar:function(a){var b="",c=a.name;switch(a.status){case transmission._status.stopped:b="iconlabel icon-pause-small";
break;case transmission._status.check:b="iconlabel icon-checking";break;case transmission._status.download:b="iconlabel icon-down";break;case transmission._status.seed:b="iconlabel icon-up";break;case transmission._status.seedwait:case transmission._status.downloadwait:case transmission._status.checkwait:b="iconlabel icon-wait"}c+="\n"+a.downloadDir;if(a.warning){b="iconlabel icon-warning-type1";c+="\n\n"+this.lang["public"]["text-info"]+": "+a.warning}if(a.error!=0){b="iconlabel icon-exclamation";
c+="\n\n"+this.lang["public"]["text-info"]+": "+a.errorString}return'<span class="'+b+'" title="'+c+'">'+a.name+"</span>"},getTorrentProgressBar:function(a,b){a+="%";var c="",d=0;d=typeof b=="object"?b.status:b;switch(d){case transmission._status.stopped:c="torrent-progress-stop";break;case transmission._status.checkwait:case transmission._status.check:c="torrent-progress-check";break;case transmission._status.downloadwait:case transmission._status.download:c="torrent-progress-download";break;case transmission._status.seedwait:case transmission._status.seed:c=
"torrent-progress-seed"}if(typeof b=="object"){if(b.warning)c="torrent-progress-warning";if(b.error!=0)c="torrent-progress-error"}return'<div class="torrent-progress" title="'+a+'"><div class="torrent-progress-text">'+a+'</div><div class="torrent-progress-bar '+c+'" style="width:'+a+';"></div></div>'},addTorrentsToServer:function(a,b,c,d){var e=b-a.length,f=a.shift();if(f){this.showStatus(this.lang.system.status.queue+(e+1)+"/"+b+"<br/>"+f,0);transmission.addTorrentFromUrl(f,d,c,function(){system.addTorrentsToServer(a,
b,c,d)})}else{this.showStatus(this.lang.system.status.queuefinish);this.getServerStatus()}},changeSelectedTorrentStatus:function(a,b,c){var d=this.control.torrentlist.datagrid("getChecked"),e=[];a||(a="start");for(var f in d)e.push(d[f].id);c||(c="torrent-"+a);if(e.length>0){if(b){var g=b.linkbutton("options").iconCls;b.linkbutton({disabled:true,iconCls:"icon-loading"})}transmission.exec({method:c,arguments:{ids:e}},function(){b&&b.linkbutton({iconCls:g});system.control.torrentlist.datagrid("uncheckAll");
"torrent-progress-seed"}if(typeof b=="object"){if(b.warning)c="torrent-progress-warning";if(b.error!=0)c="torrent-progress-error"}return'<div class="torrent-progress" title="'+a+'"><div class="torrent-progress-text">'+a+'</div><div class="torrent-progress-bar '+c+'" style="width:'+a+';"></div></div>'},addTorrentsToServer:function(a,b,c,d){var f=b-a.length,e=a.shift();if(e){this.showStatus(this.lang.system.status.queue+(f+1)+"/"+b+"<br/>"+e,0);transmission.addTorrentFromUrl(e,d,c,function(){system.addTorrentsToServer(a,
b,c,d)})}else{this.showStatus(this.lang.system.status.queuefinish);this.getServerStatus()}},changeSelectedTorrentStatus:function(a,b,c){var d=this.control.torrentlist.datagrid("getChecked"),f=[];a||(a="start");for(var e in d)f.push(d[e].id);c||(c="torrent-"+a);if(f.length>0){if(b){var g=b.linkbutton("options").iconCls;b.linkbutton({disabled:true,iconCls:"icon-loading"})}transmission.exec({method:c,arguments:{ids:f}},function(){b&&b.linkbutton({iconCls:g});system.control.torrentlist.datagrid("uncheckAll");
system.reloadTorrentBaseInfos()})}},searchTorrents:function(a){if(a!=""){var b=transmission.torrents.search(a);if(b==null||b.length==0)this.removeTreeNode("search-result");else{var c=this.panel.left.tree("find","search-result");a=this.lang.tree["search-result"]+" : "+a+" ("+b.length+")";if(c==null){this.appendTreeNode("torrent-all",[{id:"search-result",text:a,iconCls:"iconfont tr-icon-search"}]);c=this.panel.left.tree("find","search-result")}else this.panel.left.tree("update",{target:c.target,text:a});
this.panel.left.tree("select",c.target)}}},getTorrentInfos:function(a){if(transmission.torrents.all[a])if(!transmission.torrents.all[a].infoIsLoading){if(this.currentTorrentId>0&&transmission.torrents.all[this.currentTorrentId])if(transmission.torrents.all[this.currentTorrentId].infoIsLoading)return;this.currentTorrentId=a;if(!this.panel.attribute.panel("options").collapsed){var b=transmission.torrents.all[a];b.infoIsLoading=true;var c="fileStats,trackerStats,peers,leftUntilDone,status,rateDownload,rateUpload,uploadedEver,uploadRatio,error,errorString";
b.moreInfosTag||(c+=",files,trackers,comment,dateCreated,creator,downloadDir");transmission.torrents.getMoreInfos(c,a,function(d){b.infoIsLoading=false;if(d!=null){jQuery.extend(b,d[0]);if(system.currentTorrentId==0||system.currentTorrentId!=a)system.clearTorrentAttribute();else{b.completeSize=b.totalSize-b.leftUntilDone;b.moreInfosTag=true;system.fillTorrentBaseInfos(b);system.fillTorrentFileList(b);system.fillTorrentServerList(b);system.fillTorrentPeersList(b);system.fillTorrentConfig(b);transmission.torrents.all[a]=
b;transmission.torrents.datas[a]=b}}})}}},clearTorrentAttribute:function(){system.panel.attribute.find("#torrent-files-table").datagrid("loadData",[]);system.panel.attribute.find("#torrent-servers-table").datagrid("loadData",[]);system.panel.attribute.find("#torrent-peers-table").datagrid("loadData",[]);system.panel.attribute.find("span[id*='torrent-attribute-value']").html("")},updateCurrentPageDatas:function(a,b,c){var d=c.datagrid("getRows"),e=c.datagrid("options"),f=null;if(e.sortName){f=e.sortName;
b=b.sort(arrayObjectSort(f,e.sortOrder))}if(d.length==0||b.length!=c.datagrid("getData").total&&b.length>e.pageSize)c.datagrid({loadFilter:pagerFilter,pageNumber:1,sortName:f,sortOrder:e.sortOrder}).datagrid("loadData",b);else{c.datagrid("getData").originalRows=b;f=(e.pageNumber-1)*parseInt(e.pageSize);e=f+parseInt(e.pageSize);b=b.slice(f,e);e={};for(var g in b){f=b[g];e[f[a]]=f}for(g=d.length-1;g>=0;g--){f=d[g];(b=e[f[a]])?c.datagrid("updateRow",{index:g,row:b}):c.datagrid("deleteRow",g)}}},fillTorrentBaseInfos:function(a){$.each(a,
b;transmission.torrents.datas[a]=b}}})}}},clearTorrentAttribute:function(){system.panel.attribute.find("#torrent-files-table").datagrid("loadData",[]);system.panel.attribute.find("#torrent-servers-table").datagrid("loadData",[]);system.panel.attribute.find("#torrent-peers-table").datagrid("loadData",[]);system.panel.attribute.find("span[id*='torrent-attribute-value']").html("")},updateCurrentPageDatas:function(a,b,c){var d=c.datagrid("getRows"),f=c.datagrid("options"),e=null;if(f.sortName){e=f.sortName;
b=b.sort(arrayObjectSort(e,f.sortOrder))}if(d.length==0||b.length!=c.datagrid("getData").total&&b.length>f.pageSize)c.datagrid({loadFilter:pagerFilter,pageNumber:1,sortName:e,sortOrder:f.sortOrder}).datagrid("loadData",b);else{c.datagrid("getData").originalRows=b;e=(f.pageNumber-1)*parseInt(f.pageSize);f=e+parseInt(f.pageSize);b=b.slice(e,f);f={};for(var g in b){e=b[g];f[e[a]]=e}for(g=d.length-1;g>=0;g--){e=d[g];(b=f[e[a]])?c.datagrid("updateRow",{index:g,row:b}):c.datagrid("deleteRow",g)}}},fillTorrentBaseInfos:function(a){$.each(a,
function(b,c){switch(b){case "rateDownload":case "rateUpload":c=formatSize(c,true,"speed");break;case "totalSize":case "uploadedEver":case "leftUntilDone":case "completeSize":c=formatSize(c);break;case "addedDate":case "dateCreated":case "doneDate":c=formatLongTime(c);break;case "status":c=system.lang.torrent["status-text"][c];break;case "error":c==0?system.panel.attribute.find("#torrent-attribute-tr-error").hide():system.panel.attribute.find("#torrent-attribute-tr-error").show();break;case "remainingTime":c=
c>=31536E8?"∞":getTotalTime(c);break;case "comment":c=system.replaceURI(c)}system.panel.attribute.find("#torrent-attribute-value-"+b).html(c)})},fillTorrentFileList:function(a){var b=a.files,c=a.fileStats,d=[],e=a.name.length+1,f;for(f in b){var g=b[f],h=c[f],i=parseFloat(h.bytesCompleted/g.length*100).toFixed(2);d.push({name:g.name==a.name?g.name:g.name.substr(e),index:f,bytesCompleted:h.bytesCompleted,percentDone:system.getTorrentProgressBar(i,transmission._status.download),length:g.length,wanted:system.lang.torrent.attribute.status[h.wanted],
priority:'<span class="iconlabel icon-flag-'+h.priority+'">'+system.lang.torrent.attribute.priority[h.priority]+"</span>"})}this.updateCurrentPageDatas("index",d,system.panel.attribute.find("#torrent-files-table"))},fillTorrentServerList:function(a){var b=a.trackerStats,c=[],d;for(d in b){var e=b[d],f={},g;for(g in e)switch(g){case "lastAnnounceTime":case "nextAnnounceTime":f[g]=formatLongTime(e[g]);break;case "lastAnnounceSucceeded":case "lastAnnounceTimedOut":f[g]=system.lang.torrent.attribute.status[e[g]];
break;default:f[g]=e[g]}c.push(f)}transmission.torrents.addTracker(a);this.updateCurrentPageDatas("id",c,system.panel.attribute.find("#torrent-servers-table"))},fillTorrentPeersList:function(a){a=a.peers;var b=[],c;for(c in a){var d=a[c],e={},f;for(f in d)e[f]=d[f];d=parseFloat(d.progress*100).toFixed(2);e.progress=system.getTorrentProgressBar(d,transmission._status.download);b.push(e)}this.updateCurrentPageDatas("address",b,system.panel.attribute.find("#torrent-peers-table"))},fillTorrentConfig:function(a){system.panel.attribute.find("#torrent-attribute-tabs").data("selectedIndex")==
4&&transmission.torrents.getConfig(a.id,function(b){if(b!=null){jQuery.extend(transmission.torrents.all[system.currentTorrentId],b[0]);system.currentTorrentId!=0&&$.each(b[0],function(c,d){var e=false,f=false,g=false;switch(c){case "seedIdleMode":case "seedRatioMode":if(d==0){f=false;e=true}g=true;case "downloadLimited":case "uploadLimited":if(d==true||d==1)f=true;system.panel.attribute.find("input[enabledof='"+c+"']").prop("disabled",!f);g&&system.panel.attribute.find("#"+c).prop("indeterminate",
e).data("_tag",d);system.panel.attribute.find("#"+c).prop("checked",f);break;default:system.panel.attribute.find("#"+c).val(d);system.panel.attribute.find("#"+c).numberspinner("setValue",d)}})}})},setFieldFormat:function(a){if(a.formatter)switch(a.formatter){case "size":a.formatter=function(b){return formatSize(b)};break;case "speed":a.formatter=function(b){return formatSize(b,true,"speed")};break;case "longtime":a.formatter=function(b){return formatLongTime(b)};break;case "progress":a.formatter=
c>=31536E8?"∞":getTotalTime(c);break;case "comment":c=system.replaceURI(c)}system.panel.attribute.find("#torrent-attribute-value-"+b).html(c)})},fillTorrentFileList:function(a){var b=a.files,c=a.fileStats,d=[],f=a.name.length+1,e;for(e in b){var g=b[e],h=c[e],i=parseFloat(h.bytesCompleted/g.length*100).toFixed(2);d.push({name:g.name==a.name?g.name:g.name.substr(f),index:e,bytesCompleted:h.bytesCompleted,percentDone:system.getTorrentProgressBar(i,transmission._status.download),length:g.length,wanted:system.lang.torrent.attribute.status[h.wanted],
priority:'<span class="iconlabel icon-flag-'+h.priority+'">'+system.lang.torrent.attribute.priority[h.priority]+"</span>"})}this.updateCurrentPageDatas("index",d,system.panel.attribute.find("#torrent-files-table"))},fillTorrentServerList:function(a){var b=a.trackerStats,c=[],d;for(d in b){var f=b[d],e={},g;for(g in f)switch(g){case "lastAnnounceTime":case "nextAnnounceTime":e[g]=formatLongTime(f[g]);break;case "lastAnnounceSucceeded":case "lastAnnounceTimedOut":e[g]=system.lang.torrent.attribute.status[f[g]];
break;default:e[g]=f[g]}c.push(e)}transmission.torrents.addTracker(a);this.updateCurrentPageDatas("id",c,system.panel.attribute.find("#torrent-servers-table"))},fillTorrentPeersList:function(a){a=a.peers;var b=[],c;for(c in a){var d=a[c],f={},e;for(e in d)f[e]=d[e];d=parseFloat(d.progress*100).toFixed(2);f.progress=system.getTorrentProgressBar(d,transmission._status.download);b.push(f)}this.updateCurrentPageDatas("address",b,system.panel.attribute.find("#torrent-peers-table"))},fillTorrentConfig:function(a){system.panel.attribute.find("#torrent-attribute-tabs").data("selectedIndex")==
4&&transmission.torrents.getConfig(a.id,function(b){if(b!=null){jQuery.extend(transmission.torrents.all[system.currentTorrentId],b[0]);system.currentTorrentId!=0&&$.each(b[0],function(c,d){var f=false,e=false,g=false;switch(c){case "seedIdleMode":case "seedRatioMode":if(d==0){e=false;f=true}g=true;case "downloadLimited":case "uploadLimited":if(d==true||d==1)e=true;system.panel.attribute.find("input[enabledof='"+c+"']").prop("disabled",!e);g&&system.panel.attribute.find("#"+c).prop("indeterminate",
f).data("_tag",d);system.panel.attribute.find("#"+c).prop("checked",e);break;default:system.panel.attribute.find("#"+c).val(d);system.panel.attribute.find("#"+c).numberspinner("setValue",d)}})}})},setFieldFormat:function(a){if(a.formatter)switch(a.formatter){case "size":a.formatter=function(b){return formatSize(b)};break;case "speed":a.formatter=function(b){return formatSize(b,true,"speed")};break;case "longtime":a.formatter=function(b){return formatLongTime(b)};break;case "progress":a.formatter=
function(b,c){var d=parseFloat(b*100).toFixed(2);return system.getTorrentProgressBar(d,transmission.torrents.all[c.id])};break;case "_usename_":switch(a.field){case "name":a.formatter=function(b,c){return system.getTorrentNameBar(transmission.torrents.all[c.id])}}break;case "ratio":a.formatter=function(b){var c="";if(parseFloat(b)<1)c="text-status-warning";return'<span class="'+c+'">'+b+"</span>"};break;case "remainingTime":a.formatter=function(b){if(b>=31536E8)return"∞";return getTotalTime(b)};break;
case "labels":a.formatter=function(b,c){return system.formetTorrentLabels(b,c.hashString)};break;case "color":a.formatter=function(b){return $("<span class='user-label'/>").html(b).css({"background-color":b,color:getGrayLevel(b)>0.5?"#000":"#fff"}).get(0).outerHTML}}},reloadData:function(){if(this.popoverCount>0)setTimeout(function(){system.reloadData()},2E3);else{this.reloadSession();this.reloading=false;this.getServerStatus();this.reloading=false;this.reloadTorrentBaseInfos()}},loadFolderList:function(a){this.removeTreeNode("folders-loading");
for(var b in a){var c=a[b];c&&system.removeTreeNode(c.nodeid)}transmission.downloadDirs.length!=0&&timedChunk(transmission.downloadDirs,this.appendFolder,this,10,function(){navigator.userAgent.indexOf("Firefox")>0&&system.panel.left.find("span.nav-total-size").css({"margin-top":"-19px"});system.initUIStatus()})},appendFolder:function(a){if(a){var b="folders";a=a.replace(/\\/g,"/").split("/");var c="folders-",d="",e;for(e in a){var f=a[e];if(f!=""){d+=f;var g=this.B64.encode(f);c+=g.replace(/[+|\/|=]/g,
"0");g=this.panel.left.tree("find",c);var h=transmission.torrents.folders[c];if(h){f=f+this.showNodeMoreInfos(h.count,h.size);if(g)this.updateTreeNodeText(c,f);else{this.appendTreeNode(b,[{id:c,path:d,text:f,iconCls:"iconfont tr-icon-file"}]);if(b!="folders"){g=this.panel.left.tree("find",b);this.panel.left.tree("collapse",g.target)}}b=c}else{this.debug("appendFolder:key",c);this.debug("appendFolder:name",f);this.debug("appendFolder:node",g)}}}}},replaceURI:function(a){return a.replace(/(http|https|ftp):\/\/([^/:]+)(:\d*)?([^# ]*)/ig,
for(var b in a){var c=a[b];c&&system.removeTreeNode(c.nodeid)}transmission.downloadDirs.length!=0&&timedChunk(transmission.downloadDirs,this.appendFolder,this,10,function(){navigator.userAgent.indexOf("Firefox")>0&&system.panel.left.find("span.nav-total-size").css({"margin-top":"-19px"});system.initUIStatus()})},appendFolder:function(a){if(a){var b="folders";a=a.replace(/\\/g,"/").split("/");var c="folders-",d="",f;for(f in a){var e=a[f];if(e!=""){d+=e;var g=this.B64.encode(e);c+=g.replace(/[+|\/|=]/g,
"0");g=this.panel.left.tree("find",c);var h=transmission.torrents.folders[c];if(h){e=e+this.showNodeMoreInfos(h.count,h.size);if(g)this.updateTreeNodeText(c,e);else{this.appendTreeNode(b,[{id:c,path:d,text:e,iconCls:"iconfont tr-icon-file"}]);if(b!="folders"){g=this.panel.left.tree("find",b);this.panel.left.tree("collapse",g.target)}}b=c}else{this.debug("appendFolder:key",c);this.debug("appendFolder:name",e);this.debug("appendFolder:node",g)}}}}},replaceURI:function(a){return a.replace(/(http|https|ftp):\/\/([^/:]+)(:\d*)?([^# ]*)/ig,
function(b){return'<a href="'+b+'" target="_blank">'+b+"</a>"})},readConfig:function(){this.readUserConfig();var a=this.getStorageData(this.configHead+".system");if(a)this.config=$.extend(true,this.config,JSON.parse(a));for(var b in this.storageKeys.dictionary)this.dictionary[b]=this.getStorageData(this.storageKeys.dictionary[b])},saveConfig:function(){this.setStorageData(this.configHead+".system",JSON.stringify(this.config));for(var a in this.storageKeys.dictionary)this.setStorageData(this.storageKeys.dictionary[a],
this.dictionary[a]);this.saveUserConfig()},readUserConfig:function(){var a=window.localStorage[this.configHead];if(a){a=JSON.parse(a);this.userConfig=$.extend(true,this.userConfig,a)}},saveUserConfig:function(){window.localStorage[this.configHead]=JSON.stringify(this.userConfig)},uploadTorrentFile:function(a,b,c,d){if(window.FileReader){var e=$("input[id='"+a+"']")[0].files;$.each(e,function(f,g){transmission.addTorrentFromFile(g,b,c,d,e.length)})}else alert(system.lang["public"]["text-browsers-not-support-features"])},
checkUpdate:function(){$.ajax({url:this.checkUpdateScript,dataType:"json",success:function(a){if(a&&a.update)if(system.codeupdate<a.update){$("#area-update-infos").show();$("#msg-updateInfos").html(a.update+" -> "+a.infos)}else $("#area-update-infos").hide()}})},changeLanguages:function(a){if(!(a==this.lang.name||!a)){this.config.defaultLang=a;this.saveConfig();location.href="?lang="+a}},getStorageData:function(a,b){return window.localStorage[a]==null?b:window.localStorage[a]},setStorageData:function(a,
b){window.localStorage[a]=b},openDialogFromTemplate:function(a){a=$.extend(true,{id:null,options:null,datas:null,type:0},a);if(a.id!=null){var b=a.id,c=a.options,d=a.datas,e=$("#"+b);if(e.length){d&&$.each(d,function(f,g){e.data(f,g)});if(a.type==0&&e.attr("type")==a.type){e.dialog("open");e.dialog({content:system.templates[b]});return}else{if(system.popoverCount!=0){setTimeout(function(){system.openDialogFromTemplate(a)},350);return}e.remove()}}c=$.extend(true,{title:"",width:100,height:100,resizable:false,
cache:true,content:system.lang.dialog["system-config"].loading,modal:true},c);e=$("<div/>").attr({id:b,type:a.type}).appendTo(document.body);if(a.type==0)e.dialog(c);else{e.css({width:c.width,height:c.height}).data("popoverSource",a.source);$(a.source).webuiPopover({url:"#"+b,width:c.width,height:c.height-18,padding:false,onHide:function(f){$(a.source).webuiPopover("destroy");$("#"+b).remove();$(f).remove();system.popoverCount--},onShow:function(){system.popoverCount++}})}$.get(system.rootPath+"template/"+
b+".html?time="+new Date,function(f){system.templates[b]=f;d&&$.each(d,function(g,h){$("#"+b).data(g,h)});if(a.type==0)$("#"+b).dialog({content:f});else{e.html(f);$.parser.parse("#"+b);$(a.source).webuiPopover("show")}})}},debug:function(a,b){window.console&&window.console.log&&window.console.log(a,b)},initThemes:function(){this.themes&&$("#select-themes").combobox({groupField:"group",data:this.themes,editable:false,panelHeight:"auto",onChange:function(a){var b=(a+";").split(";"),c=b[0];b=b[1]||"logo.png";
$("#styleEasyui").attr("href","tr-web-control/script/easyui/themes/"+c+"/easyui.css");$("#logo").attr("src","tr-web-control/"+b);system.config.theme=a;system.saveConfig()},onLoadSuccess:function(){$(this).combobox("setValue",system.config.theme||"default")}})},getValidTreeKey:function(a){if(!a)return"";return this.B64.encode(a).replace(/[+|\/|=]/g,"0")}};
this.dictionary[a]);this.saveUserConfig()},readUserConfig:function(){var a=window.localStorage[this.configHead];if(a){a=JSON.parse(a);this.userConfig=$.extend(true,this.userConfig,a)}},saveUserConfig:function(){window.localStorage[this.configHead]=JSON.stringify(this.userConfig)},uploadTorrentFile:function(a,b,c,d){if(window.FileReader){var f=$("input[id='"+a+"']")[0].files;$.each(f,function(e,g){transmission.addTorrentFromFile(g,b,c,d,f.length)})}else alert(system.lang["public"]["text-browsers-not-support-features"])},
checkUpdate:function(){$.ajax({url:this.checkUpdateScript,dataType:"json",success:function(a){if(a&&a.tag_name){var b=a.created_at.substr(0,10).replace(/-/g,""),c=a.tag_name;if($.inArray(c,system.config.ignoreVersion)==-1)if(system.codeupdate<b){$("#area-update-infos").show();$("#msg-updateInfos").html(b+" -> "+a.name);var d=$("<div/>"),f=a.body.replace(/\r\n/g,"<br/>"),e=$("<div style='text-align:right;'/>").appendTo(d);$('<a href="https://github.com/ronggang/transmission-web-control/releases/latest" target="_blank" class="easyui-linkbutton" data-options="iconCls:\'iconfont tr-icon-github\'"/>').html(a.name+
" ("+b+")").appendTo(e).linkbutton();$("<span/>").html(" ").appendTo(e);$('<a href="https://github.com/ronggang/transmission-web-control/wiki" target="_blank" class="easyui-linkbutton" data-options="iconCls:\'iconfont tr-icon-help\'"/>').html(system.lang["public"]["text-how-to-update"]).appendTo(e).linkbutton();$("<span/>").html(" ").appendTo(e);$("<button onclick=\"javascript:system.addIgnoreVersion('"+c+'\');" class="easyui-linkbutton" data-options="iconCls:\'iconfont tr-icon-cancel-checked\'"/>').html(system.lang["public"]["text-ignore-this-version"]).appendTo(e).linkbutton();
$("<hr/>").appendTo(d);$("<div/>").html(f).appendTo(d);$("#button-download-update").webuiPopover({content:d.html(),backdrop:true})}else $("#area-update-infos").hide()}}})},addIgnoreVersion:function(a){if($.inArray(a,system.config.ignoreVersion)==-1){this.config.ignoreVersion.push(a);this.saveConfig()}$("#button-download-update").webuiPopover("hide");$("#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,type:0},a);if(a.id!=null){var b=a.id,c=a.options,d=a.datas,f=$("#"+b);if(f.length){d&&$.each(d,function(e,g){f.data(e,g)});if(a.type==0&&f.attr("type")==a.type){f.dialog("open");f.dialog({content:system.templates[b]});return}else{if(system.popoverCount!=0){setTimeout(function(){system.openDialogFromTemplate(a)},
350);return}f.remove()}}c=$.extend(true,{title:"",width:100,height:100,resizable:false,cache:true,content:system.lang.dialog["system-config"].loading,modal:true},c);f=$("<div/>").attr({id:b,type:a.type}).appendTo(document.body);if(a.type==0)f.dialog(c);else{f.css({width:c.width,height:c.height}).data("popoverSource",a.source);$(a.source).webuiPopover({url:"#"+b,width:c.width,height:c.height-18,padding:false,onHide:function(e){$(a.source).webuiPopover("destroy");$("#"+b).remove();$(e).remove();system.popoverCount--},
onShow:function(){system.popoverCount++}})}$.get(system.rootPath+"template/"+b+".html?time="+new Date,function(e){system.templates[b]=e;d&&$.each(d,function(g,h){$("#"+b).data(g,h)});if(a.type==0)$("#"+b).dialog({content:e});else{f.html(e);$.parser.parse("#"+b);$(a.source).webuiPopover("show")}})}},debug:function(a,b){window.console&&window.console.log&&window.console.log(a,b)},initThemes:function(){this.themes&&$("#select-themes").combobox({groupField:"group",data:this.themes,editable:false,panelHeight:"auto",
onChange:function(a){var b=(a+";").split(";"),c=b[0];b=b[1]||"logo.png";$("#styleEasyui").attr("href","tr-web-control/script/easyui/themes/"+c+"/easyui.css");$("#logo").attr("src","tr-web-control/"+b);system.config.theme=a;system.saveConfig()},onLoadSuccess:function(){$(this).combobox("setValue",system.config.theme||"default")}})},getValidTreeKey:function(a){if(!a)return"";return this.B64.encode(a).replace(/[+|\/|=]/g,"0")}};
$(document).ready(function(){$.getScript(system.rootPath+"lang/default.js");$.getScript(system.rootPath+"lang/_languages.js",function(){system.init(location.search.getQueryString("lang"),location.search.getQueryString("local"))})});
function pagerFilter(a){if(typeof a.length=="number"&&typeof a.splice=="function")a={total:a.length,rows:a};var b=$(this),c=b.datagrid("options"),d=b.datagrid("getPager"),e=b.data("buttons");d.pagination({onSelectPage:function(h,i){c.pageNumber=h;c.pageSize=i;d.pagination("refresh",{pageNumber:h,pageSize:i});b.datagrid("loadData",a)},buttons:e});if(!a.originalRows)a.originalRows=a.rows;var f=(c.pageNumber-1)*parseInt(c.pageSize),g=f+parseInt(c.pageSize);a.rows=a.originalRows.slice(f,g);if(e&&e.length)for(f=
0;f<e.length;f++){g=e[f];g.id&&g.title&&$("#"+g.id,d).attr("title",g.title)}return a};
function pagerFilter(a){if(typeof a.length=="number"&&typeof a.splice=="function")a={total:a.length,rows:a};var b=$(this),c=b.datagrid("options"),d=b.datagrid("getPager"),f=b.data("buttons");d.pagination({onSelectPage:function(h,i){c.pageNumber=h;c.pageSize=i;d.pagination("refresh",{pageNumber:h,pageSize:i});b.datagrid("loadData",a)},buttons:f});if(!a.originalRows)a.originalRows=a.rows;var e=(c.pageNumber-1)*parseInt(c.pageSize),g=e+parseInt(c.pageSize);a.rows=a.originalRows.slice(e,g);if(f&&f.length)for(e=
0;e<f.length;e++){g=f[e];g.id&&g.title&&$("#"+g.id,d).attr("title",g.title)}return a};

View File

@ -2,7 +2,7 @@
var system = {
version: "1.6.0 alpha",
rootPath: "tr-web-control/",
codeupdate: "20180418",
codeupdate: "20180420",
configHead: "transmission-web-control",
// default config, can be customized in config.js
config: {
@ -43,7 +43,8 @@ var system = {
labels: false
},
labels: [],
labelMaps: {}
labelMaps: {},
ignoreVersion: []
},
storageKeys: {
dictionary: {
@ -54,7 +55,7 @@ var system = {
dictionary: {
folders: null
},
checkUpdateScript: "https://raw.githubusercontent.com/ronggang/twc-release/master/update.json",
checkUpdateScript: "https://api.github.com/repos/ronggang/transmission-web-control/releases/latest",
contextMenus: {},
panel: null,
lang: null,
@ -2972,10 +2973,31 @@ var system = {
url: this.checkUpdateScript,
dataType: "json",
success: function (result) {
if (result && result.update) {
if (system.codeupdate < result.update) {
if (result && result.tag_name) {
var update = result.created_at.substr(0,10).replace(/-/g,"");
var version = result.tag_name;
if ($.inArray(version, system.config.ignoreVersion)!=-1) {
return;
}
if (system.codeupdate < update) {
$("#area-update-infos").show();
$("#msg-updateInfos").html(result.update + " -> " + result.infos);
$("#msg-updateInfos").html(update + " -> " + result.name);
var content = $("<div/>");
var html = result.body.replace(/\r\n/g,"<br/>");
var toolbar = $("<div style='text-align:right;'/>").appendTo(content);
$('<a href="https://github.com/ronggang/transmission-web-control/releases/latest" target="_blank" class="easyui-linkbutton" data-options="iconCls:\'iconfont tr-icon-github\'"/>').html(result.name + " ("+update+")").appendTo(toolbar).linkbutton();
$("<span/>").html(" ").appendTo(toolbar);
$('<a href="https://github.com/ronggang/transmission-web-control/wiki" target="_blank" class="easyui-linkbutton" data-options="iconCls:\'iconfont tr-icon-help\'"/>').html(system.lang["public"]["text-how-to-update"]).appendTo(toolbar).linkbutton();
$("<span/>").html(" ").appendTo(toolbar);
$('<button onclick="javascript:system.addIgnoreVersion(\''+version+'\');" class="easyui-linkbutton" data-options="iconCls:\'iconfont tr-icon-cancel-checked\'"/>').html(system.lang["public"]["text-ignore-this-version"]).appendTo(toolbar).linkbutton();
$("<hr/>").appendTo(content);
$("<div/>").html(html).appendTo(content);
$('#button-download-update').webuiPopover({
content: content.html(),
backdrop: true
});
} else {
$("#area-update-infos").hide();
}
@ -2983,6 +3005,14 @@ var system = {
}
});
},
addIgnoreVersion: function(version) {
if ($.inArray(version, system.config.ignoreVersion)==-1) {
this.config.ignoreVersion.push(version);
this.saveConfig();
}
$('#button-download-update').webuiPopover("hide");
$("#area-update-infos").hide();
},
// Set the language to reload the page
changeLanguages: function (lang) {
if (lang == this.lang.name || !lang) return;