增加 Added

# 增加自动检查是否可用的新版本程序
# 增加是否自动展开种子属性的选项,以便更好的操作
# 增加语言默认配置,用于其他语言未更新时,程序不会执行错误

# Automatically check for new program
# Add "Auto expand attribute" option
# Add default language configuration

更新/修复 Update/Fix
# 更新种子右键菜单的操作方式,允许在当前行上右击时,直接选中当前行操作
# 修复种子状态显示方式,未开始下载的种子,不在显示到警告状态中
# 更新种子状态进度条颜色,修改为和当前状态文本颜色相同

# Right-click to checked current row
# Fix progress bar color
This commit is contained in:
ronggang.zhou@gmail.com 2013-04-22 08:46:33 +00:00
parent d982ba1738
commit 2a7531a50f
14 changed files with 565 additions and 111 deletions

View File

@ -7,4 +7,6 @@ system.config = {
,pageSize: 30
// 初始界面默认选中的节点,名称可参考语言包中的 tree
,defaultSelectNode: "actively"
// 是否自动展开种子详细信息
,autoExpandAttribute: false
};

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=20130402" />
<link rel="stylesheet" type="text/css" href="script/easyui/themes/default/easyui.css?v=20130402"/>
<link rel="stylesheet" type="text/css" href="script/easyui/themes/icon.css?v=20130402"/>
<link rel="stylesheet" type="text/css" href="style/base.css?v=20130422" />
<link rel="stylesheet" type="text/css" href="script/easyui/themes/default/easyui.css?v=20130422"/>
<link rel="stylesheet" type="text/css" href="script/easyui/themes/icon.css?v=20130422"/>
<!-- 基础类库 -->
<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=20130402"></script>
<script type="text/javascript" src="script/easyui/jquery.easyui.min.js?v=20130422"></script>
<!-- -->
<!-- 系统类库 -->
<script type="text/javascript" src="script/min/public.js?v=20130402"></script>
<script type="text/javascript" src="script/min/cookies.js?v=20130402"></script>
<script type="text/javascript" src="script/min/clientDevice.js?v=20130402"></script>
<script type="text/javascript" src="script/min/transmission.js?v=20130402"></script>
<script type="text/javascript" src="script/min/transmission.torrents.js?v=20130402"></script>
<script type="text/javascript" src="script/min/system.js?v=20130402"></script>
<script type="text/javascript" src="config.js?v=20130402"></script>
<script type="text/javascript" src="script/min/public.js?v=20130422"></script>
<script type="text/javascript" src="script/min/cookies.js?v=20130422"></script>
<script type="text/javascript" src="script/min/clientDevice.js?v=20130422"></script>
<script type="text/javascript" src="script/min/transmission.js?v=20130422"></script>
<script type="text/javascript" src="script/min/transmission.torrents.js?v=20130422"></script>
<script type="text/javascript" src="script/min/system.js?v=20130422"></script>
<script type="text/javascript" src="config.js?v=20130422"></script>
</head>
<body>
<div id="main" class="easyui-layout">
@ -33,6 +33,10 @@
<div class="easyui-layout" data-options="fit:true">
<div id="m_title_layout" data-options="region:'center'" border="0">
<img src="logo.png"/><span id="m_title" style="padding:10px;"></span>
<span id="area-update-infos" style="display:none;">
<span id="msg-updateInfos" style="color:red;"></span>
<a id="button-download-update" href="https://code.google.com/p/transmission-control/" system-lang="public['text-have-update']" target="_blank"></a>
</span>
<div style="float:right;">Language<select id="lang" value="" style="width:200px;"></select></div>
</div>
<div id="m_toolbar" data-options="region:'south',border:0">

336
lang/default.js Normal file
View File

