dialog-torrent-changeSpeedLimit.html 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <div
  2. class="easyui-layout"
  3. data-options="fit:true"
  4. style="width: 100%; height: 100%"
  5. >
  6. <div data-options="region:'left'" style="padding: 3px; border: 0px">
  7. <div
  8. id="torrent-speed-limit"
  9. class="dialog"
  10. style="width: 100%; padding: 0px"
  11. >
  12. <table style="width: 100%">
  13. <tr>
  14. <td class="title">
  15. <input
  16. id="checkbox-downloadLimited"
  17. type="checkbox"
  18. style="width: 16px"
  19. />
  20. <label
  21. id="dialog-torrent-changeSpeedLimit-downloadLimited"
  22. for="downloadLimited"
  23. ></label>
  24. </td>
  25. <td>
  26. <input
  27. id="text-downloadLimit"
  28. type="text"
  29. class="easyui-numberspinner"
  30. enabledof="downloadLimited"
  31. style="width: 200px"
  32. />
  33. KB/s
  34. </td>
  35. </tr>
  36. <tr>
  37. <td class="title">
  38. <input
  39. id="checkbox-uploadLimited"
  40. type="checkbox"
  41. style="width: 16px"
  42. />
  43. <label
  44. id="dialog-torrent-changeSpeedLimit-uploadLimited"
  45. for="uploadLimited"
  46. ></label>
  47. </td>
  48. <td>
  49. <input
  50. id="text-uploadLimit"
  51. type="text"
  52. class="easyui-numberspinner"
  53. enabledof="uploadLimited"
  54. style="width: 200px"
  55. />
  56. KB/s
  57. </td>
  58. </tr>
  59. <tr>
  60. <td class="title">
  61. <span id="dialog-torrent-changeSpeedLimit-peer-limit"></span>
  62. </td>
  63. <td>
  64. <input
  65. id="text-peer-limit"
  66. value=""
  67. type="text"
  68. class="easyui-numberspinner"
  69. style="width: 200px"
  70. />
  71. </td>
  72. <td></td>
  73. <td></td>
  74. </tr>
  75. <tr>
  76. <td colspan="2"><hr /></td>
  77. </tr>
  78. </table>
  79. </div>
  80. </div>
  81. <div
  82. data-options="region:'south',border:false"
  83. style="text-align: right; padding: 6px"
  84. >
  85. <a
  86. id="torrent-button-ok"
  87. class="easyui-linkbutton"
  88. data-options="iconCls:'icon-ok',plain:true"
  89. href="javascript:void(0);"
  90. >Ok</a
  91. >
  92. <a
  93. id="torrent-button-cancel"
  94. class="easyui-linkbutton"
  95. data-options="iconCls:'icon-cancel',plain:true"
  96. href="javascript:void(0);"
  97. >Cancel</a
  98. >
  99. </div>
  100. </div>
  101. <script type="text/javascript">
  102. (function (thisDialog) {
  103. var title = "downloadLimited,uploadLimited,peer-limit,seedRatioMode,seedIdleMode,doneDate,seedTime".split(
  104. ","
  105. );
  106. var ids = thisDialog.data("ids");
  107. var allIds = new Array();
  108. var issimple = false;
  109. var torrent = null;
  110. var recheck = false;
  111. if (typeof ids == "object") {
  112. torrent = transmission.torrents.all[ids[0]];
  113. } else {
  114. torrent = transmission.torrents.all[ids];
  115. issimple = true;
  116. }
  117. if (!torrent) {
  118. thisDialog.dialog("close");
  119. return;
  120. }
  121. //初始化label
  122. $.each(title, function (i, item) {
  123. thisDialog
  124. .find("#dialog-torrent-changeSpeedLimit-" + item)
  125. .html(system.lang.dialog["torrent-changeSpeedLimit"][item]);
  126. });
  127. //初始化按钮
  128. title = "button-ok,button-cancel".split(",");
  129. $.each(title, function (i, item) {
  130. thisDialog
  131. .find("#torrent-" + item)
  132. .html(system.lang.dialog["public"][item]);
  133. });
  134. $.ajaxSettings.async = false;
  135. //初始化界面数据,获取第一个种子的信息
  136. transmission.torrents.getConfig(ids[0], function (result) {
  137. //debugger;
  138. if (result == null) return;
  139. var cur_torrent = result[0];
  140. thisDialog
  141. .find("#checkbox-downloadLimited")
  142. .prop("checked", cur_torrent.downloadLimited);
  143. thisDialog
  144. .find("#checkbox-uploadLimited")
  145. .prop("checked", cur_torrent.uploadLimited);
  146. thisDialog.find("#text-downloadLimit").val(cur_torrent.downloadLimit);
  147. thisDialog.find("#text-uploadLimit").val(cur_torrent.uploadLimit);
  148. thisDialog.find("#text-peer-limit").val(cur_torrent["peer-limit"]);
  149. });
  150. //debugger;
  151. $.ajaxSettings.async = true;
  152. // 确认
  153. thisDialog.find("#torrent-button-ok").click(function () {
  154. var ids = thisDialog.data("ids");
  155. if (ids.length == 0) {
  156. return;
  157. }
  158. //获取界面设置值,并写入config
  159. var torrent = transmission.torrents.all[ids[0]];
  160. var inputs = thisDialog.find("#torrent-speed-limit").find("input");
  161. var config = {};
  162. var value = null;
  163. for (var key in inputs) {
  164. var input = inputs[key];
  165. value = null;
  166. if (input.id != undefined && input.id != "") {
  167. switch (input.type) {
  168. case "checkbox":
  169. switch (input.id) {
  170. //
  171. case "seedIdleMode":
  172. case "seedRatioMode":
  173. value = $(input).data("_tag");
  174. break;
  175. default:
  176. value = input.checked;
  177. break;
  178. }
  179. break;
  180. default:
  181. value = $.isNumeric(input.value)
  182. ? parseFloat(input.value)
  183. : input.value;
  184. break;
  185. }
  186. if (value != torrent[input.id] && value != null) {
  187. config[
  188. input.id.replace("text-", "").replace("checkbox-", "")
  189. ] = value;
  190. }
  191. }
  192. }
  193. //debugger;
  194. //设置为同步
  195. $.ajaxSettings.async = false;
  196. for (var i = 0; i < ids.length; i++) {
  197. config["ids"] = ids[i];;
  198. // var index = i + 1;
  199. // $(this).linkbutton({
  200. // text:
  201. // system.lang.dialog["system-config"].saving +
  202. // "(" +
  203. // index +
  204. // "/" +
  205. // ids.length +
  206. // ")",
  207. // disabled: true,
  208. // });
  209. // 开始设置参数
  210. transmission.exec(
  211. {
  212. method: "torrent-set",
  213. arguments: config,
  214. },
  215. function (data) {
  216. if (data.result == "success") {
  217. } else {
  218. button.linkbutton({ iconCls: icon, disabled: false });
  219. $.messager.alert(
  220. "",
  221. system.lang.error["data-post-error"] + ": " + data.result,
  222. "error"
  223. );
  224. }
  225. }
  226. );
  227. }
  228. $.ajaxSettings.async = true; //变回异步
  229. //修改按钮文本
  230. // thisDialog.find("#torrent-attribute-config-button-save").linkbutton({
  231. // text: system.lang.dialog["public"]["button-save"],
  232. // disabled: false,
  233. // });
  234. //清空种子选择状态
  235. system.control.torrentlist.datagrid("uncheckAll");
  236. //刷新种子
  237. //system.reloadTorrentBaseInfos();
  238. //关闭弹窗
  239. thisDialog.dialog("close");
  240. });
  241. thisDialog.find("#torrent-button-cancel").click(function () {
  242. thisDialog.dialog("close");
  243. });
  244. })($("#dialog-torrent-changeSpeedLimit"));
  245. </script>