dialog-system-config.html 57 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201
  1. <div class="easyui-layout" data-options="fit:true" style="width:100%;height:100%;">
  2. <div data-options="region:'center'" style="padding:5px 6px 0px 6px;border:0px;">
  3. <div id="system-config-tabs" class="easyui-tabs" style="width:100%;height:100%;"
  4. data-options="fit:true,plain:true">
  5. <div title="Basic Information" style="padding:5px;padding-right:10px;" class="dialog">
  6. <table style="width:100%;">
  7. <tr>
  8. <td width="100%" colspan="2">
  9. <span id="system-config-download-dir"></span>
  10. <span style="float:right;">(<span id="system-config-download-dir-free-space"></span><span
  11. id="download-dir-free-space"></span>)</span>
  12. </td>
  13. </tr>
  14. <tr>
  15. <td colspan="2"><select id="download-dir" style="width:100%;"></select></td>
  16. </tr>
  17. <tr>
  18. <td colspan="2"><input id="incomplete-dir-enabled" type="checkbox" style="width:16px;"/><label
  19. id="system-config-incomplete-dir-enabled" for="incomplete-dir-enabled"></label></td>
  20. </tr>
  21. <tr>
  22. <td colspan="2"><input id="incomplete-dir" value="" type="text"
  23. enabledof="incomplete-dir-enabled" style="width:100%;"/></td>
  24. </tr>
  25. <tr>
  26. <td colspan="2"><input id="rename-partial-files" type="checkbox" style="width:16px;"/><label
  27. id="system-config-rename-partial-files" for="rename-partial-files"></label></td>
  28. </tr>
  29. <tr>
  30. <td colspan="2"><input id="start-added-torrents" type="checkbox" style="width:16px;"/><label
  31. id="system-config-start-added-torrents" for="start-added-torrents"></label></td>
  32. </tr>
  33. <tr>
  34. <td colspan="2">
  35. <hr/>
  36. </td>
  37. </tr>
  38. <tr>
  39. <td width="65%"><span id="system-config-cache-size-mb"></span></td>
  40. <td width="35%"><input id="cache-size-mb" value="" type="text" class="easyui-numberspinner"
  41. style="width:70px;"/> MB
  42. </td>
  43. </tr>
  44. <tr>
  45. <td colspan="2">
  46. <hr/>
  47. </td>
  48. </tr>
  49. <tr>
  50. <td colspan="2"><input id="script-torrent-done-enabled" type="checkbox"
  51. style="width:16px;"/><label for="script-torrent-done-enabled"
  52. system-lang="dialog['system-config']['script-torrent-done-enabled']"></label>
  53. <a href="https://github.com/ronggang/transmission-web-control/wiki/About-script-torrent-done-filename"
  54. target="_blank">Wiki</a>
  55. </td>
  56. </tr>
  57. <tr>
  58. <td colspan="2"><input id="script-torrent-done-filename" value="" type="text"
  59. enabledof="script-torrent-done-enabled" style="width:100%;"/></td>
  60. </tr>
  61. <tr>
  62. <td colspan="2">
  63. <hr/>
  64. </td>
  65. </tr>
  66. <tr>
  67. <td colspan="2">
  68. <span id="system-config-config-dir"></span>
  69. </td>
  70. </tr>
  71. <tr>
  72. <td colspan="2"><input id="config-dir" value="" type="text" readonly="readonly"
  73. disabled="disabled" style="width:100%;"/></td>
  74. </tr>
  75. <tr>
  76. <td colspan="2">
  77. <hr/>
  78. </td>
  79. </tr>
  80. <tr>
  81. <td colspan="2" align="right">
  82. <span id="system-config-language"></span>&nbsp;<select id="system-config-lang" value=""
  83. style="width:200px;"></select>
  84. </td>
  85. </tr>
  86. </table>
  87. </div>
  88. <div title="Network" style="padding:5px;padding-right:10px;" class="dialog">
  89. <table style="width:100%;">
  90. <tr>
  91. <td width="65%">
  92. <input id="download-queue-enabled" type="checkbox" style="width:16px;"/><label
  93. id="system-config-download-queue-enabled" for="download-queue-enabled"></label>
  94. </td>
  95. <td width="35%"><input id="download-queue-size" value="" type="text"
  96. class="easyui-numberspinner" enabledof="download-queue-enabled"/></td>
  97. </tr>
  98. <tr>
  99. <td>
  100. <input id="seed-queue-enabled" type="checkbox" style="width:16px;"/><label
  101. id="system-config-seed-queue-enabled" for="seed-queue-enabled"></label>
  102. </td>
  103. <td><input id="seed-queue-size" value="" type="text" class="easyui-numberspinner"
  104. enabledof="seed-queue-enabled"/></td>
  105. </tr>
  106. <tr>
  107. <td colspan="2">
  108. <hr/>
  109. </td>
  110. </tr>
  111. <tr>
  112. <td>
  113. <span id="system-config-encryption"></span>
  114. </td>
  115. <td>
  116. <select id="encryption" class="easyui-combobox" data-options="editable:false"></select>
  117. </td>
  118. </tr>
  119. <tr>
  120. <td valign="top">
  121. <input id="peer-port-random-on-start" type="checkbox" style="width:16px;"/><label
  122. id="system-config-peer-port-random-on-start" for="peer-port-random-on-start"></label>
  123. </td>
  124. <td>
  125. <input id="peer-port" value="" type="text" class="easyui-numberspinner"
  126. style="width:70px;"/> <a id="system-config-test-port" href="javascript:void(0);"
  127. class="easyui-linkbutton"
  128. data-options="plain:true,iconCls:'icon-test-port'"></a>
  129. </td>
  130. </tr>
  131. <tr>
  132. <td>
  133. <input id="port-forwarding-enabled" type="checkbox" style="width:16px;"/><label
  134. id="system-config-port-forwarding-enabled" for="port-forwarding-enabled"></label>
  135. </td>
  136. <td>
  137. <span id="system-config-port-is-open-true" style="display:none;color:#339900;"></span>
  138. <span id="system-config-port-is-open-false" style="display:none;color:red;"></span>
  139. </td>
  140. </tr>
  141. <tr>
  142. <td>
  143. <input id="lpd-enabled" type="checkbox" style="width:16px;"/><label
  144. id="system-config-lpd-enabled" for="lpd-enabled"></label>
  145. </td>
  146. <td>
  147. <input id="utp-enabled" type="checkbox" style="width:16px;"/><label
  148. id="system-config-utp-enabled" for="utp-enabled"></label>
  149. </td>
  150. </tr>
  151. <tr>
  152. <td>
  153. <input id="dht-enabled" type="checkbox" style="width:16px;"/><label
  154. id="system-config-dht-enabled" for="dht-enabled"></label>
  155. </td>
  156. <td>
  157. <input id="pex-enabled" type="checkbox" style="width:16px;"/><label
  158. id="system-config-pex-enabled" for="pex-enabled"></label>
  159. </td>
  160. </tr>
  161. <tr>
  162. <td colspan="2">
  163. <hr/>
  164. </td>
  165. </tr>
  166. <tr>
  167. <td colspan="2">
  168. <input id="blocklist-enabled" type="checkbox" style="width:16px;"/><label
  169. id="system-config-blocklist-enabled" for="blocklist-enabled"></label>
  170. </td>
  171. </tr>
  172. <tr>
  173. <td colspan="2">
  174. <input id="blocklist-url" type="text" enabledof="blocklist-enabled"/>
  175. </td>
  176. </tr>
  177. <tr>
  178. <td colspan="2">
  179. <span id="system-config-blocklist-size"
  180. system-lang="dialog['system-config']['blocklist-size']"></span>
  181. <button id="system-conifg-button-update-blocklist" class="easyui-linkbutton"
  182. data-options="iconCls:'iconfont tr-icon-reload'"
  183. system-lang="dialog['public']['button-update']"
  184. enabledof="blocklist-enabled"></button>
  185. </td>
  186. </tr>
  187. </table>
  188. </div>
  189. <div title="Limit" style="padding:5px;padding-right:10px;" class="dialog">
  190. <table style="width:100%;">
  191. <tr>
  192. <td width="65%">
  193. <input id="speed-limit-down-enabled" type="checkbox" style="width:16px;"/><label
  194. id="system-config-speed-limit-down-enabled" for="speed-limit-down-enabled"></label>
  195. </td>
  196. <td width="35%"><input id="speed-limit-down" value="" type="text" class="easyui-numberspinner"
  197. enabledof="speed-limit-down-enabled"/> KB/s
  198. </td>
  199. </tr>
  200. <tr>
  201. <td>
  202. <input id="speed-limit-up-enabled" type="checkbox" style="width:16px;"/><label
  203. id="system-config-speed-limit-up-enabled" for="speed-limit-up-enabled"></label>
  204. </td>
  205. <td><input id="speed-limit-up" value="" type="text" class="easyui-numberspinner"
  206. enabledof="speed-limit-up-enabled"/> KB/s
  207. </td>
  208. </tr>
  209. <tr>
  210. <td colspan="2">
  211. <hr/>
  212. </td>
  213. </tr>
  214. <tr>
  215. <td>
  216. <span id="system-config-peer-limit-global"></span>
  217. </td>
  218. <td>
  219. <input id="peer-limit-global" value="" type="text" class="easyui-numberspinner"/>
  220. </td>
  221. </tr>
  222. <tr>
  223. <td>
  224. <span id="system-config-peer-limit-per-torrent"></span>
  225. </td>
  226. <td>
  227. <input id="peer-limit-per-torrent" value="" type="text" class="easyui-numberspinner"/>
  228. </td>
  229. </tr>
  230. <tr>
  231. <td colspan="2">
  232. <hr/>
  233. </td>
  234. </tr>
  235. <tr>
  236. <td>
  237. <input id="seedRatioLimited" type="checkbox" style="width:16px;"/><label
  238. id="system-config-seedRatioLimited" for="seedRatioLimited"></label>
  239. </td>
  240. <td><input id="seedRatioLimit" value="" type="text" class="easyui-numberspinner"
  241. enabledof="seedRatioLimited" data-options="precision:2"/></td>
  242. </tr>
  243. <tr>
  244. <td>
  245. <input id="idle-seeding-limit-enabled" type="checkbox" style="width:16px;"/><label
  246. id="system-config-idle-seeding-limit-enabled" for="idle-seeding-limit-enabled"></label>
  247. </td>
  248. <td><input id="idle-seeding-limit" value="" type="text" class="easyui-numberspinner"
  249. enabledof="idle-seeding-limit-enabled"/> <span name="system-config-minutes"></span>
  250. </td>
  251. </tr>
  252. <tr>
  253. <td>
  254. <input id="queue-stalled-enabled" type="checkbox" style="width:16px;"/><label
  255. id="system-config-queue-stalled-enabled" for="queue-stalled-enabled"></label>
  256. </td>
  257. <td><input id="queue-stalled-minutes" value="" type="text" class="easyui-numberspinner"
  258. enabledof="queue-stalled-enabled"/> <span name="system-config-minutes"></span></td>
  259. </tr>
  260. </table>
  261. </div>
  262. <div title="Alt speeds" style="padding:5px;" class="dialog">
  263. <fieldset>
  264. <table style="width:100%;">
  265. <tr>
  266. <td width="65%">
  267. <span id="system-config-alt-speed-down"></span>
  268. </td>
  269. <td width="35%"><input id="alt-speed-down" value="" type="text" class="easyui-numberspinner"
  270. _enabledof="alt-speed-enabled"/> KB/s
  271. </td>
  272. </tr>
  273. <tr>
  274. <td>
  275. <label id="system-config-alt-speed-up"></label>
  276. </td>
  277. <td><input id="alt-speed-up" value="" type="text" class="easyui-numberspinner"
  278. _enabledof="alt-speed-enabled"/> KB/s
  279. </td>
  280. </tr>
  281. </table>
  282. </fieldset>
  283. <fieldset>
  284. <legend id="">
  285. <input id="alt-speed-time-enabled" type="checkbox" style="width:16px;"/><label
  286. id="system-config-alt-speed-time-enabled" for="alt-speed-time-enabled"></label>
  287. </legend>
  288. <table style="width:100%;">
  289. <tr>
  290. <td>
  291. <span id="system-config-alt-speed-time"></span>
  292. <input id="alt-speed-time-begin" value="" type="text" class="easyui-timespinner"
  293. style="width:80px;" enabledof="alt-speed-time-enabled"/> -
  294. <input id="alt-speed-time-end" value="" type="text" class="easyui-timespinner"
  295. style="width:80px;" enabledof="alt-speed-time-enabled"/>
  296. </td>
  297. </tr>
  298. <tr>
  299. <td style="padding:10px 0px 5px 0px;">
  300. <input id="alt-speed-time-weekday-1" type="checkbox" style="width:16px;"
  301. enabledof="alt-speed-time-enabled"/><label id="system-config-weekday-1"
  302. for="alt-speed-time-weekday-1"></label>
  303. <input id="alt-speed-time-weekday-2" type="checkbox" style="width:16px;"
  304. enabledof="alt-speed-time-enabled"/><label id="system-config-weekday-2"
  305. for="alt-speed-time-weekday-2"></label>
  306. <input id="alt-speed-time-weekday-3" type="checkbox" style="width:16px;"
  307. enabledof="alt-speed-time-enabled"/><label id="system-config-weekday-3"
  308. for="alt-speed-time-weekday-3"></label>
  309. <input id="alt-speed-time-weekday-4" type="checkbox" style="width:16px;"
  310. enabledof="alt-speed-time-enabled"/><label id="system-config-weekday-4"
  311. for="alt-speed-time-weekday-4"></label>
  312. <input id="alt-speed-time-weekday-5" type="checkbox" style="width:16px;"
  313. enabledof="alt-speed-time-enabled"/><label id="system-config-weekday-5"
  314. for="alt-speed-time-weekday-5"></label>
  315. <input id="alt-speed-time-weekday-6" type="checkbox" style="width:16px;"
  316. enabledof="alt-speed-time-enabled"/><label id="system-config-weekday-6"
  317. for="alt-speed-time-weekday-6"></label>
  318. <input id="alt-speed-time-weekday-0" type="checkbox" style="width:16px;"
  319. enabledof="alt-speed-time-enabled"/><label id="system-config-weekday-0"
  320. for="alt-speed-time-weekday-0"></label>
  321. </td>
  322. </tr>
  323. </table>
  324. </fieldset>
  325. <input id="alt-speed-enabled" type="checkbox" style="width:16px;"/><label
  326. id="system-config-alt-speed-enabled" for="alt-speed-enabled"></label>
  327. </div>
  328. <div title="Folders Dictionary" style="padding:5px;padding-right:10px;" class="dialog">
  329. <table style="width:100%;height:100%;">
  330. <tr>
  331. <td width="100%" height="100%">
  332. <textarea id="local-storage-dictionary-folders" style="width:100%;height:100%;"></textarea>
  333. </td>
  334. </tr>
  335. </table>
  336. </div>
  337. <div title="More" style="padding:10px;" class="dialog">
  338. <table style="width:100%;">
  339. <tr>
  340. <td width="80%">
  341. <label for="show-bt-servers"
  342. system-lang="dialog['system-config']['show-bt-servers']"></label>
  343. </td>
  344. <td>
  345. <input id="show-bt-servers" class="easyui-switchbutton" type="checkbox" config-type="1"/>
  346. </td>
  347. </tr>
  348. <tr>
  349. <td>
  350. <label for="hide-subfolders"
  351. system-lang="dialog['system-config']['hide-subfolders']"></label>
  352. </td>
  353. <td>
  354. <input id="hide-subfolders" class="easyui-switchbutton" type="checkbox" config-type="1"/>
  355. </td>
  356. </tr>
  357. <tr>
  358. <td>
  359. <label for="simpleCheckMode"
  360. system-lang="dialog['system-config']['simple-check-mode']"></label>
  361. </td>
  362. <td>
  363. <input id="simpleCheckMode" class="easyui-switchbutton" type="checkbox" config-type="1"/>
  364. </td>
  365. </tr>
  366. <tr>
  367. <td colspan="2">
  368. <hr/>
  369. </td>
  370. </tr>
  371. <tr>
  372. <td colspan="2"><span system-lang="dialog['system-config']['nav-contents']"></span></td>
  373. </tr>
  374. <tr>
  375. <td>
  376. <label system-lang="tree['servers']"></label>
  377. </td>
  378. <td>
  379. <input id="nav-servers" class="easyui-switchbutton" type="checkbox" config-type="1"/>
  380. </td>
  381. </tr>
  382. <tr>
  383. <td>
  384. <label system-lang="tree['folders']"></label>
  385. </td>
  386. <td>
  387. <input id="nav-folders" class="easyui-switchbutton" type="checkbox" config-type="1"/>
  388. </td>
  389. </tr>
  390. <tr>
  391. <td>
  392. <label system-lang="tree['statistics']['title']"></label>
  393. </td>
  394. <td>
  395. <input id="nav-statistics" class="easyui-switchbutton" type="checkbox" config-type="1"/>
  396. </td>
  397. </tr>
  398. <tr>
  399. <td>
  400. <label system-lang="tree['labels']"></label>
  401. </td>
  402. <td>
  403. <input id="nav-labels" class="easyui-switchbutton" type="checkbox" config-type="1"/>
  404. </td>
  405. </tr>
  406. <tr>
  407. <td colspan="2">
  408. <hr/>
  409. </td>
  410. </tr>
  411. <tr>
  412. <td colspan="2">
  413. <label system-lang="dialog['system-config']['ipinfo']"></label>
  414. <a id="system-config-test-port" href="http://ipinfo.io" target="_blank"
  415. class="easyui-linkbutton"
  416. data-options="plain:true,iconCls:'icon-about'"></a>
  417. <input id="ipInfoToken" value="" class="easyui-textbox" type="text" style="width: 100%;"/>
  418. </td>
  419. </tr>
  420. <tr>
  421. <td colspan="2">
  422. <hr/>
  423. </td>
  424. </tr>
  425. <tr>
  426. <td colspan="2">
  427. <label system-lang="dialog['system-config']['ipInfoCustom']"></label><br>
  428. <label system-lang="dialog['system-config']['ipInfoCountryCodeUrl']"></label>
  429. <input id="ipInfoFlagUrl" value="" class="easyui-textbox"
  430. data-options="prompt:'%protocol//%hostname:5000/code/%ip',buttonText:'Test'" type="text" style="width: 100%"/><br>
  431. <label system-lang="dialog['system-config']['ipInfoDetailUrl']"></label>
  432. <input id="ipInfoDetailUrl" value="" class="easyui-textbox"
  433. data-options="prompt:'%protocol//%hostname:5000/detail/%ip/%navlang',buttonText:'Test'" type="text" style="width: 100%"/><br>
  434. <label system-lang="dialog['system-config']['ipInfoCustomTips']"></label>
  435. </td>
  436. </tr>
  437. </table>
  438. </div>
  439. <div title="User Labels" style="padding:5px;" class="dialog">
  440. <div id="divLabels" style="width:100%;height: 100%;"></div>
  441. <div id="divLabelsToolbar" style="height: auto;">
  442. <a id="btn-UserLabel-addNew" href="javascript:void(0)" class="easyui-linkbutton"
  443. data-options="iconCls:'iconfont tr-icon-plus',plain:true"
  444. system-lang="dialog['public']['button-addnew']"></a>
  445. <a id="btn-UserLabel-remove" href="javascript:void(0)" class="easyui-linkbutton"
  446. style="color:crimson;" data-options="iconCls:'iconfont tr-icon-delete',plain:true"
  447. system-lang="dialog['public']['button-delete']"></a>
  448. <span class="button-split">|</span>
  449. <a id="btn-UserLabel-import" href="javascript:void(0)" class="easyui-linkbutton"
  450. data-options="iconCls:'iconfont tr-icon-download',plain:true"
  451. system-lang="dialog['public']['button-import']"></a>
  452. <a id="btn-UserLabel-export" href="javascript:void(0)" class="easyui-linkbutton"
  453. data-options="iconCls:'iconfont tr-icon-upload',plain:true"
  454. system-lang="dialog['public']['button-export']"></a>
  455. </div>
  456. </div>
  457. </div>
  458. </div>
  459. <div data-options="region:'south',border:false" style="text-align:right;padding:6px;">
  460. <a id="system-config-button-reload" href="javascript:void(0)" class="easyui-linkbutton"
  461. data-options="plain:true,iconCls:'icon-reload'" style="float:left;display:none;"></a>
  462. <button id="restore-default-settings" style="float:left;"
  463. system-lang="dialog['system-config']['restore-default-settings']"
  464. data-options="iconCls:'iconfont tr-icon-restore',plain:true" class="easyui-linkbutton"></button>
  465. <span style="float:left;margin-top: 4px;height: auto;" class="button-split">|</span>
  466. <button id="btn-import-config" style="float:left;" system-lang="dialog['public']['button-import']"
  467. system-tip-lang="dialog['system-config']['import-config']"
  468. data-options="iconCls:'iconfont tr-icon-download',plain:true" class="easyui-linkbutton"></button>
  469. <button id="btn-export-config" style="float:left;" system-lang="dialog['public']['button-export']"
  470. system-tip-lang="dialog['system-config']['export-config']"
  471. data-options="iconCls:'iconfont tr-icon-upload',plain:true" class="easyui-linkbutton"></button>
  472. <span id="system-config-nochange" style="display:none;"></span>
  473. <span id="system-config-saved" style="display:none;"></span>
  474. <a id="system-config-button-save" class="easyui-linkbutton" data-options="iconCls:'icon-save',plain:true"
  475. href="javascript:void(0);">Ok</a>
  476. <a id="system-config-button-cancel" class="easyui-linkbutton" data-options="iconCls:'icon-cancel',plain:true"
  477. href="javascript:void(0);">Cancel</a>
  478. </div>
  479. </div>
  480. <script type="text/javascript">
  481. (function (thisDialog) {
  482. var page = {
  483. selectedIndex: -1,
  484. init: function () {
  485. this.initLangText();
  486. this.initTabs();
  487. this.initLanguageCombo();
  488. this.initConfigValue();
  489. this.initEvents();
  490. this.initUserLabels();
  491. },
  492. // 初始化选项卡
  493. initTabs: function () {
  494. var tabs = thisDialog.find('#system-config-tabs');
  495. tabs.tabs();
  496. var base = tabs.tabs('getTab', 0);
  497. tabs.tabs('update', {
  498. tab: tabs.tabs('getTab', 0),
  499. options: {
  500. title: system.lang.dialog['system-config'].tabs.base
  501. }
  502. });
  503. tabs.tabs('update', {
  504. tab: tabs.tabs('getTab', 1),
  505. options: {
  506. title: system.lang.dialog['system-config'].tabs.network
  507. }
  508. });
  509. tabs.tabs('update', {
  510. tab: tabs.tabs('getTab', 2),
  511. options: {
  512. title: system.lang.dialog['system-config'].tabs.limit
  513. }
  514. });
  515. tabs.tabs('update', {
  516. tab: tabs.tabs('getTab', 3),
  517. options: {
  518. title: system.lang.dialog['system-config'].tabs['alt-speed']
  519. }
  520. });
  521. tabs.tabs('update', {
  522. tab: tabs.tabs('getTab', 4),
  523. options: {
  524. title: system.lang.dialog['system-config'].tabs['dictionary-folders']
  525. }
  526. });
  527. tabs.tabs('update', {
  528. tab: tabs.tabs('getTab', 5),
  529. options: {
  530. title: system.lang.dialog['system-config'].tabs['more']
  531. }
  532. });
  533. tabs.tabs('update', {
  534. tab: tabs.tabs('getTab', 6),
  535. options: {
  536. title: system.lang.dialog['system-config'].tabs['labels']
  537. }
  538. });
  539. },
  540. // Set the language
  541. initLanguageCombo: function () {
  542. $.each(system.languages, function (key, value) {
  543. $('<option/>').text(value).val(key).attr('selected', (key == system.lang.name ? true : false)).appendTo(thisDialog.find('#system-config-lang'));
  544. });
  545. $('#system-config-lang', thisDialog).combobox({
  546. editable: false,
  547. panelHeight: 'auto'
  548. });
  549. },
  550. // 初始化界面文字
  551. initLangText: function () {
  552. var title = 'button-save,button-cancel,button-reload'.split(',');
  553. $.each(title, function (i, item) {
  554. thisDialog.find('#system-config-' + item).html(system.lang.dialog.public[item]);
  555. });
  556. system.resetLangText(thisDialog);
  557. thisDialog.find('#system-config-blocklist-size').html(system.lang.dialog['system-config']['blocklist-size'].replace('%n', system.serverConfig['blocklist-size']));
  558. title = ('config-dir,download-dir,incomplete-dir-enabled,cache-size-mb,rename-partial-files,download-dir-free-space,start-added-torrents' +
  559. ',download-queue-enabled,seed-queue-enabled,encryption,peer-port-random-on-start,speed-limit-down-enabled,speed-limit-up-enabled' +
  560. ',alt-speed-enabled,alt-speed-down,alt-speed-up,test-port,port-forwarding-enabled,utp-enabled,dht-enabled,lpd-enabled,pex-enabled' +
  561. ',peer-limit-global,peer-limit-per-torrent,blocklist-enabled,seedRatioLimited,queue-stalled-enabled,idle-seeding-limit-enabled' +
  562. ',alt-speed-time-enabled,alt-speed-time,nochange,port-is-open-true,port-is-open-false,language'
  563. ).split(',');
  564. $.each(title, function (i, item) {
  565. thisDialog.find('#system-config-' + item).html(system.lang.dialog['system-config'][item]);
  566. });
  567. thisDialog.find('span[name=\'system-config-minutes\']').html(system.lang.dialog['system-config']['minutes']);
  568. },
  569. // 初始化参数值
  570. initConfigValue: function () {
  571. // Replace system settings
  572. var title = ('incomplete-dir-enabled,rename-partial-files,start-added-torrents,download-queue-enabled,seed-queue-enabled' +
  573. ',peer-port-random-on-start,speed-limit-down-enabled,speed-limit-up-enabled,alt-speed-enabled,idle-seeding-limit-enabled' +
  574. ',port-forwarding-enabled,utp-enabled,dht-enabled,lpd-enabled,pex-enabled,blocklist-enabled,seedRatioLimited,queue-stalled-enabled' +
  575. ',alt-speed-time-enabled,script-torrent-done-enabled'
  576. ).split(',');
  577. $.each(title, function (i, item) {
  578. thisDialog.find('#' + item).prop('checked', system.serverConfig[item])
  579. .click(function () {
  580. thisDialog.find('*[enabledof=\'' + this.id + '\']').prop('disabled', !this.checked);
  581. if (this.checked) {
  582. thisDialog.find('.easyui-numberspinner[enabledof=\'' + this.id + '\']').numberspinner('enable');
  583. thisDialog.find('.easyui-timespinner[enabledof=\'' + this.id + '\']').timespinner('enable');
  584. thisDialog.find('.easyui-linkbutton[enabledof=\'' + this.id + '\']').linkbutton('enable');
  585. } else {
  586. thisDialog.find('.easyui-numberspinner[enabledof=\'' + this.id + '\']').numberspinner('disable');
  587. thisDialog.find('.easyui-timespinner[enabledof=\'' + this.id + '\']').timespinner('disable');
  588. thisDialog.find('.easyui-linkbutton[enabledof=\'' + this.id + '\']').linkbutton('disable');
  589. }
  590. });
  591. });
  592. // Set content
  593. thisDialog.find('#download-dir').val(system.downloadDir);
  594. $('<option/>').text(system.downloadDir).val(system.downloadDir).attr('selected', true).appendTo(thisDialog.find('#download-dir'));
  595. $.each(transmission.downloadDirs, function (i, item) {
  596. if (item === system.downloadDir){
  597. return
  598. }
  599. $('<option/>').text(item).val(item).appendTo(thisDialog.find('#download-dir'));
  600. });
  601. thisDialog.find('#download-dir').combobox();
  602. thisDialog.find('#config-dir').val(system.serverConfig['config-dir']);
  603. thisDialog.find('#incomplete-dir').val(system.serverConfig['incomplete-dir']);
  604. thisDialog.find('#incomplete-dir').prop('disabled', !system.serverConfig['incomplete-dir-enabled']);
  605. thisDialog.find('#cache-size-mb').val(system.serverConfig['cache-size-mb']);
  606. thisDialog.find('#download-queue-size').val(system.serverConfig['download-queue-size']).prop('disabled', !system.serverConfig['download-queue-enabled']);
  607. thisDialog.find('#seed-queue-size').val(system.serverConfig['seed-queue-size']).prop('disabled', !system.serverConfig['seed-queue-enabled']);
  608. thisDialog.find('#peer-port').val(system.serverConfig['peer-port']).prop('disabled', system.serverConfig['peer-port-random-on-start']);
  609. thisDialog.find('#speed-limit-down').val(system.serverConfig['speed-limit-down']).prop('disabled', !system.serverConfig['speed-limit-down-enabled']);
  610. thisDialog.find('#speed-limit-up').val(system.serverConfig['speed-limit-up']).prop('disabled', !system.serverConfig['speed-limit-up-enabled']);
  611. thisDialog.find('#alt-speed-down').val(system.serverConfig['alt-speed-down']);
  612. thisDialog.find('#alt-speed-up').val(system.serverConfig['alt-speed-up']);
  613. thisDialog.find('#alt-speed-time-begin').val(getHoursFromMinutes(system.serverConfig['alt-speed-time-begin'])).prop('disabled', !system.serverConfig['alt-speed-time-enabled']);
  614. thisDialog.find('#alt-speed-time-end').val(getHoursFromMinutes(system.serverConfig['alt-speed-time-end'])).prop('disabled', !system.serverConfig['alt-speed-time-enabled']);
  615. var days = ('0000000' + system.serverConfig['alt-speed-time-day'].toString(2)).right(7).split('').reverse();
  616. var weekday = system.lang.dialog['system-config']['weekday'];
  617. // Set schedule
  618. for (var day in weekday) {
  619. thisDialog.find('#alt-speed-time-weekday-' + day).prop('checked', (days[day] == 1 ? true : false)).prop('disabled', !system.serverConfig['alt-speed-time-enabled']);
  620. thisDialog.find('#system-config-weekday-' + day).text(weekday[day]);
  621. }
  622. thisDialog.find('#peer-limit-global').val(system.serverConfig['peer-limit-global']);
  623. thisDialog.find('#peer-limit-per-torrent').val(system.serverConfig['peer-limit-per-torrent']);
  624. thisDialog.find('#blocklist-url').val(system.serverConfig['blocklist-url']).prop('disabled', !system.serverConfig['blocklist-enabled']);
  625. thisDialog.find('#system-conifg-button-update-blocklist').prop('disabled', !system.serverConfig['blocklist-enabled']);
  626. thisDialog.find('#seedRatioLimit').val(system.serverConfig['seedRatioLimit']).prop('disabled', !system.serverConfig['seedRatioLimited']);
  627. thisDialog.find('#queue-stalled-minutes').val(system.serverConfig['queue-stalled-minutes']).prop('disabled', !system.serverConfig['queue-stalled-enabled']);
  628. thisDialog.find('#idle-seeding-limit').val(system.serverConfig['idle-seeding-limit']).prop('disabled', !system.serverConfig['idle-seeding-limit-enabled']);
  629. thisDialog.find('#script-torrent-done-filename').val(system.serverConfig['script-torrent-done-filename']).prop('disabled', !system.serverConfig['script-torrent-done-enabled']);
  630. var etype = system.lang.dialog['system-config']['encryption-type'];
  631. for (var key in etype) {
  632. $('<option/>').val(key).attr('selected', (key == system.serverConfig['encryption'] ? true : false)).text(etype[key]).appendTo(thisDialog.find('#encryption'));
  633. }
  634. var tmp = system.serverConfig['download-dir-free-space'];
  635. if (tmp == -1) {
  636. tmp = system.lang.public['text-unknown'];
  637. } else {
  638. tmp = formatSize(tmp);
  639. }
  640. thisDialog.find('#download-dir-free-space').text(tmp);
  641. // Local dictionary folder list (not including transmission.downloadDirs)
  642. if (system.dictionary.folders == null || system.dictionary.folders == '') {
  643. thisDialog.find('#local-storage-dictionary-folders').val('');
  644. } else {
  645. thisDialog.find('#local-storage-dictionary-folders').val(system.dictionary.folders);
  646. }
  647. //thisDialog.find("#local-storage-dictionary-folders").val(transmission.downloadDirs);
  648. thisDialog.find('#show-bt-servers').switchbutton({
  649. checked: system.config.showBTServers
  650. });
  651. thisDialog.find('#hide-subfolders').switchbutton({
  652. checked: system.config.hideSubfolders
  653. });
  654. thisDialog.find('#simpleCheckMode').switchbutton({
  655. checked: system.config.simpleCheckMode
  656. });
  657. thisDialog.find('#ipInfoToken').val(system.config.ipInfoToken);
  658. thisDialog.find('#ipInfoFlagUrl').val(system.config.ipInfoFlagUrl);
  659. thisDialog.find('#ipInfoDetailUrl').val(system.config.ipInfoDetailUrl);
  660. for (var key in system.config.nav) {
  661. var value = system.config.nav[key];
  662. thisDialog.find('#nav-' + key).switchbutton({
  663. checked: value
  664. });
  665. }
  666. },
  667. // 初始化相关按钮事件
  668. initEvents: function () {
  669. // Cancel
  670. thisDialog.find('#system-config-button-cancel').click(function () {
  671. thisDialog.dialog('close');
  672. });
  673. /**/
  674. // 测试端口
  675. thisDialog.find('#system-config-test-port').click(function () {
  676. var button = $(this);
  677. var newPort = parseInt(thisDialog.find('#peer-port').val());
  678. function buttonPortTestStatus(enabled) {
  679. button.linkbutton({
  680. text: system.lang.dialog['system-config'][enabled?'test-port':'testing'],
  681. disabled: !enabled
  682. });
  683. }
  684. function labelPortOpenStatus(opened) {
  685. if (opened) {
  686. thisDialog.find('#system-config-port-is-open-true').fadeInAndOut();
  687. } else {
  688. thisDialog.find('#system-config-port-is-open-false').fadeInAndOut();
  689. }
  690. }
  691. buttonPortTestStatus(false);
  692. // 如果端口有变更,则先保存
  693. if (newPort != system.serverConfig['peer-port']) {
  694. transmission.exec({
  695. method: 'session-set',
  696. arguments: {
  697. 'peer-port': newPort
  698. }
  699. }, function (data) {
  700. if (data.result == 'success') {
  701. system.serverConfig['peer-port'] = newPort;
  702. transmission.exec({
  703. method: 'port-test'
  704. }, function (data) {
  705. if (data.result == 'success') {
  706. labelPortOpenStatus(data.arguments['port-is-open']==true);
  707. }
  708. buttonPortTestStatus(true);
  709. });
  710. } else {
  711. buttonPortTestStatus(true);
  712. }
  713. });
  714. } else {
  715. transmission.exec({
  716. method: 'port-test'
  717. }, function (data) {
  718. if (data.result == 'success') {
  719. labelPortOpenStatus(data.arguments['port-is-open']==true);
  720. }
  721. buttonPortTestStatus(true);
  722. });
  723. }
  724. });
  725. // 保存参数
  726. thisDialog.find('#system-config-button-save').click(function () {
  727. var inputs = thisDialog.find('input');
  728. var config = {};
  729. var days = new Array();
  730. var value = null;
  731. var reloadPage = false;
  732. // 提交标签列表的变更
  733. if (page.endEditing()) {
  734. page.userLabelsTable.datagrid('acceptChanges');
  735. }
  736. for (var i = 0; i < inputs.length; i++) {
  737. var input = inputs[i];
  738. var configType = input.getAttribute('config-type') || 0;
  739. value = null;
  740. // 0 表示服务器配置,默认为0
  741. if (configType == 0 && input.id != undefined && input.id != '') {
  742. switch (input.type) {
  743. case 'checkbox':
  744. switch (input.id) {
  745. // 星期
  746. case 'alt-speed-time-weekday-0':
  747. case 'alt-speed-time-weekday-1':
  748. case 'alt-speed-time-weekday-2':
  749. case 'alt-speed-time-weekday-3':
  750. case 'alt-speed-time-weekday-4':
  751. case 'alt-speed-time-weekday-5':
  752. case 'alt-speed-time-weekday-6':
  753. days.push(input.checked ? 1 : 0);
  754. break;
  755. default:
  756. value = input.checked;
  757. break;
  758. }
  759. break;
  760. default:
  761. switch (input.id) {
  762. // 限制时间
  763. case 'alt-speed-time-begin':
  764. case 'alt-speed-time-end':
  765. value = getMinutesFromHours(input.value);
  766. break;
  767. default:
  768. value = ($.isNumeric(input.value) ? parseFloat(input.value) : input.value);
  769. break;
  770. }
  771. break;
  772. }
  773. if (value != system.serverConfig[input.id] && value != null) {
  774. config[input.id] = value;
  775. }
  776. }
  777. }
  778. //console.log("days:",days);
  779. var sunday = days.pop();
  780. //console.log("days1:",days);
  781. days.unshift(sunday);
  782. value = parseInt(days.reverse().join(''), 2);
  783. if (value != system.serverConfig['alt-speed-time-day'] && value != null) {
  784. config['alt-speed-time-day'] = value;
  785. }
  786. value = thisDialog.find('#encryption').combobox('getValue');
  787. if (value != system.serverConfig['encryption'] && value != null) {
  788. config['encryption'] = value;
  789. }
  790. value = thisDialog.find('#download-dir').combobox('getValue');
  791. if (value != system.serverConfig['download-dir'] && value != null) {
  792. config['download-dir'] = value;
  793. }
  794. system.config.showBTServers = thisDialog.find('#show-bt-servers').prop('checked');
  795. system.config.hideSubfolders = thisDialog.find('#hide-subfolders').prop('checked');
  796. system.config.simpleCheckMode = thisDialog.find('#simpleCheckMode').prop('checked');
  797. system.config.ipInfoToken = thisDialog.find('#ipInfoToken').val();
  798. system.config.ipInfoFlagUrl = thisDialog.find('#ipInfoFlagUrl').val();
  799. system.config.ipInfoDetailUrl = thisDialog.find('#ipInfoDetailUrl').val();
  800. var _temp = JSON.stringify(system.config.nav);
  801. for (var key in system.config.nav) {
  802. system.config.nav[key] = thisDialog.find('#nav-' + key).prop('checked');
  803. }
  804. if (_temp != JSON.stringify(system.config.nav)) {
  805. reloadPage = true;
  806. }
  807. var cuslang = thisDialog.find('#system-config-lang').val();
  808. // If the parameters are changed, save
  809. if (!$.isEmptyObject(config)) {
  810. $(this).linkbutton({
  811. text: system.lang.dialog['system-config'].saving,
  812. disabled: true
  813. });
  814. // Start setting parameters
  815. transmission.exec({
  816. method: 'session-set',
  817. arguments: config
  818. }, function (data) {
  819. if (data.result == 'success') {
  820. // Once the settings are successful, regain the current parameters
  821. transmission.exec({
  822. method: 'session-get'
  823. }, function (data) {
  824. if (data.result == 'success') {
  825. system.serverConfig = data.arguments;
  826. $('#status_version').html(system.lang.statusbar.version + data.arguments['version']);
  827. if (data.arguments['alt-speed-enabled'] == true) {
  828. system.panel.toolbar.find('#toolbar_alt_speed').linkbutton({
  829. iconCls: 'icon-alt-speed-true'
  830. });
  831. $('#status_alt_speed').show();
  832. } else {
  833. system.panel.toolbar.find('#toolbar_alt_speed').linkbutton({
  834. iconCls: 'icon-alt-speed-false'
  835. });
  836. $('#status_alt_speed').hide();
  837. }
  838. system.downloadDir = data.arguments['download-dir'];
  839. saveLocalData();
  840. if (cuslang != system.lang.name) {
  841. system.changeLanguages(cuslang);
  842. }
  843. }
  844. });
  845. }
  846. });
  847. return;
  848. }
  849. // If the language changes, reload the page
  850. else if (cuslang != system.lang.name) {
  851. system.changeLanguages(cuslang);
  852. } else {
  853. if (system.dictionary.folders == thisDialog.find('#local-storage-dictionary-folders').val()) {
  854. thisDialog.find('#system-config-nochange').fadeInAndOut();
  855. return;
  856. }
  857. }
  858. saveLocalData();
  859. // Save the local data
  860. function saveLocalData () {
  861. if (thisDialog.find('#local-storage-dictionary-folders').val().replace(/^\s*[\r\n]/gm, '').length == 0) {
  862. system.dictionary.folders = '';
  863. } else {
  864. system.dictionary.folders = thisDialog.find('#local-storage-dictionary-folders').val().replace(/^\s*[\r\n]/gm, '');
  865. }
  866. system.saveConfig();
  867. if (reloadPage) {
  868. location.href = location.href;
  869. } else {
  870. thisDialog.dialog('close');
  871. }
  872. }
  873. });
  874. // Update blacklist
  875. thisDialog.find('#system-conifg-button-update-blocklist').click(function () {
  876. var button = $(this);
  877. button.prop('disabled', true);
  878. transmission.updateBlocklist(function (data) {
  879. if (data.result == 'success') {
  880. thisDialog.find('#system-config-blocklist-size').html(system.lang.dialog['system-config']['blocklist-size'].replace('%n', data.arguments['blocklist-size']));
  881. }
  882. ;
  883. button.prop('disabled', false);
  884. });
  885. });
  886. thisDialog.find('#ipInfoFlagUrl').textbox({onClickButton: function (){
  887. if (this.value !== '' && this.value !== undefined) {
  888. alert(system.expandIpInfoUrl(this.value, '8.8.8.8'));
  889. }
  890. }});
  891. thisDialog.find('#ipInfoDetailUrl').textbox({onClickButton: function (){
  892. if (this.value !== '' && this.value !== undefined) {
  893. alert(system.expandIpInfoUrl(this.value, '8.8.8.8'));
  894. }
  895. }});
  896. // 恢复界面默认设置
  897. $('#restore-default-settings', thisDialog).click(function () {
  898. if (confirm(system.lang['public']['text-confirm']) == false) {
  899. return;
  900. }
  901. system.config = {};
  902. system.userConfig = {};
  903. system.saveConfig();
  904. system.saveUserConfig();
  905. location.href = location.href;
  906. });
  907. },
  908. // 初始化用户标签列表
  909. initUserLabels: function () {
  910. this.userLabelsTable = $('<table/>').appendTo($('#divLabels', thisDialog));
  911. var headContextMenu = null;
  912. var selectedIndex = -1;
  913. // 添加
  914. $('#btn-UserLabel-addNew', thisDialog).on('click', function () {
  915. if (page.endEditing()) {
  916. page.userLabelsTable.datagrid('appendRow', {
  917. 'ck': false,
  918. 'color': '#000000'
  919. });
  920. page.editIndex = page.userLabelsTable.datagrid('getRows').length - 1;
  921. page.userLabelsTable.datagrid('selectRow', page.editIndex).datagrid('beginEdit', page.editIndex);
  922. }
  923. });
  924. // 删除
  925. $('#btn-UserLabel-remove', thisDialog).on('click', function () {
  926. var checkedRows = page.userLabelsTable.datagrid('getChecked');
  927. if (checkedRows.length == 0) {
  928. return;
  929. }
  930. if (!confirm(system.lang['public']['text-confirm'])) {
  931. return;
  932. }
  933. page.userLabelsTable.datagrid('cancelEdit', page.editIndex);
  934. var removed = [];
  935. for (var index = checkedRows.length - 1; index >= 0; index--) {
  936. var item = checkedRows[index];
  937. var rowIndex = page.userLabelsTable.datagrid('getRowIndex', item);
  938. console.log(rowIndex);
  939. removed.push(rowIndex);
  940. page.userLabelsTable.datagrid('deleteRow', rowIndex);
  941. system.config.labels.splice(rowIndex, 1);
  942. }
  943. // 清除已打过标签的种子
  944. for (var key in system.config.labelMaps) {
  945. if (system.config.labelMaps.hasOwnProperty(key)) {
  946. var items = system.config.labelMaps[key];
  947. for (var index = items.length - 1; index >= 0; index--) {
  948. if ($.inArray(items[index], removed) != -1) {
  949. items.splice(index, 1);
  950. }
  951. }
  952. }
  953. }
  954. system.saveConfig();
  955. system.control.torrentlist.refresh();
  956. system.resetNavLabels(true);
  957. page.editIndex = undefined;
  958. });
  959. // 导出
  960. $('#btn-UserLabel-export', thisDialog).on('click', function () {
  961. var data = {
  962. labels: system.config.labels,
  963. maps: system.config.labelMaps
  964. };
  965. var exportData = JSON.parse(JSON.stringify(data));
  966. saveFileAs('tr-web-control-labels.json', JSON.stringify(exportData));
  967. });
  968. // 导入
  969. $('#btn-UserLabel-import', thisDialog).on('click', function () {
  970. loadFileContent('json', function (content) {
  971. var item = content;
  972. if (typeof (content) === 'string') {
  973. try {
  974. item = JSON.parse(content);
  975. } catch (error) {
  976. alert(system.lang['public']['text-json-file-parsing-failed']);
  977. return;
  978. }
  979. }
  980. if (item.labels && item.maps) {
  981. if (confirm(system.lang.dialog['system-config']['labels-manage']['import-confirm'])) {
  982. system.config.labels = item.labels;
  983. system.config.labelMaps = item.maps;
  984. system.saveConfig();
  985. reloadData();
  986. system.control.torrentlist.refresh();
  987. system.resetNavLabels(true);
  988. }
  989. }
  990. });
  991. });
  992. function reloadData () {
  993. page.userLabelsTable.empty();
  994. $.get(system.rootPath + 'template/config-user-labels-fields.json?time=' + (new Date()), function (data) {
  995. var fields = data.fields;
  996. var _fields = {};
  997. for (var i = 0; i < fields.length; i++) {
  998. var item = fields[i];
  999. _fields[item.field] = item;
  1000. }
  1001. for (var key in fields) {
  1002. var item = fields[key];
  1003. var _field = _fields[item.field];
  1004. if (_field && _field['formatter']) {
  1005. item['formatter'] = _field['formatter'];
  1006. }
  1007. item.title = system.lang.dialog['system-config']['labels-manage'][item.field] || item.field;
  1008. system.setFieldFormat(item);
  1009. }
  1010. page.userLabelsTable.datagrid({
  1011. autoRowHeight: true,
  1012. rownumbers: true,
  1013. remoteSort: false,
  1014. checkOnSelect: false,
  1015. singleSelect: true,
  1016. selectOnCheck: false,
  1017. toolbar: $('#divLabelsToolbar', thisDialog),
  1018. fit: true,
  1019. striped: true,
  1020. columns: [fields],
  1021. data: system.config.labels,
  1022. onSelect: function (rowIndex, rowData) {
  1023. if (page.selectedIndex != -1) {
  1024. // page.userLabelsTable.datagrid("unselectRow", page.selectedIndex);
  1025. }
  1026. page.selectedIndex = rowIndex;
  1027. },
  1028. onUnselect: function (rowIndex, rowData) {
  1029. page.selectedIndex = -1;
  1030. },
  1031. onClickCell: function (index, field) {
  1032. if (page.editIndex != index) {
  1033. if (page.endEditing()) {
  1034. page.userLabelsTable.datagrid('selectRow', index).datagrid('beginEdit', index);
  1035. var ed = page.userLabelsTable.datagrid('getEditor', { index: index, field: field });
  1036. if (ed) {
  1037. ($(ed.target).data('textbox') ? $(ed.target).textbox('textbox') : $(ed.target)).focus();
  1038. }
  1039. page.editIndex = index;
  1040. } else {
  1041. setTimeout(function () {
  1042. page.userLabelsTable.datagrid('selectRow', page.editIndex);
  1043. }, 0);
  1044. }
  1045. }
  1046. },
  1047. onEndEdit: function (index, row, changes) {
  1048. if (row.name) {
  1049. if (row.ck !== undefined) {
  1050. delete row.ck;
  1051. }
  1052. system.config.labels[index] = row;
  1053. system.saveConfig();
  1054. system.control.torrentlist.refresh();
  1055. system.resetNavLabels(true);
  1056. }
  1057. }
  1058. });
  1059. }, 'json');
  1060. };
  1061. reloadData();
  1062. $('#btn-export-config', thisDialog).on('click.cus', function () {
  1063. page.exportConfig(this);
  1064. });
  1065. $('#btn-import-config', thisDialog).on('click', function () {
  1066. page.importConfig(this);
  1067. });
  1068. },
  1069. endEditing: function () {
  1070. if (page.editIndex == undefined) {return true;}
  1071. if (page.userLabelsTable.datagrid('validateRow', page.editIndex)) {
  1072. page.userLabelsTable.datagrid('endEdit', page.editIndex);
  1073. page.editIndex = undefined;
  1074. return true;
  1075. } else {
  1076. return false;
  1077. }
  1078. },
  1079. importConfig: function (button) {
  1080. loadFileContent('json', function (content) {
  1081. var item = content;
  1082. if (typeof (content) === 'string') {
  1083. try {
  1084. item = JSON.parse(content);
  1085. } catch (error) {
  1086. alert(system.lang['public']['text-json-file-parsing-failed']);
  1087. return;
  1088. }
  1089. }
  1090. if (item.system || item.user || item.server || item.dictionary) {
  1091. system.openDialogFromTemplate({
  1092. id: 'dialog-import-config',
  1093. options: {
  1094. title: system.lang.dialog['import-config'].title,
  1095. width: 500,
  1096. height: 120
  1097. },
  1098. datas: {
  1099. config: item
  1100. },
  1101. type: 1,
  1102. source: $(button),
  1103. onClose: function () {
  1104. $(button).on('click', function () {
  1105. page.importConfig(this);
  1106. });
  1107. }
  1108. });
  1109. } else {
  1110. alert(system.lang.dialog['import-config']['invalid-file']);
  1111. // thisDialog.find("#system-config-nochange").html(system.lang.dialog["import-config"]["invalid-file"]).fadeInAndOut();
  1112. }
  1113. });
  1114. },
  1115. /**
  1116. * 导出当前配置到文件
  1117. */
  1118. exportConfig: function (button) {
  1119. system.openDialogFromTemplate({
  1120. id: 'dialog-export-config',
  1121. options: {
  1122. title: system.lang.dialog['export-config'].title,
  1123. width: 500,
  1124. height: 120
  1125. },
  1126. type: 1,
  1127. source: $(button),
  1128. onClose: function () {
  1129. $(button).on('click', function () {
  1130. page.exportConfig(this);
  1131. });
  1132. }
  1133. });
  1134. }
  1135. };
  1136. page.init();
  1137. })($('#dialog-system-config'));
  1138. </script>