wiki.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. var _word = "";
  18. var _channal = "";
  19. var _lang = "";
  20. var _author = "";
  21. function wiki_index_init() {}
  22. function wiki_load_id(guid) {
  23. note_lookup_guid_json(guid, "wiki_contents");
  24. }
  25. function wiki_load_word(word) {
  26. term_get_word_to_div(word, "wiki_contents", wiki_word_loaded);
  27. }
  28. function wiki_goto_word(guid, strWord) {
  29. window.open("wiki.php?word=" + strWord, "_blank");
  30. }
  31. function wiki_word_loaded(wordlist) {
  32. $("#doc_title").text(
  33. wordlist[0].word + "[" + wordlist[0].meaning + "]-圣典百科"
  34. );
  35. }
  36. function term_show_win(guid, word) {
  37. window.location.assign("wiki.php?word=" + word);
  38. }
  39. function wiki_search_keyup(e, obj) {
  40. var keynum;
  41. var keychar;
  42. var numcheck;
  43. if ($("#wiki_search_input").val() == "") {
  44. $("#search_result").html("");
  45. return;
  46. }
  47. if (window.event) {
  48. // IE
  49. keynum = e.keyCode;
  50. } else if (e.which) {
  51. // Netscape/Firefox/Opera
  52. keynum = e.which;
  53. }
  54. var keychar = String.fromCharCode(keynum);
  55. if (keynum == 13) {
  56. //dict_search(obj.value);
  57. } else {
  58. wiki_pre_search(obj.value);
  59. }
  60. }
  61. function wiki_pre_search(keyword) {
  62. $.get(
  63. "../term/term.php",
  64. {
  65. op: "pre",
  66. word: keyword,
  67. format: "json",
  68. },
  69. function (data, status) {
  70. let result = JSON.parse(data);
  71. let html = "<ul class='wiki_search_list'>";
  72. if (result.length > 0) {
  73. for (x in result) {
  74. html +=
  75. "<li><a href='wiki.php?op=get&word=" +
  76. result[x].word +
  77. "'>" +
  78. result[x].word +
  79. "[" +
  80. result[x].meaning +
  81. "]</a></li>";
  82. }
  83. }
  84. html += "</ul>";
  85. $("#search_result").html(html);
  86. }
  87. );
  88. }
  89. function set_channal(channalid) {
  90. location.assign("../wiki/wiki.php?word=" + _word + "&channal=" + channalid);
  91. }