term.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792
  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;
  395. termText = $(this).attr("pali");
  396. if(typeof termText=="undefined"){
  397. termText = $(this).text();
  398. }
  399. if (termText.slice(0, 1) == "#") {
  400. if (status == 0) {
  401. $(this).attr("status", "1");
  402. $(this).attr("type", "1");
  403. $(this).attr("text", termText.slice(1));
  404. }
  405. let noteText = $(this).attr("text");
  406. $(this).html("<a onclick=\"alert('" + noteText + "')\">[" + noteCounter + "]</a>");
  407. noteCounter++;
  408. } else {
  409. //if (status == 0 || status == 2)
  410. {
  411. let myterm = term_lookup_my(
  412. termText,
  413. $(this).attr("channal"),
  414. $(this).attr("editor"),
  415. $(this).attr("lang")
  416. ); //我的术语字典
  417. if (myterm) {
  418. $(this).attr("status", "1");
  419. $(this).attr("type", "0");
  420. $(this).attr("guid", myterm.guid);
  421. $(this).attr("pali", myterm.word);
  422. $(this).attr("mean", myterm.meaning);
  423. $(this).attr("mean2", myterm.other_meaning);
  424. $(this).attr("replace", myterm.meaning);
  425. } else {
  426. $(this).attr("status", "2");
  427. $(this).attr("pali", termText);
  428. }
  429. }
  430. let guid = $(this).attr("guid");
  431. let pali = $(this).attr("pali");
  432. let mean = $(this).attr("mean");
  433. let mean2 = $(this).attr("mean2");
  434. let renderTo = $(this).attr("pos");
  435. let channel = $(this).attr("channal");
  436. let lang = $(this).attr("lang");
  437. let noteText = "";
  438. if (termCounter[guid]) {
  439. termCounter[guid] = 2;
  440. } else {
  441. termCounter[guid] = 1;
  442. }
  443. myterm = term_lookup_my(pali, $(this).attr("channal"), $(this).attr("editor"), $(this).attr("lang")); //我的术语字典
  444. let linkclass = "";
  445. if (myterm) {
  446. linkclass = "term_link";
  447. } else {
  448. linkclass = "term_link_new";
  449. }
  450. if (guid) {
  451. if (renderTo == "wbw") {
  452. noteText = "%note%";
  453. } else {
  454. if (typeof setting !== "undefined") {
  455. let currTermCounter = termCounter[guid];
  456. if (currTermCounter > iValidTmp) {
  457. currTermCounter = iValidTmp;
  458. }
  459. noteText = setting["term.template"][currTermCounter - 1];
  460. } else {
  461. if (termCounter[guid] == 1) {
  462. noteText = strTermTanslationTmp;
  463. } else {
  464. noteText = strTermTanslationTmp2;
  465. }
  466. }
  467. }
  468. noteText = noteText.replace(
  469. "[",
  470. "<span class='" +
  471. linkclass +
  472. "' id='term_link_" +
  473. guid +
  474. "' gid='" +
  475. guid +
  476. "' onclick=\"" +
  477. str_term_fun_word_link +
  478. "('" +
  479. guid +
  480. "','" +
  481. pali +
  482. "','"+channel+"','"+lang+"')\">"
  483. );
  484. noteText = noteText.replace("]", "</span>");
  485. noteText = noteText.replace("%mean%", "<span class='term_mean'>" + mean + "</span>");
  486. noteText = noteText.replace("%pali%", "<span class='term_pali'>" + pali + "</span>");
  487. if (mean2 != "") {
  488. noteText = noteText.replace("%mean2%", ", <span class='term_mean2'>" + mean2 + "</span>");
  489. } else {
  490. noteText = noteText.replace("%mean2%", "");
  491. }
  492. noteText = noteText.replace("%note%", "<span class='term_note'>" + "" + "</span>");
  493. if (myterm) {
  494. if (myterm.meaning != mean) {
  495. noteText = noteText.replace(
  496. "%mymean%",
  497. "<span class='term_mean_my'>" + myterm.meaning + "</span>"
  498. );
  499. } else {
  500. noteText = noteText.replace("%mymean%", "");
  501. }
  502. } else {
  503. noteText = noteText.replace("%mymean%", "");
  504. }
  505. } else {
  506. noteText =
  507. "<span class='" +
  508. linkclass +
  509. "' onclick=\"" +
  510. str_term_fun_word_link +
  511. "('','" +
  512. termText +
  513. "','"+channel+"','"+lang+"')\">" +
  514. termText +
  515. "</span>";
  516. }
  517. $(this).html(noteText);
  518. }
  519. });
  520. term_popup_init();
  521. }
  522. function term_show_win(guid, keyWord = "",channel="",lang="") {
  523. if (guid == "") {
  524. if (typeof term_body == "undefined") {
  525. term_edit_dlg_open("", keyWord,channel,lang);
  526. } else {
  527. $(term_body).html(
  528. "“" +
  529. keyWord +
  530. "”" +
  531. gLocal.gui.no_created +
  532. "<br /><button onclick=\"term_add_new('" +
  533. keyWord +
  534. "')\">" +
  535. gLocal.gui.create_now +
  536. "</button>"
  537. );
  538. }
  539. } else {
  540. let currWord = term_lookup_my_id(guid);
  541. if (currWord) {
  542. let termString = "";
  543. let pali = currWord.word;
  544. let pali_1 = pali.substring(0, 1).toUpperCase();
  545. pali = pali_1 + pali.substring(1);
  546. let mean = currWord.meaning;
  547. let myterm = term_lookup_my(currWord.word); //我的术语字典
  548. termString += "<div class='term_win_mean'>" + pali + "</div>";
  549. termString += "<div class='term_win_pali'>意思:" + currWord.meaning + "</div>";
  550. termString += "<div class='term_win_mean2'>其他意思:" + currWord.other_meaning + "</div>";
  551. termString += "<div class='term_win_mymean'>我的词库:";
  552. if (myterm) {
  553. termString += "<b>" + myterm.meaning + "</b> ";
  554. } else {
  555. termString += "<input type='input' placeholder='我的释义'>";
  556. }
  557. termString += "<span>其他:</span><span id='term_win_other_mean'></span>";
  558. termString += "</div>";
  559. if (currWord.note) {
  560. termString += "<div class='term_win_note'>" + currWord.note + "</div>";
  561. } else {
  562. termString += "<div class='term_win_note'>Loading</div>";
  563. }
  564. $(term_body).html(termString);
  565. term_get_all_meaning(currWord.word);
  566. if (!currWord.note) {
  567. $.get(
  568. "../term/term.php",
  569. {
  570. op: "load_id",
  571. id: currWord.guid,
  572. },
  573. function (data, status, xhr) {
  574. switch (status) {
  575. case "success":
  576. try {
  577. let loadWord = JSON.parse(data);
  578. $("#term_win_note").html(loadWord[0].note);
  579. //修改内存数据
  580. for (let index = 0; index < arrMyTerm.length; index++) {
  581. if (arrMyTerm[index].guid == loadWord[0].guid) {
  582. arrMyTerm[index].note = loadWord[0].note;
  583. return;
  584. }
  585. }
  586. } catch (e) {
  587. console.error(e + " data:" + data);
  588. }
  589. break;
  590. case "error":
  591. console.error("Error: " + xhr.status + ": " + xhr.statusText);
  592. break;
  593. }
  594. }
  595. );
  596. }
  597. } else {
  598. $(term_body).html("undefined guid");
  599. }
  600. }
  601. document.getElementById("term_win").style.display = "flex";
  602. }
  603. function term_tmp(type, tmp) {
  604. if (tmp == "new") {
  605. switch (type) {
  606. case "a":
  607. strTermTanslationTmp = $("#term_my_tmp").val();
  608. break;
  609. case "a2":
  610. strTermTanslationTmp2 = $("#term_my_tmp").val();
  611. break;
  612. }
  613. } else {
  614. switch (type) {
  615. case "a":
  616. strTermTanslationTmp = tmp;
  617. break;
  618. case "a2":
  619. strTermTanslationTmp2 = tmp;
  620. break;
  621. }
  622. }
  623. term_updata_translation();
  624. }
  625. function term_add_new(keyword) {
  626. document.getElementById("term_win").style.display = "none";
  627. tab_click_b("sys_term", "tab_rb_sys_term", right_panal_slide_toggle, "tab_rb_sys_term");
  628. editor_show_right_tool_bar(true);
  629. note_lookup(keyword, "term_dict");
  630. }
  631. function term_show_new() {
  632. $("#term_new_recorder").slideToggle();
  633. $("#new_term_button").hide();
  634. guide_init();
  635. }
  636. function term_get_dict() {
  637. if (arrMyTerm.length > 0) {
  638. term_updata_translation();
  639. return;
  640. }
  641. let termwordlist = new Array();
  642. $("term").each(function () {
  643. if ($(this).attr("status") == 0) {
  644. $(this).attr("pali", $(this).text());
  645. }
  646. let termword = new Object();
  647. termword.pali = $(this).attr("pali");
  648. termword.channal = $(this).attr("channal");
  649. termword.editor = $(this).attr("editor");
  650. termword.lang = $(this).attr("lang");
  651. termwordlist.push(termword);
  652. });
  653. let readonly = true;
  654. if (_display == "sent") {
  655. readonly = false;
  656. }
  657. $.post(
  658. "../term/term_get.php",
  659. {
  660. words: JSON.stringify(termwordlist),
  661. channal: _channal,
  662. readonly: readonly,
  663. },
  664. function (data, status) {
  665. if (data.length > 0) {
  666. try {
  667. arrMyTerm = JSON.parse(data);
  668. term_updata_translation();
  669. } catch (e) {
  670. console.error(e.error + " data:" + data);
  671. }
  672. }
  673. }
  674. );
  675. }
  676. /*
  677. function term_popup_init() {
  678. $(".term_link").each(function () {
  679. if ($(this).attr("init") != "1") {
  680. if ($(this).text().length > 0) {
  681. $(this).css("background", "unset");
  682. }
  683. let gid = $(this).attr("gid");
  684. if ($(this).offset().left < $(document.body).width() / 2) {
  685. //出现在左侧
  686. $(this).append(
  687. '<div id="gid_' +
  688. gid +
  689. '" class="guide_contence" style="left: -5px;"></div>'
  690. );
  691. $(".guide_contence:after").css("left", "0");
  692. } else {
  693. //出现在右侧
  694. $(this).append(
  695. '<div id="gid_' +
  696. gid +
  697. '" class="guide_contence" style="right: -5px;"></div>'
  698. );
  699. $(".guide_contence:after").css("right", "0");
  700. }
  701. $(this).attr("init", "1");
  702. }
  703. });
  704. $(".term_link").mouseenter(function () {
  705. if ($(this).children(".guide_contence").first().html().length > 0) {
  706. return;
  707. }
  708. let gid = $(this).attr("gid");
  709. term_load_preview(gid, "gid_" + gid);
  710. });
  711. }
  712. function term_load_preview(guid, showto) {
  713. $.get(
  714. "../term/term.php",
  715. {
  716. op: "load_id",
  717. id: guid,
  718. format: "json",
  719. },
  720. function (data, status) {
  721. let html = "";
  722. if (status == "success") {
  723. try {
  724. let result = JSON.parse(data)[0];
  725. html = "<div class='term_block'>";
  726. html += "<h2>" + result.word + "</h2>";
  727. html += "<div class='meaning'>" + result.meaning + "</div>";
  728. html +=
  729. "<div class='term_note' status='1'>" +
  730. note_init(result.note) +
  731. "</div>";
  732. html +=
  733. "<div ><a href='../wiki/wiki.php?word=" +
  734. result.word +
  735. "' target='_blank'>更多</a></div>";
  736. html += "</div>";
  737. $("#" + showto).html(html);
  738. } catch (e) {
  739. console.error("note_lookup_guid_json:" + e + " data:" + data);
  740. }
  741. }
  742. }
  743. );
  744. }
  745. */