Explorar el Código

术语表增加更改对话框

visuddhinanda hace 5 años
padre
commit
85e91d13ea
Se han modificado 3 ficheros con 126 adiciones y 0 borrados
  1. 0 0
      app/term/term_edit.dlg.css
  2. 100 0
      app/term/term_edit_dlg.js
  3. 26 0
      app/term/term_get_id.php

+ 0 - 0
app/term/term_edit.dlg.css


+ 100 - 0
app/term/term_edit_dlg.js

@@ -0,0 +1,100 @@
+function term_edit_dlg_init(title = "Trem") {
+  $("body").append(
+    '<div id="term_edit_dlg" title="' +
+      title +
+      '"><div id="term_edit_dlg_content"></div></div>'
+  );
+
+  $("#term_edit_dlg").dialog({
+    autoOpen: false,
+    width: 550,
+    buttons: [
+      {
+        text: "Save",
+        click: function () {
+          term_edit_dlg_save();
+          $(this).dialog("close");
+        },
+      },
+      {
+        text: "Cancel",
+        click: function () {
+          $(this).dialog("close");
+        },
+      },
+    ],
+  });
+}
+function term_edit_dlg_open(id = "") {
+  if (id == "") {
+    $("#term_edit_dlg").dialog("open");
+  } else {
+    $.post(
+      "../term/term_get_id.php",
+      {
+        id: id,
+      },
+      function (data) {
+        let word = JSON.parse(data);
+        let html = term_edit_dlg_render(word);
+        $("#term_edit_dlg_content").html(html);
+        $("#term_edit_dlg").dialog("open");
+      }
+    );
+  }
+}
+
+function term_edit_dlg_render(word = "") {
+  if (word == "") {
+    word = new Object();
+    word.pali = "";
+  }
+  let output = "";
+  output +=
+    "<input type='hidden' id='term_edit_form_id' value='" + word.guid + "'>";
+  output += "<fieldset>";
+  output += "<legend>Spell</legend>";
+  output +=
+    "<input type='input' id='term_edit_form_word' value='" + word.word + "'>";
+  output += "</fieldset>";
+
+  output += "<fieldset>";
+  output += "<legend>Meaning</legend>";
+  output +=
+    "<input type='input' id='term_edit_form_meaning' value='" +
+    word.meaning +
+    "'>";
+  output += "</fieldset>";
+
+  output += "<fieldset>";
+  output += "<legend>Meaning</legend>";
+  output +=
+    "<input type='input' id='term_edit_form_othermeaning value='" +
+    word.other_meaning +
+    "'>";
+  output += "</fieldset>";
+
+  output += "<fieldset>";
+  output += "<legend>Language</legend>";
+  output +=
+    "<input type='input' id='term_edit_form_language' value='" +
+    word.language +
+    "'>";
+  output += "</fieldset>";
+
+  output += "<fieldset>";
+  output += "<legend>Channal</legend>";
+  output +=
+    "<input type='input' id='term_edit_form_channal' value='" +
+    word.channal +
+    "'>";
+  output += "</fieldset>";
+
+  output += "<fieldset>";
+  output += "<legend>Note</legend>";
+  output += "<textarea id='term_edit_form_note'>" + word.note + "</textarea>";
+  output += "</fieldset>";
+
+  return output;
+}
+function term_edit_dlg_save() {}

+ 26 - 0
app/term/term_get_id.php

@@ -0,0 +1,26 @@
+<?php
+/*
+查询term字典
+输入单词列表
+输出查到的结果
+*/
+require_once "../path.php";
+require_once "../public/_pdo.php";
+require_once '../ucenter/function.php';
+
+PDO_Connect("sqlite:"._FILE_DB_TERM_);
+
+$fetch = array();
+if(isset($_POST["id"])){
+        $query = "SELECT * FROM term WHERE guid = ? ";
+
+        $fetch = PDO_FetchRow($query,array($_POST["id"]));
+        $userinfo = new UserInfo();
+        if($fetch){
+            # code...
+            $fetch["user"]=$userinfo->getName($fetch["owner"]);
+        }
+    }
+
+echo json_encode($fetch, JSON_UNESCAPED_UNICODE);
+?>