@ -0,0 +1,336 @@
// lang file
system.defaultLang = {
"name":"en"
,"system":{
"title":"Transmission WEB Control"
,"status":{
"connect":"Connecting..."
,"connected":"Connected"
,"queue":"Queue:"
,"queuefinish":"The queue(s) is finish."
,"notfinal":"Not final"
}
}
,"error":{
"data-error":"Data error."
,"data-post-error":"Data post error."
}
,"config":{
"save-path":"Download dir"
}
,"toolbar":{
"start":"Start"
,"pause":"Pause"
,"recheck":"Recheck"
,"start-all":"Start all"
,"pause-all":"Pause all"
,"remove":"Remove"
,"remove-all":"Remove all"
,"remove-data":"Remove data"
,"add-torrent":"Add Torrent"
,"attribute":"Attribute"
,"alt-speed":"Alt-Speed"
,"system-config":"Config"
,"system-reload":"Reload"
,"about":"About"
,"reload-time":"Auto Reload:"
,"reload-time-unit":"s/time"
,"autoreload-disabled":"Disabled"
,"autoreload-enabled":"Enabled"
,"search-prompt":"Search Loacl Torrents"
,"tracker-replace":"Replace trackers"
,"tip":{
"start":"Start the checked torrents"
,"pause":"Pause the checked torrents"
,"recheck":"Recheck the checked torrents"
,"recheck-confirm":"You sure you want to re-check the selected torrents? This may take some time!"
,"start-all":"Start all"
,"pause-all":"Pause all"
,"remove":"Remove"
,"delete-all":"Delete-all"
,"delete-data":"Delete-data"
,"add-torrent":"Add torrent(s)"
,"attribute":"Attribute"
,"alt-speed":"Alt-speed"
,"system-config":"Config"
,"system-reload":"Reload"
,"about":"About this app"
,"autoreload-disabled":"Disabled auto reload"
,"autoreload-enabled":"Enabled auto reload"
,"tracker-replace":"Replace trackers"
,"change-download-dir":"Set location"
,"ui-mobile":"Mobile UI"
,"ui-original":"Original UI"
,"more-peers":"Ask tracker for more peers"
}
}
,"title":{
"left":"Navigation"
,"list":"Torrents"
,"attribute":"Attribute"
,"status":"Status"
}
,"tree":{
"all":"All"
,"active":"Active"
,"paused":"Paused"
,"downloading":"Downloading"
,"sending":"Sending"
,"error":"Error"
,"warning":"Warning"
,"actively":"Actively"
,"check":"Checking"
,"wait":"Waiting"
,"search-result":"Search Result"
,"status":{
"loading":"Loading..."
}
,"statistics":"Statistics"
,"statistics":{
"title":"Statistics"
,"cumulative":"Cumulative"
,"current":"Current"
,"uploadedBytes":"UploadedBytes: "
,"downloadedBytes":"DownloadedBytes: "
,"filesAdded":"FilesAdded: "
,"sessionCount":"SessionCount: "
,"secondsActive":"SecondsActive: "
}
,"servers":"Trackers"
,"folders":"Folders"
,"toolbar":{
"nav":{
"folders":"Folders"
}
}
}
,"statusbar":{
"downloadspeed":"Download speed:"
,"uploadspeed":"Send speed:"
,"version":"Version:"
}
,"dialog":{
"torrent-add":{
"download-dir":"Download Dir:"
,"torrent-url":"Torrent URL:"
,"tip-torrent-url":"TipPlease multiple content with 'Enter' to separate"
,"autostart":"Auto Start:"
,"tip-autostart":""
,"set-default-download-dir":"Set as default dir"
,"upload-file":"Torrent file(s):"
,"nosource":"No torrent file or URL."
,"tip-title":"Upload the torrent file takes precedence over the torrent URL"
}
,"system-config":{
"title":"Server Config"
,"tabs":{
"base":"Base"
,"network":"Network"
,"limit":"Limit"
,"alt-speed":"Scheduled"
}
,"config-dir":"Location of transmission's configuration directory:"
,"download-dir":"Default path to download torrents:"
,"download-dir-free-space":"Free space:"
,"incomplete-dir-enabled":"Use incomplete dir"
,"cache-size-mb":"Disk cache size:"
,"rename-partial-files":"Append '.part' to incomplete files"
,"start-added-torrents":"Auto start added torrents"
,"download-queue-enabled":"Enabled download queue, max queue number:"
,"seed-queue-enabled":"Enabled seed queue, max queue number:"
,"peer-port-random-on-start":"Use random port on start"
,"port-forwarding-enabled":"Enabled forwarding"
,"test-port":"Test the port"
,"port-is-open-true":"The port is open"
,"port-is-open-false":"The port is closed"
,"testing":"Testing..."
,"encryption":"Encryption:"
,"encryption-type":{
"required":"Required"
,"preferred":"Preferred"
,"tolerated":"Tolerated"
}
,"utp-enabled":"Enabled uTP(UPnP)"
,"dht-enabled":"Enabled DHT"
,"lpd-enabled":"Enabled LPD"
,"pex-enabled":"Enabled PEX"
,"peer-limit-global":"Maximum global number of peers:"
,"peer-limit-per-torrent":"Maximum peers number of torrent:"
,"speed-limit-down-enabled":"Max global download speed:"
,"speed-limit-up-enabled":"Max global upload speed:"
,"alt-speed-enabled":"Use the alt speeds"
,"alt-speed-down":"Max global download speed:"
,"alt-speed-up":"Max global upload speed:"
,"alt-speed-time-enabled":"Use scheduled"
,"alt-speed-time":"Time"
,"weekday":{
"1":"Monday"
,"2":"Tuesday"
,"3":"Wednesday"
,"4":"Thursday"
,"5":"Friday"
,"6":"Saturday"
,"0":"Sunday"
}
,"blocklist-enabled":"Use blocklist"
,"seedRatioLimited":"The default seed ratio for torrents to use:"
,"queue-stalled-enabled":"Whether or not to consider idle torrents as stalled:"
,"idle-seeding-limit-enabled":"Torrents we're seeding will be stopped if they're idle for this long:"
,"minuets":"Minuets"
,"nochange":"No change"
,"saveing":"Saveing..."
}
,"public":{
"button-ok":"OK"
,"button-cancel":"Cancel"
,"button-reload":"Reload"
,"button-save":"Save"
,"button-close":"Close"
}
,"about":{
"infos":"Authorculturist<br/>StatementMost of the icons used in this program from the network, if any violation of your rights, please contact me delete."
}
,"torrent-remove":{
"title":"Remove confirm"
,"confirm-text":"Are you sure you want to remove the checked torrent(s)?"
,"remove-data":"Delete local data"
,"remove-error":"Delete failed!"
}
,"torrent-changeDownloadDir":{
"title":"Set new dir"
,"old-download-dir":"Old dir:"
,"new-download-dir":"New dir:"
,"move-data":"If checked, move from previous location. otherwise, search 'New dir' for files."
,"set-error":"set error!"
}
,"system-replaceTracker":{
"title":"Replace Trackers"
,"old-tracker":"Old tracker"
,"new-tracker":"New tracker"
,"tip":"This function will find <b>all torrents</b> Tracker."
,"not-found":"Tracker is not found."
}
}
,"torrent":{
"fields":{
"id":"#"
,"name":"Name"
,"hashString":"HASH"
,"downloadDir":"Download Dir"
,"totalSize":"Total size"
,"status":"Status"
,"percentDone":"Percent done"
,"remainingTime":"Remaining time"
,"addedDate":"Added date"
,"completeSize":"Complete size"
,"rateDownload":"Rate download"
,"rateUpload":"Rate upload"
,"leecherCount":"Leecher"
,"seederCount":"Seeder"
,"uploadedEver":"Uploaded ever"
,"uploadRatio":"Ratio"
}
,"status-text":{
"0":"Paused"
,"1":"Wait check"
,"2":"Checking"
,"3":"Wait download"
,"4":"Downloading"
,"5":"Wait seed"
,"6":"Seeding"
}
,"attribute":{
"tabs":{
"base":"Base"
,"servers":"Trackers"
,"files":"Files"
,"users":"Peers"
,"config":"Config"
}
,"files-fields":{
"name":"Name"
,"length":"Size"
,"percentDone":"Percent done"
,"bytesCompleted":"Complete size"
,"wanted":"Wanted"
,"priority":"Priority"
}
,"servers-fields":{
"announce":"Announce"
,"announceState":"Status"
,"lastAnnounceResult":"Infos"
,"lastAnnounceSucceeded":"Succeeded"
,"lastAnnounceTime":"AnnounceTime"
,"lastAnnounceTimedOut":"TimedOut"
,"downloadCount":"Download count"
,"nextAnnounceTime":"Next announce"
}
,"peers-fields":{
"address":"IP address"
,"clientName":"Client"
,"flagStr":"Flag"
,"progress":"Progress"
,"rateToClient":"RateToClient"
,"rateToPeer":"RateToPeer"
}
,"status":{
"true":"True"
,"false":"False"
}
,"priority":{
"0":"Normal"
,"1":"High"
,"-1":"Low"
}
,"label":{
"name":"Name:"
,"addedDate":"Added date:"
,"totalSize":"Total size:"
,"completeSize":"Complete size:"
,"leftUntilDone":"Left until done:"
,"hashString":"HASH:"
,"downloadDir":"Download dir:"
,"status":"Status:"
,"rateDownload":"Rate download:"
,"rateUpload":"Rate upload:"
,"leecherCount":"Leecher:"
,"seederCount":"Seeder:"
,"uploadedEver":"Uploaded ever:"
,"uploadRatio":"Upload Ratio:"
,"creator":"Creator:"
,"dateCreated":"Date created:"
,"comment":"Comment:"
,"errorString":"Error string:"
,"downloadLimited":"Max global download speed"
,"uploadLimited":"Max global upload speed"
,"peer-limit":"Maximum peers number of torrent"
,"seedRatioMode":"Seed ratio for torrents to use"
,"seedIdleMode":"Torrents we're seeding will be stopped if they're idle for this long"
}
,"tip":{
"button-allow":"Download checked file(s)"
,"button-deny":"Skip checked file(s)"
,"button-priority":"Set priority"
}
,"other":{
"tracker-remove-confim":"Are you sure want to remove this Tracker?"
}
}
}
,"torrent-head":{
"buttons":{
"autoExpandAttribute":"Auto expand attribute"
}
}
,"public":{
"text-unknown":"Unknown"
,"text-drop-title":"Drag and drop the file in the region to add to the Transmission."
,"text-saved":"Saved"
,"text-nochange":"No change"
,"text-info":"Infos"
,"text-confirm":"Are you sure?"
,"text-browsers-not-support-features":"The current browser does not support this feature!"
,"text-download-update":"Download this update"
,"text-have-update":"An update is available"
}
};

