wbw_channal_list.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. var _wbw_channel;
  2. function wbw_channal_list_init() {
  3. $("body").append(
  4. '<div id="wbw_channal_list_dlg" title="Open WBW"><div id="wbw_channal_list_dlg_content"></div></div>'
  5. );
  6. $("#wbw_channal_list_dlg").dialog({
  7. autoOpen: false,
  8. width: 550,
  9. buttons: [
  10. {
  11. text: "Cancel",
  12. click: function () {
  13. $(this).dialog("close");
  14. },
  15. },
  16. ],
  17. });
  18. }
  19. function wbw_channal_list_open(book, paralist) {
  20. $.post(
  21. "../uwbw/wbw_channel_list.php",
  22. {
  23. book: book,
  24. para: JSON.stringify(paralist),
  25. },
  26. function (data) {
  27. _wbw_channel = JSON.parse(data);
  28. if (_wbw_channel.status == 0) {
  29. let html = "";
  30. for (let index = 0; index < _wbw_channel.data.length; index++) {
  31. const element = _wbw_channel.data[index];
  32. html += "<div style='display:flex;'>";
  33. html += "<span style='flex:2'>";
  34. html += "<button onclick=\"wbw_create('" + index + "')\">";
  35. if (parseInt(element.wbw_para) > 0) {
  36. html += "打开";
  37. } else {
  38. html += "新建";
  39. }
  40. html += "</button>";
  41. html += "</span>";
  42. html += "<span style='flex:1'>" + (index + 1) + "</span>";
  43. html += "<span style='flex:3'>" + element.name + "</span>";
  44. html += "<span style='flex:2'>" + element.lang + "</span>";
  45. html += "<span style='flex:2'>" + element.wbw_para + "/" + element.count + "</span>";
  46. html += "</div>";
  47. }
  48. $("#wbw_channal_list_dlg_content").html(html);
  49. $("#wbw_channal_list_dlg").dialog("open");
  50. } else {
  51. ntf_show(_wbw_channel.error);
  52. }
  53. }
  54. );
  55. }
  56. function wbw_create(index) {
  57. $.post(
  58. "../uwbw/create_wbw.php",
  59. {
  60. book: _wbw_channel.book,
  61. para: _wbw_channel.para,
  62. lang: _wbw_channel.data[index].lang,
  63. channel: _wbw_channel.data[index].id,
  64. },
  65. function (data) {
  66. let msg = JSON.parse(data);
  67. if (msg.status == 0) {
  68. $("#wbw_channal_list_dlg_content").html("正在打开编辑窗口");
  69. let book = msg.book;
  70. let paralist = msg.para.join(",");
  71. let channel = msg.channel;
  72. let url =
  73. "../studio/editor.php?op=openchannal&book=" + book + "&para=" + paralist + "&channal=" + channel;
  74. window.open(url, "_blank");
  75. $("#wbw_channal_list_dlg").dialog("close");
  76. } else {
  77. ntf_show(msg.error);
  78. }
  79. }
  80. );
  81. }