* 添加队列功能;

* 在种子变更目录功能中添加“完成后重新校验”选项;
* 修复删除种子时,列表无法刷新的BUG;
* 修复RPC版本在15以上,无法显示空间大小的BUG;
* 修复多次删除、添加种子时,导致显示不正常的BUG;
This commit is contained in:
ronggang.zhou@gmail.com 2013-07-31 01:14:38 +00:00
parent 9a9e6e031c
commit 36cb97c70a
22 changed files with 336 additions and 174 deletions

View File

@ -8,24 +8,24 @@
<meta http-equiv="Cache-Control" content="no-cache">
<title>Transmission Web Control</title>
<!-- 样式表 -->
<link rel="stylesheet" type="text/css" href="style/base.css?v=20130627" />
<link rel="stylesheet" type="text/css" href="script/easyui/themes/default/easyui.css?v=20130627"/>
<link rel="stylesheet" type="text/css" href="script/easyui/themes/icon.css?v=20130627"/>
<link rel="stylesheet" type="text/css" href="style/base.css?v=20130731" />
<link rel="stylesheet" type="text/css" href="script/easyui/themes/default/easyui.css?v=20130731"/>
<link rel="stylesheet" type="text/css" href="script/easyui/themes/icon.css?v=20130731"/>
<!-- 基础类库 -->
<script type="text/javascript" src="script/jquery/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="script/jquery/jquery.form.js"></script>
<script type="text/javascript" src="script/jquery/json2.min.js"></script>
<script type="text/javascript" src="script/jquery/Base64.js"></script>
<script type="text/javascript" src="script/easyui/jquery.easyui.min.js?v=20130627"></script>
<script type="text/javascript" src="script/easyui/jquery.easyui.min.js?v=20130731"></script>
<!-- -->
<!-- 系统类库 -->
<script type="text/javascript" src="script/min/public.js?v=20130627"></script>
<script type="text/javascript" src="script/min/cookies.js?v=20130627"></script>
<script type="text/javascript" src="script/min/clientDevice.js?v=20130627"></script>
<script type="text/javascript" src="script/min/transmission.js?v=20130627"></script>
<script type="text/javascript" src="script/min/transmission.torrents.js?v=20130627"></script>
<script type="text/javascript" src="script/min/system.js?v=20130627"></script>
<script type="text/javascript" src="config.js?v=20130627"></script>
<script type="text/javascript" src="script/min/public.js?v=20130731"></script>
<script type="text/javascript" src="script/min/cookies.js?v=20130731"></script>
<script type="text/javascript" src="script/min/clientDevice.js?v=20130731"></script>
<script type="text/javascript" src="script/min/transmission.js?v=20130731"></script>
<script type="text/javascript" src="script/min/transmission.torrents.js?v=20130731"></script>
<script type="text/javascript" src="script/min/system.js?v=20130731"></script>
<script type="text/javascript" src="config.js?v=20130731"></script>
</head>
<body>
<div id="main" class="easyui-layout">
@ -39,25 +39,44 @@
</span>
<div style="float:right;display:none;">Language<select id="lang" value="" style="width:200px;"></select></div>
</div>
<!-- 工具栏 -->
<div id="m_toolbar" data-options="region:'south',border:0">
<!-- 增加种子 -->
<a id="toolbar_add_torrents" href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true,disabled:true"></a>
<span class="button-split">|</span>
<!-- 刷新 -->
<a id="toolbar_reload" href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-reload',plain:true"></a>
<!-- 限速 -->
<a id="toolbar_alt_speed" href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-alt-speed-false',plain:true"></a>
<!-- 设置 -->
<a id="toolbar_config" href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-system-config',plain:true"></a>
<span class="button-split">|</span>
<!-- 批量替换 Tracker -->
<a id="toolbar_tracker_replace" href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-tracker-replace',plain:true"></a>
<!-- 切换到移动版 -->
<a id="toolbar_mobile" href="javascript:location.href = 'index.mobile.html';" class="easyui-linkbutton" data-options="iconCls:'icon-mobile',plain:true" system-tip-lang="toolbar.tip['ui-mobile']"></a>
<!-- 切换到原版 -->
<a id="" href="javascript:location.href = 'index.original.html';" class="easyui-linkbutton" data-options="iconCls:'icon-transmission',plain:true" system-tip-lang="toolbar.tip['ui-original']"></a>
<span class="button-split">|</span>
<!-- 开始 -->
<a id="toolbar_start" href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-start-one',plain:true,disabled:true"></a>
<!-- 暂停 -->
<a id="toolbar_pause" href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-pause-one',plain:true,disabled:true"></a>
<!-- 删除 -->
<a id="toolbar_remove" href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-remove-torrent',plain:true,disabled:true"></a>
<!-- 重新校验 -->
<a id="toolbar_recheck" href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-recheck-torrent',plain:true,disabled:true"></a>
<!-- 获取更多Peers -->
<a id="toolbar_morepeers" href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-more-peers',plain:true,disabled:true" system-tip-lang="toolbar.tip['more-peers']"></a>
<!-- 设置下载目录 -->
<a id="toolbar_changeDownloadDir" href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-folder-change',plain:true,disabled:true"></a>
<span class="button-split">|</span>
<!-- 队列 -->
<a id="toolbar_queue" href="#" class="easyui-menubutton" data-options="menu:'#menu-queue',iconCls:'icon-queue-move',disabled:true" system-tip-lang="toolbar.queue"></a>
<span class="button-split">|</span>
<!-- 开始所有 -->
<a id="toolbar_start_all" href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-start-all',plain:true,disabled:true"></a>
<!-- 暂停所有 -->
<a id="toolbar_pause_all" href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-pause-all',plain:true,disabled:true"></a>
<span class="button-split">|</span>
<label id="toolbar_label_reload_time"></label>
@ -98,5 +117,11 @@
<span id="text-drop-title" style="position:absolute;top:150px;left:150px;font-size:40px;font-weight: bold;" disabled="disabled"></span>
</div>
</div>
<div id="menu-queue" style="width:150px;">
<div id="menu-queue-move-top" data-options="iconCls:'icon-queue-move-top'" onclick="system.changeSelectedTorrentStatus('',null,'queue-move-top');" system-tip-lang="menus.queue['move-top']"><span system-lang="menus.queue['move-top']"></span></div>
<div id="menu-queue-move-up" data-options="iconCls:'icon-queue-move-up'" onclick="system.changeSelectedTorrentStatus('',null,'queue-move-up');" system-tip-lang="menus.queue['move-up']"><span system-lang="menus.queue['move-up']"></span></div>
<div id="menu-queue-move-down" data-options="iconCls:'icon-queue-move-down'" onclick="system.changeSelectedTorrentStatus('',null,'queue-move-down');" system-tip-lang="menus.queue['move-down']"><span system-lang="menus.queue['move-down']"></span></div>
<div id="menu-queue-move-bottom" data-options="iconCls:'icon-queue-move-bottom'" onclick="system.changeSelectedTorrentStatus('',null,'queue-move-bottom');" system-tip-lang="menus.queue['move-bottom']"><span system-lang="menus.queue['move-bottom']"></span></div>
</div>
</body>
</html>

View File

@ -9,21 +9,21 @@
<meta http-equiv="Cache-Control" content="no-cache">
<title>Transmission Web Control Mobile</title>
<!-- 样式表 -->
<link rel="stylesheet" type="text/css" href="style/base.mobile.css?v=20130128" />
<link rel="stylesheet" type="text/css" href="script/jquery/mobile/themes/default/jquery.mobile-1.3.0-beta.1.min.css?v=20130128"/>
<link rel="stylesheet" type="text/css" href="style/base.mobile.css?v=20130731" />
<link rel="stylesheet" type="text/css" href="script/jquery/mobile/themes/default/jquery.mobile-1.3.0-beta.1.min.css?v=20130731"/>
<!-- 基础类库 -->
<script type="text/javascript" src="script/jquery/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="script/jquery/jquery.form.js"></script>
<script type="text/javascript" src="script/jquery/json2.min.js"></script>
<script type="text/javascript" src="script/jquery/Base64.js"></script>
<script type="text/javascript" src="script/jquery/mobile/jquery.mobile-1.3.0-beta.1.min.js?v=20130128"></script>
<script type="text/javascript" src="script/jquery/mobile/jquery.mobile-1.3.0-beta.1.min.js?v=20130731"></script>
<!-- -->
<!-- 系统类库 -->
<script type="text/javascript" src="script/min/public.js?v=20130128"></script>
<script type="text/javascript" src="script/min/cookies.js?v=20130128"></script>
<script type="text/javascript" src="script/min/transmission.js?v=20130128"></script>
<script type="text/javascript" src="script/min/transmission.torrents.js?v=20130128"></script>
<script type="text/javascript" src="script/min/system.mobile.js?v=20130128"></script>
<script type="text/javascript" src="script/min/public.js?v=20130731"></script>
<script type="text/javascript" src="script/min/cookies.js?v=20130731"></script>
<script type="text/javascript" src="script/min/transmission.js?v=20130731"></script>
<script type="text/javascript" src="script/min/transmission.torrents.js?v=20130731"></script>
<script type="text/javascript" src="script/min/system.mobile.js?v=20130731"></script>
</head>
<body>
<!-- Home -->

View File