View File

@ -317,6 +317,11 @@ system.lang = {
}
}
}
,"torrent-head":{
"buttons":{
"autoExpandAttribute":"Auto expand attribute"
}
}
,"public":{
"text-unknown":"Unknown"
,"text-drop-title":"Drag and drop the file in the region to add to the Transmission."
@ -325,5 +330,7 @@ system.lang = {
,"text-info":"Infos"
,"text-confirm":"Are you sure?"
,"text-browsers-not-support-features":"The current browser does not support this feature!"
,"text-download-update":"Download this update"
,"text-have-update":"An update is available"
}
};

View File

@ -316,6 +316,11 @@ system.lang = {
}
}
}
,"torrent-head":{
"buttons":{
"autoExpandAttribute":"自动显示种子属性"
}
}
,"public":{
"text-unknown":"未知"
,"text-drop-title":"将文件拖放在该区域内即可添加到 Transmission。"
@ -324,5 +329,7 @@ system.lang = {
,"text-info":"信息"
,"text-confirm":"确认要这样做吗?"
,"text-browsers-not-support-features":"当前浏览器不支持该功能!"
,"text-download-update":"下载这个更新"
,"text-have-update":"有可用的更新"
}
};

View File

@ -316,6 +316,11 @@ system.lang = {
}
}
}
,"torrent-head":{
"buttons":{
"autoExpandAttribute":"自動顯示種子屬性"
}
}
,"public":{
"text-unknown":"未知"
,"text-drop-title":"將檔拖放在該區域內即可添加到 Transmission。"
@ -324,5 +329,7 @@ system.lang = {
,"text-info":"信息"
,"text-confirm":"確認要這樣做嗎?"
,"text-browsers-not-support-features":"當前流覽器不支援該功能!"
,"text-download-update":"下載這個更新"
,"text-have-update":"有可用的更新"
}
};

