torrent-attribute.html 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  1. <div class="easyui-layout" data-options="fit:true" style="width:100%;height:100%;" id="torrent-attribute-layout">
  2. <div data-options="region:'center'" style="padding:0px;border:0px;">
  3. <div id="torrent-attribute-tabs" class="easyui-tabs" style="width:100%;height:100%;" data-options="fit:true,plain:true,tabPosition:'left',border:0,headerWidth:105">
  4. <div title="常规" style="padding:2px;" class="dialog">
  5. <table style="width:100%;">
  6. <tr>
  7. <td class="title"><span id="torrent-attribute-label-name"></span></td>
  8. <td colspan="3"><span id="torrent-attribute-value-name"></span></td>
  9. </tr>
  10. <tr>
  11. <td class="title"><span id="torrent-attribute-label-downloadDir"></span></td>
  12. <td colspan="3">
  13. <span id="torrent-attribute-value-downloadDir"></span>
  14. <a id="torrent-attribute-config-button-changeDownloadDir" class="easyui-linkbutton" data-options="iconCls:'iconfont tr-icon-folder-change',plain:true" href="javascript:void(0);" system-tip-lang="toolbar.tip['change-download-dir']"></a>
  15. <a id="torrent-attribute-config-button-copyPath" class="easyui-linkbutton" data-options="iconCls:'iconfont tr-icon-clippy',plain:true" href="javascript:void(0);" data-clipboard-action="copy" data-clipboard-target="#torrent-attribute-value-downloadDir" system-tip-lang="toolbar.tip['copy-path-to-clipboard']"></a>
  16. </td>
  17. </tr>
  18. <tr>
  19. <td class="title"><span id="torrent-attribute-label-status"></span></td>
  20. <td><span id="torrent-attribute-value-status"></span></td>
  21. <td class="title"><span id="torrent-attribute-label-hashString"></span></td>
  22. <td><span id="torrent-attribute-value-hashString"></span></td>
  23. </tr>
  24. <tr id="torrent-attribute-tr-error" style="display:none;">
  25. <td class="title" style="color:red;"><span id="torrent-attribute-label-errorString"></span></td>
  26. <td colspan="3" style="color:red;"><span id="torrent-attribute-value-errorString"></span> (<span id="torrent-attribute-value-error"></span>)</td>
  27. </tr>
  28. <tr>
  29. <td width="12%" class="title"><span id="torrent-attribute-label-totalSize"></span></td>
  30. <td width="38%"><span id="torrent-attribute-value-totalSize"></span></td>
  31. <td width="12%" class="title"><span id="torrent-attribute-label-addedDate"></span></td>
  32. <td width="38%"><span id="torrent-attribute-value-addedDate"></span></td>
  33. </tr>
  34. <tr>
  35. <td class="title"><span id="torrent-attribute-label-leftUntilDone"></span></td>
  36. <td><span id="torrent-attribute-value-leftUntilDone"></span> (<span id="torrent-attribute-value-remainingTime"></span>)</td>
  37. <td class="title"><span id="torrent-attribute-label-completeSize"></span></td>
  38. <td><span id="torrent-attribute-value-completeSize"></span></td>
  39. </tr>
  40. <tr>
  41. <td class="title"><span id="torrent-attribute-label-rateDownload"></span></td>
  42. <td><span id="torrent-attribute-value-rateDownload"></span></td>
  43. <td class="title"><span id="torrent-attribute-label-rateUpload"></span></td>
  44. <td><span id="torrent-attribute-value-rateUpload"></span></td>
  45. </tr>
  46. <tr>
  47. <td class="title"><span id="torrent-attribute-label-leecherCount"></span></td>
  48. <td><span id="torrent-attribute-value-leecherCount"></span></td>
  49. <td class="title"><span id="torrent-attribute-label-seederCount"></span></td>
  50. <td><span id="torrent-attribute-value-seederCount"></span></td>
  51. </tr>
  52. <tr>
  53. <td class="title"><span id="torrent-attribute-label-uploadedEver"></span></td>
  54. <td><span id="torrent-attribute-value-uploadedEver"></span></td>
  55. <td class="title"><span id="torrent-attribute-label-uploadRatio"></span></td>
  56. <td><span id="torrent-attribute-value-uploadRatio"></span></td>
  57. </tr>
  58. <tr>
  59. <td class="title"><span id="torrent-attribute-label-creator"></span></td>
  60. <td><span id="torrent-attribute-value-creator"></span></td>
  61. <td class="title"><span id="torrent-attribute-label-dateCreated"></span></td>
  62. <td><span id="torrent-attribute-value-dateCreated"></span></td>
  63. </tr>
  64. <tr>
  65. <td class="title"><span id="torrent-attribute-label-comment"></span></td>
  66. <td colspan="3"><span id="torrent-attribute-value-comment"></span></td>
  67. </tr>
  68. <tr>
  69. <td colspan="4">
  70. <hr/>
  71. <div id="torrent-attribute-pieces">
  72. <i style="filter:saturate(0)" title="100MB x 0%"></i><i style="filter:saturate(0.5)" title="100MB x 50%"></i><br/>
  73. <i style="filter:saturate(1)" title="100MB x 100%"></i>
  74. </div>
  75. </td>
  76. </tr>
  77. </table>
  78. </div>
  79. <div title="服务器" style="padding:0px;" id="torrent-attribute-servers">
  80. </div>
  81. <div title="文件" style="padding:0px;" id="torrent-attribute-files">
  82. </div>
  83. <div title="用户" style="padding:0px;" id="torrent-attribute-peers">
  84. </div>
  85. <div title="设置" style="padding:0px;" id="torrent-attribute-config" class="dialog">
  86. <div class="easyui-layout" data-options="fit:true" style="width:100%;">
  87. <div data-options="region:'center'" style="padding:2px;border:0px;">
  88. <table style="width:100%;">
  89. <tr>
  90. <td width="30%" class="title">
  91. <input id="downloadLimited" type="checkbox" style="width:16px;"/><label id="torrent-attribute-label-downloadLimited" for="downloadLimited"></label>
  92. </td>
  93. <td width="20%"><input id="downloadLimit" type="text" class="easyui-numberspinner" enabledof="downloadLimited"/> KB/s</td>
  94. <td width="30%" class="title">
  95. <input id="seedRatioMode" type="checkbox" style="width:16px;"/><label id="torrent-attribute-label-seedRatioMode" for="seedRatioMode"></label>
  96. </td>
  97. <td width="20%"><input id="seedRatioLimit" type="text" class="easyui-numberspinner" enabledof="seedRatioMode"/></td>
  98. </tr>
  99. <tr>
  100. <td class="title">
  101. <input id="uploadLimited" type="checkbox" style="width:16px;"/><label id="torrent-attribute-label-uploadLimited" for="uploadLimited"></label>
  102. </td>
  103. <td><input id="uploadLimit" type="text" class="easyui-numberspinner" enabledof="uploadLimited"/> KB/s</td>
  104. <td class="title">
  105. <input id="seedIdleMode" type="checkbox" style="width:16px;"/><label id="torrent-attribute-label-seedIdleMode" for="seedIdleMode"></label>
  106. </td>
  107. <td><input id="seedIdleLimit" type="text" class="easyui-numberspinner" enabledof="seedIdleMode"/> <span name="system-config-minutes"></span></td>
  108. </tr>
  109. <tr>
  110. <td class="title">
  111. <span id="torrent-attribute-label-peer-limit"></span>
  112. </td>
  113. <td>
  114. <input id="peer-limit" value="" type="text" class="easyui-numberspinner"/>
  115. </td>
  116. <td></td>
  117. <td></td>
  118. </tr>
  119. </table>
  120. </div>
  121. <div data-options="region:'south'" style="padding:2px;height:32px;">
  122. <a id="torrent-attribute-config-button-save" class="easyui-linkbutton" data-options="iconCls:'icon-save',plain:true" href="javascript:void(0);">Ok</a>
  123. <span id="torrent-attribute-config-nochange" style="display:none;"></span>
  124. <span id="torrent-attribute-config-saved" style="display:none;"></span>
  125. </div>
  126. </div>
  127. </div>
  128. </div>
  129. </div>
  130. </div>
  131. <script type="text/javascript">
  132. (function(thisLayout){
  133. var labels = system.lang.torrent.attribute.label;
  134. system.resetLangText(thisLayout);
  135. var clipboard = new ClipboardJS('#torrent-attribute-config-button-copyPath');
  136. $.each(labels, function(key, item){
  137. thisLayout.find("#torrent-attribute-label-"+key).html(item);
  138. });
  139. thisLayout.find("#torrent-attribute-config-button-save").html(system.lang.dialog["public"]["button-save"]);
  140. thisLayout.find("#torrent-attribute-config-nochange").html(system.lang["public"]["text-nochange"]);
  141. thisLayout.find("#torrent-attribute-config-saved").html(system.lang["public"]["text-saved"]);
  142. thisLayout.find(".title").css({
  143. // background:"#e6e6e6"
  144. "border-bottom": "1px solid #ccc"
  145. });
  146. var tabs = thisLayout.find("#torrent-attribute-tabs");
  147. tabs.tabs();
  148. tabs.tabs("update",{
  149. tab:tabs.tabs("getTab",0)
  150. ,options:{
  151. title:system.lang.torrent["attribute"]["tabs"].base
  152. }
  153. });
  154. tabs.tabs("update",{
  155. tab:tabs.tabs("getTab",1)
  156. ,options:{
  157. title:system.lang.torrent["attribute"]["tabs"].servers
  158. }
  159. });
  160. tabs.tabs("update",{
  161. tab:tabs.tabs("getTab",2)
  162. ,options:{
  163. title:system.lang.torrent["attribute"]["tabs"].files
  164. }
  165. });
  166. tabs.tabs("update",{
  167. tab:tabs.tabs("getTab",3)
  168. ,options:{
  169. title:system.lang.torrent["attribute"]["tabs"].users
  170. }
  171. });
  172. tabs.tabs("update",{
  173. tab:tabs.tabs("getTab",4)
  174. ,options:{
  175. title:system.lang.torrent["attribute"]["tabs"]["config"]
  176. }
  177. });
  178. tabs.tabs({
  179. onSelect:function(title,index){
  180. thisLayout.find("#torrent-attribute-tabs").data("selectedIndex",index);
  181. switch (index)
  182. {
  183. // 设置
  184. case 4:
  185. if (system.currentTorrentId==0)
  186. {
  187. return;
  188. }
  189. system.fillTorrentConfig(transmission.torrents.all[system.currentTorrentId]);
  190. break;
  191. }
  192. }
  193. });
  194. var title = ("downloadLimited,seedIdleMode,seedRatioMode,uploadLimited").split(",");
  195. $.each(title, function(i, item){
  196. thisLayout.find("#"+item)
  197. .click(function(){
  198. var checked = this.checked;
  199. var indeterminate = false;
  200. var tag = $(this).data("_tag");
  201. // 用作3态
  202. switch (tag)
  203. {
  204. case 0:
  205. tag = 1;
  206. checked = true;
  207. break;
  208. case 1:
  209. tag = 2;
  210. checked = false;
  211. break;
  212. case 2:
  213. tag = 0;
  214. indeterminate = true;
  215. checked = false;
  216. break;
  217. }
  218. $(this).prop("checked",checked).prop("indeterminate",indeterminate).data("_tag",tag);
  219. thisLayout.find("input[enabledof='"+this.id+"']").prop("disabled",!checked);
  220. });
  221. });
  222. // 初始化文件显示列表
  223. var filelist = $("<table/>").attr("class","torrent-list").attr("id","torrent-files-table").appendTo(thisLayout.find("#torrent-attribute-files"));
  224. $.get(system.rootPath+"template/torrent-attribute-files-fields.json?time="+(new Date()),function(data){
  225. var fields = data.fields;
  226. var config = data.config;
  227. for (var key in fields)
  228. {
  229. fields[key].title = system.lang.torrent.attribute["files-fields"][fields[key].field];
  230. system.setFieldFormat(fields[key]);
  231. }
  232. config.pageSize = system.config.pageSize;
  233. config.columns = [fields];
  234. config.fit = true;
  235. filelist.datagrid(config);
  236. var pager = filelist.datagrid("getPager");
  237. var buttons = [{
  238. id:"pager-button-allow",
  239. iconCls:'icon-allow',
  240. title: system.lang.torrent.attribute["tip"]["button-allow"],
  241. handler:function(){
  242. changeSelectedFilesWanted(true,$(this));
  243. }
  244. },'-',{
  245. id:"pager-button-deny",
  246. iconCls:'icon-deny',
  247. title: system.lang.torrent.attribute["tip"]["button-deny"],
  248. handler:function(){
  249. changeSelectedFilesWanted(false,$(this));
  250. }
  251. },'-',{
  252. id:"pager-button-priority",
  253. iconCls:'icon-flag-edit',
  254. title: system.lang.torrent.attribute["tip"]["button-priority"],
  255. handler:function(){
  256. priorityMenu.menu("show",$(this).offset());
  257. }
  258. },'-',{
  259. id:"torrent-files-filter",
  260. iconCls:"icon-filter",
  261. title: system.lang.torrent.attribute["tip"]["button-filter"],
  262. handler:function(){
  263. filelist.datagrid("getPager").find(".pagination-load").click();
  264. }
  265. }];
  266. var priorityMenu = $("<div/>").attr("id","priorityMenu").appendTo(thisLayout.find("#torrent-attribute-files"));
  267. priorityMenu.menu({
  268. onClick:function(item)
  269. {
  270. changeSelectedFilesPriority(item.id);
  271. }
  272. });
  273. priorityMenu.menu("appendItem",{
  274. id: "0",
  275. text: system.lang.torrent.attribute["priority"]["0"],
  276. iconCls: 'iconlabel icon-flag-0'
  277. });
  278. priorityMenu.menu("appendItem",{
  279. id: "1",
  280. text: system.lang.torrent.attribute["priority"]["1"],
  281. iconCls: 'iconlabel icon-flag-1'
  282. });
  283. priorityMenu.menu("appendItem",{
  284. id: "-1",
  285. text: system.lang.torrent.attribute["priority"]["-1"],
  286. iconCls: 'iconlabel icon-flag--1'
  287. });
  288. filelist.data("buttons",buttons);
  289. //system.debug("pager",pager);
  290. pager.pagination({
  291. buttons:buttons
  292. });
  293. // pager.find("#pager-button-allow").attr({"title":system.lang.torrent.attribute["tip"]["button-allow"],"alt":system.lang.torrent.attribute["tip"]["button-allow"]});
  294. // pager.find("#pager-button-deny").attr({"title":system.lang.torrent.attribute["tip"]["button-deny"],"alt":system.lang.torrent.attribute["tip"]["button-deny"]});
  295. // pager.find("#pager-button-priority").attr({"title":system.lang.torrent.attribute["tip"]["button-priority"],"alt":system.lang.torrent.attribute["tip"]["button-priority"]});
  296. },"json");
  297. // 设置已选中的文件是否下载
  298. function changeSelectedFilesWanted(wanted,button)
  299. {
  300. var rows = filelist.datagrid("getChecked");
  301. var files = new Array();
  302. var arguments = null;
  303. for (var i in rows)
  304. {
  305. files.push(parseInt(rows[i].index));
  306. }
  307. if (files.length>0)
  308. {
  309. if (wanted)
  310. {
  311. arguments = {
  312. ids:system.currentTorrentId
  313. ,"files-wanted":files
  314. };
  315. }
  316. else
  317. {
  318. arguments = {
  319. ids:system.currentTorrentId
  320. ,"files-unwanted":files
  321. };
  322. }
  323. var icon = button.linkbutton("options").iconCls;
  324. button.linkbutton({disabled:true,iconCls:"icon-loading"});
  325. transmission.exec({
  326. method:"torrent-set"
  327. ,arguments:arguments
  328. }
  329. ,function(data){
  330. if (data.result=="success")
  331. {
  332. system.getTorrentInfos(system.currentTorrentId);
  333. }
  334. button.linkbutton({iconCls:icon,disabled:false});
  335. }
  336. );
  337. }
  338. }
  339. // 设置已选中的文件优先级别
  340. function changeSelectedFilesPriority(priority)
  341. {
  342. var rows = filelist.datagrid("getChecked");
  343. var files = new Array();
  344. var arguments = null;
  345. for (var i in rows)
  346. {
  347. files.push(parseInt(rows[i].index));
  348. }
  349. if (files.length>0)
  350. {
  351. switch (priority)
  352. {
  353. case "0":
  354. arguments = {
  355. ids:system.currentTorrentId
  356. ,"priority-normal":files
  357. };
  358. break;
  359. case "1":
  360. arguments = {
  361. ids:system.currentTorrentId
  362. ,"priority-high":files
  363. };
  364. break;
  365. case "-1":
  366. arguments = {
  367. ids:system.currentTorrentId
  368. ,"priority-low":files
  369. };
  370. break;
  371. }
  372. transmission.exec({
  373. method:"torrent-set"
  374. ,arguments:arguments
  375. }
  376. ,function(data){
  377. if (data.result=="success")
  378. {
  379. system.getTorrentInfos(system.currentTorrentId);
  380. }
  381. }
  382. );
  383. }
  384. }
  385. // 服务器列表
  386. var serverlist = $("<table/>").attr("class","torrent-list").attr("id","torrent-servers-table").appendTo(thisLayout.find("#torrent-attribute-servers"));
  387. $.get(system.rootPath+"template/torrent-attribute-servers-fields.json?time="+(new Date()),function(data){
  388. var fields = data.fields;
  389. var config = data.config;
  390. for (var key in fields)
  391. {
  392. var title = system.lang.torrent.attribute["servers-fields"][fields[key].field];
  393. if (!title)
  394. title = fields[key].field;
  395. fields[key].title = title;
  396. system.setFieldFormat(fields[key]);
  397. }
  398. config.pageSize = system.config.pageSize;
  399. config.columns = [fields];
  400. config.fit = true;
  401. serverlist.datagrid(config);
  402. var pager = serverlist.datagrid("getPager");
  403. var buttons = [{
  404. id:"pager-button-trackerAdd",
  405. iconCls:'icon-tracker-add',
  406. title: system.lang.torrent.attribute["tip"]["button-tracker-add"],
  407. handler:function(){
  408. addTracker();
  409. }
  410. },'-',{
  411. id:"pager-button-trackerReplace",
  412. iconCls:'icon-tracker-edit',
  413. title: system.lang.torrent.attribute["tip"]["button-tracker-edit"],
  414. handler:function(){
  415. changeSelectedTracker($(this));
  416. }
  417. },'-',{
  418. id:"pager-button-trackerRemove",
  419. iconCls:'icon-tracker-remove',
  420. title: system.lang.torrent.attribute["tip"]["button-tracker-remove"],
  421. handler:function(){
  422. var tracker = serverlist.datagrid("getSelected");
  423. if (tracker)
  424. {
  425. if (confirm(system.lang.torrent.attribute["other"]["tracker-remove-confim"])==false)
  426. {
  427. return;
  428. }
  429. var button = $(this);
  430. var icon = button.linkbutton("options").iconCls;
  431. button.linkbutton({disabled:true,iconCls:"icon-loading"});
  432. transmission.exec({
  433. method:"torrent-set"
  434. ,arguments:{
  435. ids:system.currentTorrentId
  436. ,trackerRemove:[tracker.id]
  437. }
  438. }
  439. ,function(data){
  440. if (data.result=="success")
  441. {
  442. system.getTorrentInfos(system.currentTorrentId);
  443. }
  444. button.linkbutton({iconCls:icon,disabled:false});
  445. }
  446. );
  447. }
  448. }
  449. }];
  450. serverlist.data("buttons",buttons);
  451. //system.debug("pager",pager);
  452. pager.pagination({
  453. buttons:buttons
  454. });
  455. },"json");
  456. // 替换已选中的服务器地址
  457. function changeSelectedTracker(button)
  458. {
  459. var tracker = serverlist.datagrid("getSelected");
  460. if (tracker)
  461. {
  462. var URL = prompt("Tracker:",tracker.announce);
  463. if (URL!=""&&URL!=tracker.announce)
  464. {
  465. var icon = button.linkbutton("options").iconCls;
  466. button.linkbutton({disabled:true,iconCls:"icon-loading"});
  467. transmission.exec({
  468. method:"torrent-set"
  469. ,arguments:{
  470. ids:system.currentTorrentId
  471. ,trackerReplace:[tracker.id,URL]
  472. }
  473. }
  474. ,function(data){
  475. if (data.result=="success")
  476. {
  477. system.getTorrentInfos(system.currentTorrentId);
  478. }
  479. button.linkbutton({iconCls:icon,disabled:false});
  480. }
  481. );
  482. }
  483. }
  484. }
  485. /**
  486. * 添加Tracker
  487. */
  488. function addTracker() {
  489. if (system.currentTorrentId==0) return;
  490. var dialog = $("#dialog-torrent-attribute-add-tracker");
  491. if (dialog.length)
  492. {
  493. dialog.dialog("open");
  494. dialog.data("ids",system.currentTorrentId);
  495. dialog.dialog({content:system.templates["dialog-torrent-attribute-add-tracker.html"]});
  496. return;
  497. }
  498. $("<div/>").attr("id","dialog-torrent-attribute-add-tracker").appendTo(document.body).dialog({
  499. title: system.lang.dialog["torrent-attribute-add-tracker"].title,
  500. width: 520,
  501. height: 240,
  502. resizable: false,
  503. cache: true,
  504. content:"loading...",
  505. modal: true
  506. });
  507. $.get(system.rootPath+"template/dialog-torrent-attribute-add-tracker.html?time="+(new Date()),function(data){
  508. system.templates["dialog-torrent-attribute-add-tracker.html"] = data;
  509. $("#dialog-torrent-attribute-add-tracker").data("ids",system.currentTorrentId);
  510. $("#dialog-torrent-attribute-add-tracker").dialog({content:data});
  511. });
  512. }
  513. // 用户列表
  514. var peerslist = $("<table/>").attr("class","torrent-list").attr("id","torrent-peers-table").appendTo(thisLayout.find("#torrent-attribute-peers"));
  515. $.get(system.rootPath+"template/torrent-attribute-users-fields.json?time="+(new Date()),function(data){
  516. var fields = data.fields;
  517. var config = data.config;
  518. for (var key in fields)
  519. {
  520. var title = system.lang.torrent.attribute["peers-fields"][fields[key].field];
  521. if (!title)
  522. title = fields[key].field;
  523. fields[key].title = title;
  524. system.setFieldFormat(fields[key]);
  525. }
  526. config.pageSize = system.config.pageSize;
  527. config.columns = [fields];
  528. config.fit = true;
  529. peerslist.datagrid(config);
  530. },"json");
  531. // 变更保存目录
  532. thisLayout.find("#torrent-attribute-config-button-changeDownloadDir").click(function(){
  533. if (system.currentTorrentId==0) return;
  534. var dialog = $("#dialog-torrent-changeDownloadDir");
  535. if (dialog.length)
  536. {
  537. dialog.dialog("open");
  538. dialog.data("ids",system.currentTorrentId);
  539. dialog.dialog({content:system.templates["dialog-torrent-changeDownloadDir.html"]});
  540. return;
  541. }
  542. $("<div/>").attr("id","dialog-torrent-changeDownloadDir").appendTo(document.body).dialog({
  543. title: system.lang.dialog["torrent-changeDownloadDir"].title,
  544. width: 600,
  545. height: 200,
  546. resizable: false,
  547. cache: true,
  548. content:"loading...",
  549. modal: true
  550. });
  551. $.get(system.rootPath+"template/dialog-torrent-changeDownloadDir.html?time="+(new Date()),function(data){
  552. system.templates["dialog-torrent-changeDownloadDir.html"] = data;
  553. $("#dialog-torrent-changeDownloadDir").data("ids",system.currentTorrentId);
  554. $("#dialog-torrent-changeDownloadDir").dialog({content:data});
  555. });
  556. });
  557. // 保存参数
  558. thisLayout.find("#torrent-attribute-config-button-save").click(function()
  559. {
  560. if (system.currentTorrentId==0)
  561. {
  562. return;
  563. }
  564. var torrent = transmission.torrents.all[system.currentTorrentId];
  565. var inputs = thisLayout.find("#torrent-attribute-config").find("input");
  566. var config = {};
  567. var value = null;
  568. for (var key in inputs)
  569. {
  570. var input = inputs[key];
  571. value = null;
  572. if (input.id!=undefined&&input.id!="")
  573. {
  574. switch (input.type)
  575. {
  576. case "checkbox":
  577. switch (input.id)
  578. {
  579. //
  580. case "seedIdleMode":
  581. case "seedRatioMode":
  582. value = $(input).data("_tag");
  583. break;
  584. default:
  585. value = input.checked;
  586. break;
  587. }
  588. break;
  589. default:
  590. value = ($.isNumeric(input.value)?parseFloat(input.value):input.value);
  591. break;
  592. }
  593. if (value!=torrent[input.id]&&value!=null)
  594. {
  595. config[input.id] = value;
  596. }
  597. }
  598. }
  599. // 如果参数有改变则保存
  600. if (!$.isEmptyObject(config))
  601. {
  602. jQuery.extend(torrent,config);
  603. config["ids"] = torrent.id;
  604. $(this).linkbutton({text:system.lang.dialog["system-config"].saving,disabled:true});
  605. // 开始设置参数
  606. transmission.exec(
  607. {
  608. method:"torrent-set"
  609. ,arguments:config
  610. }
  611. ,function(data){
  612. thisLayout.find("#torrent-attribute-config-button-save").linkbutton({text:system.lang.dialog["public"]["button-save"],disabled:false});
  613. if (data.result=="success")
  614. {
  615. thisLayout.find("#torrent-attribute-config-saved").fadeInAndOut();
  616. }
  617. }
  618. );
  619. }
  620. else
  621. {
  622. thisLayout.find("#torrent-attribute-config-nochange").fadeInAndOut();
  623. }
  624. //console.log("config:",config);
  625. });
  626. })($("#torrent-attribute-layout"));
  627. </script>