2
0

title.js 8.0 KB

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