View File

@ -1,80 +1,83 @@
var system={version:"0.3 Beta",codeupdate:"20130402",config:{autoReload:true,reloadStep:5E3,pageSize:30,defaultSelectNode:null},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=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();$.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(){var a=$("*[system-lang]");
$.each(a,function(b,c){var d=$(c).attr("system-lang");$(c).html(eval("system.lang."+d))});a=$("*[system-tip-lang]");$.each(a,function(b,c){var d=$(c).attr("system-tip-lang");$(c).attr("title",eval("system.lang."+d))})},initdata:function(){this.panel.title.text(this.lang.system.title+" "+this.version+" ("+this.codeupdate+")");$(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)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);">'+this.lang.tree.toolbar.nav[c]+"</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);this.panel.body.panel("setTitle",this.lang.title.list);this.panel.status.panel("setTitle",this.lang.title.status);
this.panel.attribute.panel({title:this.lang.title.attribute,onExpand:function(){system.currentTorrentId!=0&&$(this).data("isload")?system.getTorrentInfos(system.currentTorrentId):system.clearTorrentAttribute()},onLoad:function(){if(!$(this).data("isload")){$(this).data("isload",true);system.currentTorrentId!=0&&setTimeout(function(){system.getTorrentInfos(system.currentTorrentId)},500)}}});$.each(this.languages,function(d,e){$("<option/>").text(e).val(d).attr("selected",d==system.lang.name?true:false).appendTo(system.panel.top.find("#lang"))});
this.panel.top.find("#lang").change(function(){location.href="?lang="+this.value});this.panel.toolbar.attr("class","panel-header");this.initTree();this.initToolbar();this.initStatusBar();this.initTorrentTable();this.connect();this.initEvent()},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",
var system={version:"0.4 Beta",codeupdate:"20130422",config:{autoReload:true,reloadStep:5E3,pageSize:30,defaultSelectNode:null,autoExpandAttribute:false},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=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(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(){var a=$("*[system-lang]");$.each(a,function(b,c){var d=$(c).attr("system-lang");$(c).html(eval("system.lang."+d))});a=$("*[system-tip-lang]");$.each(a,function(b,c){var d=$(c).attr("system-tip-lang");$(c).attr("title",eval("system.lang."+d))})},initdata:function(){this.panel.title.text(this.lang.system.title+" "+this.version+" ("+this.codeupdate+")");$(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"))});
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")}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)}},
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,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.panel.attribute.panel("options").collapsed&&system.panel.layout_body.layout("expand","south");system.getTorrentInfos(d.id)},onUnselect:function(){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){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(){$(this).linkbutton({iconCls:"icon-loading"});transmission.exec({method:"torrent-start"},function(a){var b=system.panel.toolbar.find("#toolbar_start_all");
b.linkbutton({iconCls:"icon-start-all"});a.result=="success"&&b.linkbutton({disabled:true})})});this.panel.toolbar.find("#toolbar_pause_all").linkbutton({disabled:false}).attr("title",this.lang.toolbar.tip["pause-all"]).click(function(){transmission.exec({method:"torrent-stop"},function(a){a.result=="success"&&system.panel.toolbar.find("#toolbar_pause_all").linkbutton({disabled:true})})});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:400,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"]);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}}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});b=this.control.torrentlist.datagrid("options");e=null;if(b.sortName){e=b.sortName;a=a.sort(arrayObjectSort(e,b.sortOrder))}this.control.torrentlist.datagrid({loadFilter:pagerFilter,pageNumber:b.pageNumber,sortName:e,sortOrder:b.sortOrder}).datagrid("loadData",a)}}},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="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.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("")},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>"})}system.panel.attribute.find("#torrent-files-table").datagrid({loadFilter:pagerFilter,pageNumber:1}).datagrid("loadData",d)},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);
system.panel.attribute.find("#torrent-servers-table").datagrid({loadFilter:pagerFilter,pageNumber:1}).datagrid("loadData",d)},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)}system.panel.attribute.find("#torrent-peers-table").datagrid({loadFilter:pagerFilter,pageNumber:1}).datagrid("loadData",b)},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,c.statusCode)};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"])},debug:function(a,b){window.console&&window.console.log&&window.console.log(a,b)}};$(document).ready(function(){$.getScript("lang/_languages.js",function(){system.init(location.search.getQueryString("lang"),location.search.getQueryString("local"))})});
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,
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(){$(this).linkbutton({iconCls:"icon-loading"});
transmission.exec({method:"torrent-start"},function(a){var b=system.panel.toolbar.find("#toolbar_start_all");b.linkbutton({iconCls:"icon-start-all"});a.result=="success"&&b.linkbutton({disabled:true})})});this.panel.toolbar.find("#toolbar_pause_all").linkbutton({disabled:false}).attr("title",this.lang.toolbar.tip["pause-all"]).click(function(){transmission.exec({method:"torrent-stop"},function(a){a.result=="success"&&system.panel.toolbar.find("#toolbar_pause_all").linkbutton({disabled:true})})});
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:400,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"]);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}}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});b=this.control.torrentlist.datagrid("options");e=null;if(b.sortName){e=b.sortName;a=a.sort(arrayObjectSort(e,b.sortOrder))}this.control.torrentlist.datagrid({loadFilter:pagerFilter,
pageNumber:b.pageNumber,sortName:e,sortOrder:b.sortOrder}).datagrid("loadData",a)}}},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=
"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.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("")},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>"})}system.panel.attribute.find("#torrent-files-table").datagrid({loadFilter:pagerFilter,pageNumber:1}).datagrid("loadData",d)},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);system.panel.attribute.find("#torrent-servers-table").datagrid({loadFilter:pagerFilter,pageNumber:1}).datagrid("loadData",d)},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)}system.panel.attribute.find("#torrent-peers-table").datagrid({loadFilter:pagerFilter,pageNumber:1}).datagrid("loadData",b)},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=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()})},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};

