title.js 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. var dict_pre_searching=false;
  2. var dict_pre_search_curr_word="";
  3. var dict_search_xml_http=null;
  4. var title_search_curr_key="";
  5. function search_book_filter(objid,type){
  6. if(document.getElementById(objid).checked==true){
  7. $("."+type).show();
  8. }
  9. else{
  10. $("."+type).hide();
  11. }
  12. }
  13. function dict_bold_word_all_select(){
  14. var wordcount=$("#bold_word_count").val();
  15. for(var i=0;i<wordcount;i++){
  16. document.getElementById("bold_word_"+i).checked=document.getElementById("bold_all_word").checked;
  17. }
  18. dict_update_bold(0);
  19. }
  20. function dict_bold_word_select(id){
  21. var wordcount=$("#bold_word_count").val();
  22. for(var i=0;i<wordcount;i++){
  23. document.getElementById("bold_word_"+i).checked=false;
  24. }
  25. document.getElementById("bold_word_"+id).checked=true;
  26. dict_update_bold(0);
  27. }
  28. function dict_bold_book_select(id){
  29. var bookcount=$("#bold_book_count").val();
  30. for(var i=0;i<bookcount;i++){
  31. document.getElementById("bold_book_"+i).checked=false;
  32. }
  33. document.getElementById("bold_book_"+id).checked=true;
  34. dict_update_bold(0);
  35. }
  36. function dict_update_bold(currpage){
  37. var booklist="(";
  38. var bookcount=$("#bold_book_count").val();
  39. for(var i=0;i<bookcount;i++){
  40. if(document.getElementById("bold_book_"+i).checked){
  41. booklist+="'"+$("#bold_book_"+i).val()+"',";
  42. }
  43. }
  44. booklist=booklist.slice(0,-1);
  45. booklist+=")";
  46. $.get("title_search.php",
  47. {
  48. op:"search",
  49. word:title_search_curr_key,
  50. booklist:booklist,
  51. currpage:currpage
  52. },
  53. function(data,status){
  54. $("#dict_bold_right").html(data);
  55. $("#bold_book_list").html($("#bold_book_list_new").html());
  56. $("#bold_book_list_new").html("");
  57. });
  58. }
  59. function search_search(word){
  60. $("#pre_search_result").hide();
  61. $("#pre_search_result_1").hide();
  62. title_search_curr_key = word;
  63. if(!localStorage.searchword){
  64. localStorage.searchword="";
  65. }
  66. let oldHistory=localStorage.searchword;
  67. let arrOldHistory=oldHistory.split(",");
  68. let isExist=false;
  69. for(let i=0;i<arrOldHistory.length;i++){
  70. if(arrOldHistory[i]==word){
  71. isExist=true;
  72. }
  73. }
  74. if(!isExist){
  75. localStorage.searchword=word+","+oldHistory;
  76. }
  77. if(window.XMLHttpRequest)
  78. {// code for IE7, Firefox, Opera, etc.
  79. dict_search_xml_http=new XMLHttpRequest();
  80. }
  81. else if(window.ActiveXObject)
  82. {// code for IE6, IE5
  83. dict_search_xml_http=new ActiveXObject("Microsoft.XMLHTTP");
  84. }
  85. if (dict_search_xml_http!=null)
  86. {
  87. dict_search_xml_http.onreadystatechange=dict_search_serverResponse;
  88. word=word.replace(/\+/g,"%2b");
  89. dict_search_xml_http.open("GET", "title_search.php?op=search&word="+word, true);
  90. dict_search_xml_http.send();
  91. }
  92. else
  93. {
  94. alert("Your browser does not support XMLHTTP.");
  95. }
  96. }
  97. function dict_search_serverResponse(){
  98. if (dict_search_xml_http.readyState==4)// 4 = "loaded"
  99. {
  100. if (dict_search_xml_http.status==200)
  101. {// 200 = "OK"
  102. var serverText = dict_search_xml_http.responseText;
  103. dict_result=document.getElementById("dict_ref_search_result");
  104. if(dict_result){
  105. dict_result.innerHTML=serverText;
  106. $("#dict_ref_dict_link").html($("#dictlist").html());
  107. $("#dictlist").html("");
  108. }
  109. //$("#dict_type").html($("#real_dict_tab").html());
  110. }
  111. else
  112. {
  113. alert(dict_pre_search_xml_http.statusText,0);
  114. }
  115. }
  116. }
  117. var dict_pre_search_xml_http=null;
  118. function search_pre_search(word){
  119. if(dict_pre_searching==true){return;}
  120. dict_pre_searching=true;
  121. dict_pre_search_curr_word=word;
  122. if(window.XMLHttpRequest)
  123. {// code for IE7, Firefox, Opera, etc.
  124. dict_pre_search_xml_http=new XMLHttpRequest();
  125. }
  126. else if(window.ActiveXObject)
  127. {// code for IE6, IE5
  128. dict_pre_search_xml_http=new ActiveXObject("Microsoft.XMLHTTP");
  129. }
  130. if (dict_pre_search_xml_http!=null)
  131. {
  132. dict_pre_search_xml_http.onreadystatechange=dict_pre_search_serverResponse;
  133. dict_pre_search_xml_http.open("GET", "title_search.php?op=pre&word="+word, true);
  134. dict_pre_search_xml_http.send();
  135. }
  136. else
  137. {
  138. alert("Your browser does not support XMLHTTP.");
  139. }
  140. }
  141. function dict_pre_search_serverResponse(){
  142. if (dict_pre_search_xml_http.readyState==4)// 4 = "loaded"
  143. {
  144. if (dict_pre_search_xml_http.status==200)
  145. {// 200 = "OK"
  146. var serverText = dict_pre_search_xml_http.responseText;
  147. $("#pre_search_word_content").html(serverText);
  148. $("#pre_search_word_content_1").html(serverText);
  149. }
  150. else
  151. {
  152. alert(dict_pre_search_xml_http.statusText,0);
  153. }
  154. dict_pre_searching=false;
  155. var newword = document.getElementById("dict_ref_search_input").value;
  156. if(newword!=dict_pre_search_curr_word){
  157. search_pre_search(newword);
  158. }
  159. }
  160. }
  161. function dict_pre_word_click(word){
  162. $("#pre_search_result").hide();
  163. $("#pre_search_result_1").hide();
  164. let inputSearch = $("#dict_ref_search_input").val();
  165. let arrSearch = inputSearch.split(" ");
  166. arrSearch[arrSearch.length-1]=word;
  167. let strSearchWord = arrSearch.join(" ");
  168. $("#dict_ref_search_input").val(strSearchWord);
  169. $("#dict_ref_search_input_1").val(strSearchWord);
  170. search_search(word);
  171. }
  172. function dict_input_change(obj){
  173. search_pre_search(obj.value);
  174. }
  175. function search_show_history(){
  176. if(!localStorage.searchword){
  177. localStorage.searchword="";
  178. }
  179. var arrHistory=localStorage.searchword.split(",");
  180. var strHistory="";
  181. if(arrHistory.length>0){
  182. strHistory+="<a onclick=\"cls_word_search_history()\">清空历史记录</a>";
  183. }
  184. for(var i=0;i<arrHistory.length;i++){
  185. var word=arrHistory[i];
  186. strHistory+="<div class='dict_word_list'>";
  187. strHistory+="<a onclick='dict_pre_word_click(\""+word+"\")'>"+word+"</a>";
  188. strHistory+="</div>";
  189. }
  190. $("#dict_ref_search_result").html(strHistory);
  191. }
  192. function search_input_onfocus(){
  193. if($("#dict_ref_search_input").val()==""){
  194. search_show_history();
  195. }
  196. }
  197. function search_input_keyup(e,obj){
  198. var keynum
  199. var keychar
  200. var numcheck
  201. if($("#dict_ref_search_input").val()==""){
  202. search_show_history();
  203. $("#pre_search_result").hide();
  204. $("#pre_search_result_1").hide();
  205. return;
  206. }
  207. if(window.event) // IE
  208. {
  209. keynum = e.keyCode
  210. }
  211. else if(e.which) // Netscape/Firefox/Opera
  212. {
  213. keynum = e.which
  214. }
  215. var keychar = String.fromCharCode(keynum)
  216. if(keynum==13){
  217. //search_search(obj.value);
  218. window.location.assign("../search/title.php?key="+obj.value);
  219. }
  220. else{
  221. if(obj.value.indexOf(" ")>=0){
  222. //search_pre_sent(obj.value);
  223. }
  224. else{
  225. $("#pre_search_sent").hide();
  226. }
  227. $("#pre_search_result").show();
  228. $("#pre_search_result_1").show();
  229. search_pre_search(obj.value);
  230. }
  231. }
  232. function search_pre_sent(word){
  233. pali_sent_get_word(word,function(result){
  234. let html="";
  235. try{
  236. let arrResult= JSON.parse(result);
  237. for(x in arrResult){
  238. html+=arrResult[x].text+"<br>";
  239. }
  240. $("#pre_search_sent_title_right").html("总共"+arrResult.lenght);
  241. $("#pre_search_sent_content").html(html);
  242. $("#pre_search_sent").show();
  243. }
  244. catch(e){
  245. console.error(e.message);
  246. }
  247. });
  248. }
  249. function cls_word_search_history(){
  250. localStorage.searchword="";
  251. $("#dict_ref_search_result").html("");
  252. }
  253. function search_edit_now(book,para,title){
  254. var res_list = new Array();
  255. res_list.push({"type":"1","album_id":"-1","book":book,"parNum":para,"parlist":para,"title":title+"-"+para});
  256. res_list.push({"type":"6","album_id":"-1","book":book,"parNum":para,"parlist":para,"title":title+"-"+para});
  257. var res_data = JSON.stringify(res_list);
  258. window.open("../studio/project.php?op=create&data="+res_data,"_blank");
  259. }