term_edit_dlg.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. function term_edit_dlg_init(title = "Trem") {
  2. $("body").append(
  3. '<div id="term_edit_dlg" title="' +
  4. title +
  5. '"><div id="term_edit_dlg_content"></div></div>'
  6. );
  7. $("#term_edit_dlg").dialog({
  8. autoOpen: false,
  9. width: 550,
  10. buttons: [
  11. {
  12. text: "Save",
  13. click: function () {
  14. term_edit_dlg_save();
  15. $(this).dialog("close");
  16. },
  17. },
  18. {
  19. text: "Cancel",
  20. click: function () {
  21. $(this).dialog("close");
  22. },
  23. },
  24. ],
  25. });
  26. }
  27. function term_edit_dlg_open(id = "") {
  28. if (id == "") {
  29. $("#term_edit_dlg").dialog("open");
  30. } else {
  31. $.post(
  32. "../term/term_get_id.php",
  33. {
  34. id: id,
  35. },
  36. function (data) {
  37. let word = JSON.parse(data);
  38. let html = term_edit_dlg_render(word);
  39. $("#term_edit_dlg_content").html(html);
  40. $("#term_edit_dlg").dialog("open");
  41. }
  42. );
  43. }
  44. }
  45. function term_edit_dlg_render(word = "") {
  46. if (word == "") {
  47. word = new Object();
  48. word.pali = "";
  49. }
  50. let output = "";
  51. output +=
  52. "<input type='hidden' id='term_edit_form_id' value='" + word.guid + "'>";
  53. output += "<fieldset>";
  54. output += "<legend>Spell</legend>";
  55. output +=
  56. "<input type='input' id='term_edit_form_word' value='" + word.word + "'>";
  57. output += "</fieldset>";
  58. output += "<fieldset>";
  59. output += "<legend>Meaning</legend>";
  60. output +=
  61. "<input type='input' id='term_edit_form_meaning' value='" +
  62. word.meaning +
  63. "'>";
  64. output += "</fieldset>";
  65. output += "<fieldset>";
  66. output += "<legend>Meaning</legend>";
  67. output +=
  68. "<input type='input' id='term_edit_form_othermeaning value='" +
  69. word.other_meaning +
  70. "'>";
  71. output += "</fieldset>";
  72. output += "<fieldset>";
  73. output += "<legend>Language</legend>";
  74. output +=
  75. "<input type='input' id='term_edit_form_language' value='" +
  76. word.language +
  77. "'>";
  78. output += "</fieldset>";
  79. output += "<fieldset>";
  80. output += "<legend>Channal</legend>";
  81. output +=
  82. "<input type='input' id='term_edit_form_channal' value='" +
  83. word.channal +
  84. "'>";
  85. output += "</fieldset>";
  86. output += "<fieldset>";
  87. output += "<legend>Note</legend>";
  88. output += "<textarea id='term_edit_form_note'>" + word.note + "</textarea>";
  89. output += "</fieldset>";
  90. return output;
  91. }
  92. function term_edit_dlg_save() {}