View File

@ -2,6 +2,6 @@ var transmission={SessionId:"",isInitialized:false,host:"",port:"9091",path:"/tr
true;b.SessionId=c;b.headers["X-Transmission-Session-Id"]=c;a&&a()}},headers:this.headers})},init:function(b,a){jQuery.extend(this,b);if(this.islocal==true)this.fullpath=this.path;else{if(this.fullpath=="")this.fullpath=this.host+(this.port?":"+this.port:"")+this.path;if(this.username&&this.password)this.headers.Authorization="Basic "+(new Base64).encode(this.username+":"+this.password)}this.getSessionId(this,a)},exec:function(b,a,d){if(!this.isInitialized)return false;var c={method:"",arguments:{},
tag:""};jQuery.extend(c,b);var f={type:"POST",url:this.fullpath,dataType:"json",data:JSON.stringify(c),success:function(e){a&&a(e,d)},error:function(e){var g="";if(e.status===409&&(g=e.getResponseHeader("X-Transmission-Session-Id"))){transmission.SessionId=g;transmission.headers["X-Transmission-Session-Id"]=g;jQuery.ajax(f)}else transmission.on.postError&&transmission.on.postError(e)},headers:this.headers};jQuery.ajax(f)},getStatus:function(b){this.exec({method:"session-stats"},function(a){if(a.result==
"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;case "duplicate torrent":c&&c("duplicate")}})},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)})}};
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)})}};

