wiki.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. }
  19. function wiki_load_id(guid){
  20. note_lookup_guid_json(guid,"wiki_contents");
  21. }
  22. function wiki_load_word(word){
  23. term_get_word_to_div(word,"wiki_contents",wiki_word_loaded);
  24. }
  25. function wiki_goto_word(guid,strWord){
  26. window.open("wiki.php?word="+strWord,"_blank");
  27. }
  28. function wiki_word_loaded(wordlist){
  29. $("#doc_title").text(wordlist[0].word+"["+wordlist[0].meaning+"]-圣典百科");
  30. }
  31. function run(){
  32. $("chapter").click(function(){
  33. let bookid = $(this).attr("book");
  34. let paragraph = $(this).attr("para");
  35. window.open("../pcdl/reader.php?book="+bookid+"&paragraph="+paragraph,"_blank");
  36. });
  37. }
  38. function run2(){
  39. var wordlist = new Array();
  40. $("term").each(function(index,element){
  41. wordlist.push($(this).attr("pali"));
  42. }
  43. );
  44. var wordquery ="('" + wordlist.join("','")+"')";
  45. $.post("../term/term.php",
  46. {
  47. op:"extract",
  48. words:wordquery
  49. },
  50. function(data,status){
  51. if(data.length>0){
  52. try{
  53. arrMyTerm = JSON.parse(data);
  54. term_updata_translation();
  55. }
  56. catch(e){
  57. console.error(e.error+" data:"+data);
  58. }
  59. }
  60. });
  61. }
  62. function term_show_win(guid,word){
  63. window.location.assign("wiki.php?word="+word);
  64. }
  65. function wiki_search_keyup(e,obj){
  66. var keynum
  67. var keychar
  68. var numcheck
  69. if($("#wiki_search_input").val()==""){
  70. $("#search_result").html("");
  71. return;
  72. }
  73. if(window.event) // IE
  74. {
  75. keynum = e.keyCode
  76. }
  77. else if(e.which) // Netscape/Firefox/Opera
  78. {
  79. keynum = e.which
  80. }
  81. var keychar = String.fromCharCode(keynum)
  82. if(keynum==13){
  83. //dict_search(obj.value);
  84. }
  85. else{
  86. wiki_pre_search(obj.value);
  87. }
  88. }
  89. function wiki_pre_search(keyword){
  90. $.get("../term/term.php",
  91. {
  92. op:"pre",
  93. word:keyword,
  94. format:"json"
  95. },
  96. function(data,status){
  97. let result= JSON.parse(data);
  98. let html="<ul class='wiki_search_list'>";
  99. if(result.length>0){
  100. for(x in result){
  101. html += "<li><a href='wiki.php?op=get&word="+result[x].word+"'>"+result[x].word+"["+result[x].meaning+"]</a></li>";
  102. }
  103. }
  104. html += "</ul>";
  105. $("#search_result").html(html);
  106. });
  107. }