@ -1,11 +1,12 @@
// 设置当前可用的语言
system.languages = {
"zh-CN":"简体中文|Chinese(Simplified)"
,"zh-TW":"繁體中文|Chinese(Traditional)"
,"en":"English"
,"ru":"Русский(Russian)"
,"es":"Español(Spanish)"
,"pl":"Polski(Polish)"
,"hu":"Magyarország(Hungarian)"
,"ro":"Română (Romanian)"
// 设置当前可用的语言
system.languages = {
"zh-CN":"简体中文|Chinese(Simplified)"
,"zh-TW":"繁體中文|Chinese(Traditional)"
,"en":"English"
,"ru":"Русский(Russian)"
,"es":"Español(Spanish)"
,"pl":"Polski(Polish)"
,"hu":"Magyarország(Hungarian)"
,"ro":"Română(Romanian)"
,"it":"Italiano(Italian)"
};

View File

@ -37,8 +37,9 @@ system.defaultLang = {
,"reload-time-unit":"s/time"
,"autoreload-disabled":"Disabled"
,"autoreload-enabled":"Enabled"
,"search-prompt":"Search Loacl Torrents"
,"search-prompt":"Search Local Torrents"
,"tracker-replace":"Replace trackers"
,"queue":"Queue"
,"tip":{
"start":"Start the checked torrents"
,"pause":"Pause the checked torrents"
@ -64,6 +65,14 @@ system.defaultLang = {
,"more-peers":"Ask tracker for more peers"
}
}
,"menus":{
"queue":{
"move-top":"Move to top"
,"move-up":"Move up"
,"move-down":"Move down"
,"move-bottom":"Move to bottom"
}
}
,"title":{
"left":"Navigation"
,"list":"Torrents"
@ -204,6 +213,7 @@ system.defaultLang = {
,"new-download-dir":"New dir:"
,"move-data":"If checked, move from previous location. otherwise, search 'New dir' for files."
,"set-error":"set error!"
,"recheck-data":"Recheck data."
}
,"system-replaceTracker":{
"title":"Replace Trackers"

View File

@ -37,7 +37,7 @@ system.lang = {
,"reload-time-unit":"s/time"
,"autoreload-disabled":"Disabled"
,"autoreload-enabled":"Enabled"
,"search-prompt":"Search Loacl Torrents"
,"search-prompt":"Search Local Torrents"
,"tracker-replace":"Replace trackers"
,"tip":{
"start":"Start the checked torrents"

View File

@ -39,6 +39,7 @@ system.lang = {
,"autoreload-enabled":"已启用"
,"search-prompt":"搜索本地种子"
,"tracker-replace":"替换 Tracker"
,"queue":"队列"
,"tip":{
"start":"重新开始已经选中的种子"
,"pause":"暂停已经选中的种子"
@ -64,6 +65,14 @@ system.lang = {
,"more-peers":"获取更多Peer"
}
}
,"menus":{
"queue":{
"move-top":"队列排到最前"
,"move-up":"队列向上移动"
,"move-down":"队列向下移动"
,"move-bottom":"队列排到最后"
}
}
,"title":{
"left":"导航"
,"list":"种子列表"
@ -203,6 +212,7 @@ system.lang = {
,"new-download-dir":"新目录:"
,"move-data":"同时移动数据(如果不钩选,则从新目录下查找文件)"
,"set-error":"设置目录失败!"
,"recheck-data":"设置完成后重新校验。"
}
,"system-replaceTracker":{
"title":"替换 Tracker 地址"

View File

@ -39,6 +39,7 @@ system.lang = {
,"autoreload-enabled":"已啟用"
,"search-prompt":"搜索本地種子"
,"tracker-replace":"替換 Tracker"
,"queue":"隊列"
,"tip":{
"start":"重新開始已經選中的種子"
,"pause":"暫停已經選中的種子"
@ -64,6 +65,14 @@ system.lang = {
,"more-peers":"獲取更多Peer"
}
}
,"menus":{
"queue":{
"move-top":"隊列排到最前"
,"move-up":"隊列向上移動"
,"move-down":"隊列向下移動"
,"move-bottom":"隊列排到最後"
}
}
,"title":{
"left":"分類目錄"
,"list":"種子列表"
@ -203,6 +212,7 @@ system.lang = {
,"new-download-dir":"新目錄:"
,"move-data":"同時移動數據(如不鉤選,則從新目錄下查找資料)"
,"set-error":"设置目录失败!"
,"recheck-data":"設置完成後重新校驗。"
}
,"system-replaceTracker":{
"title":"替換 Tracker 地址"

View File

@ -1,87 +1,88 @@
var system={version:"0.4 Beta",codeupdate:"20130627",config:{autoReload:true,reloadStep:5E3,pageSize:30,defaultSelectNode:null,autoExpandAttribute:false,defaultLang:""},checkUpdateScript:"https://transmission-control.googlecode.com/svn/resouces/checkupdate.js",contextMenus:{},panel:null,lang:null,reloading:false,autoReloadTimer:null,downloadDir:"",islocal:false,B64:new Base64,currentTorrentId:0,control:{tree:null,torrentlist:null},serverConfig:null,serverSessionStats:null,templates:{"dialog-about.html":"",
var system={version:"0.5 Beta",codeupdate:"20130731",config:{autoReload:true,reloadStep:5E3,pageSize:30,defaultSelectNode:null,autoExpandAttribute:false,defaultLang:""},checkUpdateScript:"https://transmission-control.googlecode.com/svn/resouces/checkupdate.js",contextMenus:{},panel:null,lang:null,reloading:false,autoReloadTimer:null,downloadDir:"",islocal:false,B64:new Base64,currentTorrentId:0,control:{tree:null,torrentlist:null},serverConfig:null,serverSessionStats:null,templates:{"dialog-about.html":"",
"dialog-system-config.html":"","dialog-torrent-add.html":"","dialog-torrent-addfile.html":"","dialog-torrent-remove-confirm.html":""},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("lang/"+a+".js",function(){system.lang=$.extend(true,system.defaultLang,system.lang);system.resetLangText();
$.getScript("script/easyui/locale/easyui-lang-"+a.replace("-","_")+".js").done(function(){b&&b()}).fail(function(){$.getScript("script/easyui/locale/easyui-lang-en.js",function(){b&&b()})})})},init:function(a,b){this.readConfig();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"),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()},resetLangText:function(a){a||(a=$);var b=a.find("*[system-lang]");$.each(b,function(c,d){var e=$(d).attr("system-lang");$(d).html(eval("system.lang."+e))});b=a.find("*[system-tip-lang]");$.each(b,function(c,d){var e=$(d).attr("system-tip-lang");$(d).attr("title",eval("system.lang."+e))})},initdata:function(){$(document).attr("title",
this.lang.system.title+" "+this.version);var a=[],b="<span>"+this.lang.title.left+"</span>";a.push("<span class='tree-title-toolbar'>");for(var c in this.lang.tree.toolbar.nav){var d=this.lang.tree.toolbar.nav[c];a.push('<a href="javascript:void(0);" id="tree-toolbar-nav-'+c+'" class="easyui-linkbutton" data-options="plain:true,iconCls:\'icon-disabled\'" onclick="javascript:system.navToolbarClick(this);">'+d+"</a>")}a.push("</span>");if(a.length>1){b+=a.join("");this.panel.left_layout.panel("setTitle",
b);for(c in this.lang.tree.toolbar.nav)$("#tree-toolbar-nav-"+c).linkbutton()}else this.panel.left_layout.panel("setTitle",b);b="<span>"+this.lang.title.list+"</span>";a.length=0;a.push("<span class='tree-title-toolbar'>");for(c in this.lang["torrent-head"].buttons){d=this.lang["torrent-head"].buttons[c];a.push('<a href="javascript:void(0);" id="torrent-head-buttons-'+c+'" class="easyui-linkbutton" data-options="plain:true,iconCls:\'icon-disabled\'" onclick="javascript:system.navToolbarClick(this);">'+
d+"</a>")}a.push("</span>");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(e,f){$("<option/>").text(f).val(e).attr("selected",e==system.lang.name?true:false).appendTo(system.panel.top.find("#lang"))});
status:$("#m_status"),statusbar:$("#m_statusbar"),status_text:$("#status_text"),droparea:$("#dropArea")};this.lang==null?this.setlang(a,function(){system.initdata()}):this.initdata()},resetLangText:function(a){a||(a=$);var b=a.find("*[system-lang]");$.each(b,function(c,e){var d=$(e).attr("system-lang");$(e).html(eval("system.lang."+d))});b=a.find("*[system-tip-lang]");$.each(b,function(c,e){var d=$(e).attr("system-tip-lang");$(e).attr("title",eval("system.lang."+d))})},initdata:function(){$(document).attr("title",
this.lang.system.title+" "+this.version);var a=[],b="<span>"+this.lang.title.left+"</span>";a.push("<span class='tree-title-toolbar'>");for(var c in this.lang.tree.toolbar.nav){var e=this.lang.tree.toolbar.nav[c];a.push('<a href="javascript:void(0);" id="tree-toolbar-nav-'+c+'" class="easyui-linkbutton" data-options="plain:true,iconCls:\'icon-disabled\'" onclick="javascript:system.navToolbarClick(this);">'+e+"</a>")}a.push("</span>");if(a.length>1){b+=a.join("");this.panel.left_layout.panel("setTitle",
b);for(c in this.lang.tree.toolbar.nav)$("#tree-toolbar-nav-"+c).linkbutton()}else this.panel.left_layout.panel("setTitle",b);b="<span>"+this.lang.title.list+"</span>";a.length=0;a.push("<span class='tree-title-toolbar'>");for(c in this.lang["torrent-head"].buttons){e=this.lang["torrent-head"].buttons[c];a.push('<a href="javascript:void(0);" id="torrent-head-buttons-'+c+'" class="easyui-linkbutton" data-options="plain:true,iconCls:\'icon-disabled\'" onclick="javascript:system.navToolbarClick(this);">'+
e+"</a>")}a.push("</span>");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"])},navToolbarClick:function(a){var b=a.id,c=$(a).data("status"),d=null;switch(b){case "tree-toolbar-nav-folders":d=this.panel.left.tree("find","folders");break;case "tree-toolbar-nav-statistics":d=this.panel.left.tree("find","statistics");break;case "torrent-head-buttons-autoExpandAttribute":d={};d.target=null;this.config.autoExpandAttribute=c==1?false:true}if(d){if(c==1){$(a).linkbutton({iconCls:"icon-disabled"});$(d.target).parent().hide();
c=0}else{$(a).linkbutton({iconCls:"icon-enabled"});$(d.target).parent().show();c=1}$(a).data("status",c);this.saveConfig()}},checkDropFiles:function(a){if(a&&a.length){for(var b=[],c=0;c<a.length;c++){var d=a[c];d.name.split(".").pop().toLowerCase()=="torrent"&&b.push(d)}if(b.length>0){a=$("#dialog-torrent-addfile");if(a.length){a.data("files",b);a.dialog("open");a.dialog({content:system.templates["dialog-torrent-addfile.html"]})}else{$("<div/>").attr("id","dialog-torrent-addfile").data("files",b).appendTo(document.body).dialog({title:system.lang.toolbar["add-torrent"],
width:620,height:300,resizable:true,cache:false,content:"loading...",modal:true});$.get("template/dialog-torrent-addfile.html",function(e){system.templates["dialog-torrent-addfile.html"]=e;$("#dialog-torrent-addfile").dialog({content:e})})}}}},initTree:function(){this.panel.left.tree({data:[{id:"torrent-all",iconCls:"icon-home",text:this.lang.tree.all+" ("+this.lang.tree.status.loading+")",children:[{id:"downloading",text:this.lang.tree.downloading,iconCls:"icon-download"},{id:"paused",text:this.lang.tree.paused,
false);$("#text-drop-title").html(this.lang["public"]["text-drop-title"])},navToolbarClick:function(a){var b=a.id,c=$(a).data("status"),e=null;switch(b){case "tree-toolbar-nav-folders":e=this.panel.left.tree("find","folders");break;case "tree-toolbar-nav-statistics":e=this.panel.left.tree("find","statistics");break;case "torrent-head-buttons-autoExpandAttribute":e={};e.target=null;this.config.autoExpandAttribute=c==1?false:true}if(e){if(c==1){$(a).linkbutton({iconCls:"icon-disabled"});$(e.target).parent().hide();
c=0}else{$(a).linkbutton({iconCls:"icon-enabled"});$(e.target).parent().show();c=1}$(a).data("status",c);this.saveConfig()}},checkDropFiles:function(a){if(a&&a.length){for(var b=[],c=0;c<a.length;c++){var e=a[c];e.name.split(".").pop().toLowerCase()=="torrent"&&b.push(e)}if(b.length>0){a=$("#dialog-torrent-addfile");if(a.length){a.data("files",b);a.dialog("open");a.dialog({content:system.templates["dialog-torrent-addfile.html"]})}else{$("<div/>").attr("id","dialog-torrent-addfile").data("files",b).appendTo(document.body).dialog({title:system.lang.toolbar["add-torrent"],
width:620,height:300,resizable:true,cache:false,content:"loading...",modal:true});$.get("template/dialog-torrent-addfile.html",function(d){system.templates["dialog-torrent-addfile.html"]=d;$("#dialog-torrent-addfile").dialog({content:d})})}}}},initTree:function(){this.panel.left.tree({data:[{id:"torrent-all",iconCls:"icon-home",text:this.lang.tree.all+" ("+this.lang.tree.status.loading+")",children:[{id:"downloading",text:this.lang.tree.downloading,iconCls:"icon-download"},{id:"paused",text:this.lang.tree.paused,
iconCls:"icon-pause"},{id:"sending",text:this.lang.tree.sending,iconCls:"icon-seed"},{id:"check",text:this.lang.tree.check,iconCls:"icon-check"},{id:"actively",text:this.lang.tree.actively,iconCls:"icon-actively"},{id:"error",text:this.lang.tree.error,iconCls:"icon-error"},{id:"warning",text:this.lang.tree.warning,iconCls:"icon-warning"}]},{id:"servers",text:this.lang.tree.servers,iconCls:"icon-servers",children:[{id:"servers-loading",text:this.lang.tree.status.loading,iconCls:"tree-loading"}]},{id:"folders",
text:this.lang.tree.folders,children:[{id:"folders-loading",text:this.lang.tree.status.loading,iconCls:"tree-loading"}]},{id:"statistics",text:this.lang.tree.statistics.title,state:"closed",iconCls:"icon-chart",children:[{id:"cumulative-stats",text:this.lang.tree.statistics.cumulative,children:[{id:"uploadedBytes",text:this.lang.tree.statistics.uploadedBytes},{id:"downloadedBytes",text:this.lang.tree.statistics.downloadedBytes},{id:"filesAdded",text:this.lang.tree.statistics.filesAdded},{id:"sessionCount",
text:this.lang.tree.statistics.sessionCount},{id:"secondsActive",text:this.lang.tree.statistics.secondsActive}]},{id:"current-stats",text:this.lang.tree.statistics.current,children:[{id:"current-uploadedBytes",text:this.lang.tree.statistics.uploadedBytes},{id:"current-downloadedBytes",text:this.lang.tree.statistics.downloadedBytes},{id:"current-filesAdded",text:this.lang.tree.statistics.filesAdded},{id:"current-sessionCount",text:this.lang.tree.statistics.sessionCount},{id:"current-secondsActive",
text:this.lang.tree.statistics.secondsActive}]}]}],onSelect:function(c){system.loadTorrentToList({node:c})},lines:true});for(var a in this.lang.tree.toolbar.nav){var b=this.panel.left.tree("find",a);$(b.target).parent().hide()}if(this.config.defaultSelectNode)(a=this.panel.left.tree("find",this.config.defaultSelectNode))&&this.panel.left.tree("select",a.target)},initTorrentTable:function(){this.control.torrentlist=$("<table/>").attr("class","torrent-list").appendTo(this.panel.list);$.get("template/torrent-fields.json?time="+
new Date,function(a){a=a.fields;for(var b in a){a[b].title=system.lang.torrent.fields[a[b].field];system.setFieldFormat(a[b])}system.control.torrentlist.datagrid({autoRowHeight:false,pagination:true,rownumbers:true,remoteSort:false,checkOnSelect:false,pageSize:system.config.pageSize,idField:"id",fit:true,striped:true,columns:[a],onCheck:function(c,d){system.checkTorrentRow(c,d)},onUncheck:function(c,d){system.checkTorrentRow(c,d)},onCheckAll:function(){system.checkTorrentRow("all",false)},onUncheckAll:function(){system.checkTorrentRow("all",
true)},onSelect:function(c,d){$(this).datagrid("clearSelections");system.config.autoExpandAttribute&&system.panel.attribute.panel("options").collapsed&&system.panel.layout_body.layout("expand","south");system.getTorrentInfos(d.id)},onUnselect:function(){if(system.config.autoExpandAttribute)system.panel.attribute.panel("options").collapsed||system.panel.layout_body.layout("collapse","south");system.currentTorrentId=0},onBeforeLoad:function(){system.currentTorrentId=0},onSortColumn:function(c,d){var e=
system.control.torrentlist.datagrid("getData").originalRows.sort(arrayObjectSort(c,d));system.control.torrentlist.datagrid("loadData",e)},onRowContextMenu:function(c,d){system.control.torrentlist.datagrid("checkRow",d);c.preventDefault();system.showContextMenu("torrent-list",c)}})},"json");this.panel.list.bind("contextmenu",function(a){a.preventDefault();system.showContextMenu("torrent-list",a)})},showContextMenu:function(a,b){var c=this.contextMenus[a];if(c)c.empty();else{c=$("<div/>").attr("class",
"easyui-menu").css({width:"180px"}).appendTo(this.panel.main);this.contextMenus[a]=c;c.menu()}var d=null;switch(a){case "torrent-list":d=["start","pause","-","remove","recheck","-","morepeers","changeDownloadDir"];var e=this.panel.toolbar,f;for(f in d){var g=d[f];if(g=="-"){g=("line-"+Math.random()).replace(".","");c.menu("appendItem",{text:"",id:g});c.find("#"+g).attr("class","menu-sep").attr("disabled",true).html("&nbsp;").unbind(".menu")}else{var h=e.find("#toolbar_"+g);h&&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()}});h=null}}}c.menu("show",{left:b.pageX,top:b.pageY});d=c=null},checkTorrentRow:function(a,b){if(a=="all"){this.panel.toolbar.find("#toolbar_start").linkbutton({disabled:b});this.panel.toolbar.find("#toolbar_pause").linkbutton({disabled:b});this.panel.toolbar.find("#toolbar_remove").linkbutton({disabled:b});
this.panel.toolbar.find("#toolbar_recheck").linkbutton({disabled:b});this.panel.toolbar.find("#toolbar_changeDownloadDir").linkbutton({disabled:b});this.panel.toolbar.find("#toolbar_morepeers").linkbutton({disabled:b})}else if(this.control.torrentlist.datagrid("getChecked").length==0){this.panel.toolbar.find("#toolbar_start").linkbutton({disabled:true});this.panel.toolbar.find("#toolbar_pause").linkbutton({disabled:true});this.panel.toolbar.find("#toolbar_remove").linkbutton({disabled:true});this.panel.toolbar.find("#toolbar_recheck").linkbutton({disabled:true});
this.panel.toolbar.find("#toolbar_changeDownloadDir").linkbutton({disabled:true});this.panel.toolbar.find("#toolbar_morepeers").linkbutton({disabled:true})}else{this.panel.toolbar.find("#toolbar_remove").linkbutton({disabled:false});this.panel.toolbar.find("#toolbar_changeDownloadDir").linkbutton({disabled:false});switch(transmission.torrents.all[b.id].status){case transmission._status.stopped:this.panel.toolbar.find("#toolbar_start").linkbutton({disabled:false});this.panel.toolbar.find("#toolbar_pause").linkbutton({disabled:true});
this.panel.toolbar.find("#toolbar_recheck").linkbutton({disabled:false});this.panel.toolbar.find("#toolbar_morepeers").linkbutton({disabled:true});break;case transmission._status.check:case transmission._status.checkwait:this.panel.toolbar.find("#toolbar_start").linkbutton({disabled:true});this.panel.toolbar.find("#toolbar_pause").linkbutton({disabled:true});this.panel.toolbar.find("#toolbar_recheck").linkbutton({disabled:true});this.panel.toolbar.find("#toolbar_morepeers").linkbutton({disabled:true});
break;default:this.panel.toolbar.find("#toolbar_start").linkbutton({disabled:true});this.panel.toolbar.find("#toolbar_pause").linkbutton({disabled:false});this.panel.toolbar.find("#toolbar_recheck").linkbutton({disabled:true});this.panel.toolbar.find("#toolbar_morepeers").linkbutton({disabled:false})}}},initToolbar:function(){this.panel.toolbar.find("#toolbar_about").linkbutton({text:this.lang.toolbar.about}).attr("title",this.lang.toolbar.tip.about).click(function(){var a=$("#dialog-about");if(a.length){a.dialog("open");
a.dialog({content:system.templates["dialog-about.html"]})}else{$("<div/>").attr("id","dialog-about").appendTo(document.body).dialog({title:system.lang.toolbar.about,width:340,height:210,resizable:true,cache:false,content:"loading...",modal:true});$.get("template/dialog-about.html?time="+new Date,function(b){system.templates["dialog-about.html"]=b;$("#dialog-about").dialog({content:b})})}});this.panel.toolbar.find("#toolbar_label_reload_time").html(this.lang.toolbar["reload-time"]);this.panel.toolbar.find("#toolbar_label_reload_time_unit").html(this.lang.toolbar["reload-time-unit"]);
this.panel.toolbar.find("#toolbar_reload_time").numberspinner({value:this.config.reloadStep/1E3,min:3,disabled:!this.config.autoReload,onChange:function(){var a=this.value;if($.isNumeric(a)){system.config.reloadStep=a*1E3;system.saveConfig()}}});this.panel.toolbar.find("#toolbar_autoreload").linkbutton({text:this.config.autoReload?this.lang.toolbar["autoreload-enabled"]:this.lang.toolbar["autoreload-disabled"],iconCls:this.config.autoReload?"icon-enabled":"icon-disabled"}).attr("title",this.config.autoReload?
this.lang.toolbar.tip["autoreload-disabled"]:this.lang.toolbar.tip["autoreload-enabled"]).click(function(){if(system.config.autoReload){system.config.autoReload=false;clearTimeout(system.autoReloadTimer);system.panel.toolbar.find("#toolbar_reload_time").numberspinner("disable")}else{system.config.autoReload=true;system.reloadData();system.panel.toolbar.find("#toolbar_reload_time").numberspinner("enable")}system.saveConfig();$(this).linkbutton({text:system.config.autoReload?system.lang.toolbar["autoreload-enabled"]:
system.lang.toolbar["autoreload-disabled"],iconCls:system.config.autoReload?"icon-enabled":"icon-disabled"}).attr("title",system.config.autoReload?system.lang.toolbar.tip["autoreload-disabled"]:system.lang.toolbar.tip["autoreload-enabled"])});this.panel.toolbar.find("#toolbar_add_torrents").linkbutton({text:this.lang.toolbar["add-torrent"],disabled:false}).attr("title",this.lang.toolbar.tip["add-torrent"]).click(function(){var a=$("#dialog-torrent-add");if(a.length){a.dialog("open");a.dialog({content:system.templates["dialog-torrent-add.html"]})}else{$("<div/>").attr("id",
"dialog-torrent-add").appendTo(document.body).dialog({title:system.lang.toolbar["add-torrent"],width:620,height:400,resizable:true,cache:false,content:"loading...",modal:true});$.get("template/dialog-torrent-add.html?time="+new Date,function(b){system.templates["dialog-torrent-add.html"]=b;$("#dialog-torrent-add").dialog({content:b})})}});this.panel.toolbar.find("#toolbar_start_all").linkbutton({disabled:false}).attr("title",this.lang.toolbar.tip["start-all"]).click(function(){var a=$(this),b=a.linkbutton("options").iconCls;
a.linkbutton({disabled:true,iconCls:"icon-loading"});transmission.exec({method:"torrent-start"},function(){a.linkbutton({iconCls:b,disabled:false});a=null})});this.panel.toolbar.find("#toolbar_pause_all").linkbutton({disabled:false}).attr("title",this.lang.toolbar.tip["pause-all"]).click(function(){var a=$(this),b=a.linkbutton("options").iconCls;a.linkbutton({disabled:true,iconCls:"icon-loading"});transmission.exec({method:"torrent-stop"},function(){a.linkbutton({iconCls:b,disabled:false});a=null})});
this.panel.toolbar.find("#toolbar_tracker_replace").attr("title",this.lang.toolbar.tip["tracker-replace"]).click(function(){var a=$("#dialog-system-replaceTracker");if(a.length){a.dialog("open");a.dialog({content:system.templates["dialog-system-replaceTracker.html"]})}else{$("<div/>").attr("id","dialog-system-replaceTracker").appendTo(document.body).dialog({title:system.lang.dialog["system-replaceTracker"].title,width:600,height:220,resizable:true,cache:false,content:"loading...",modal:true});$.get("template/dialog-system-replaceTracker.html?time="+
new Date,function(b){system.templates["dialog-system-replaceTracker.html"]=b;$("#dialog-system-replaceTracker").dialog({content:b})})}});this.panel.toolbar.find("#toolbar_start").linkbutton({disabled:true}).attr("title",this.lang.toolbar.tip.start).click(function(){system.changeSelectedTorrentStatus("start",$(this))});this.panel.toolbar.find("#toolbar_pause").linkbutton({disabled:true}).attr("title",this.lang.toolbar.tip.pause).click(function(){system.changeSelectedTorrentStatus("stop",$(this))});
this.panel.toolbar.find("#toolbar_recheck").linkbutton({disabled:true}).attr("title",this.lang.toolbar.tip.recheck).click(function(){var a=system.control.torrentlist.datagrid("getChecked");if(a.length>0)if(a.length==1)if(transmission.torrents.all[a[0].id].percentDone>0)confirm(system.lang.toolbar.tip["recheck-confirm"])&&system.changeSelectedTorrentStatus("verify",$(this));else system.changeSelectedTorrentStatus("verify",$(this));else confirm(system.lang.toolbar.tip["recheck-confirm"])&&system.changeSelectedTorrentStatus("verify",
$(this))});this.panel.toolbar.find("#toolbar_morepeers").linkbutton({disabled:true}).click(function(){system.changeSelectedTorrentStatus("reannounce",$(this))});this.panel.toolbar.find("#toolbar_remove").linkbutton({disabled:true}).attr("title",this.lang.toolbar.tip.remove).click(function(){var a=system.control.torrentlist.datagrid("getChecked"),b=[],c;for(c in a)b.push(a[c].id);if(b.length!=0){a=$("#dialog-torrent-remove-confirm");if(a.length){a.dialog("open");a.dialog("refresh");a.data("ids",b)}else $("<div/>").attr("id",
"dialog-torrent-remove-confirm").data("ids",b).appendTo(document.body).dialog({title:system.lang.dialog["torrent-remove"].title,width:350,height:150,resizable:false,cache:true,href:"template/dialog-torrent-remove-confirm.html",modal:true})}});this.panel.toolbar.find("#toolbar_changeDownloadDir").linkbutton({disabled:true}).attr("title",this.lang.toolbar.tip["change-download-dir"]).click(function(){var a=system.control.torrentlist.datagrid("getChecked"),b=[],c;for(c in a)b.push(a[c].id);if(b.length!=
0){a=$("#dialog-torrent-changeDownloadDir");if(a.length){a.dialog("open");a.data("ids",b);a.dialog({content:system.templates["dialog-torrent-changeDownloadDir.html"]})}else{$("<div/>").attr("id","dialog-torrent-changeDownloadDir").appendTo(document.body).dialog({title:system.lang.dialog["torrent-changeDownloadDir"].title,width:520,height:180,resizable:false,cache:true,content:"loading...",modal:true});$.get("template/dialog-torrent-changeDownloadDir.html?time="+new Date,function(d){system.templates["dialog-torrent-changeDownloadDir.html"]=
d;$("#dialog-torrent-changeDownloadDir").data("ids",b);$("#dialog-torrent-changeDownloadDir").dialog({content:d})})}}});this.panel.toolbar.find("#toolbar_alt_speed").linkbutton().attr("title",this.lang.toolbar.tip["alt-speed"]).click(function(){var a=$(this),b=false;if(a.linkbutton("options").iconCls=="icon-alt-speed-false")b=true;transmission.exec({method:"session-set",arguments:{"alt-speed-enabled":b}},function(c){if(c.result=="success"){system.serverConfig["alt-speed-enabled"]=b;a.linkbutton({iconCls:"icon-alt-speed-"+
b.toString()});b?$("#status_alt_speed").show():$("#status_alt_speed").hide()}});a.linkbutton({iconCls:"icon-loading"})});this.panel.toolbar.find("#toolbar_config").linkbutton().attr("title",this.lang.toolbar.tip["system-config"]).click(function(){var a=$("#dialog-system-config");if(a.length){a.dialog("open");a.dialog({content:system.templates["dialog-system-config.html"]})}else{$("<div/>").attr("id","dialog-system-config").appendTo(document.body).dialog({title:system.lang.toolbar["system-config"],
width:620,height:440,resizable:true,cache:false,content:"loading...",modal:true});$.get("template/dialog-system-config.html?time="+new Date,function(b){system.templates["dialog-system-config.html"]=b;$("#dialog-system-config").dialog({content:b})})}});this.panel.toolbar.find("#toolbar_reload").linkbutton().attr("title",this.lang.toolbar.tip["system-reload"]).click(function(){system.reloadData()});this.panel.toolbar.find("#toolbar_search").searchbox({searcher:function(a){system.searchTorrents(a)},
prompt:this.lang.toolbar["search-prompt"]})},initStatusBar:function(){this.panel.statusbar.find("#status_title_downloadspeed").html(this.lang.statusbar.downloadspeed);this.panel.statusbar.find("#status_title_uploadspeed").html(this.lang.statusbar.uploadspeed)},connect:function(){this.showStatus(this.lang.system.status.connect,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:"icon-alt-speed-true"});$("#status_alt_speed").show()}else{system.panel.toolbar.find("#toolbar_alt_speed").linkbutton({iconCls:"icon-alt-speed-false"});
$("#status_alt_speed").hide()}system.downloadDir=b["download-dir"];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){if(!this.reloading){clearTimeout(this.autoReloadTimer);this.reloading=true;var b={trackers:transmission.trackers,folders:transmission.torrents.folders};transmission.torrents.getallids(function(c){var d=[],e;for(e in c)d.push(c[e].id);c=transmission.torrents.getErrorIds(d,true);c.length>0?transmission.torrents.getallids(function(){system.resetTorrentInfos(b)},
c):system.resetTorrentInfos(b)},a)}},resetTorrentInfos:function(a){var b=this.currentTorrentId,c=this.panel.left.tree("find","servers");if(c)this.removeTreeNode("servers-loading");else{this.appendTreeNode(null,[{id:"servers",text:this.lang.tree.servers,iconCls:"icon-servers"}]);c=this.panel.left.tree("find","servers")}for(var d in transmission.trackers){var e=transmission.trackers[d],f=system.panel.left.tree("find",e.nodeid),g=e.name+this.showNodeMoreInfos(e.count,e.size);f?system.updateTreeNodeText(e.nodeid,
g,e.connected?"icon-server":"icon-server-error"):system.appendTreeNode(c,[{id:e.nodeid,text:g,iconCls:e.connected?"icon-server":"icon-server-error"}]);a.trackers[e.nodeid]=null}for(d in a.trackers)(e=a.trackers[d])&&system.removeTreeNode(e.nodeid);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]){f=system.panel.left.tree("find","sending");c=system.panel.left.tree("getChildren",f.target);g=system.lang.tree.wait+this.showNodeMoreInfos(transmission.torrents.status[transmission._status.seedwait].length);
c.length>0?system.updateTreeNodeText(c[0].id,g):system.appendTreeNode(f,[{id:"seedwait",text:g,iconCls:"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]){f=system.panel.left.tree("find",
"check");c=system.panel.left.tree("getChildren",f.target);g=system.lang.tree.wait+this.showNodeMoreInfos(transmission.torrents.status[transmission._status.checkwait].length);c.length>0?system.updateTreeNodeText(c[0].id,g):system.appendTreeNode(f,[{id:"checkwait",text:g,iconCls:"icon-wait"}])}else system.removeTreeNode("checkwait");transmission.torrents.status[transmission._status.download]?system.updateTreeNodeText("downloading",system.lang.tree.downloading+this.showNodeMoreInfos(transmission.torrents.status[transmission._status.download].length)):
system.updateTreeNodeText("downloading",system.lang.tree.downloading);if(transmission.torrents.status[transmission._status.downloadwait]){f=system.panel.left.tree("find","downloading");c=system.panel.left.tree("getChildren",f.target);g=system.lang.tree.wait+this.showNodeMoreInfos(transmission.torrents.status[transmission._status.downloadwait].length);c.length>0?system.updateTreeNodeText(c[0].id,g):system.appendTreeNode(f,[{id:"downloadwait",text:g,iconCls:"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));f=system.panel.left.tree("getSelected");if(f!=null){g=system.control.torrentlist.datagrid("options").pageNumber;system.loadTorrentToList({node:f,
page:g})}b!=0&&system.control.torrentlist.datagrid("selectRecord",b);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));b="uploadedBytes,downloadedBytes,filesAdded,sessionCount,secondsActive".split(",");$.each(b,function(h,i){switch(i){case "uploadedBytes":case "downloadedBytes":system.updateTreeNodeText(i,
system.lang.tree.statistics[i]+formatSize(system.serverSessionStats["cumulative-stats"][i]));system.updateTreeNodeText("current-"+i,system.lang.tree.statistics[i]+formatSize(system.serverSessionStats["current-stats"][i]));break;case "secondsActive":system.updateTreeNodeText(i,system.lang.tree.statistics[i]+getTotalTime(system.serverSessionStats["cumulative-stats"][i]*1E3));system.updateTreeNodeText("current-"+i,system.lang.tree.statistics[i]+getTotalTime(system.serverSessionStats["current-stats"][i]*
1E3));break;default:system.updateTreeNodeText(i,system.lang.tree.statistics[i]+system.serverSessionStats["cumulative-stats"][i]);system.updateTreeNodeText("current-"+i,system.lang.tree.statistics[i]+system.serverSessionStats["current-stats"][i])}});for(d in transmission.torrents.folders)a.folders[transmission.torrents.folders[d].nodeid]=null;this.loadFolderList(a.folders);navigator.userAgent.indexOf("Firefox")>0&&system.panel.left.find("span.nav-total-size").css({"margin-top":"-19px"})},showNodeMoreInfos:function(a,
b){var c="";if(a>0)c=" <span class='nav-torrents-number'>("+a+")</span>";if(b>0)c+="<span class='nav-total-size'>["+formatSize(b)+"]</span>";return c},getServerStatus:function(){if(!this.reloading){clearTimeout(this.autoReloadTimer);this.reloading=true;transmission.getStatus(function(a){system.reloading=false;$("#status_downloadspeed").html(formatSize(a.downloadSpeed,false,"speed"));$("#status_uploadspeed").html(formatSize(a.uploadSpeed,false,"speed"));system.serverSessionStats=a;if(a.torrentCount==
0){(a=system.panel.left.tree("find","servers"))&&system.panel.left.tree("remove",a.target);system.updateTreeNodeText("torrent-all",system.lang.tree.all)}})}},showStatus:function(a,b){$("#m_status").panel("options").collapsed&&$("#layout_left").layout("expand","south");this.panel.status_text.show();this.panel.status_text.html(a);if(b!=0){if(b==undefined)b=3E3;this.panel.status_text.fadeOut(b,function(){$("#layout_left").layout("collapse","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({pageNumber:1});d=a.node.id}this.panel.left.data("currentNodeId",d);switch(c.id){case "servers":b=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;default:if(a.node.id.indexOf("folders-")!=-1)if(c=transmission.torrents.folders[a.node.id])b=c.torrents}}if(this.config.defaultSelectNode!=a.node.id){this.control.torrentlist.datagrid("loadData",[]);this.config.defaultSelectNode=a.node.id;this.saveConfig()}a=[];for(var 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>";a.push({id:b[e].id,name:b[e].name,totalSize:b[e].totalSize,percentDone:b[e].percentDone,remainingTime:b[e].remainingTime,status:c,statusCode:b[e].status,addedDate:b[e].addedDate,completeSize:b[e].totalSize-b[e].leftUntilDone,rateDownload:b[e].rateDownload,
rateUpload:b[e].rateUpload,leecherCount:b[e].leecher,seederCount:b[e].seeder,uploadRatio:b[e].uploadRatio,uploadedEver:b[e].uploadedEver})}this.panel.toolbar.find("#toolbar_start").linkbutton({disabled:true});this.panel.toolbar.find("#toolbar_pause").linkbutton({disabled:true});this.panel.toolbar.find("#toolbar_remove").linkbutton({disabled:true});this.panel.toolbar.find("#toolbar_recheck").linkbutton({disabled:true});this.panel.toolbar.find("#toolbar_changeDownloadDir").linkbutton({disabled:true});
this.panel.toolbar.find("#toolbar_morepeers").linkbutton({disabled:true});this.updateTorrentCurrentPageDatas(a)}}},updateTorrentCurrentPageDatas:function(a){var b=this.control.torrentlist.datagrid("getRows"),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];if(c[f.id]){var h=d[f.id];if(h){this.control.torrentlist.datagrid("updateRow",{index:e,row:h});g[f.id]=f}else this.control.torrentlist.datagrid("deleteRow",
e)}else g[f.id]=f}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 transmission._status.check:b="iconlabel icon-checking";break;case transmission._status.download:b="iconlabel icon-down";break;case transmission._status.seed:b="iconlabel icon-up";break;case transmission._status.seedwait:case transmission._status.downloadwait:case transmission._status.checkwait:b=
"iconlabel icon-wait"}if(a.warning){b="iconlabel icon-warning-type1";c+="\n\n"+this.lang["public"]["text-info"]+": "+a.warning}if(a.error!=0){b="iconlabel icon-exclamation";c+="\n\n"+this.lang["public"]["text-info"]+": "+a.errorString}return'<span class="'+b+'" title="'+c+'">'+a.name+"</span>"},getTorrentProgressBar:function(a,b){a+="%";var c="",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=
new Date,function(a){a=a.fields;for(var b in a){a[b].title=system.lang.torrent.fields[a[b].field];system.setFieldFormat(a[b])}system.control.torrentlist.datagrid({autoRowHeight:false,pagination:true,rownumbers:true,remoteSort:false,checkOnSelect:false,pageSize:system.config.pageSize,idField:"id",fit:true,striped:true,columns:[a],onCheck:function(c,e){system.checkTorrentRow(c,e)},onUncheck:function(c,e){system.checkTorrentRow(c,e)},onCheckAll:function(){system.checkTorrentRow("all",false)},onUncheckAll:function(){system.checkTorrentRow("all",
true)},onSelect:function(c,e){$(this).datagrid("clearSelections");system.config.autoExpandAttribute&&system.panel.attribute.panel("options").collapsed&&system.panel.layout_body.layout("expand","south");system.getTorrentInfos(e.id)},onUnselect:function(){if(system.config.autoExpandAttribute)system.panel.attribute.panel("options").collapsed||system.panel.layout_body.layout("collapse","south");system.currentTorrentId=0},onBeforeLoad:function(){system.currentTorrentId=0},onSortColumn:function(c,e){var d=
system.control.torrentlist.datagrid("getData").originalRows.sort(arrayObjectSort(c,e));system.control.torrentlist.datagrid("loadData",d)},onRowContextMenu:function(c,e){system.control.torrentlist.datagrid("checkRow",e);c.preventDefault();system.showContextMenu("torrent-list",c)}})},"json");this.panel.list.bind("contextmenu",function(a){a.preventDefault();system.showContextMenu("torrent-list",a)})},showContextMenu:function(a,b){var c=this.contextMenus[a];if(c)c.empty();else{c=$("<div/>").attr("class",
"easyui-menu").css({width:"180px"}).appendTo(this.panel.main);this.contextMenus[a]=c;c.menu()}var e=null;switch(a){case "torrent-list":e=["start","pause","-","remove","recheck","-","morepeers","changeDownloadDir","-","menu-queue-move-top","menu-queue-move-up","menu-queue-move-down","menu-queue-move-bottom"];var d=this.panel.toolbar,f;for(f in e){var g=e[f];if(g=="-"){g=("line-"+Math.random()).replace(".","");c.menu("appendItem",{text:"",id:g});c.find("#"+g).attr("class","menu-sep").attr("disabled",
true).html("&nbsp;").unbind(".menu")}else{var h=d.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);h.length>0&&c.menu("appendItem",{text:h.attr("title"),id:g,iconCls:h.attr("id").replace("menu","icon"),disabled:d.find("#toolbar_changeDownloadDir").linkbutton("options").disabled,onclick:function(){$("#"+
$(this).attr("id")).click()}})}h=null}}}c.menu("show",{left:b.pageX,top:b.pageY});e=c=null},checkTorrentRow:function(a,b){if(a=="all"){this.panel.toolbar.find("#toolbar_start").linkbutton({disabled:b});this.panel.toolbar.find("#toolbar_pause").linkbutton({disabled:b});this.panel.toolbar.find("#toolbar_remove").linkbutton({disabled:b});this.panel.toolbar.find("#toolbar_recheck").linkbutton({disabled:b});this.panel.toolbar.find("#toolbar_changeDownloadDir").linkbutton({disabled:b});this.panel.toolbar.find("#toolbar_morepeers").linkbutton({disabled:b})}else if(this.control.torrentlist.datagrid("getChecked").length==
0){this.panel.toolbar.find("#toolbar_start").linkbutton({disabled:true});this.panel.toolbar.find("#toolbar_pause").linkbutton({disabled:true});this.panel.toolbar.find("#toolbar_remove").linkbutton({disabled:true});this.panel.toolbar.find("#toolbar_recheck").linkbutton({disabled:true});this.panel.toolbar.find("#toolbar_changeDownloadDir").linkbutton({disabled:true});this.panel.toolbar.find("#toolbar_morepeers").linkbutton({disabled:true});this.panel.toolbar.find("#toolbar_queue").menubutton("disable")}else{this.panel.toolbar.find("#toolbar_remove").linkbutton({disabled:false});
this.panel.toolbar.find("#toolbar_changeDownloadDir").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").linkbutton({disabled:false});this.panel.toolbar.find("#toolbar_pause").linkbutton({disabled:true});this.panel.toolbar.find("#toolbar_recheck").linkbutton({disabled:false});this.panel.toolbar.find("#toolbar_morepeers").linkbutton({disabled:true});
break;case transmission._status.check:case transmission._status.checkwait:this.panel.toolbar.find("#toolbar_start").linkbutton({disabled:true});this.panel.toolbar.find("#toolbar_pause").linkbutton({disabled:true});this.panel.toolbar.find("#toolbar_recheck").linkbutton({disabled:true});this.panel.toolbar.find("#toolbar_morepeers").linkbutton({disabled:true});break;default:this.panel.toolbar.find("#toolbar_start").linkbutton({disabled:true});this.panel.toolbar.find("#toolbar_pause").linkbutton({disabled:false});
this.panel.toolbar.find("#toolbar_recheck").linkbutton({disabled:true});this.panel.toolbar.find("#toolbar_morepeers").linkbutton({disabled:false})}}},initToolbar:function(){this.panel.toolbar.find("#toolbar_about").linkbutton({text:this.lang.toolbar.about}).attr("title",this.lang.toolbar.tip.about).click(function(){var a=$("#dialog-about");if(a.length){a.dialog("open");a.dialog({content:system.templates["dialog-about.html"]})}else{$("<div/>").attr("id","dialog-about").appendTo(document.body).dialog({title:system.lang.toolbar.about,
width:340,height:210,resizable:true,cache:false,content:"loading...",modal:true});$.get("template/dialog-about.html?time="+new Date,function(b){system.templates["dialog-about.html"]=b;$("#dialog-about").dialog({content:b})})}});this.panel.toolbar.find("#toolbar_label_reload_time").html(this.lang.toolbar["reload-time"]);this.panel.toolbar.find("#toolbar_label_reload_time_unit").html(this.lang.toolbar["reload-time-unit"]);this.panel.toolbar.find("#toolbar_reload_time").numberspinner({value:this.config.reloadStep/
1E3,min:3,disabled:!this.config.autoReload,onChange:function(){var a=this.value;if($.isNumeric(a)){system.config.reloadStep=a*1E3;system.saveConfig()}}});this.panel.toolbar.find("#toolbar_autoreload").linkbutton({text:this.config.autoReload?this.lang.toolbar["autoreload-enabled"]:this.lang.toolbar["autoreload-disabled"],iconCls:this.config.autoReload?"icon-enabled":"icon-disabled"}).attr("title",this.config.autoReload?this.lang.toolbar.tip["autoreload-disabled"]:this.lang.toolbar.tip["autoreload-enabled"]).click(function(){if(system.config.autoReload){system.config.autoReload=
false;clearTimeout(system.autoReloadTimer);system.panel.toolbar.find("#toolbar_reload_time").numberspinner("disable")}else{system.config.autoReload=true;system.reloadData();system.panel.toolbar.find("#toolbar_reload_time").numberspinner("enable")}system.saveConfig();$(this).linkbutton({text:system.config.autoReload?system.lang.toolbar["autoreload-enabled"]:system.lang.toolbar["autoreload-disabled"],iconCls:system.config.autoReload?"icon-enabled":"icon-disabled"}).attr("title",system.config.autoReload?
system.lang.toolbar.tip["autoreload-disabled"]:system.lang.toolbar.tip["autoreload-enabled"])});this.panel.toolbar.find("#toolbar_add_torrents").linkbutton({text:this.lang.toolbar["add-torrent"],disabled:false}).attr("title",this.lang.toolbar.tip["add-torrent"]).click(function(){var a=$("#dialog-torrent-add");if(a.length){a.dialog("open");a.dialog({content:system.templates["dialog-torrent-add.html"]})}else{$("<div/>").attr("id","dialog-torrent-add").appendTo(document.body).dialog({title:system.lang.toolbar["add-torrent"],
width:620,height:400,resizable:true,cache:false,content:"loading...",modal:true});$.get("template/dialog-torrent-add.html?time="+new Date,function(b){system.templates["dialog-torrent-add.html"]=b;$("#dialog-torrent-add").dialog({content:b})})}});this.panel.toolbar.find("#toolbar_start_all").linkbutton({disabled:false}).attr("title",this.lang.toolbar.tip["start-all"]).click(function(){var a=$(this),b=a.linkbutton("options").iconCls;a.linkbutton({disabled:true,iconCls:"icon-loading"});transmission.exec({method:"torrent-start"},
function(){a.linkbutton({iconCls:b,disabled:false});a=null})});this.panel.toolbar.find("#toolbar_pause_all").linkbutton({disabled:false}).attr("title",this.lang.toolbar.tip["pause-all"]).click(function(){var a=$(this),b=a.linkbutton("options").iconCls;a.linkbutton({disabled:true,iconCls:"icon-loading"});transmission.exec({method:"torrent-stop"},function(){a.linkbutton({iconCls:b,disabled:false});a=null})});this.panel.toolbar.find("#toolbar_tracker_replace").attr("title",this.lang.toolbar.tip["tracker-replace"]).click(function(){var a=
$("#dialog-system-replaceTracker");if(a.length){a.dialog("open");a.dialog({content:system.templates["dialog-system-replaceTracker.html"]})}else{$("<div/>").attr("id","dialog-system-replaceTracker").appendTo(document.body).dialog({title:system.lang.dialog["system-replaceTracker"].title,width:600,height:220,resizable:true,cache:false,content:"loading...",modal:true});$.get("template/dialog-system-replaceTracker.html?time="+new Date,function(b){system.templates["dialog-system-replaceTracker.html"]=b;
$("#dialog-system-replaceTracker").dialog({content:b})})}});this.panel.toolbar.find("#toolbar_start").linkbutton({disabled:true}).attr("title",this.lang.toolbar.tip.start).click(function(){system.changeSelectedTorrentStatus("start",$(this))});this.panel.toolbar.find("#toolbar_pause").linkbutton({disabled:true}).attr("title",this.lang.toolbar.tip.pause).click(function(){system.changeSelectedTorrentStatus("stop",$(this))});this.panel.toolbar.find("#toolbar_recheck").linkbutton({disabled:true}).attr("title",
this.lang.toolbar.tip.recheck).click(function(){var a=system.control.torrentlist.datagrid("getChecked");if(a.length>0)if(a.length==1)if(transmission.torrents.all[a[0].id].percentDone>0)confirm(system.lang.toolbar.tip["recheck-confirm"])&&system.changeSelectedTorrentStatus("verify",$(this));else system.changeSelectedTorrentStatus("verify",$(this));else confirm(system.lang.toolbar.tip["recheck-confirm"])&&system.changeSelectedTorrentStatus("verify",$(this))});this.panel.toolbar.find("#toolbar_morepeers").linkbutton({disabled:true}).click(function(){system.changeSelectedTorrentStatus("reannounce",
$(this))});this.panel.toolbar.find("#toolbar_remove").linkbutton({disabled:true}).attr("title",this.lang.toolbar.tip.remove).click(function(){var a=system.control.torrentlist.datagrid("getChecked"),b=[],c;for(c in a)b.push(a[c].id);if(b.length!=0){a=$("#dialog-torrent-remove-confirm");if(a.length){a.dialog("open");a.dialog("refresh");a.data("ids",b)}else $("<div/>").attr("id","dialog-torrent-remove-confirm").data("ids",b).appendTo(document.body).dialog({title:system.lang.dialog["torrent-remove"].title,
width:350,height:150,resizable:false,cache:true,href:"template/dialog-torrent-remove-confirm.html",modal:true})}});this.panel.toolbar.find("#toolbar_changeDownloadDir").linkbutton({disabled:true}).attr("title",this.lang.toolbar.tip["change-download-dir"]).click(function(){var a=system.control.torrentlist.datagrid("getChecked"),b=[],c;for(c in a)b.push(a[c].id);if(b.length!=0){a=$("#dialog-torrent-changeDownloadDir");if(a.length){a.dialog("open");a.data("ids",b);a.dialog({content:system.templates["dialog-torrent-changeDownloadDir.html"]})}else{$("<div/>").attr("id",
"dialog-torrent-changeDownloadDir").appendTo(document.body).dialog({title:system.lang.dialog["torrent-changeDownloadDir"].title,width:520,height:200,resizable:false,cache:true,content:"loading...",modal:true});$.get("template/dialog-torrent-changeDownloadDir.html?time="+new Date,function(e){system.templates["dialog-torrent-changeDownloadDir.html"]=e;$("#dialog-torrent-changeDownloadDir").data("ids",b);$("#dialog-torrent-changeDownloadDir").dialog({content:e})})}}});this.panel.toolbar.find("#toolbar_alt_speed").linkbutton().attr("title",
this.lang.toolbar.tip["alt-speed"]).click(function(){var a=$(this),b=false;if(a.linkbutton("options").iconCls=="icon-alt-speed-false")b=true;transmission.exec({method:"session-set",arguments:{"alt-speed-enabled":b}},function(c){if(c.result=="success"){system.serverConfig["alt-speed-enabled"]=b;a.linkbutton({iconCls:"icon-alt-speed-"+b.toString()});b?$("#status_alt_speed").show():$("#status_alt_speed").hide()}});a.linkbutton({iconCls:"icon-loading"})});this.panel.toolbar.find("#toolbar_config").linkbutton().attr("title",
this.lang.toolbar.tip["system-config"]).click(function(){var a=$("#dialog-system-config");if(a.length){a.dialog("open");a.dialog({content:system.templates["dialog-system-config.html"]})}else{$("<div/>").attr("id","dialog-system-config").appendTo(document.body).dialog({title:system.lang.toolbar["system-config"],width:620,height:440,resizable:true,cache:false,content:"loading...",modal:true});$.get("template/dialog-system-config.html?time="+new Date,function(b){system.templates["dialog-system-config.html"]=
b;$("#dialog-system-config").dialog({content:b})})}});this.panel.toolbar.find("#toolbar_reload").linkbutton().attr("title",this.lang.toolbar.tip["system-reload"]).click(function(){system.reloadData()});this.panel.toolbar.find("#toolbar_search").searchbox({searcher:function(a){system.searchTorrents(a)},prompt:this.lang.toolbar["search-prompt"]})},initStatusBar:function(){this.panel.statusbar.find("#status_title_downloadspeed").html(this.lang.statusbar.downloadspeed);this.panel.statusbar.find("#status_title_uploadspeed").html(this.lang.statusbar.uploadspeed)},
connect:function(){this.showStatus(this.lang.system.status.connect,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:"icon-alt-speed-true"});$("#status_alt_speed").show()}else{system.panel.toolbar.find("#toolbar_alt_speed").linkbutton({iconCls:"icon-alt-speed-false"});$("#status_alt_speed").hide()}system.downloadDir=b["download-dir"];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){if(!this.reloading){clearTimeout(this.autoReloadTimer);this.reloading=true;var b={trackers:transmission.trackers,
folders:transmission.torrents.folders};transmission.torrents.getallids(function(c){var e=[],d;for(d in c)e.push(c[d].id);c=transmission.torrents.getErrorIds(e,true);c.length>0?transmission.torrents.getallids(function(){system.resetTorrentInfos(b)},c):system.resetTorrentInfos(b)},a)}},resetTorrentInfos:function(a){var b=this.currentTorrentId,c=this.panel.left.tree("find","servers");if(c)this.removeTreeNode("servers-loading");else{this.appendTreeNode(null,[{id:"servers",text:this.lang.tree.servers,
iconCls:"icon-servers"}]);c=this.panel.left.tree("find","servers")}for(var e in transmission.trackers){var d=transmission.trackers[e],f=system.panel.left.tree("find",d.nodeid),g=d.name+this.showNodeMoreInfos(d.count,d.size);f?system.updateTreeNodeText(d.nodeid,g,d.connected?"icon-server":"icon-server-error"):system.appendTreeNode(c,[{id:d.nodeid,text:g,iconCls:d.connected?"icon-server":"icon-server-error"}]);a.trackers[d.nodeid]=null}for(e in a.trackers)(d=a.trackers[e])&&system.removeTreeNode(d.nodeid);
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]){f=system.panel.left.tree("find","sending");c=system.panel.left.tree("getChildren",f.target);g=system.lang.tree.wait+this.showNodeMoreInfos(transmission.torrents.status[transmission._status.seedwait].length);c.length>0?system.updateTreeNodeText(c[0].id,g):system.appendTreeNode(f,[{id:"seedwait",text:g,iconCls:"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]){f=system.panel.left.tree("find","check");c=system.panel.left.tree("getChildren",f.target);g=system.lang.tree.wait+this.showNodeMoreInfos(transmission.torrents.status[transmission._status.checkwait].length);c.length>0?system.updateTreeNodeText(c[0].id,
g):system.appendTreeNode(f,[{id:"checkwait",text:g,iconCls:"icon-wait"}])}else system.removeTreeNode("checkwait");transmission.torrents.status[transmission._status.download]?system.updateTreeNodeText("downloading",system.lang.tree.downloading+this.showNodeMoreInfos(transmission.torrents.status[transmission._status.download].length)):system.updateTreeNodeText("downloading",system.lang.tree.downloading);if(transmission.torrents.status[transmission._status.downloadwait]){f=system.panel.left.tree("find",
"downloading");c=system.panel.left.tree("getChildren",f.target);g=system.lang.tree.wait+this.showNodeMoreInfos(transmission.torrents.status[transmission._status.downloadwait].length);c.length>0?system.updateTreeNodeText(c[0].id,g):system.appendTreeNode(f,[{id:"downloadwait",text:g,iconCls:"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));f=system.panel.left.tree("getSelected");if(f!=null){g=system.control.torrentlist.datagrid("options").pageNumber;system.loadTorrentToList({node:f,page:g})}b!=0&&system.control.torrentlist.datagrid("selectRecord",b);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));b="uploadedBytes,downloadedBytes,filesAdded,sessionCount,secondsActive".split(",");$.each(b,function(h,i){switch(i){case "uploadedBytes":case "downloadedBytes":system.updateTreeNodeText(i,system.lang.tree.statistics[i]+formatSize(system.serverSessionStats["cumulative-stats"][i]));system.updateTreeNodeText("current-"+i,system.lang.tree.statistics[i]+
formatSize(system.serverSessionStats["current-stats"][i]));break;case "secondsActive":system.updateTreeNodeText(i,system.lang.tree.statistics[i]+getTotalTime(system.serverSessionStats["cumulative-stats"][i]*1E3));system.updateTreeNodeText("current-"+i,system.lang.tree.statistics[i]+getTotalTime(system.serverSessionStats["current-stats"][i]*1E3));break;default:system.updateTreeNodeText(i,system.lang.tree.statistics[i]+system.serverSessionStats["cumulative-stats"][i]);system.updateTreeNodeText("current-"+
i,system.lang.tree.statistics[i]+system.serverSessionStats["current-stats"][i])}});for(e in transmission.torrents.folders)a.folders[transmission.torrents.folders[e].nodeid]=null;this.loadFolderList(a.folders);navigator.userAgent.indexOf("Firefox")>0&&system.panel.left.find("span.nav-total-size").css({"margin-top":"-19px"})},showNodeMoreInfos:function(a,b){var c="";if(a>0)c=" <span class='nav-torrents-number'>("+a+")</span>";if(b>0)c+="<span class='nav-total-size'>["+formatSize(b)+"]</span>";return c},
getServerStatus:function(){if(!this.reloading){clearTimeout(this.autoReloadTimer);this.reloading=true;transmission.getStatus(function(a){system.reloading=false;$("#status_downloadspeed").html(formatSize(a.downloadSpeed,false,"speed"));$("#status_uploadspeed").html(formatSize(a.uploadSpeed,false,"speed"));system.serverSessionStats=a;if(a.torrentCount==0){(a=system.panel.left.tree("find","servers"))&&system.panel.left.tree("remove",a.target);system.updateTreeNodeText("torrent-all",system.lang.tree.all)}})}},
showStatus:function(a,b){$("#m_status").panel("options").collapsed&&$("#layout_left").layout("expand","south");this.panel.status_text.show();this.panel.status_text.html(a);if(b!=0){if(b==undefined)b=3E3;this.panel.status_text.fadeOut(b,function(){$("#layout_left").layout("collapse","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:""},e=this.panel.left.data("currentNodeId");if(e!=a.node.id){this.control.torrentlist.datagrid({pageNumber:1});
e=a.node.id}this.panel.left.data("currentNodeId",e);switch(c.id){case "servers":b=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;default:if(a.node.id.indexOf("folders-")!=
-1)if(c=transmission.torrents.folders[a.node.id])b=c.torrents}}if(this.config.defaultSelectNode!=a.node.id){this.control.torrentlist.datagrid("loadData",[]);this.config.defaultSelectNode=a.node.id;this.saveConfig()}a=[];for(var d in b){if(!b[d])return;c=this.lang.torrent["status-text"][b[d].status];parseFloat(b[d].percentDone*100).toFixed(2);c==transmission._status.check&&parseFloat(b[d].recheckProgress*100).toFixed(2);if(b[d].error!=0)c="<span class='text-status-error'>"+c+"</span>";else if(b[d].warning)c=
"<span class='text-status-warning' title='"+b[d].warning+"'>"+c+"</span>";a.push({id:b[d].id,name:b[d].name,totalSize:b[d].totalSize,percentDone:b[d].percentDone,remainingTime:b[d].remainingTime,status:c,statusCode:b[d].status,addedDate:b[d].addedDate,completeSize:b[d].totalSize-b[d].leftUntilDone,rateDownload:b[d].rateDownload,rateUpload:b[d].rateUpload,leecherCount:b[d].leecher,seederCount:b[d].seeder,uploadRatio:b[d].uploadRatio,uploadedEver:b[d].uploadedEver})}this.panel.toolbar.find("#toolbar_start").linkbutton({disabled:true});
this.panel.toolbar.find("#toolbar_pause").linkbutton({disabled:true});this.panel.toolbar.find("#toolbar_remove").linkbutton({disabled:true});this.panel.toolbar.find("#toolbar_recheck").linkbutton({disabled:true});this.panel.toolbar.find("#toolbar_changeDownloadDir").linkbutton({disabled:true});this.panel.toolbar.find("#toolbar_morepeers").linkbutton({disabled:true});this.panel.toolbar.find("#toolbar_queue").menubutton("disable");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"),e=null;if(c.sortName){e=c.sortName;a=a.sort(arrayObjectSort(e,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:e,sortOrder:c.sortOrder}).datagrid("loadData",a);else{this.control.torrentlist.datagrid("getData").originalRows=
a;e=(c.pageNumber-1)*parseInt(c.pageSize);c=e+parseInt(c.pageSize);a=a.slice(e,c);c={};e={};for(var d in transmission.torrents.recently){var f=transmission.torrents.recently[d];c[f.id]=true}for(d in a){f=a[d];e[f.id]=f}var g={};for(d=b.length-1;d>=0;d--){f=b[d];if(c[f.id]){var h=e[f.id];if(h){this.control.torrentlist.datagrid("updateRow",{index:d,row:h});g[f.id]=f}else this.control.torrentlist.datagrid("deleteRow",d)}else if(transmission.torrents.removed.length>0&&$.inArray(f.id,transmission.torrents.removed)!=
-1)this.control.torrentlist.datagrid("deleteRow",d);else g[f.id]=f}for(d in a){f=a[d];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 transmission._status.check:b="iconlabel icon-checking";break;case transmission._status.download:b="iconlabel icon-down";break;case transmission._status.seed:b="iconlabel icon-up";break;case transmission._status.seedwait:case transmission._status.downloadwait:case transmission._status.checkwait:b=
"iconlabel icon-wait"}if(a.warning){b="iconlabel icon-warning-type1";c+="\n\n"+this.lang["public"]["text-info"]+": "+a.warning}if(a.error!=0){b="iconlabel icon-exclamation";c+="\n\n"+this.lang["public"]["text-info"]+": "+a.errorString}return'<span class="'+b+'" title="'+c+'">'+a.name+"</span>"},getTorrentProgressBar:function(a,b){a+="%";var c="",e=0;e=typeof b=="object"?b.status:b;switch(e){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){var c=this.control.torrentlist.datagrid("getChecked"),d=[];a||(a="start");for(var e in c)d.push(c[e].id);if(d.length>0){var f=b.linkbutton("options").iconCls;
b.linkbutton({disabled:true,iconCls:"icon-loading"});transmission.exec({method:"torrent-"+a,arguments:{ids:d}},function(g){g.result=="success"&&system.panel.toolbar.find("#toolbar_start").linkbutton({disabled:true});b.linkbutton({iconCls:f});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:"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].infoIsLoading){if(this.currentTorrentId>0)if(transmission.torrents.all[this.currentTorrentId].infoIsLoading)return;
this.currentTorrentId=a;if(!this.panel.attribute.panel("options").collapsed){this.panel.attribute.panel({iconCls:"icon-loading"});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;system.panel.attribute.panel({iconCls:""});
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,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":c=formatLongTime(c);break;case "status":c=system.lang.torrent["status-text"][c];break;case "error":c==0?system.panel.attribute.find("#torrent-attribute-tr-error").hide():system.panel.attribute.find("#torrent-attribute-tr-error").show();break;case "comment":c=system.replaceURI(c)}system.panel.attribute.find("#torrent-attribute-value-"+b).html(c)})},fillTorrentFileList:function(a){var b=a.files,c=a.fileStats,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.trackers,c=a.trackerStats,d=[],e;for(e in b){var f=c[e],g={},h;for(h in f)switch(h){case "lastAnnounceTime":case "nextAnnounceTime":g[h]=formatLongTime(f[h]);break;case "lastAnnounceSucceeded":case "lastAnnounceTimedOut":g[h]=system.lang.torrent.attribute.status[f[h]];break;default:g[h]=f[h]}d.push(g)}transmission.torrents.addTracker(a);this.updateCurrentPageDatas("id",d,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=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=
addTorrentsToServer:function(a,b,c,e){var d=b-a.length,f=a.shift();if(f){this.showStatus(this.lang.system.status.queue+(d+1)+"/"+b+"<br/>"+f,0);transmission.addTorrentFromUrl(f,e,c,function(){system.addTorrentsToServer(a,b,c,e)})}else{this.showStatus(this.lang.system.status.queuefinish);this.getServerStatus()}},changeSelectedTorrentStatus:function(a,b,c){var e=this.control.torrentlist.datagrid("getChecked"),d=[];a||(a="start");for(var f in e)d.push(e[f].id);c||(c="torrent-"+a);if(d.length>0){if(b){var g=
b.linkbutton("options").iconCls;b.linkbutton({disabled:true,iconCls:"icon-loading"})}transmission.exec({method:c,arguments:{ids:d}},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:"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){this.panel.attribute.panel({iconCls:"icon-loading"});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(e){b.infoIsLoading=false;system.panel.attribute.panel({iconCls:""});
if(e!=null){jQuery.extend(b,e[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 e=c.datagrid("getRows"),d=c.datagrid("options"),f=null;if(d.sortName){f=d.sortName;b=b.sort(arrayObjectSort(f,d.sortOrder))}if(e.length==0||b.length!=c.datagrid("getData").total&&b.length>d.pageSize)c.datagrid({loadFilter:pagerFilter,
pageNumber:1,sortName:f,sortOrder:d.sortOrder}).datagrid("loadData",b);else{c.datagrid("getData").originalRows=b;f=(d.pageNumber-1)*parseInt(d.pageSize);d=f+parseInt(d.pageSize);b=b.slice(f,d);d={};for(var g in b){f=b[g];d[f[a]]=f}for(g=e.length-1;g>=0;g--){f=e[g];(b=d[f[a]])?c.datagrid("updateRow",{index:g,row:b}):c.datagrid("deleteRow",g)}}},fillTorrentBaseInfos:function(a){$.each(a,function(b,c){switch(b){case "rateDownload":case "rateUpload":c=formatSize(c,true,"speed");break;case "totalSize":case "uploadedEver":case "leftUntilDone":case "completeSize":c=
formatSize(c);break;case "addedDate":case "dateCreated":c=formatLongTime(c);break;case "status":c=system.lang.torrent["status-text"][c];break;case "error":c==0?system.panel.attribute.find("#torrent-attribute-tr-error").hide():system.panel.attribute.find("#torrent-attribute-tr-error").show();break;case "comment":c=system.replaceURI(c)}system.panel.attribute.find("#torrent-attribute-value-"+b).html(c)})},fillTorrentFileList:function(a){var b=a.files,c=a.fileStats,e=[],d=a.name.length+1,f;for(f in b){var g=
b[f],h=c[f],i=parseFloat(h.bytesCompleted/g.length*100).toFixed(2);e.push({name:g.name==a.name?g.name:g.name.substr(d),index:f,bytesCompleted:h.bytesCompleted,percentDone:system.getTorrentProgressBar(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",e,system.panel.attribute.find("#torrent-files-table"))},
fillTorrentServerList:function(a){var b=a.trackers,c=a.trackerStats,e=[],d;for(d in b){var f=c[d],g={},h;for(h in f)switch(h){case "lastAnnounceTime":case "nextAnnounceTime":g[h]=formatLongTime(f[h]);break;case "lastAnnounceSucceeded":case "lastAnnounceTimedOut":g[h]=system.lang.torrent.attribute.status[f[h]];break;default:g[h]=f[h]}e.push(g)}transmission.torrents.addTracker(a);this.updateCurrentPageDatas("id",e,system.panel.attribute.find("#torrent-servers-table"))},fillTorrentPeersList:function(a){a=
a.peers;var b=[],c;for(c in a){var e=a[c],d={},f;for(f in e)d[f]=e[f];e=parseFloat(e.progress*100).toFixed(2);d.progress=system.getTorrentProgressBar(e,transmission._status.download);b.push(d)}this.updateCurrentPageDatas("address",b,system.panel.attribute.find("#torrent-peers-table"))},fillTorrentConfig:function(a){system.panel.attribute.find("#torrent-attribute-tabs").data("selectedIndex")==4&&transmission.torrents.getConfig(a.id,function(b){if(b!=null){jQuery.extend(transmission.torrents.all[system.currentTorrentId],
b[0]);system.currentTorrentId!=0&&$.each(b[0],function(c,e){var d=false,f=false,g=false;switch(c){case "seedIdleMode":case "seedRatioMode":if(e==0){f=false;d=true}g=true;case "downloadLimited":case "uploadLimited":if(e==true||e==1)f=true;system.panel.attribute.find("input[enabledof='"+c+"']").prop("disabled",!f);g&&system.panel.attribute.find("#"+c).prop("indeterminate",d).data("_tag",e);system.panel.attribute.find("#"+c).prop("checked",f);break;default:system.panel.attribute.find("#"+c).val(e);system.panel.attribute.find("#"+
c).numberspinner("setValue",e)}})}})},setFieldFormat:function(a){if(a.formatter)switch(a.formatter){case "size":a.formatter=function(b){return formatSize(b)};break;case "speed":a.formatter=function(b){return formatSize(b,true,"speed")};break;case "longtime":a.formatter=function(b){return formatLongTime(b)};break;case "progress":a.formatter=function(b,c){var e=parseFloat(b*100).toFixed(2);return system.getTorrentProgressBar(e,transmission.torrents.all[c.id])};break;case "_usename_":switch(a.field){case "name":a.formatter=
function(b,c){return system.getTorrentNameBar(transmission.torrents.all[c.id])}}}},reloadData:function(){this.reloadSession();this.reloading=false;this.getServerStatus();this.reloading=false;this.reloadTorrentBaseInfos()},loadFolderList:function(a){this.removeTreeNode("folders-loading");for(var b in a){var c=a[b];c&&system.removeTreeNode(c.nodeid)}transmission.downloadDirs.length!=0&&timedChunk(transmission.downloadDirs,this.appendFolder,this,10,function(){navigator.userAgent.indexOf("Firefox")>0&&
system.panel.left.find("span.nav-total-size").css({"margin-top":"-19px"})})},appendFolder:function(a){var b="folders";a=a.split("/");var c="folders-",d;for(d in a){var e=a[d];if(e!=""){c+=this.B64.encode(e);var f=this.panel.left.tree("find",c),g=transmission.torrents.folders[c];e=e+this.showNodeMoreInfos(g.count,g.size);if(f)this.updateTreeNodeText(c,e);else{this.appendTreeNode(b,[{id:c,text:e}]);if(b!="folders"){f=this.panel.left.tree("find",b);this.panel.left.tree("collapse",f.target)}}b=c}}},replaceURI:function(a){return a.replace(/(http|https|ftp):\/\/([^/:]+)(:\d*)?([^# ]*)/ig,
function(b){return'<a href="'+b+'" target="_blank">'+b+"</a>"})},readConfig:function(){var a=cookies.get("transmission-web-control");if($.isPlainObject(a))this.config=$.extend(this.config,a)},saveConfig:function(){cookies.set("transmission-web-control",this.config,100)},uploadTorrentFile:function(a,b,c,d){if(window.FileReader){a=$("input[id='"+a+"']")[0].files;$.each(a,function(e,f){transmission.addTorrentFromFile(f,b,c,d)})}else alert(system.lang.publit["text-browsers-not-support-features"])},checkUpdate:function(){$.getScript(this.checkUpdateScript,
function(){if(system.codeupdate<system.lastUpdateInfos.update){$("#area-update-infos").show();$("#msg-updateInfos").html(system.lastUpdateInfos.update+" -> "+system.lastUpdateInfos.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}},debug:function(a,b){window.console&&window.console.log&&window.console.log(a,b)}};
$(document).ready(function(){$.getScript("lang/default.js");$.getScript("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(g,h){c.pageNumber=g;c.pageSize=h;d.pagination("refresh",{pageNumber:g,pageSize:h});b.datagrid("loadData",a)},buttons:e});if(!a.originalRows)a.originalRows=a.rows;e=(c.pageNumber-1)*parseInt(c.pageSize);var f=e+parseInt(c.pageSize);a.rows=a.originalRows.slice(e,f);return a};
system.panel.left.find("span.nav-total-size").css({"margin-top":"-19px"})})},appendFolder:function(a){if(a){var b="folders";a=a.split("/");var c="folders-",e;for(e in a){var d=a[e];if(d!=""){c+=this.B64.encode(d);var f=this.panel.left.tree("find",c),g=transmission.torrents.folders[c];d=d+this.showNodeMoreInfos(g.count,g.size);if(f)this.updateTreeNodeText(c,d);else{this.appendTreeNode(b,[{id:c,text:d}]);if(b!="folders"){f=this.panel.left.tree("find",b);this.panel.left.tree("collapse",f.target)}}b=
c}}}},replaceURI:function(a){return a.replace(/(http|https|ftp):\/\/([^/:]+)(:\d*)?([^# ]*)/ig,function(b){return'<a href="'+b+'" target="_blank">'+b+"</a>"})},readConfig:function(){var a=cookies.get("transmission-web-control");if($.isPlainObject(a))this.config=$.extend(this.config,a)},saveConfig:function(){cookies.set("transmission-web-control",this.config,100)},uploadTorrentFile:function(a,b,c,e){if(window.FileReader){a=$("input[id='"+a+"']")[0].files;$.each(a,function(d,f){transmission.addTorrentFromFile(f,
b,c,e)})}else alert(system.lang.publit["text-browsers-not-support-features"])},checkUpdate:function(){$.getScript(this.checkUpdateScript,function(){if(system.codeupdate<system.lastUpdateInfos.update){$("#area-update-infos").show();$("#msg-updateInfos").html(system.lastUpdateInfos.update+" -> "+system.lastUpdateInfos.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}},debug:function(a,
b){window.console&&window.console.log&&window.console.log(a,b)}};$(document).ready(function(){$.getScript("lang/default.js");$.getScript("lang/_languages.js",function(){system.init(location.search.getQueryString("lang"),location.search.getQueryString("local"))})});
function pagerFilter(a){if(typeof a.length=="number"&&typeof a.splice=="function")a={total:a.length,rows:a};var b=$(this),c=b.datagrid("options"),e=b.datagrid("getPager"),d=b.data("buttons");e.pagination({onSelectPage:function(g,h){c.pageNumber=g;c.pageSize=h;e.pagination("refresh",{pageNumber:g,pageSize:h});b.datagrid("loadData",a)},buttons:d});if(!a.originalRows)a.originalRows=a.rows;d=(c.pageNumber-1)*parseInt(c.pageSize);var f=d+parseInt(c.pageSize);a.rows=a.originalRows.slice(d,f);return a};

View File

@ -1,23 +1,23 @@
var system={version:"0.3 Beta",codeupdate:"20130311",config:{autoReload:true,reloadStep:5E3,pageSize:30,defaultSelectNode:null},lang:null,reloading:false,autoReloadTimer:null,downloadDir:"",islocal:false,B64:new Base64,currentTorrentId:0,currentContentPage:"home",currentContentConfig:null,control:{tree:null,torrentlist:null},serverConfig:null,serverSessionStats:null,debug:function(a,b){window.console&&window.console.log&&window.console.log(a,b)},setlang:function(a,b){a||(a=navigator.language||navigator.browserLanguage);
var system={version:"0.5 Beta",codeupdate:"20130731",config:{autoReload:true,reloadStep:5E3,pageSize:30,defaultSelectNode:null},lang:null,reloading:false,autoReloadTimer:null,downloadDir:"",islocal:false,B64:new Base64,currentTorrentId:0,currentContentPage:"home",currentContentConfig:null,control:{tree:null,torrentlist:null},serverConfig:null,serverSessionStats:null,debug:function(a,b){window.console&&window.console.log&&window.console.log(a,b)},setlang:function(a,b){a||(a=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("lang/"+a+".js",function(){system.resetLangText();b&&b()})},resetLangText:function(){var a=$("*[system-lang]");$.each(a,function(b,c){var d=$(c).attr("system-lang");$(c).html(eval("system.lang."+d))})},init:function(a){this.readConfig();transmission.options.getFolders=false;this.lang==null?this.setlang(a,function(){system.initdata()}):this.initdata()},
initdata:function(){$(document).attr("title",this.lang.system.title+" "+this.version);this.control.torrentlist=$("#torrent-list");this.connect()},readConfig:function(){var a=cookies.get("transmission-web-control");if($.isPlainObject(a))this.config=$.extend(this.config,a)},saveConfig:function(){cookies.set("transmission-web-control",this.config,100)},connect:function(){transmission.on.torrentCountChange=function(){system.reloadTorrentBaseInfos()};transmission.on.postError=function(){};transmission.init({islocal:true},
function(){system.reloadSession(true);system.getServerStatus()})},reloadSession:function(){transmission.getSession(function(a){system.serverConfig=a;a["alt-speed-enabled"]==true?$("#status_alt_speed").show():$("#status_alt_speed").hide();system.downloadDir=a["download-dir"];system.serverConfig["rpc-version"]>=15?transmission.getFreeSpace(system.downloadDir,function(b){system.serverConfig["download-dir-free-space"]=b["size-bytes"];system.showFreeSpace(b["size-bytes"])}):system.showFreeSpace(system.serverConfig["download-dir-free-space"])})},
showFreeSpace:function(a){a=a;a=a==-1?system.lang["public"]["text-unknown"]:formatSize(a);$("#status_freespace").text(a)},getServerStatus:function(){if(!this.reloading){clearTimeout(this.autoReloadTimer);this.reloading=true;transmission.getStatus(function(a){system.reloading=false;$("#status_downloadspeed").html(formatSize(a.downloadSpeed,false,"speed"));$("#status_uploadspeed").html(formatSize(a.uploadSpeed,false,"speed"));system.serverSessionStats=a})}},reloadTorrentBaseInfos:function(a){if(!this.reloading){clearTimeout(this.autoReloadTimer);
this.reloading=true;var b={trackers:transmission.trackers,folders:transmission.torrents.folders};transmission.torrents.getallids(function(c){var d=[],e;for(e in c)d.push(c[e].id);c=transmission.torrents.getErrorIds(d,true);c.length>0?transmission.torrents.getallids(function(){system.resetTorrentInfos(b)},c):system.resetTorrentInfos(b)},a)}},resetTorrentInfos:function(){transmission.torrents.status[transmission._status.stopped]?this.updateCount("paused",transmission.torrents.status[transmission._status.stopped].length):
this.updateCount("paused",0);transmission.torrents.status[transmission._status.seed]?this.updateCount("sending",transmission.torrents.status[transmission._status.seed].length):this.updateCount("sending",0);transmission.torrents.status[transmission._status.check]?this.updateCount("check",transmission.torrents.status[transmission._status.check].length):this.updateCount("check",0);transmission.torrents.status[transmission._status.download]?this.updateCount("downloading",transmission.torrents.status[transmission._status.download].length):
this.updateCount("downloading",0);this.updateCount("actively",transmission.torrents.actively.length);this.updateCount("error",transmission.torrents.error.length);this.updateCount("warning",transmission.torrents.warning.length);system.reloading=false;if(system.config.autoReload)system.autoReloadTimer=setTimeout(function(){system.reloadData()},system.config.reloadStep);this.updateCount("all",transmission.torrents.count);if(this.currentContentPage=="torrent-list"){var a=this.currentContentConfig;a.reload=
true;this.showContent(a)}},updateCount:function(a,b){var c=$("#count-"+a);c.text(b);b==0?c.hide():c.show()},reloadData:function(){this.reloadSession();this.reloading=false;this.getServerStatus();this.reloading=false;this.reloadTorrentBaseInfos()},showContent:function(a){var b={page:"",type:"",data:"",title:this.lang.system.title,reload:false},c=null;if(typeof a=="string"){b.page=a;c=b}else c=jQuery.extend(b,a);if(!(c.page==this.currentContentPage&&!c.reload)){$("#content-"+c.page).show();c.page!=
this.currentContentPage&&$("#content-"+this.currentContentPage).hide();$("#torrent-page-bar").hide();$("#torrent-toolbar").hide();this.currentContentPage=c.page;switch(c.type){case "torrent-list":c.title=this.lang.tree[c.data];this.loadTorrentToList({target:c.data})}$("#page-title").text(c.title);c.reload=false;this.currentContentConfig=c}},getTorrentFromType:function(a){var b=null;switch(a){case "torrent-all":case "all":case "servers":b=transmission.torrents.all;break;case "paused":b=transmission.torrents.status[transmission._status.stopped];
break;case "sending":b=transmission.torrents.status[transmission._status.seed];break;case "seedwait":b=transmission.torrents.status[transmission._status.seedwait];break;case "check":b=transmission.torrents.status[transmission._status.check];break;case "checkwait":b=transmission.torrents.status[transmission._status.checkwait];break;case "downloading":b=transmission.torrents.status[transmission._status.download];break;case "downloadwait":b=transmission.torrents.status[transmission._status.downloadwait];
break;case "actively":b=transmission.torrents.actively;break;case "error":b=transmission.torrents.error;break;case "warning":b=transmission.torrents.warning;break;case "search-result":b=transmission.torrents.searchResult}return b},loadTorrentToList:function(a){if(transmission.torrents.all){jQuery.extend({node:null,page:1,target:"all"},a);if(a.target){var b=this.getTorrentFromType(a.target);this.config.defaultSelectNode=a.target;this.saveConfig();var c=[];this.control.torrentlist.empty();for(var d in b)if(b[d]){var e=
parseFloat(b[d].percentDone*100).toFixed(2),f=this.lang.torrent["status-text"][b[d].status];if(b[d].error!=0)f="<span class='text-status-error'>"+f+"</span>";else if(b[d].warning)f="<span class='text-status-warning' title='"+b[d].warning+"'>"+f+"</span>";e={id:b[d].id,name:this.getTorrentNameBar(b[d]),totalSize:b[d].totalSize,percentDone:this.getTorrentProgressBar(e,b[d]),percentDoneNumber:e,status:f,addedDate:formatLongTime(b[d].addedDate),completeSize:b[d].totalSize-b[d].leftUntilDone,rateDownload:b[d].rateDownload,
rateUpload:b[d].rateUpload,leecherCount:b[d].leecher,seederCount:b[d].seeder,uploadRatio:b[d].uploadRatio,uploadedEver:b[d].uploadedEver};c.push(e)}if(c.length==0)setTimeout(function(){system.showContent("home")},100);else{if(this.torrentPager.onGotoPage==null)this.torrentPager.onGotoPage=function(g){system.control.torrentlist.empty();$("#torrent-toolbar").hide();for(var h in g)system.appendTorrentToList(g[h])};this.torrentPager.setDatas(c,a.target)}}}},appendTorrentToList:function(a){var b=$("<input id='torrent-"+
a.id+"' type='checkbox'/>").attr("inited",0),c=$("<label for='torrent-"+a.id+"'>"+a.name+a.percentDone+"<span class='torrent-list-infos'>↓"+formatSize(a.rateDownload,false,"speed")+" ↑"+formatSize(a.rateUpload,false,"speed")+"|"+formatSize(a.completeSize)+"/"+formatSize(a.totalSize)+"</span></label>");b.click(function(){system.changeTorrentToolbar(this,a)});c.appendTo(b);b.appendTo(this.control.torrentlist);b.checkboxradio({theme:"c"})},getTorrentNameBar:function(a){var b="",c=a.name;switch(a.status){case transmission._status.stopped:b=
"iconlabel icon-pause-small";break;case transmission._status.check:b="iconlabel icon-checking";break;case transmission._status.download:b="iconlabel icon-down";break;case transmission._status.seed:b="iconlabel icon-up";break;case transmission._status.seedwait:case transmission._status.downloadwait:case transmission._status.checkwait:b="iconlabel icon-wait"}if(a.warning){b="iconlabel icon-warning-type1";c+="\n\n"+this.lang["public"]["text-info"]+": "+a.warning}if(a.error!=0){b="iconlabel icon-exclamation";
c+="\n\n"+this.lang["public"]["text-info"]+": "+a.errorString}return'<span class="'+b+'" title="'+c+'">'+a.name+"</span>"},getTorrentProgressBar:function(a,b){a+="%";var c="";switch(b.status){case transmission._status.stopped:c="torrent-progress-stop";break;case transmission._status.checkwait:case transmission._status.check:c="torrent-progress-check";break;case transmission._status.downloadwait:case transmission._status.download:c="torrent-progress-download";break;case transmission._status.seedwait:case transmission._status.seed:c=
"torrent-progress-seed"}if(b.warning)c="torrent-progress-warning";if(b.error!=0)c="torrent-progress-error";return'<div class="torrent-progress" title="'+a+'"><div class="torrent-progress-text">'+a+'</div><div class="torrent-progress-bar '+c+'" style="width:'+a+';"></div></div>'},changeTorrentToolbar:function(a,b){this.control.torrentlist.find("input:checked").length>0?$("#torrent-toolbar").show():$("#torrent-toolbar").hide();this.currentTorrentId=b.id},torrentPager:{datas:null,pageSize:30,pageNumber:0,
pageCount:0,count:0,onGotoPage:null,currentDatas:null,pageBar:null,controls:{prev:null,next:null,number:null},head:"",init:function(a){this.pageBar=$("#torrent-page-bar");this.controls.next=this.pageBar.find("#page-next");this.controls.next.click(function(){system.torrentPager.gotoPage("next")});this.controls.prev=this.pageBar.find("#page-prev");this.controls.prev.click(function(){system.torrentPager.gotoPage("prev")});this.controls.number=this.pageBar.find("#page-number");a&&this.setDatas(a)},setDatas:function(a,
b){this.datas||this.init();this.datas=a;this.pageBar.show();this.count=this.datas.length;this.pageCount=parseInt(this.count/this.pageSize);this.count%this.pageSize>0&&this.pageCount++;this.pageCount==1&&this.pageBar.hide();this.head==b?this.gotoPage():this.gotoPage(1);this.head=b},gotoPage:function(a){if(typeof a=="number")this.pageNumber=a;else switch(a){case "next":this.pageNumber++;break;case "prev":this.pageNumber--}if(this.pageNumber>this.pageCount)this.pageNumber=this.pageCount;if(this.pageNumber<
1)this.pageNumber=1;a=(this.pageNumber-1)*parseInt(this.pageSize);var b=a+parseInt(this.pageSize);this.currentDatas=this.datas.slice(a,b);this.controls.number.text(this.pageNumber+"/"+this.pageCount);this.pageNumber>1?this.controls.prev.show():this.controls.prev.hide();this.pageNumber<this.pageCount?this.controls.next.show():this.controls.next.hide();this.onGotoPage&&this.onGotoPage(this.currentDatas)}},changeSelectedTorrentStatus:function(a,b){var c=this.control.torrentlist.find("input:checked"),
d=[];a||(a="start");for(var e=0;e<c.length;e++)d.push(parseInt(c[e].id.replace("torrent-","")));if(d.length>0){switch(a){case "remove":return;case "verify":if(rows.length==1){if(transmission.torrents.all[d[0].id].percentDone>0)if(confirm(system.lang.toolbar.tip["recheck-confirm"])==false)return}else if(confirm(system.lang.toolbar.tip["recheck-confirm"])==false)return}b=$(b);b.attr("disabled",true);transmission.exec({method:"torrent-"+a,arguments:{ids:d}},function(){b.attr("disabled",false);system.reloadTorrentBaseInfos()})}}};
$(document).ready(function(){$.getScript("lang/_languages.js",function(){system.init(location.search.getQueryString("lang"))})});
function(){system.reloadSession(true);system.getServerStatus()})},reloadSession:function(){transmission.getSession(function(a){system.serverConfig=a;a["alt-speed-enabled"]==true?$("#status_alt_speed").show():$("#status_alt_speed").hide();system.downloadDir=a["download-dir"];parseInt(system.serverConfig["rpc-version"])>=15?transmission.getFreeSpace(system.downloadDir,function(b){system.serverConfig["download-dir-free-space"]=b.arguments["size-bytes"];system.showFreeSpace(b.arguments["size-bytes"])}):
system.showFreeSpace(system.serverConfig["download-dir-free-space"])})},showFreeSpace:function(a){a=a;a=a==-1?system.lang["public"]["text-unknown"]:formatSize(a);$("#status_freespace").text(a)},getServerStatus:function(){if(!this.reloading){clearTimeout(this.autoReloadTimer);this.reloading=true;transmission.getStatus(function(a){system.reloading=false;$("#status_downloadspeed").html(formatSize(a.downloadSpeed,false,"speed"));$("#status_uploadspeed").html(formatSize(a.uploadSpeed,false,"speed"));system.serverSessionStats=
a})}},reloadTorrentBaseInfos:function(a){if(!this.reloading){clearTimeout(this.autoReloadTimer);this.reloading=true;var b={trackers:transmission.trackers,folders:transmission.torrents.folders};transmission.torrents.getallids(function(c){var d=[],e;for(e in c)d.push(c[e].id);c=transmission.torrents.getErrorIds(d,true);c.length>0?transmission.torrents.getallids(function(){system.resetTorrentInfos(b)},c):system.resetTorrentInfos(b)},a)}},resetTorrentInfos:function(){transmission.torrents.status[transmission._status.stopped]?
this.updateCount("paused",transmission.torrents.status[transmission._status.stopped].length):this.updateCount("paused",0);transmission.torrents.status[transmission._status.seed]?this.updateCount("sending",transmission.torrents.status[transmission._status.seed].length):this.updateCount("sending",0);transmission.torrents.status[transmission._status.check]?this.updateCount("check",transmission.torrents.status[transmission._status.check].length):this.updateCount("check",0);transmission.torrents.status[transmission._status.download]?
this.updateCount("downloading",transmission.torrents.status[transmission._status.download].length):this.updateCount("downloading",0);this.updateCount("actively",transmission.torrents.actively.length);this.updateCount("error",transmission.torrents.error.length);this.updateCount("warning",transmission.torrents.warning.length);system.reloading=false;if(system.config.autoReload)system.autoReloadTimer=setTimeout(function(){system.reloadData()},system.config.reloadStep);this.updateCount("all",transmission.torrents.count);
if(this.currentContentPage=="torrent-list"){var a=this.currentContentConfig;a.reload=true;this.showContent(a)}},updateCount:function(a,b){var c=$("#count-"+a);c.text(b);b==0?c.hide():c.show()},reloadData:function(){this.reloadSession();this.reloading=false;this.getServerStatus();this.reloading=false;this.reloadTorrentBaseInfos()},showContent:function(a){var b={page:"",type:"",data:"",title:this.lang.system.title,reload:false},c=null;if(typeof a=="string"){b.page=a;c=b}else c=jQuery.extend(b,a);if(!(c.page==
this.currentContentPage&&!c.reload)){$("#content-"+c.page).show();c.page!=this.currentContentPage&&$("#content-"+this.currentContentPage).hide();$("#torrent-page-bar").hide();$("#torrent-toolbar").hide();this.currentContentPage=c.page;switch(c.type){case "torrent-list":c.title=this.lang.tree[c.data];this.loadTorrentToList({target:c.data})}$("#page-title").text(c.title);c.reload=false;this.currentContentConfig=c}},getTorrentFromType:function(a){var b=null;switch(a){case "torrent-all":case "all":case "servers":b=
transmission.torrents.all;break;case "paused":b=transmission.torrents.status[transmission._status.stopped];break;case "sending":b=transmission.torrents.status[transmission._status.seed];break;case "seedwait":b=transmission.torrents.status[transmission._status.seedwait];break;case "check":b=transmission.torrents.status[transmission._status.check];break;case "checkwait":b=transmission.torrents.status[transmission._status.checkwait];break;case "downloading":b=transmission.torrents.status[transmission._status.download];
break;case "downloadwait":b=transmission.torrents.status[transmission._status.downloadwait];break;case "actively":b=transmission.torrents.actively;break;case "error":b=transmission.torrents.error;break;case "warning":b=transmission.torrents.warning;break;case "search-result":b=transmission.torrents.searchResult}return b},loadTorrentToList:function(a){if(transmission.torrents.all){jQuery.extend({node:null,page:1,target:"all"},a);if(a.target){var b=this.getTorrentFromType(a.target);this.config.defaultSelectNode=
a.target;this.saveConfig();var c=[];this.control.torrentlist.empty();for(var d in b)if(b[d]){var e=parseFloat(b[d].percentDone*100).toFixed(2),f=this.lang.torrent["status-text"][b[d].status];if(b[d].error!=0)f="<span class='text-status-error'>"+f+"</span>";else if(b[d].warning)f="<span class='text-status-warning' title='"+b[d].warning+"'>"+f+"</span>";e={id:b[d].id,name:this.getTorrentNameBar(b[d]),totalSize:b[d].totalSize,percentDone:this.getTorrentProgressBar(e,b[d]),percentDoneNumber:e,status:f,
addedDate:formatLongTime(b[d].addedDate),completeSize:b[d].totalSize-b[d].leftUntilDone,rateDownload:b[d].rateDownload,rateUpload:b[d].rateUpload,leecherCount:b[d].leecher,seederCount:b[d].seeder,uploadRatio:b[d].uploadRatio,uploadedEver:b[d].uploadedEver};c.push(e)}if(c.length==0)setTimeout(function(){system.showContent("home")},100);else{if(this.torrentPager.onGotoPage==null)this.torrentPager.onGotoPage=function(g){system.control.torrentlist.empty();$("#torrent-toolbar").hide();for(var h in g)system.appendTorrentToList(g[h])};
this.torrentPager.setDatas(c,a.target)}}}},appendTorrentToList:function(a){var b=$("<input id='torrent-"+a.id+"' type='checkbox'/>").attr("inited",0),c=$("<label for='torrent-"+a.id+"'>"+a.name+a.percentDone+"<span class='torrent-list-infos'>↓"+formatSize(a.rateDownload,false,"speed")+" ↑"+formatSize(a.rateUpload,false,"speed")+"|"+formatSize(a.completeSize)+"/"+formatSize(a.totalSize)+"</span></label>");b.click(function(){system.changeTorrentToolbar(this,a)});c.appendTo(b);b.appendTo(this.control.torrentlist);
b.checkboxradio({theme:"c"})},getTorrentNameBar:function(a){var b="",c=a.name;switch(a.status){case transmission._status.stopped:b="iconlabel icon-pause-small";break;case transmission._status.check:b="iconlabel icon-checking";break;case transmission._status.download:b="iconlabel icon-down";break;case transmission._status.seed:b="iconlabel icon-up";break;case transmission._status.seedwait:case transmission._status.downloadwait:case transmission._status.checkwait:b="iconlabel icon-wait"}if(a.warning){b=
"iconlabel icon-warning-type1";c+="\n\n"+this.lang["public"]["text-info"]+": "+a.warning}if(a.error!=0){b="iconlabel icon-exclamation";c+="\n\n"+this.lang["public"]["text-info"]+": "+a.errorString}return'<span class="'+b+'" title="'+c+'">'+a.name+"</span>"},getTorrentProgressBar:function(a,b){a+="%";var c="";switch(b.status){case transmission._status.stopped:c="torrent-progress-stop";break;case transmission._status.checkwait:case transmission._status.check:c="torrent-progress-check";break;case transmission._status.downloadwait:case transmission._status.download:c=
"torrent-progress-download";break;case transmission._status.seedwait:case transmission._status.seed:c="torrent-progress-seed"}if(b.warning)c="torrent-progress-warning";if(b.error!=0)c="torrent-progress-error";return'<div class="torrent-progress" title="'+a+'"><div class="torrent-progress-text">'+a+'</div><div class="torrent-progress-bar '+c+'" style="width:'+a+';"></div></div>'},changeTorrentToolbar:function(a,b){this.control.torrentlist.find("input:checked").length>0?$("#torrent-toolbar").show():
$("#torrent-toolbar").hide();this.currentTorrentId=b.id},torrentPager:{datas:null,pageSize:30,pageNumber:0,pageCount:0,count:0,onGotoPage:null,currentDatas:null,pageBar:null,controls:{prev:null,next:null,number:null},head:"",init:function(a){this.pageBar=$("#torrent-page-bar");this.controls.next=this.pageBar.find("#page-next");this.controls.next.click(function(){system.torrentPager.gotoPage("next")});this.controls.prev=this.pageBar.find("#page-prev");this.controls.prev.click(function(){system.torrentPager.gotoPage("prev")});
this.controls.number=this.pageBar.find("#page-number");a&&this.setDatas(a)},setDatas:function(a,b){this.datas||this.init();this.datas=a;this.pageBar.show();this.count=this.datas.length;this.pageCount=parseInt(this.count/this.pageSize);this.count%this.pageSize>0&&this.pageCount++;this.pageCount==1&&this.pageBar.hide();this.head==b?this.gotoPage():this.gotoPage(1);this.head=b},gotoPage:function(a){if(typeof a=="number")this.pageNumber=a;else switch(a){case "next":this.pageNumber++;break;case "prev":this.pageNumber--}if(this.pageNumber>
this.pageCount)this.pageNumber=this.pageCount;if(this.pageNumber<1)this.pageNumber=1;a=(this.pageNumber-1)*parseInt(this.pageSize);var b=a+parseInt(this.pageSize);this.currentDatas=this.datas.slice(a,b);this.controls.number.text(this.pageNumber+"/"+this.pageCount);this.pageNumber>1?this.controls.prev.show():this.controls.prev.hide();this.pageNumber<this.pageCount?this.controls.next.show():this.controls.next.hide();this.onGotoPage&&this.onGotoPage(this.currentDatas)}},changeSelectedTorrentStatus:function(a,
b){var c=this.control.torrentlist.find("input:checked"),d=[];a||(a="start");for(var e=0;e<c.length;e++)d.push(parseInt(c[e].id.replace("torrent-","")));if(d.length>0){switch(a){case "remove":return;case "verify":if(rows.length==1){if(transmission.torrents.all[d[0].id].percentDone>0)if(confirm(system.lang.toolbar.tip["recheck-confirm"])==false)return}else if(confirm(system.lang.toolbar.tip["recheck-confirm"])==false)return}b=$(b);b.attr("disabled",true);transmission.exec({method:"torrent-"+a,arguments:{ids:d}},
function(){b.attr("disabled",false);system.reloadTorrentBaseInfos()})}}};$(document).ready(function(){$.getScript("lang/_languages.js",function(){system.init(location.search.getQueryString("lang"))})});

View File

@ -4,4 +4,4 @@ tag:""};jQuery.extend(c,b);var f={type:"POST",url:this.fullpath,dataType:"json",
"success"){b&&b(a.arguments);if(transmission.torrents.count!=a.arguments.torrentCount||transmission.torrents.activeTorrentCount!=a.arguments.activeTorrentCount||transmission.torrents.pausedTorrentCount!=a.arguments.pausedTorrentCount){transmission.torrents.count=a.arguments.torrentCount;transmission.torrents.activeTorrentCount=a.arguments.activeTorrentCount;transmission.torrents.pausedTorrentCount=a.arguments.pausedTorrentCount;transmission._onTorrentCountChange()}}})},getSession:function(b){this.exec({method:"session-get"},
function(a){a.result=="success"&&b&&b(a.arguments)})},addTorrentFromUrl:function(b,a,d,c){if(b.match(/^[0-9a-f]{40}$/i))b="magnet:?xt=urn:btih:"+b;this.exec({method:"torrent-add",arguments:{filename:b,"download-dir":a,paused:!d}},function(f){switch(f.result){case "success":c&&c(f.arguments["torrent-added"]);break;default:c&&c(f.result)}})},addTorrentFromFile:function(b,a,d,c){var f=new FileReader;f.onload=function(e){e=e.target.result;var g=e.indexOf("base64,");if(g!=-1){e=e.substring(g+7);transmission.exec({method:"torrent-add",
arguments:{metainfo:e,"download-dir":a,paused:d}},function(h){switch(h.result){case "success":c&&c(h.arguments["torrent-added"]);break;case "duplicate torrent":c&&c("duplicate")}})}};f.readAsDataURL(b)},_onTorrentCountChange:function(){this.torrents.loadSimpleInfo=false;this.on.torrentCountChange&&this.on.torrentCountChange()},removeTorrent:function(b,a,d){this.exec({method:"torrent-remove",arguments:{ids:b,"delete-local-data":a}},function(c){d&&d(c.result)})},getFreeSpace:function(b,a){this.exec({method:"free-space",
arguments:{path:b}},function(d){a&&a(d.result)})},updateBlocklist:function(b){this.exec({method:"blocklist-update"},function(a){b&&b(a.result)})}};
arguments:{path:b}},function(d){a&&a(d)})},updateBlocklist:function(b){this.exec({method:"blocklist-update"},function(a){b&&b(a.result)})}};

View File

@ -3,8 +3,8 @@ config:"downloadLimit,downloadLimited,peer-limit,seedIdleLimit,seedIdleMode,seed
arguments:arguments},function(a){if(a.result=="success"){transmission.torrents.newIds.length=0;transmission.torrents.loadSimpleInfo=true;transmission.torrents.recently=a.arguments.torrents;transmission.torrents.removed=a.arguments.removed;transmission.torrents.splitid();b&&b(a.arguments.torrents)}else{transmission.torrents.datas=null;b&&b(null)}})},splitid:function(){this.downloading=[];this.puased=[];this.actively=[];this.error=[];this.warning=[];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 g=[];for(c in this.removed){a=this.removed[c];g.push(a)}for(c in this.datas){a=this.datas[c];if(!a)return;if($.inArray(a.id,g)!=-1&&g.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="∞";a.infoIsLoading=false;var e=this.status[a.status];this.addTracker(a);if(!e){this.status[a.status]=[];e=this.status[a.status]}a.remainingTime=a.rateDownload>0&&a.leftUntilDone>0?getTotalTime(a.leftUntilDone/a.rateDownload*1E3):a.rateDownload==0&&a.leftUntilDone==0?0:"∞";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;this.totalSize+=a.totalSize;$.inArray(a.downloadDir,transmission.downloadDirs)==-1&&transmission.downloadDirs.push(a.downloadDir);if(transmission.options.getFolders){e=a.downloadDir.split("/");var h="folders-",i;for(i in e){var f=e[i];if(f!=""){h+=d.encode(f);(f=this.folders[h])||(f={count:0,torrents:[],size:0,nodeid:h});f.torrents.push(a);f.count++;f.size+=a.totalSize;this.folders[h]=f}}}this.count++}}transmission.downloadDirs=transmission.downloadDirs.sort();this.newIds.length>0&&this.getallids(null,
this.newIds)},addTracker:function(b){var d=b.trackerStats,c=false;b.leecherCount=0;b.seederCount=0;if(d.length>0){for(var a in d){var g=d[a],e=g.lastAnnounceResult.toLowerCase(),h=g.host.replace("http://","").replace("https://","").split(":")[0].split(".");$.inArray(h[0],"www,tracker".split(","))!=-1&&h.shift();h=h.join(".");var i="tracker-"+h.replace(/\./g,"-"),f=transmission.trackers[i];if(!f){transmission.trackers[i]={count:0,torrents:[],size:0,connected:true};f=transmission.trackers[i]}f.name=
a;this.totalSize+=a.totalSize;$.inArray(a.downloadDir,transmission.downloadDirs)==-1&&transmission.downloadDirs.push(a.downloadDir);if(transmission.options.getFolders)if(a.downloadDir){e=a.downloadDir.split("/");var h="folders-",i;for(i in e){var f=e[i];if(f!=""){h+=d.encode(f);(f=this.folders[h])||(f={count:0,torrents:[],size:0,nodeid:h});f.torrents.push(a);f.count++;f.size+=a.totalSize;this.folders[h]=f}}}this.count++}}transmission.downloadDirs=transmission.downloadDirs.sort();this.newIds.length>
0&&this.getallids(null,this.newIds)},addTracker:function(b){var d=b.trackerStats,c=false;b.leecherCount=0;b.seederCount=0;if(d.length>0){for(var a in d){var g=d[a],e=g.lastAnnounceResult.toLowerCase(),h=g.host.replace("http://","").replace("https://","").split(":")[0].split(".");$.inArray(h[0],"www,tracker".split(","))!=-1&&h.shift();h=h.join(".");var i="tracker-"+h.replace(/\./g,"-"),f=transmission.trackers[i];if(!f){transmission.trackers[i]={count:0,torrents:[],size:0,connected:true};f=transmission.trackers[i]}f.name=
h;f.nodeid=i;f.host=g.host;if(e!="success"&&g.announceState!=0){c=true;b.warning=g.lastAnnounceResult;if(e=="could not connect to tracker")f.connected=false}f.torrents.push(b);f.count++;f.size+=b.totalSize;b.leecherCount+=g.leecherCount;b.seederCount+=g.seederCount}if(c){if(b.nextAnnounceTime){if(b.nextAnnounceTime>g.nextAnnounceTime)b.nextAnnounceTime=g.nextAnnounceTime}else b.nextAnnounceTime=g.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+")"}},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 g in this.error){var e=this.error[g];

View File

@ -1,7 +1,7 @@
// 当前系统全局对象
var system = {
version:"0.4 Beta"
,codeupdate:"20130627"
version:"0.5 Beta"
,codeupdate:"20130731"
,config:{
autoReload: true
,reloadStep: 5000
@ -640,7 +640,8 @@ var system = {
switch (type)
{
case "torrent-list":
menus = new Array("start","pause","-","remove","recheck","-","morepeers","changeDownloadDir");
menus = new Array("start","pause","-","remove","recheck","-","morepeers","changeDownloadDir"
,"-","menu-queue-move-top","menu-queue-move-up","menu-queue-move-down","menu-queue-move-bottom");
var toolbar = this.panel.toolbar;
for (var item in menus)
{
@ -658,7 +659,7 @@ var system = {
else
{
var menu = toolbar.find("#toolbar_"+key);
if (menu)
if (menu.length>0)
{
parent.menu("appendItem",{
text: menu.attr("title")
@ -670,6 +671,22 @@ var system = {
}
});
}
else
{
menu = $("#"+key);
if (menu.length>0)
{
parent.menu("appendItem",{
text: menu.attr("title")
,id: key
,iconCls: menu.attr("id").replace("menu","icon")
,disabled: toolbar.find("#toolbar_changeDownloadDir").linkbutton("options").disabled
,onclick: function(){
$("#"+$(this).attr("id")).click();
}
});
}
}
menu = null;
}
}
@ -701,11 +718,13 @@ var system = {
this.panel.toolbar.find("#toolbar_recheck").linkbutton({disabled:true});
this.panel.toolbar.find("#toolbar_changeDownloadDir").linkbutton({disabled:true});
this.panel.toolbar.find("#toolbar_morepeers").linkbutton({disabled:true});
this.panel.toolbar.find("#toolbar_queue").menubutton("disable");
return;
}
this.panel.toolbar.find("#toolbar_remove").linkbutton({disabled:false});
this.panel.toolbar.find("#toolbar_changeDownloadDir").linkbutton({disabled:false});
this.panel.toolbar.find("#toolbar_queue").menubutton("enable");
var torrent = transmission.torrents.all[rowData.id];
switch (torrent.status)
@ -1006,7 +1025,7 @@ var system = {
$("<div/>").attr("id","dialog-torrent-changeDownloadDir").appendTo(document.body).dialog({
title: system.lang.dialog["torrent-changeDownloadDir"].title,
width: 520,
height: 180,
height: 200,
resizable: false,
cache: true,
content:"loading...",
@ -1703,23 +1722,30 @@ var system = {
this.panel.toolbar.find("#toolbar_recheck").linkbutton({disabled:true});
this.panel.toolbar.find("#toolbar_changeDownloadDir").linkbutton({disabled:true});
this.panel.toolbar.find("#toolbar_morepeers").linkbutton({disabled:true});
this.panel.toolbar.find("#toolbar_queue").menubutton("disable");
this.updateTorrentCurrentPageDatas(datas);
}
// 更新种子列表当前页数据
,updateTorrentCurrentPageDatas: function(currentTypeDatas)
{
// 获取当前页数据
var rows = this.control.torrentlist.datagrid("getRows");
if (currentTypeDatas.length==0&&rows.length>0)
{
this.control.torrentlist.datagrid("loadData",[]);
return;
}
var _options = this.control.torrentlist.datagrid("options");
var orderField = null;
if (_options.sortName)
{
orderField = _options.sortName;
currentTypeDatas = currentTypeDatas.sort(arrayObjectSort(orderField,_options.sortOrder));
}
}
if (rows.length==0||(currentTypeDatas.length!=this.control.torrentlist.datagrid("getData").total)&&currentTypeDatas.length>_options.pageSize)
{
@ -1788,6 +1814,11 @@ var system = {
}
data = null;
}
// 移除当前删除的种子
else if (transmission.torrents.removed.length>0&&$.inArray(item.id,transmission.torrents.removed)!=-1)
{
this.control.torrentlist.datagrid("deleteRow",index);
}
else
{
addedDatas[item.id] = item;
@ -1922,7 +1953,7 @@ var system = {
});
}
// 开始/暂停已选择的种子
,changeSelectedTorrentStatus:function(status,button)
,changeSelectedTorrentStatus:function(status,button,method)
{
var rows = this.control.torrentlist.datagrid("getChecked");
var ids = new Array();
@ -1934,22 +1965,30 @@ var system = {
{
ids.push(rows[i].id);
}
if (!method)
{
method = "torrent-"+status;
}
if (ids.length>0)
{
var icon = button.linkbutton("options").iconCls;
button.linkbutton({disabled:true,iconCls:"icon-loading"});
if (button)
{
var icon = button.linkbutton("options").iconCls;
button.linkbutton({disabled:true,iconCls:"icon-loading"});
}
transmission.exec({
method:"torrent-"+status
method:method
,arguments:{
ids:ids
}
}
,function(data){
if (data.result=="success")
if (button)
{
system.panel.toolbar.find("#toolbar_start").linkbutton({disabled:true});
}
button.linkbutton({iconCls:icon});
button.linkbutton({iconCls:icon});
}
system.control.torrentlist.datagrid("uncheckAll");
system.reloadTorrentBaseInfos();
}
@ -1986,8 +2025,9 @@ var system = {
// 获取种子详细信息
,getTorrentInfos:function(id)
{
if (!transmission.torrents.all[id]) return;
if (transmission.torrents.all[id].infoIsLoading) return;
if (this.currentTorrentId>0)
if (this.currentTorrentId>0&&transmission.torrents.all[this.currentTorrentId])
{
if (transmission.torrents.all[this.currentTorrentId].infoIsLoading) return;
}
@ -2379,6 +2419,8 @@ var system = {
}
,appendFolder:function(fullkey)
{
if (!fullkey) return;
var rootkey = "folders";
var parentkey = rootkey;
var folder = fullkey.split("/");

View File

@ -2,8 +2,8 @@
移动版
*/
var system = {
version:"0.3 Beta"
,codeupdate:"20130311"
version:"0.5 Beta"
,codeupdate:"20130731"
,config:{
autoReload: true
,reloadStep: 5000
@ -151,11 +151,11 @@ var system = {
system.downloadDir = result["download-dir"];
// rpc-version 版本为 15 起,不再提供 download-dir-free-space 参数,需从新的方法获取
if (system.serverConfig["rpc-version"]>=15)
if (parseInt(system.serverConfig["rpc-version"])>=15)
{
transmission.getFreeSpace(system.downloadDir,function(result){
system.serverConfig["download-dir-free-space"] = result["size-bytes"];
system.showFreeSpace(result["size-bytes"]);
system.serverConfig["download-dir-free-space"] = result.arguments["size-bytes"];
system.showFreeSpace(result.arguments["size-bytes"]);
});
}
else

View File

@ -294,9 +294,9 @@ var transmission = {
"path":path
}
}
,function(data){
,function(result){
if (callback)
callback(data.result);
callback(result);
}
);
}

View File

@ -215,25 +215,28 @@ transmission.torrents = {
if (transmission.options.getFolders)
{
var folder = item.downloadDir.split("/");
var folderkey = "folders-";
for (var i in folder)
if (item.downloadDir)
{
var text = folder[i];
if (text=="")
var folder = item.downloadDir.split("/");
var folderkey = "folders-";
for (var i in folder)
{
continue;
var text = folder[i];
if (text=="")
{
continue;
}
folderkey += B64.encode(text);
var node = this.folders[folderkey];
if (!node)
{
node = {count:0,torrents:new Array(),size:0,nodeid:folderkey};
}
node.torrents.push(item);
node.count++;
node.size+=item.totalSize;
this.folders[folderkey] = node;
}
folderkey += B64.encode(text);
var node = this.folders[folderkey];
if (!node)
{
node = {count:0,torrents:new Array(),size:0,nodeid:folderkey};
}
node.torrents.push(item);
node.count++;
node.size+=item.totalSize;
this.folders[folderkey] = node;
}
}

View File

@ -272,4 +272,24 @@ html, body {
.icon-download-update{
background:url('images/drive-download.png') no-repeat;
}
.icon-queue-move{
background:url('images/queue-move.png') no-repeat;
}
.icon-queue-move-top{
background:url('images/queue-move-top.png') no-repeat;
}
.icon-queue-move-up{
background:url('images/queue-move-up.png') no-repeat;
}
.icon-queue-move-down{
background:url('images/queue-move-down.png') no-repeat;
}
.icon-queue-move-bottom{
background:url('images/queue-move-bottom.png') no-repeat;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 667 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 611 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 628 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 628 B

BIN
style/images/queue-move.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 643 B

View File

@ -20,6 +20,12 @@
<input type="checkbox" id="move-data" style="width:20px;"/><label for="move-data" id="dialog-torrent-changeDownloadDir-move-data"></label>
</td>
</tr>
<tr>
<td class="title"></td>
<td>
<input type="checkbox" id="recheck-data" style="width:20px;"/><label for="recheck-data" id="dialog-torrent-changeDownloadDir-recheck-data"></label>
</td>
</tr>
<tr>
<td colspan="2"><hr/></td>
</tr>
@ -35,10 +41,12 @@
</div>
<script type="text/javascript">
(function(thisDialog){
var title = "old-download-dir,new-download-dir,move-data".split(",");
var title = "old-download-dir,new-download-dir,move-data,recheck-data".split(",");
var ids = thisDialog.data("ids");
var allIds = new Array();
var issimple = false;
var torrent = null;
var recheck = false;
if (typeof(ids)=="object")
{
torrent = transmission.torrents.all[ids[0]];
@ -91,6 +99,8 @@
var movedata = thisDialog.find("#move-data").prop("checked");
var button = $(this);
var icon = button.linkbutton("options").iconCls;
recheck = thisDialog.find("#recheck-data").prop("checked");
// 新目录
if (isnewdir)
@ -115,6 +125,20 @@
{
system.getTorrentInfos(torrent.id);
torrent.downloadDir = dir;
if (recheck)
{
transmission.exec({
method:"torrent-verify"
,arguments:{
ids:torrent.id
}
}
,function(data){
system.control.torrentlist.datagrid("uncheckAll");
system.reloadTorrentBaseInfos();
}
);
}
thisDialog.dialog("close");
}
else
@ -138,17 +162,33 @@
function doSetFolder(ids,count,button,icon,dir,movedata)
{
var id = ids;
//var id = ids;
var index = count-ids.length;
var id = ids.shift();
if (!id)
{
button.linkbutton({iconCls:icon,disabled:false});
system.control.torrentlist.datagrid("uncheckAll");
if (recheck)
{
transmission.exec({
method:"torrent-verify"
,arguments:{
ids:allIds
}
}
,function(data){
system.control.torrentlist.datagrid("uncheckAll");
system.reloadTorrentBaseInfos();
}
);
}
thisDialog.dialog("close");
return;
}
allIds.push(id);
var torrent = transmission.torrents.all[id];
thisDialog.find("#text-count").text("-> "+torrent.name + " [" + (index+1)+"/"+count + "] ");