View File

@ -5,8 +5,8 @@ this.status={};transmission.trackers={};this.totalSize=0;this.folders={};this.co
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=
h;f.nodeid=i;f.host=g.host;if(e!="success"){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];if(!($.inArray(e.id,b)!=-1&&b.length>0)){if(d==true)if(a<e.nextAnnounceTime)continue;
c.push(e.id)}}for(g in this.warning){e=this.warning[g];if(!($.inArray(e.id,b)!=-1&&b.length>0)){if(d==true)if(a<e.nextAnnounceTime)continue;c.push(e.id)}}return c},searchAndReplaceTrackers:function(b,d,c){if(b&&d){var a={},g=0,e;for(e in this.all){var h=this.all[e];if(!h)return;var i=h.trackerStats,f;for(f in i)if(i[f].announce==b){a[f]||(a[f]={ids:[],tracker:d});a[f].ids.push(h.id);g++}}g==0&&c&&c(null,0);for(e in a)transmission.exec({method:"torrent-set",arguments:{ids:a[e].ids,trackerReplace:[parseInt(e),
a[e].tracker]}},function(j,k){if(j.result=="success")c&&c(k,g);else c&&c(null)},a[e].ids)}}};
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];
if(!($.inArray(e.id,b)!=-1&&b.length>0)){if(d==true)if(a<e.nextAnnounceTime)continue;c.push(e.id)}}for(g in this.warning){e=this.warning[g];if(!($.inArray(e.id,b)!=-1&&b.length>0)){if(d==true)if(a<e.nextAnnounceTime)continue;c.push(e.id)}}return c},searchAndReplaceTrackers:function(b,d,c){if(b&&d){var a={},g=0,e;for(e in this.all){var h=this.all[e];if(!h)return;var i=h.trackerStats,f;for(f in i)if(i[f].announce==b){a[f]||(a[f]={ids:[],tracker:d});a[f].ids.push(h.id);g++}}g==0&&c&&c(null,0);for(e in a)transmission.exec({method:"torrent-set",
arguments:{ids:a[e].ids,trackerReplace:[parseInt(e),a[e].tracker]}},function(j,k){if(j.result=="success")c&&c(k,g);else c&&c(null)},a[e].ids)}}};

