dialog-torrent-rename.html 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <div class="easyui-layout" data-options="fit:true" style="width:100%;height:100%;">
  2. <div data-options="region:'center'" style="padding:3px;border:0px;">
  3. <div id="" class="dialog" style="width:100%;">
  4. <table style="width:100%;">
  5. <tr>
  6. <td width="20%" class="title"><span system-lang="dialog['torrent-rename']['oldname']"></span></td>
  7. <td width="80%">
  8. <span id="oldname" ></span>
  9. </td>
  10. </tr>
  11. <tr>
  12. <td class="title"><span system-lang="dialog['torrent-rename']['newname']"></span></td>
  13. <td>
  14. <textarea id="newname" style="width:98%;height:50px;"></textarea>
  15. </td>
  16. </tr>
  17. <tr>
  18. <td colspan="2"><hr/></td>
  19. </tr>
  20. </table>
  21. </div>
  22. </div>
  23. <div data-options="region:'south',border:false" style="text-align:right;padding:6px;">
  24. <span id="text-infos" style="display:none;" system-lang="['public']['text-nochange']"></span>
  25. <a id="button-ok" class="easyui-linkbutton" data-options="iconCls:'icon-ok',plain:true" href="javascript:void(0);" system-lang="dialog['public']['button-ok']"></a>
  26. <a id="button-cancel" class="easyui-linkbutton" data-options="iconCls:'icon-cancel',plain:true" href="javascript:void(0);" system-lang="dialog['public']['button-cancel']"></a>
  27. </div>
  28. </div>
  29. <script type="text/javascript">
  30. (function(thisDialog){
  31. system.resetLangText(thisDialog);
  32. var torrent = transmission.torrents.all[thisDialog.data("id")];
  33. thisDialog.find("#oldname").text(torrent.name);
  34. thisDialog.find("#newname").val(torrent.name);
  35. // 确认
  36. thisDialog.find("#button-ok").click(function()
  37. {
  38. var oldValue = thisDialog.find("#oldname").text();
  39. var newValue = thisDialog.find("#newname").val();
  40. var button = $(this);
  41. // 如果有指定參數時,開始替換
  42. if (oldValue&&newValue&&(oldValue!=newValue))
  43. {
  44. if (confirm(system.lang["public"]["text-confirm"])==false)
  45. {
  46. return;
  47. }
  48. var icon = button.linkbutton("options").iconCls;
  49. button.linkbutton({disabled:true,iconCls:"icon-loading"});
  50. // 开始设置参数
  51. transmission.renameTorrent(
  52. torrent.id
  53. ,""
  54. ,newValue
  55. ,function(data){
  56. button.linkbutton({iconCls:icon,disabled:false});
  57. if (data.result!="success")
  58. {
  59. thisDialog.find("#text-infos").html(system.lang["error"]["rename-error"]).fadeInAndOut();
  60. return;
  61. }
  62. torrent.moreInfosTag = false;
  63. system.reloadTorrentBaseInfos(data.arguments.id, ["name"]);
  64. thisDialog.dialog("close");
  65. }
  66. );
  67. }
  68. else
  69. {
  70. thisDialog.find("#text-infos").fadeInAndOut();
  71. }
  72. });
  73. thisDialog.find("#button-cancel").click(function()
  74. {
  75. thisDialog.dialog("close");
  76. });
  77. })($("#dialog-torrent-rename"));
  78. </script>