term.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784
  1. var arrTerm = new Array();
  2. var arrTerm2 = new Array();
  3. var arrMyTerm = new Array();
  4. var arrAllMean = new Array();
  5. var arrTermAllPali = new Array();
  6. var arrWordIdTermId = new Array();
  7. //术语渲染模板
  8. var strTermTanslationTmp = "[%mean%](%pali% %mean2% %mymean%)";
  9. var strTermTanslationTmp2 = "[%mean%]";
  10. var termCounter = new Array();
  11. var noteCounter = 0; //正文内注释计数器
  12. function note(noteId, strDef = "unkow") {
  13. document.write("haha");
  14. }
  15. function note_replace(strIn) {
  16. /*
  17. */
  18. var output = strIn.replace("/*", "<script>");
  19. output = output.replace("*/", "</script>");
  20. return output;
  21. }
  22. function term_init() {}
  23. var str_term_fun_word_link = "term_show_win";
  24. function term_word_link_fun(fun_name) {
  25. str_term_fun_word_link = fun_name;
  26. }
  27. //将存储状态的字符串转换为预显示字符串
  28. //设置状态为 0:未处理的原始状态
  29. function term_std_str_to_tran(strIn, channal = "", editor = "", lang = "") {
  30. return strIn
  31. .replace(/\[\[/g, "<term status='0' channal='" + channal + "' editor='" + editor + "' lang='" + lang + "'>")
  32. .replace(/\]\]/g, "</term>");
  33. }
  34. function term_std_str_to_edit(strIn) {
  35. var arrText = strIn.split("/");
  36. for (var i in arrText) {
  37. //头尾是*
  38. if (arrText[i].substring(0, 1) == "*" && arrText[i].substring(arrText[i].length - 1) == "*") {
  39. var arrOneTermWord = arrText[i].split("@");
  40. if (arrOneTermWord.length == 2) {
  41. arrText[i] = "*" + arrOneTermWord[1];
  42. }
  43. }
  44. }
  45. return arrText.join("/");
  46. }
  47. function term_tran_edit_replace(strIn) {
  48. var strEdit = strIn;
  49. for (var x = 0; x < arrTerm2.length; x++) {
  50. var strReplace = "strEdit=strEdit.replace(/" + arrTerm2[x].meaning + '/g,"/*' + arrTerm2[x].meaning + '*/")';
  51. eval(strReplace);
  52. }
  53. //strEdit=strEdit.replace(/\/*\/*/g,"\/*");
  54. //strEdit=strEdit.replace(/\*\/\*\//g,"*\/");
  55. return strEdit;
  56. }
  57. function term_edit_to_std_str(strIn) {
  58. var arrText = strIn.split("/");
  59. for (var i in arrText) {
  60. //头尾是*
  61. if (arrText[i].substring(0, 1) == "*" && arrText[i].substring(arrText[i].length - 1) == "*") {
  62. var wordMeaning = arrText[i].substring(1, arrText[i].length - 1);
  63. arrText[i] = "*" + term_get_std_str(wordMeaning) + "*";
  64. }
  65. }
  66. return arrText.join("/");
  67. }
  68. function term_get_std_str(strMean) {
  69. for (var x = 0; x < arrTerm2.length; x++) {
  70. if (arrTerm2[x].meaning == strMean) {
  71. return arrTerm2[x].guid + "@" + strMean;
  72. }
  73. }
  74. return "unkow@" + strMean;
  75. }
  76. function term_get_my_std_str(strMean) {
  77. for (const iterator of arrMyTerm) {
  78. if (iterator.meaning == strMean) {
  79. return iterator.guid + "@" + strMean;
  80. }
  81. }
  82. return "unkow@" + strMean;
  83. }
  84. function note_lookup(word, showto) {
  85. $("#" + showto).load(
  86. "../term/term.php?op=search&word=" + word + "&username=" + getCookie("username"),
  87. function (responseTxt, statusTxt, xhr) {
  88. if (statusTxt == "success") {
  89. $(".term_note").each(function (index, element) {
  90. $(this).html(note_init($(this).html()));
  91. $(this).attr("status", 1);
  92. note_refresh_new();
  93. });
  94. } else if (statusTxt == "error") {
  95. console.error("Error: " + xhr.status + ": " + xhr.statusText);
  96. }
  97. }
  98. );
  99. }
  100. function term_get_guid_to_html(strGuid) {}
  101. function term_apply(guid) {
  102. if (g_eCurrWord) {
  103. setNodeText(g_eCurrWord, "note", "=term(" + guid + ")");
  104. term_array_updata();
  105. }
  106. }
  107. function term_data_copy_to_me(guid) {
  108. $("#term_dict").load("../term/term.php?op=copy&wordid=" + guid);
  109. }
  110. //我的术语字典进入编辑模式
  111. function term_edit(guid) {
  112. $("#term_edit_btn1_" + guid).hide();
  113. $("#term_edit_btn2_" + guid).show();
  114. document.getElementById("term_dict_my_" + guid).style.display = "none";
  115. document.getElementById("term_dict_my_edit_" + guid).style.display = "block";
  116. }
  117. //我的术语字典退出编辑模式
  118. function term_data_esc_edit(guid) {
  119. $("#term_edit_btn1_" + guid).show();
  120. $("#term_edit_btn2_" + guid).hide();
  121. document.getElementById("term_dict_my_" + guid).style.display = "block";
  122. document.getElementById("term_dict_my_edit_" + guid).style.display = "none";
  123. }
  124. //我的术语字典 编辑模式 保存
  125. function term_data_save(guid) {
  126. if (guid == "") {
  127. var strWord = $("#term_new_word").val();
  128. var strMean = $("#term_new_mean").val();
  129. var strMean2 = $("#term_new_mean2").val();
  130. var strTag = $("#term_new_tag").val();
  131. var strChannal = $("#term_new_channal").val();
  132. var strLanguage = $("#term_new_language").val();
  133. var strNote = $("#term_new_note").val();
  134. let newTerm = new Object();
  135. newTerm.guid = com_guid();
  136. newTerm.word = strWord;
  137. newTerm.meaning = strMean;
  138. newTerm.other_meaning = strMean2;
  139. newTerm.tag = strTag;
  140. newTerm.channal = strChannal;
  141. newTerm.language = strLanguage;
  142. arrMyTerm.push(newTerm);
  143. } else {
  144. var strWord = $("#term_edit_word_" + guid).val();
  145. var strMean = $("#term_edit_mean_" + guid).val();
  146. var strMean2 = $("#term_edit_mean2_" + guid).val();
  147. var strTag = $("#term_edit_tag_" + guid).val();
  148. var strChannal = $("#term_edit_channal_" + guid).val();
  149. var strLanguage = $("#term_edit_language_" + guid).val();
  150. var strNote = $("#term_edit_note_" + guid).val();
  151. }
  152. $.post(
  153. "../term/term_post.php",
  154. {
  155. id: guid,
  156. word: strWord,
  157. mean: strMean,
  158. mean2: strMean2,
  159. tag: strTag,
  160. channal: strChannal,
  161. language: strLanguage,
  162. note: strNote,
  163. },
  164. function (data, status) {
  165. try {
  166. let result = JSON.parse(data);
  167. if (result.status == 0) {
  168. note_lookup(result.message, "term_dict");
  169. } else {
  170. ntf_show("term error" + result.message);
  171. }
  172. } catch (e) {
  173. console.error("term_get_all_pali:" + e + " data:" + data);
  174. ntf_show("term error");
  175. }
  176. }
  177. );
  178. }
  179. function term_get_all_pali() {
  180. $.get(
  181. "../term/term.php",
  182. {
  183. op: "allpali",
  184. },
  185. function (data, status) {
  186. if (data.length > 0) {
  187. try {
  188. arrTermAllPali = JSON.parse(data);
  189. } catch (e) {
  190. console.error("term_get_all_pali:" + e + " data:" + data);
  191. }
  192. }
  193. }
  194. );
  195. }
  196. function term_lookup_all(pali) {
  197. for (var x in arrTermAllPali) {
  198. if (arrTermAllPali[x].word == pali) {
  199. return arrTermAllPali[x];
  200. }
  201. }
  202. return null;
  203. }
  204. function term_get_my() {
  205. $.get(
  206. "../term/term.php",
  207. {
  208. op: "my",
  209. },
  210. function (data, status) {
  211. if (data.length > 0) {
  212. try {
  213. arrMyTerm = JSON.parse(data);
  214. } catch (e) {
  215. console.error(e.error + " data:" + data);
  216. }
  217. }
  218. }
  219. );
  220. }
  221. //在我的术语字典里查询
  222. function term_lookup_my(pali, channal = "", owner = "", lang = "") {
  223. let langFamily = lang.split("-")[0];
  224. //相同的channel
  225. for (const iterator of arrMyTerm) {
  226. if (channal != "") {
  227. if (channal == iterator.channal && iterator.word == pali) {
  228. return iterator;
  229. }
  230. }
  231. }
  232. if (owner != "") {
  233. //我自己的相同语言
  234. for (const iterator of arrMyTerm) {
  235. if (iterator.word == pali && owner == iterator.owner && iterator.language == lang) {
  236. return iterator;
  237. }
  238. }
  239. //自己相似的语言
  240. for (const iterator of arrMyTerm) {
  241. if (pali == iterator.word && owner == iterator.owner) {
  242. let thisLangFamily = iterator.language.split("-")[0];
  243. if (thisLangFamily == langFamily) {
  244. return iterator;
  245. }
  246. }
  247. }
  248. }
  249. //别人的相同语言
  250. for (const iterator of arrMyTerm) {
  251. if (iterator.word == pali && iterator.language == lang) {
  252. return iterator;
  253. }
  254. }
  255. //找别人的相似语言
  256. for (const iterator of arrMyTerm) {
  257. if (pali == iterator.word) {
  258. let thisLangFamily = iterator.language.split("-")[0];
  259. if (thisLangFamily == langFamily) {
  260. return iterator;
  261. }
  262. }
  263. }
  264. return false;
  265. }
  266. //在我的术语字典里查询 模糊查询
  267. function term_lookup_my_a(pali, channal = "", owner = "", lang = "") {
  268. let langFamily = lang.split("-")[0];
  269. for (const iterator of arrMyTerm) {
  270. if (channal != "") {
  271. if (channal == iterator.channal) {
  272. if (iterator.word.indexOf(pali) != -1) {
  273. return iterator;
  274. }
  275. }
  276. }
  277. }
  278. //我自己的相同语言
  279. if (owner != "") {
  280. for (const iterator of arrMyTerm) {
  281. if (pali == iterator.word && owner == iterator.owner && iterator.language == lang) {
  282. return iterator;
  283. }
  284. }
  285. //自己相似的语言
  286. for (const iterator of arrMyTerm) {
  287. if (pali == iterator.word && owner == iterator.owner) {
  288. let thisLangFamily = iterator.language.split("-")[0];
  289. if (thisLangFamily == langFamily) {
  290. return iterator;
  291. }
  292. }
  293. }
  294. //别人的相同语言
  295. for (const iterator of arrMyTerm) {
  296. if (pali == iterator.word && iterator.language == lang) {
  297. return iterator;
  298. }
  299. }
  300. //找别人的相似语言
  301. for (const iterator of arrMyTerm) {
  302. if (pali == iterator.word) {
  303. let thisLangFamily = iterator.language.split("-")[0];
  304. if (thisLangFamily == langFamily) {
  305. return iterator;
  306. }
  307. }
  308. }
  309. }
  310. return false;
  311. }
  312. function term_lookup_my_id(id) {
  313. for (const iterator of arrMyTerm) {
  314. if (iterator.guid == id) {
  315. return iterator;
  316. }
  317. }
  318. return null;
  319. }
  320. function term_get_all_meaning(word) {
  321. $.get(
  322. "../term/term.php",
  323. {
  324. op: "allmean",
  325. word: word,
  326. },
  327. function (data, status) {
  328. $("#term_win_other_mean").html(data);
  329. }
  330. );
  331. }
  332. //刷新文档正在使用的术语数据
  333. function term_array_updata() {
  334. arrTerm2 = new Array();
  335. var arrTermDownLoadList = new Array();
  336. var arrWordIdTermId = new Array();
  337. var xAllWord = gXmlBookDataBody.getElementsByTagName("word");
  338. for (var x = 0; x < xAllWord.length; x++) {
  339. var sNote = getNodeText(xAllWord[x], "note");
  340. var wid = getNodeText(xAllWord[x], "id");
  341. if (sNote.substring(0, 6) == "=term(") {
  342. var termId = sNote.slice(6, -1);
  343. if (!arrTerm[termId]) {
  344. arrTermDownLoadList.push(termId);
  345. }
  346. //person={wid:wid,tid:termId};
  347. arrWordIdTermId.push({ wid: wid, tid: termId });
  348. }
  349. }
  350. if (arrTermDownLoadList.length > 0) {
  351. var idlist = arrTermDownLoadList.join();
  352. idlist = idlist.replace(/,/g, "','");
  353. idlist = "'" + idlist + "'";
  354. $.get(
  355. "../term/term.php",
  356. {
  357. op: "extract",
  358. list: idlist,
  359. },
  360. function (data, status) {
  361. var obj = JSON.parse(data);
  362. for (var x in obj) {
  363. arrTerm[obj[x].guid] = obj[x];
  364. arrTerm2.push(obj[x]);
  365. }
  366. if (g_eCurrWord) {
  367. updataWordHeadById(getNodeText(g_eCurrWord, "id"));
  368. refreshWordNote(g_eCurrWord.parentNode.parentNode);
  369. }
  370. for (var i = 0; i < arrWordIdTermId.length; i++) {
  371. var wid = arrWordIdTermId[i].wid;
  372. var sMean = arrTerm[arrWordIdTermId[i].tid].meaning;
  373. doc_setWordDataById(wid, "mean", sMean);
  374. updateWordBodyById(wid);
  375. }
  376. }
  377. );
  378. }
  379. }
  380. function term_updata_translation() {
  381. termCounter = new Array();
  382. noteCounter = 1;
  383. //计算有效模版数量
  384. let iValidTmp = 0;
  385. if (typeof setting !== "undefined") {
  386. for (const iterator of setting["term.template"]) {
  387. if (iterator != "") {
  388. iValidTmp++;
  389. }
  390. }
  391. }
  392. $("term").each(function () {
  393. let status = $(this).attr("status");
  394. let termText = $(this).text();
  395. if (termText.slice(0, 1) == "#") {
  396. if (status == 0) {
  397. $(this).attr("status", "1");
  398. $(this).attr("type", "1");
  399. $(this).attr("text", termText.slice(1));
  400. }
  401. let noteText = $(this).attr("text");
  402. $(this).html("<a onclick=\"alert('" + noteText + "')\">[" + noteCounter + "]</a>");
  403. noteCounter++;
  404. } else {
  405. if (status == 0 || status == 2) {
  406. let myterm = term_lookup_my(
  407. termText,
  408. $(this).attr("channal"),
  409. $(this).attr("editor"),
  410. $(this).attr("lang")
  411. ); //我的术语字典
  412. if (myterm) {
  413. $(this).attr("status", "1");
  414. $(this).attr("type", "0");
  415. $(this).attr("guid", myterm.guid);
  416. $(this).attr("pali", myterm.word);
  417. $(this).attr("mean", myterm.meaning);
  418. $(this).attr("mean2", myterm.other_meaning);
  419. $(this).attr("replace", myterm.meaning);
  420. } else {
  421. $(this).attr("status", "2");
  422. $(this).attr("pali", termText);
  423. }
  424. }
  425. let guid = $(this).attr("guid");
  426. let pali = $(this).attr("pali");
  427. let mean = $(this).attr("mean");
  428. let mean2 = $(this).attr("mean2");
  429. let renderTo = $(this).attr("pos");
  430. let noteText = "";
  431. if (termCounter[guid]) {
  432. termCounter[guid] = 2;
  433. } else {
  434. termCounter[guid] = 1;
  435. }
  436. myterm = term_lookup_my(pali, $(this).attr("channal"), $(this).attr("editor"), $(this).attr("lang")); //我的术语字典
  437. let linkclass = "";
  438. if (myterm) {
  439. linkclass = "term_link";
  440. } else {
  441. linkclass = "term_link_new";
  442. }
  443. if (guid) {
  444. if (renderTo == "wbw") {
  445. noteText = "%note%";
  446. } else {
  447. if (typeof setting !== "undefined") {
  448. let currTermCounter = termCounter[guid];
  449. if (currTermCounter > iValidTmp) {
  450. currTermCounter = iValidTmp;
  451. }
  452. noteText = setting["term.template"][currTermCounter - 1];
  453. } else {
  454. if (termCounter[guid] == 1) {
  455. noteText = strTermTanslationTmp;
  456. } else {
  457. noteText = strTermTanslationTmp2;
  458. }
  459. }
  460. }
  461. noteText = noteText.replace(
  462. "[",
  463. "<span class='" +
  464. linkclass +
  465. "' id='term_link_" +
  466. guid +
  467. "' gid='" +
  468. guid +
  469. "' onclick=\"" +
  470. str_term_fun_word_link +
  471. "('" +
  472. guid +
  473. "','" +
  474. pali +
  475. "')\">"
  476. );
  477. noteText = noteText.replace("]", "</span>");
  478. noteText = noteText.replace("%mean%", "<span class='term_mean'>" + mean + "</span>");
  479. noteText = noteText.replace("%pali%", "<span class='term_pali'>" + pali + "</span>");
  480. if (mean2 != "") {
  481. noteText = noteText.replace("%mean2%", ", <span class='term_mean2'>" + mean2 + "</span>");
  482. } else {
  483. noteText = noteText.replace("%mean2%", "");
  484. }
  485. noteText = noteText.replace("%note%", "<span class='term_note'>" + "" + "</span>");
  486. if (myterm) {
  487. if (myterm.meaning != mean) {
  488. noteText = noteText.replace(
  489. "%mymean%",
  490. "<span class='term_mean_my'>" + myterm.meaning + "</span>"
  491. );
  492. } else {
  493. noteText = noteText.replace("%mymean%", "");
  494. }
  495. } else {
  496. noteText = noteText.replace("%mymean%", "");
  497. }
  498. } else {
  499. noteText =
  500. "<span class='" +
  501. linkclass +
  502. "' onclick=\"" +
  503. str_term_fun_word_link +
  504. "('','" +
  505. termText +
  506. "')\">" +
  507. termText +
  508. "</span>";
  509. }
  510. $(this).html(noteText);
  511. }
  512. });
  513. term_popup_init();
  514. }
  515. function term_show_win(guid, keyWord = "") {
  516. if (guid == "") {
  517. if (typeof term_body == "undefined") {
  518. term_edit_dlg_open("", keyWord);
  519. } else {
  520. $(term_body).html(
  521. "“" +
  522. keyWord +
  523. "”" +
  524. gLocal.gui.no_created +
  525. "<br /><button onclick=\"term_add_new('" +
  526. keyWord +
  527. "')\">" +
  528. gLocal.gui.create_now +
  529. "</button>"
  530. );
  531. }
  532. } else {
  533. let currWord = term_lookup_my_id(guid);
  534. if (currWord) {
  535. let termString = "";
  536. let pali = currWord.word;
  537. let pali_1 = pali.substring(0, 1).toUpperCase();
  538. pali = pali_1 + pali.substring(1);
  539. let mean = currWord.meaning;
  540. let myterm = term_lookup_my(currWord.word); //我的术语字典
  541. termString += "<div class='term_win_mean'>" + pali + "</div>";
  542. termString += "<div class='term_win_pali'>意思:" + currWord.meaning + "</div>";
  543. termString += "<div class='term_win_mean2'>其他意思:" + currWord.other_meaning + "</div>";
  544. termString += "<div class='term_win_mymean'>我的词库:";
  545. if (myterm) {
  546. termString += "<b>" + myterm.meaning + "</b> ";
  547. } else {
  548. termString += "<input type='input' placeholder='我的释义'>";
  549. }
  550. termString += "<span>其他:</span><span id='term_win_other_mean'></span>";
  551. termString += "</div>";
  552. if (currWord.note) {
  553. termString += "<div class='term_win_note'>" + currWord.note + "</div>";
  554. } else {
  555. termString += "<div class='term_win_note'>Loading</div>";
  556. }
  557. $(term_body).html(termString);
  558. term_get_all_meaning(currWord.word);
  559. if (!currWord.note) {
  560. $.get(
  561. "../term/term.php",
  562. {
  563. op: "load_id",
  564. id: currWord.guid,
  565. },
  566. function (data, status, xhr) {
  567. switch (status) {
  568. case "success":
  569. try {
  570. let loadWord = JSON.parse(data);
  571. $("#term_win_note").html(loadWord[0].note);
  572. //修改内存数据
  573. for (let index = 0; index < arrMyTerm.length; index++) {
  574. if (arrMyTerm[index].guid == loadWord[0].guid) {
  575. arrMyTerm[index].note = loadWord[0].note;
  576. return;
  577. }
  578. }
  579. } catch (e) {
  580. console.error(e + " data:" + data);
  581. }
  582. break;
  583. case "error":
  584. console.error("Error: " + xhr.status + ": " + xhr.statusText);
  585. break;
  586. }
  587. }
  588. );
  589. }
  590. } else {
  591. $(term_body).html("undefined guid");
  592. }
  593. }
  594. document.getElementById("term_win").style.display = "flex";
  595. }
  596. function term_tmp(type, tmp) {
  597. if (tmp == "new") {
  598. switch (type) {
  599. case "a":
  600. strTermTanslationTmp = $("#term_my_tmp").val();
  601. break;
  602. case "a2":
  603. strTermTanslationTmp2 = $("#term_my_tmp").val();
  604. break;
  605. }
  606. } else {
  607. switch (type) {
  608. case "a":
  609. strTermTanslationTmp = tmp;
  610. break;
  611. case "a2":
  612. strTermTanslationTmp2 = tmp;
  613. break;
  614. }
  615. }
  616. term_updata_translation();
  617. }
  618. function term_add_new(keyword) {
  619. document.getElementById("term_win").style.display = "none";
  620. tab_click_b("sys_term", "tab_rb_sys_term", right_panal_slide_toggle, "tab_rb_sys_term");
  621. editor_show_right_tool_bar(true);
  622. note_lookup(keyword, "term_dict");
  623. }
  624. function term_show_new() {
  625. $("#term_new_recorder").slideToggle();
  626. $("#new_term_button").hide();
  627. guide_init();
  628. }
  629. function term_get_dict() {
  630. if (arrMyTerm.length > 0) {
  631. term_updata_translation();
  632. return;
  633. }
  634. let termwordlist = new Array();
  635. $("term").each(function () {
  636. if ($(this).attr("status") == 0) {
  637. $(this).attr("pali", $(this).text());
  638. }
  639. let termword = new Object();
  640. termword.pali = $(this).attr("pali");
  641. termword.channal = $(this).attr("channal");
  642. termword.editor = $(this).attr("editor");
  643. termword.lang = $(this).attr("lang");
  644. termwordlist.push(termword);
  645. });
  646. let readonly = true;
  647. if (_display == "sent") {
  648. readonly = false;
  649. }
  650. $.post(
  651. "../term/term_get.php",
  652. {
  653. words: JSON.stringify(termwordlist),
  654. channal: _channal,
  655. readonly: readonly,
  656. },
  657. function (data, status) {
  658. if (data.length > 0) {
  659. try {
  660. arrMyTerm = JSON.parse(data);
  661. term_updata_translation();
  662. } catch (e) {
  663. console.error(e.error + " data:" + data);
  664. }
  665. }
  666. }
  667. );
  668. }
  669. /*
  670. function term_popup_init() {
  671. $(".term_link").each(function () {
  672. if ($(this).attr("init") != "1") {
  673. if ($(this).text().length > 0) {
  674. $(this).css("background", "unset");
  675. }
  676. let gid = $(this).attr("gid");
  677. if ($(this).offset().left < $(document.body).width() / 2) {
  678. //出现在左侧
  679. $(this).append(
  680. '<div id="gid_' +
  681. gid +
  682. '" class="guide_contence" style="left: -5px;"></div>'
  683. );
  684. $(".guide_contence:after").css("left", "0");
  685. } else {
  686. //出现在右侧
  687. $(this).append(
  688. '<div id="gid_' +
  689. gid +
  690. '" class="guide_contence" style="right: -5px;"></div>'
  691. );
  692. $(".guide_contence:after").css("right", "0");
  693. }
  694. $(this).attr("init", "1");
  695. }
  696. });
  697. $(".term_link").mouseenter(function () {
  698. if ($(this).children(".guide_contence").first().html().length > 0) {
  699. return;
  700. }
  701. let gid = $(this).attr("gid");
  702. term_load_preview(gid, "gid_" + gid);
  703. });
  704. }
  705. function term_load_preview(guid, showto) {
  706. $.get(
  707. "../term/term.php",
  708. {
  709. op: "load_id",
  710. id: guid,
  711. format: "json",
  712. },
  713. function (data, status) {
  714. let html = "";
  715. if (status == "success") {
  716. try {
  717. let result = JSON.parse(data)[0];
  718. html = "<div class='term_block'>";
  719. html += "<h2>" + result.word + "</h2>";
  720. html += "<div class='meaning'>" + result.meaning + "</div>";
  721. html +=
  722. "<div class='term_note' status='1'>" +
  723. note_init(result.note) +
  724. "</div>";
  725. html +=
  726. "<div ><a href='../wiki/wiki.php?word=" +
  727. result.word +
  728. "' target='_blank'>更多</a></div>";
  729. html += "</div>";
  730. $("#" + showto).html(html);
  731. } catch (e) {
  732. console.error("note_lookup_guid_json:" + e + " data:" + data);
  733. }
  734. }
  735. }
  736. );
  737. }
  738. */