wbw_channal_list.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. var _wbw_channel;
  2. function wbw_channal_list_init() {
  3. $("body").append(
  4. '<div id="wbw_channal_list_dlg" title=' +
  5. gLocal.gui.open +
  6. gLocal.gui.wbw +
  7. '><div id="wbw_channal_list_dlg_content"></div></div>'
  8. );
  9. $("#wbw_channal_list_dlg").dialog({
  10. autoOpen: false,
  11. width: 550,
  12. buttons: [
  13. {
  14. text: gLocal.gui.cancel,
  15. click: function () {
  16. $(this).dialog("close");
  17. },
  18. },
  19. ],
  20. });
  21. }
  22. function wbw_channal_list_open(book, paralist) {
  23. $.post(
  24. "../uwbw/wbw_channel_list.php",
  25. {
  26. book: book,
  27. para: JSON.stringify(paralist),
  28. },
  29. function (data) {
  30. _wbw_channel = JSON.parse(data);
  31. if (_wbw_channel.status == 0) {
  32. let html = "";
  33. for (let index = 0; index < _wbw_channel.data.length; index++) {
  34. const element = _wbw_channel.data[index];
  35. html += "<div style='display:flex;line-height: 2.5em;border-bottom: 1px solid gray;'>";
  36. html += "<span style='flex:4'>";
  37. let style = "";
  38. let text = "";
  39. if (parseInt(element.wbw_para) > 0) {
  40. if (parseInt(element.power) < 20) {
  41. text = "查看";
  42. style = "background-color: yellow;";
  43. } else {
  44. text = gLocal.gui.edit;
  45. style = "background-color: greenyellow;";
  46. }
  47. } else {
  48. text = gLocal.gui.new;
  49. }
  50. html +=
  51. "<button style='" + style + "' onclick=\"wbw_create('" + index + "')\">" + text + "</button>";
  52. if (parseInt(element.power) < 30) {
  53. html += "<button onclick=\"wbw_fork('" + index + "')\">";
  54. html += "复制到";
  55. html += "</button>";
  56. }
  57. html += "</span>";
  58. html += "<span style='flex:1'>" + (index + 1) + "</span>";
  59. html += "<span style='flex:5'>" + element.name + "</span>";
  60. html += "<span style='flex:1'>";
  61. let power = [
  62. { id: 10, note: "查看者" },
  63. { id: 20, note: "编辑者" },
  64. { id: 30, note: "拥有者" },
  65. ];
  66. for (const iterator of power) {
  67. if (parseInt(element.power) == iterator.id) {
  68. html += iterator.note;
  69. }
  70. }
  71. html += "</span>";
  72. html += "<span style='flex:2'>" + element.lang + "</span>";
  73. html += "<span style='flex:2;display:none;'>" + element.wbw_para + "/" + element.count + "</span>";
  74. html += "</div>";
  75. }
  76. $("#wbw_channal_list_dlg_content").html(html);
  77. $("#wbw_channal_list_dlg").dialog("open");
  78. } else {
  79. ntf_show(_wbw_channel.error);
  80. }
  81. }
  82. );
  83. }
  84. function wbw_create(index) {
  85. $("#wbw_channal_list_dlg").dialog("close");
  86. $.post(
  87. "../uwbw/create_wbw.php",
  88. {
  89. book: _wbw_channel.book,
  90. para: _wbw_channel.para,
  91. lang: _wbw_channel.data[index].lang,
  92. channel: _wbw_channel.data[index].id,
  93. },
  94. function (data) {
  95. let msg = JSON.parse(data);
  96. if (msg.status == 0) {
  97. $("#wbw_channal_list_dlg_content").html("正在打开编辑窗口");
  98. let book = msg.book;
  99. let paralist = msg.para.join(",");
  100. let channel = msg.channel;
  101. let url =
  102. "../studio/editor.php?op=openchannal&book=" + book + "&para=" + paralist + "&channal=" + channel;
  103. window.open(url, "_blank");
  104. $("#wbw_channal_list_dlg").dialog("close");
  105. } else {
  106. ntf_show(msg.error);
  107. }
  108. }
  109. );
  110. }
  111. function wbw_fork(index) {
  112. $("#wbw_channal_list_dlg").dialog("close");
  113. let url =
  114. "../doc/fork_channel.php?book=" +
  115. _wbw_channel.book +
  116. "&para=" +
  117. _wbw_channel.para +
  118. "&src_channel=" +
  119. _wbw_channel.data[index].id;
  120. window.open(url, "_blank");
  121. }