View File

@ -1,13 +1,15 @@
// 当前系统全局对象
var system = {
version:"0.3 Beta"
,codeupdate:"20130402"
version:"0.4 Beta"
,codeupdate:"20130422"
,config:{
autoReload: true
,reloadStep: 5000
,pageSize: 30
,defaultSelectNode: null
,autoExpandAttribute: false
}
,checkUpdateScript:"https://transmission-control.googlecode.com/svn/resouces/checkupdate.js"
,contextMenus:{
}
,panel:null
@ -56,6 +58,7 @@ var system = {
}
$.getScript("lang/"+lang+".js",function(){
system.lang = $.extend(system.defaultLang, system.lang);
system.resetLangText();
// 设置 easyui 语言
$.getScript("script/easyui/locale/easyui-lang-"+lang.replace("-","_")+".js")
@ -132,6 +135,8 @@ var system = {
{
this.panel.title.text(this.lang.system.title+" "+this.version+" ("+this.codeupdate+")");
$(document).attr("title",this.lang.system.title+" "+this.version);
// 初始导航栏
var buttons = new Array();
var title = "<span>" + this.lang.title.left+"</span>";
buttons.push("<span class='tree-title-toolbar'>");
@ -155,7 +160,47 @@ var system = {
this.panel.left_layout.panel("setTitle",title);
}
this.panel.body.panel("setTitle",this.lang.title.list);
// 初始化种子列表栏目标题
title = "<span>" + this.lang.title.list+"</span>";
buttons.length = 0;
buttons.push("<span class='tree-title-toolbar'>");
for (var key in this.lang["torrent-head"].buttons)
{
var value = this.lang["torrent-head"].buttons[key];
buttons.push('<a href="javascript:void(0);" id="torrent-head-buttons-'+key+'" class="easyui-linkbutton" data-options="plain:true,iconCls:\'icon-disabled\'" onclick="javascript:system.navToolbarClick(this);">'+value+"</a>");
}
buttons.push("</span>");
if (buttons.length>1)
{
title+=buttons.join("");
this.panel.body.panel("setTitle",title);
for (var key in this.lang["torrent-head"].buttons)
{
$("#torrent-head-buttons-"+key).linkbutton();
switch (key)
{
case "autoExpandAttribute":
if (system.config.autoExpandAttribute)
{
$("#torrent-head-buttons-"+key).linkbutton({iconCls:"icon-enabled"}).data("status",1);
}
else
{
$("#torrent-head-buttons-"+key).linkbutton({iconCls:"icon-disabled"}).data("status",0);
}
break;
default:
break;
}
}
}
else
{
this.panel.body.panel("setTitle",title);
}
this.panel.status.panel("setTitle",this.lang.title.status);
this.panel.attribute.panel({
title:this.lang.title.attribute
@ -200,6 +245,8 @@ var system = {
this.initTorrentTable();
this.connect();
this.initEvent();
// 检查更新
this.checkUpdate();
}
//
,initEvent:function()
@ -258,6 +305,18 @@ var system = {
treenode = this.panel.left.tree("find","statistics");
break;
case "torrent-head-buttons-autoExpandAttribute":
treenode = {};
treenode.target = null;
if (status==1){
this.config.autoExpandAttribute = false;
}
else
{
this.config.autoExpandAttribute = true;
}
break;
}
if (!treenode)
@ -279,6 +338,7 @@ var system = {
}
$(source).data("status",status);
this.saveConfig();
}
// 检查拖放的文件
,checkDropFiles:function(sources)
@ -511,16 +571,24 @@ var system = {
,onSelect:function(rowIndex, rowData)
{
$(this).datagrid("clearSelections");
// 如果没有展开时,将其展开
if (system.panel.attribute.panel("options").collapsed)
system.panel.layout_body.layout("expand","south");
if (system.config.autoExpandAttribute)
{
// 如果没有展开时,将其展开
if (system.panel.attribute.panel("options").collapsed)
system.panel.layout_body.layout("expand","south");
}
system.getTorrentInfos(rowData.id);
}
,onUnselect:function(rowIndex, rowData)
{
// 如果展开时,将其合拢
if (!system.panel.attribute.panel("options").collapsed)
system.panel.layout_body.layout("collapse","south");
if (system.config.autoExpandAttribute)
{
// 如果展开时,将其合拢
if (!system.panel.attribute.panel("options").collapsed)
system.panel.layout_body.layout("collapse","south");
}
system.currentTorrentId = 0;
}
// 加载数据之前
@ -536,6 +604,7 @@ var system = {
}
,onRowContextMenu: function(e, rowIndex, rowData)
{
system.control.torrentlist.datagrid("checkRow",rowIndex);
e.preventDefault();
system.showContextMenu("torrent-list",e);
}
@ -2078,7 +2147,7 @@ var system = {
case "progress":
field.formatter = function(value,row,index){
var percentDone = parseFloat(value*100).toFixed(2);
return system.getTorrentProgressBar(percentDone,row["statusCode"]);
return system.getTorrentProgressBar(percentDone,transmission.torrents.all[row["id"]]);
};
break;
@ -2210,7 +2279,18 @@ var system = {
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();
});
}
// 调试信息
,debug:function(label,text){
if (window.console)
@ -2224,6 +2304,8 @@ var system = {
};
$(document).ready(function(){
// 加载默认语言内容
$.getScript("lang/default.js");
// 加载可用的语言列表
$.getScript("lang/_languages.js",function(){
system.init(location.search.getQueryString("lang"),location.search.getQueryString("local"));

View File

@ -198,11 +198,13 @@ var transmission = {
callback(data.arguments["torrent-added"]);
}
break;
// 重复的种子
case "duplicate torrent":
default:
if (callback)
{
callback("duplicate");
callback(data.result);
}
break;

View File

@ -280,7 +280,7 @@ transmission.torrents = {
tracker["nodeid"] = id;
tracker["host"] = trackerInfo.host;
if (lastResult!="success")
if (lastResult!="success"&&trackerInfo.announceState!=0)
{
haveWarning = true;
item["warning"] = trackerInfo.lastAnnounceResult;

View File

@ -269,3 +269,7 @@ html, body {
.icon-more-peers{
background:url('images/more-peers.png') no-repeat;
}
.icon-download-update{
background:url('images/drive-download.png') no-repeat;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 734 B