wiki.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. function wiki_load(word){
  3. $("#wiki_contents").load("../term/term.php?op=search&word="+word,function(responseTxt,statusTxt,xhr){
  4. if(statusTxt=="success"){
  5. $(".note").each(function(index,element){
  6. $(this).html(note_init($(this).html()));
  7. $(this).attr("status",1);
  8. note_refresh_new();
  9. });
  10. }
  11. else if(statusTxt=="error"){
  12. console.error("Error: "+xhr.status+": "+xhr.statusText);
  13. }
  14. });
  15. }
  16. */
  17. function wiki_index_init() {}
  18. function wiki_load_id(guid) {
  19. note_lookup_guid_json(guid, "wiki_contents");
  20. }
  21. function wiki_load_word(word) {
  22. term_get_word_to_div(word, "wiki_contents", wiki_word_loaded);
  23. }
  24. function wiki_goto_word(guid, strWord) {
  25. window.open("wiki.php?word=" + strWord, "_blank");
  26. }
  27. function wiki_word_loaded(wordlist) {
  28. $("#doc_title").text(
  29. wordlist[0].word + "[" + wordlist[0].meaning + "]-圣典百科"
  30. );
  31. }
  32. function term_show_win(guid, word) {
  33. window.location.assign("wiki.php?word=" + word);
  34. }
  35. function wiki_search_keyup(e, obj) {
  36. var keynum;
  37. var keychar;
  38. var numcheck;
  39. if ($("#wiki_search_input").val() == "") {
  40. $("#search_result").html("");
  41. return;
  42. }
  43. if (window.event) {
  44. // IE
  45. keynum = e.keyCode;
  46. } else if (e.which) {
  47. // Netscape/Firefox/Opera
  48. keynum = e.which;
  49. }
  50. var keychar = String.fromCharCode(keynum);
  51. if (keynum == 13) {
  52. //dict_search(obj.value);
  53. } else {
  54. wiki_pre_search(obj.value);
  55. }
  56. }
  57. function wiki_pre_search(keyword) {
  58. $.get(
  59. "../term/term.php",
  60. {
  61. op: "pre",
  62. word: keyword,
  63. format: "json",
  64. },
  65. function (data, status) {
  66. let result = JSON.parse(data);
  67. let html = "<ul class='wiki_search_list'>";
  68. if (result.length > 0) {
  69. for (x in result) {
  70. html +=
  71. "<li><a href='wiki.php?op=get&word=" +
  72. result[x].word +
  73. "'>" +
  74. result[x].word +
  75. "[" +
  76. result[x].meaning +
  77. "]</a></li>";
  78. }
  79. }
  80. html += "</ul>";
  81. $("#search_result").html(html);
  82. }
  83. );
  84. }