wbw_channal_list.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. var _wbw_channel;
  2. function wbw_channal_list_init() {
  3. let channelListHtml = "";
  4. let style = "<style>";
  5. style += "#wbw_channal_list_dlg_content .ui-widget-content{border:unset;} ";
  6. style += "#wbw_channal_list_dlg_content .ui-widget-header{background:unset;border:unset;border-bottom: 1px solid #dddddd;} ";
  7. style += "</style>";
  8. channelListHtml += '<div id="wbw_channal_list_dlg" title=' + gLocal.gui.open + gLocal.gui.wbw + '>';
  9. channelListHtml += style;
  10. channelListHtml += '<div id="wbw_channal_list_dlg_content">';
  11. channelListHtml += '<div id="tabs">';
  12. channelListHtml += '<ul>';
  13. channelListHtml += '<li><a href="#tabs-1">我的<span id="my-num" class="circle_num">3</span></a></li>';
  14. channelListHtml += '<li><a href="#tabs-2">协作<span id="co-num" class="circle_num">2</span></a></li>';
  15. channelListHtml += '<li><a href="#tabs-3">网络公开<span id="pu-num" class="circle_num">1</span></a></li>';
  16. channelListHtml += '</ul>';
  17. channelListHtml += '<div id="tabs-1">';
  18. channelListHtml += '</div>';
  19. channelListHtml += '<div id="tabs-2">';
  20. channelListHtml += '</div>';
  21. channelListHtml += '<div id="tabs-3">';
  22. channelListHtml += '</div>';
  23. channelListHtml += '</div>';
  24. channelListHtml += '</div>';
  25. channelListHtml += '</div>';
  26. $("body").append(channelListHtml);
  27. $("#wbw_channal_list_dlg").dialog({
  28. autoOpen: false,
  29. width: 700,
  30. height:650,
  31. maxHeight: $(window).height()*0.7,
  32. buttons: [
  33. {
  34. text: gLocal.gui.cancel,
  35. click: function () {
  36. $(this).dialog("close");
  37. },
  38. },
  39. ],
  40. });
  41. $( "#tabs" ).tabs();
  42. }
  43. function wbw_channal_list_open(book, paralist) {
  44. $.post(
  45. "../uwbw/wbw_channel_list.php",
  46. {
  47. book: book,
  48. para: JSON.stringify(paralist),
  49. },
  50. function (data) {
  51. _wbw_channel = JSON.parse(data);
  52. if (_wbw_channel.status == 0) {
  53. let htmlMy = "";
  54. let htmlCollaborate = "";
  55. let htmlPublic = "";
  56. let myNum = 0;
  57. let coNum = 0;
  58. let puNum = 0;
  59. for (let index = 0; index < _wbw_channel.data.length; index++) {
  60. const element = _wbw_channel.data[index];
  61. let html = "";
  62. html += "<div style='display:flex;line-height: 2.5em;border-bottom: 1px solid gray;'>";
  63. html += "<span style='flex:3'>";
  64. let style = "";
  65. let text = "";
  66. if (parseInt(element.wbw_para) > 0) {
  67. if (parseInt(element.power) < 20) {
  68. text = "查看";
  69. style = "background-color: yellow;";
  70. } else {
  71. text = gLocal.gui.edit;
  72. style = "background-color: greenyellow;";
  73. }
  74. } else {
  75. text = gLocal.gui.new;
  76. }
  77. html +=
  78. "<button style='" + style + "' onclick=\"wbw_create('" + index + "')\">" + text + "</button>";
  79. if (parseInt(element.power) < 30) {
  80. html += "<button onclick=\"wbw_fork('" + index + "')\">";
  81. html += gLocal.gui.copy_to;
  82. html += "</button>";
  83. }
  84. html += "</span>";
  85. html += "<span style='flex:1'>" + (index + 1) + "</span>";
  86. html += "<span style='flex:5'>" + element.name + "</span>";
  87. html += "<span style='flex:2'>";
  88. let power = [
  89. { id: 10, note: gLocal.gui.viewer },
  90. { id: 20, note: gLocal.gui.editor },
  91. { id: 30, note: gLocal.gui.owner },
  92. ];
  93. for (const iterator of power) {
  94. if (parseInt(element.power) == iterator.id) {
  95. html += iterator.note;
  96. }
  97. }
  98. html += "</span>";
  99. html += "<span style='flex:2'>";
  100. html += element.user.nickname;
  101. html += "</span>";
  102. html += "<span style='flex:1;text-align: right;'>" + element.lang + "</span>";
  103. html += "<span style='flex:2;display:none;'>" + element.wbw_para + "/" + element.count + "</span>";
  104. html += "</div>";
  105. switch (element.type) {
  106. case "my":
  107. htmlMy +=html;
  108. myNum++;
  109. break;
  110. case "collaborate":
  111. htmlCollaborate +=html;
  112. coNum++
  113. break;
  114. case "public":
  115. htmlPublic +=html;
  116. puNum++
  117. break;
  118. }
  119. }
  120. $("#tabs-1").html(htmlMy);
  121. $("#tabs-2").html(htmlCollaborate);
  122. $("#tabs-3").html(htmlPublic);
  123. $("#my-num").text(myNum);
  124. $("#co-num").text(coNum);
  125. $("#pu-num").text(puNum);
  126. $("#wbw_channal_list_dlg").dialog("open");
  127. } else {
  128. ntf_show(_wbw_channel.error);
  129. }
  130. }
  131. );
  132. }
  133. function wbw_create(index) {
  134. $("#wbw_channal_list_dlg").dialog("close");
  135. $.post(
  136. "../uwbw/create_wbw.php",
  137. {
  138. book: _wbw_channel.book,
  139. para: _wbw_channel.para,
  140. lang: _wbw_channel.data[index].lang,
  141. channel: _wbw_channel.data[index].id,
  142. },
  143. function (data) {
  144. let msg = JSON.parse(data);
  145. if (msg.status == 0) {
  146. let book = msg.book;
  147. let paralist = msg.para.join(",");
  148. let channel = msg.channel;
  149. let url =
  150. "../studio/editor.php?op=openchannel&book=" + book + "&par=" + paralist + "&channel=" + channel;
  151. window.open(url, "_blank");
  152. $("#wbw_channal_list_dlg").dialog("close");
  153. } else {
  154. ntf_show(msg.error);
  155. }
  156. }
  157. );
  158. }
  159. function wbw_fork(index) {
  160. $("#wbw_channal_list_dlg").dialog("close");
  161. let url =
  162. "../doc/fork_channel.php?book=" +
  163. _wbw_channel.book +
  164. "&para=" +
  165. _wbw_channel.para +
  166. "&src_channel=" +
  167. _wbw_channel.data[index].id;
  168. window.open(url, "_blank");
  169. }