common.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714
  1. var g_is_mobile = false;
  2. var g_language = "langrage_cn";
  3. var gConfigDirMydocument = "../user/My Document/";
  4. //输出调试信息
  5. function debugOutput(str, level = 0) {
  6. console.log(str);
  7. }
  8. function var_dump(str) {
  9. getStyleClass("debug_info").style.display = "-webkit-flex";
  10. getStyleClass("debug_info").style.animation = "viewbug 2s";
  11. document.getElementById("debug").innerHTML = str;
  12. var t = setTimeout("clearDebugMsg()", 2000);
  13. }
  14. function clearDebugMsg() {
  15. document.getElementById("debug").innerHTML = "";
  16. getStyleClass("debug_info").style.display = "none";
  17. }
  18. //页面初始字体大小 单位 %
  19. var iStartFontSize = 100;
  20. function setHitsVisibility(isVisible) {
  21. var c = getStyleClass("hit");
  22. if (isVisible) {
  23. c.style.backgroundColor = "blue";
  24. c.style.color = "white";
  25. } else {
  26. c.style.backgroundColor = "white";
  27. c.style.color = "black";
  28. }
  29. }
  30. const root = document.documentElement;
  31. function setPageColor(sColor) {
  32. var cssobj = document.getElementById("colorchange");
  33. switch (sColor) {
  34. case 0:
  35. cssobj.setAttribute("href", "css/color_day.css");
  36. break;
  37. case 1:
  38. cssobj.setAttribute("href", "css/color_dawn.css");
  39. break;
  40. case 2:
  41. cssobj.setAttribute("href", "css/color_night.css");
  42. break;
  43. }
  44. }
  45. //修改页面字体大小
  46. function setPageFontSize(fChange) {
  47. iStartFontSize = iStartFontSize * fChange;
  48. var myBody = document.getElementById("mbody");
  49. myBody.style.fontSize = iStartFontSize + "%";
  50. setCookie("fontsize", iStartFontSize, 65);
  51. }
  52. function editSandhiDisplay(item, obj) {
  53. var isVisible = obj.checked;
  54. var xAllWord = gXmlBookDataBody.getElementsByTagName("word");
  55. switch (item) {
  56. case "parent":
  57. getStyleClass("un_parent").style.display = isVisible ? "block" : "none";
  58. break;
  59. case "comp_parent":
  60. getStyleClass("comp_parent").style.display = isVisible ? "block" : "none";
  61. break;
  62. }
  63. for (iWordIndex = 0; iWordIndex < xAllWord.length; iWordIndex++) {
  64. var un = getNodeText(xAllWord[iWordIndex], "un");
  65. if (un.length > 0) {
  66. switch (item) {
  67. case "begin":
  68. if (getNodeText(xAllWord[iWordIndex], "case") == ".un:begin.") {
  69. wordid = "wb" + getNodeText(xAllWord[iWordIndex], "id");
  70. document.getElementById(wordid).style.display = isVisible
  71. ? "block"
  72. : "none";
  73. }
  74. break;
  75. case "end":
  76. if (getNodeText(xAllWord[iWordIndex], "case") == ".un:end.") {
  77. wordid = "wb" + getNodeText(xAllWord[iWordIndex], "id");
  78. document.getElementById(wordid).style.display = isVisible
  79. ? "block"
  80. : "none";
  81. }
  82. break;
  83. case "word":
  84. if (
  85. getNodeText(xAllWord[iWordIndex], "case") != ".un:begin." ||
  86. getNodeText(xAllWord[iWordIndex], "case") != ".un:end." ||
  87. getNodeText(xAllWord[iWordIndex], "case") != ".ctl.#.a."
  88. ) {
  89. //既不是開始也不是結束
  90. wordid = "wb" + getNodeText(xAllWord[iWordIndex], "id");
  91. document.getElementById(wordid).style.display = isVisible
  92. ? "block"
  93. : "none";
  94. }
  95. break;
  96. case "parent":
  97. //document.getElementById("wb"+un).style.display=(isVisible ? 'block' : 'none');
  98. break;
  99. }
  100. }
  101. }
  102. }
  103. function setFootnotesVisibility(isVisible) {
  104. getStyleClass("note").style.display = isVisible ? "inline" : "none";
  105. }
  106. function setIdVisibility() {
  107. var isVisible = document.getElementById("B_Id").checked;
  108. getStyleClass("ID").style.display = isVisible ? "block" : "none";
  109. }
  110. function setMeaningVisibility(obj) {
  111. var isVisible = obj.checked;
  112. getStyleClass("mean").style.display = isVisible ? "flex" : "none";
  113. }
  114. function setOrgVisibility(obj) {
  115. var isVisible = obj.checked;
  116. getStyleClass("org").style.display = isVisible ? "flex" : "none";
  117. }
  118. function setOrgMeaningVisibility(obj) {
  119. var isVisible = obj.checked;
  120. getStyleClass("om").style.display = isVisible ? "flex" : "none";
  121. }
  122. function setGrammaVisibility(obj) {
  123. var isVisible = obj.checked;
  124. getStyleClass("case").style.display = isVisible ? "flex" : "none";
  125. }
  126. function set_WBW_ALL_Visibility(obj) {
  127. let isVisible = obj.checked;
  128. getStyleClass("mean").style.display = isVisible ? "flex" : "none";
  129. getStyleClass("org").style.display = isVisible ? "flex" : "none";
  130. getStyleClass("om").style.display = isVisible ? "flex" : "none";
  131. getStyleClass("case").style.display = isVisible ? "flex" : "none";
  132. document.getElementById("WBW_B_Meaning").checked = obj.checked;
  133. document.getElementById("WBW_B_Org").checked = obj.checked;
  134. document.getElementById("WBW_B_OrgMeaning").checked = obj.checked;
  135. document.getElementById("WBW_B_Gramma").checked = obj.checked;
  136. }
  137. //显示英译
  138. function setParTranEnVisibility(obj) {
  139. var isVisible = obj.checked;
  140. //getStyleClass('tran_par_en').style.display = (isVisible ? 'block' : 'none');
  141. getStyleClass("en_text").style.display = isVisible ? "block" : "none";
  142. }
  143. //显示中译
  144. function setParTranCnVisibility(obj) {
  145. var isVisible = obj.checked;
  146. //getStyleClass('tran_par_cn').style.display = (isVisible ? 'block' : 'none');
  147. getStyleClass("zh_text").style.display = isVisible ? "block" : "none";
  148. getStyleClass("tw_text").style.display = isVisible ? "block" : "none";
  149. }
  150. /*
  151. //显示模式
  152. _display_para_arrange=0;//0:横向 排列 1:纵向排列
  153. _display_sbs=0; //0:逐段 1:逐句
  154. */
  155. function setArrange(mode) {
  156. if (_display_para_arrange == mode) {
  157. return;
  158. }
  159. _display_para_arrange = mode;
  160. if (_display_para_arrange == 1) {
  161. /* 上下对读 */
  162. getStyleClass("wbwdiv").style.flex = "1";
  163. getStyleClass("trandiv").style.flex = "1";
  164. getStyleClass("pardiv").style.flexDirection = "column";
  165. getStyleClass("sent_wbw_trans").style.flexDirection = "column";
  166. } else if (_display_para_arrange == 0) {
  167. /* 0 左右对读 */
  168. getStyleClass("wbwdiv").style.flex = "7";
  169. getStyleClass("trandiv").style.flex = "3";
  170. getStyleClass("pardiv").style.flexDirection = "row";
  171. getStyleClass("sent_wbw_trans").style.flexDirection = "row";
  172. }
  173. if (_display_sbs == 1) {
  174. /* 逐句对读 */
  175. getStyleClass("pardiv").style.flexDirection = "column";
  176. }
  177. }
  178. function setSbs(mode) {
  179. if (_display_sbs != mode) {
  180. _display_sbs = mode;
  181. if (_display_sbs == 1) {
  182. /* 逐句对读 */
  183. getStyleClass("translate_sent").style.display = "block";
  184. getStyleClass("pardiv").style.flexDirection = "column";
  185. updateWordParBlockInnerAll();
  186. var eAllSent = document.getElementsByClassName("tran_sent");
  187. for (var iSen = 0; iSen < eAllSent.length; iSen++) {
  188. var senA = eAllSent[iSen].getAttributeNode("sn").value;
  189. var blockId = eAllSent[iSen].getAttributeNode("block").value;
  190. var eSBSDiv = document.getElementById("sent_" + senA);
  191. if (eSBSDiv) {
  192. var eBlockSenDiv = document.getElementById(
  193. "sent_" + senA + "_" + blockId
  194. );
  195. if (!eBlockSenDiv) {
  196. //没有 添加
  197. var divSen = document.createElement("div");
  198. var typ = document.createAttribute("class");
  199. typ.nodeValue = "sbs_sent_block";
  200. divSen.attributes.setNamedItem(typ);
  201. var typId = document.createAttribute("id");
  202. typId.nodeValue = "sent_" + senA + "_" + blockId;
  203. divSen.attributes.setNamedItem(typId);
  204. var sn = document.createAttribute("sn");
  205. sn.nodeValue = senA;
  206. divSen.attributes.setNamedItem(sn);
  207. var block = document.createAttribute("block");
  208. block.nodeValue = blockId;
  209. divSen.attributes.setNamedItem(block);
  210. divSen.innerHTML = eAllSent[iSen].innerHTML;
  211. eSBSDiv.appendChild(divSen);
  212. } else {
  213. eBlockSenDiv.innerHTML = eAllSent[iSen].innerHTML;
  214. }
  215. eAllSent[iSen].innerHTML = "";
  216. }
  217. }
  218. } else {
  219. /* 逐段对读 */
  220. //因为wbw重绘会覆盖逐句html
  221. //所以将逐句对读里的句子 转移到逐段div
  222. getStyleClass("translate_sent").style.display = "none";
  223. var eAllSent = document.getElementsByClassName("sbs_sent_block");
  224. for (var iSen = 0; iSen < eAllSent.length; iSen++) {
  225. var senA = eAllSent[iSen].getAttributeNode("sn").value;
  226. var blockId = eAllSent[iSen].getAttributeNode("block").value;
  227. var eSBSDiv = document.getElementById(
  228. "tran_sent_" + blockId + "_" + senA
  229. );
  230. if (eSBSDiv) {
  231. //逐段div
  232. eSBSDiv.innerHTML = eAllSent[iSen].innerHTML;
  233. eAllSent[iSen].innerHTML = "";
  234. } else {
  235. ntf_show("error: 没有找到div:" + "tran_sent_" + blockId + "_" + senA);
  236. }
  237. }
  238. updateWordParBlockInnerAll();
  239. }
  240. }
  241. }
  242. //显示段对译模式
  243. function setParTranShowMode(obj) {
  244. var isVisible = obj.checked;
  245. if (isVisible) {
  246. /* 上下对读 */
  247. _display_para_arrange = 1;
  248. getStyleClass("wbwdiv").style.flex = "1";
  249. getStyleClass("trandiv").style.flex = "1";
  250. getStyleClass("pardiv").style.flexDirection = "column";
  251. getStyleClass("sent_wbw_trans").style.flexDirection = "column";
  252. } else {
  253. /* 左右对读 */
  254. _display_para_arrange = 0;
  255. getStyleClass("wbwdiv").style.flex = "7";
  256. getStyleClass("trandiv").style.flex = "3";
  257. getStyleClass("pardiv").style.flexDirection = "row";
  258. getStyleClass("sent_wbw_trans").style.flexDirection = "row";
  259. }
  260. }
  261. //顯示逐句對讀模式
  262. function setSentTranShowMode(obj) {
  263. var isVisible = obj.checked;
  264. if (isVisible) {
  265. /* 逐句对读 */
  266. _display_sbs = 1;
  267. updateWordParBlockInnerAll();
  268. var eAllSent = document.getElementsByClassName("tran_sent");
  269. for (var iSen = 0; iSen < eAllSent.length; iSen++) {
  270. var senA = eAllSent[iSen].getAttributeNode("sn").value;
  271. var eSBSDiv = document.getElementById("sent_" + senA);
  272. if (eSBSDiv) {
  273. eSBSDiv.innerHTML = eAllSent[iSen].innerHTML;
  274. eAllSent[iSen].innerHTML = "";
  275. }
  276. }
  277. } else {
  278. /* 逐段对读 */
  279. _display_sbs = 0;
  280. //getStyleClass('trandiv').style.display="block";
  281. //getStyleClass('translate_sent').style.display="none";
  282. updateWordParBlockInnerAll();
  283. }
  284. }
  285. //显示单词表
  286. function setWordTableVisibility() {
  287. var isVisible = document.getElementById("B_WordTableShowMode").checked;
  288. document.getElementById("word_table").style.display = isVisible
  289. ? "block"
  290. : "none";
  291. }
  292. function getStyle(styleName) {
  293. for (var s = 0; s < document.styleSheets.length; s++) {
  294. if (document.styleSheets[s].rules) {
  295. for (var r = 0; r < document.styleSheets[s].rules.length; r++) {
  296. if (document.styleSheets[s].rules[r].selectorText == styleName) {
  297. return document.styleSheets[s].rules[r];
  298. }
  299. }
  300. } else if (document.styleSheets[s].cssRules) {
  301. for (var r = 0; r < document.styleSheets[s].cssRules.length; r++) {
  302. if (document.styleSheets[s].cssRules[r].selectorText == styleName)
  303. return document.styleSheets[s].cssRules[r];
  304. }
  305. }
  306. }
  307. return null;
  308. }
  309. function getStyleClass(className) {
  310. for (var s = 0; s < document.styleSheets.length; s++) {
  311. if (document.styleSheets[s].rules) {
  312. for (var r = 0; r < document.styleSheets[s].rules.length; r++) {
  313. if (document.styleSheets[s].rules[r].selectorText == "." + className) {
  314. return document.styleSheets[s].rules[r];
  315. }
  316. }
  317. } else if (document.styleSheets[s].cssRules) {
  318. for (var r = 0; r < document.styleSheets[s].cssRules.length; r++) {
  319. if (document.styleSheets[s].cssRules[r].selectorText == "." + className)
  320. return document.styleSheets[s].cssRules[r];
  321. }
  322. }
  323. }
  324. return null;
  325. }
  326. //读取cookie 中的字体大小
  327. function checkCookie() {
  328. mFontSize = getCookie("fontsize");
  329. if (mFontSize != null && mFontSize != "") {
  330. iStartFontSize = mFontSize;
  331. } else {
  332. mFontSize = 100;
  333. iStartFontSize = 100;
  334. setCookie("fontsize", mFontSize, 365);
  335. }
  336. setPageFontSize(1);
  337. setPageColor(0);
  338. }
  339. function setObjectVisibilityAlone(strIdGroup, strId) {
  340. var hiden = new Array();
  341. hiden = strIdGroup.split("&");
  342. for (i = 0; i < hiden.length; i++) {
  343. document.getElementById(hiden[i]).style.display = "none";
  344. }
  345. var obj = document.getElementById(strId);
  346. obj.style.display = "block";
  347. }
  348. function setObjectVisibility(strId) {
  349. var obj = document.getElementById(strId);
  350. if (obj.style.display == "none") {
  351. obj.style.display = "block";
  352. } else {
  353. obj.style.display = "none";
  354. }
  355. }
  356. function setObjectVisibility2(ControllerId, ObjId) {
  357. var isVisible = document.getElementById(ControllerId).checked;
  358. document.getElementById(ObjId).style.display = isVisible ? "block" : "none";
  359. }
  360. function setObjectVisibility3(Controller, ObjId) {
  361. var isVisible = Controller.checked;
  362. document.getElementById(ObjId).style.display = isVisible ? "block" : "none";
  363. }
  364. function setAllTitleVisibility(Controller, numTitle) {
  365. for (var i = 0; i < numTitle; i++) {
  366. document.getElementById("titlevisable" + numTitle).checked =
  367. Controller.checked;
  368. }
  369. }
  370. function windowsInit() {
  371. var strSertch = location.search;
  372. if (strSertch.length > 0) {
  373. strSertch = strSertch.substr(1);
  374. var sertchList = strSertch.split("&");
  375. for (x in sertchList) {
  376. var item = sertchList[x].split("=");
  377. if (item[0] == "filename") {
  378. g_filename = item[1];
  379. }
  380. }
  381. }
  382. checkCookie();
  383. setUseMode("Read");
  384. if (g_filename.length > 0) {
  385. loadDictFromDB(g_filename);
  386. loadxml(g_filename);
  387. } else {
  388. alert("error:没有指定文件名。");
  389. }
  390. }
  391. /*静态页面使用的初始化函数*/
  392. function windowsInitStatic() {
  393. checkCookie();
  394. setUseMode_Static("Read");
  395. }
  396. function indexInit() {
  397. showUserFilaList();
  398. }
  399. function goHome() {
  400. var r = confirm(
  401. "在返回前请保存文件。否则所有的更改将丢失。\n 按<确定>回到主页。按<取消>留在当前页面。"
  402. );
  403. if (r == true) {
  404. window.location.assign("index.php?device=" + g_device);
  405. }
  406. }
  407. function get_Local_Code_Str(inStr, language) {
  408. var get_Local_Code_Str_i = 0;
  409. switch (language) {
  410. case "sinhala":
  411. for (get_Local_Code_Str_i in local_codestr_sinhala) {
  412. inStr = inStr.replace(
  413. local_codestr_sinhala[get_Local_Code_Str_i].id,
  414. local_codestr_sinhala[get_Local_Code_Str_i].value
  415. );
  416. }
  417. break;
  418. /*case "sc":
  419. for(get_Local_Code_Str_i in local_codestr_sc){
  420. inStr=inStr.replace(local_codestr_sc[get_Local_Code_Str_i].id,local_codestr_sc[get_Local_Code_Str_i].value);
  421. }
  422. break;
  423. case "tc":
  424. for(get_Local_Code_Str_i in local_codestr_tc){
  425. inStr=inStr.replace(local_codestr_tc[get_Local_Code_Str_i].id,local_codestr_tc[get_Local_Code_Str_i].value);
  426. }
  427. break;*/
  428. case "pali":
  429. break;
  430. }
  431. return inStr;
  432. }
  433. function getLocalGrammaStr(inStr) {
  434. let str = inStr;
  435. for (let i in gLocal.grammastr) {
  436. str = str.replace(gLocal.grammastr[i].id, gLocal.grammastr[i].value);
  437. //eval("inStr=inStr.replace(/"+gLocal.grammastr[getLocalGrammaStr_i].id+"/g,gLocal.grammastr[getLocalGrammaStr_i].value);");
  438. }
  439. return str;
  440. }
  441. function getLocalGrammaStr_a(inStr) {
  442. var inStr_array_0 = new Array();
  443. i_inStr_array_0 = 0;
  444. if (inStr.lastIndexOf("<br>") != -1) {
  445. var split_str = "<br>";
  446. } else if (inStr.lastIndexOf("#") != -1) {
  447. var split_str = "#";
  448. } else {
  449. inStr_array_0.push(inStr);
  450. }
  451. inStr_array_0 = inStr.split(split_str);
  452. for (i_inStr_array_0 in inStr_array_0) {
  453. if (inStr_array_0[i_inStr_array_0].lastIndexOf("$") != -1) {
  454. var inStr_array = inStr_array_0[i_inStr_array_0].split("$");
  455. for (i_instr in inStr_array) {
  456. inStr_array[i_instr] = inStr_array[i_instr].slice(
  457. 1,
  458. inStr_array[i_instr].length - 1
  459. );
  460. inStr_array[i_instr] = "。" + inStr_array[i_instr] + "。";
  461. }
  462. inStr_array_0.splice(i_inStr_array_0, 1, inStr_array.join("@"));
  463. } else if (
  464. inStr_array_0[i_inStr_array_0] !=
  465. "" /*&& inStr_array_0[i_inStr_array_0].lastIndexOf(\s)=-1*/
  466. ) {
  467. inStr_array_0[i_inStr_array_0] = inStr_array_0[i_inStr_array_0].slice(
  468. 1,
  469. inStr_array_0[i_inStr_array_0].length - 1
  470. );
  471. inStr_array_0[i_inStr_array_0] =
  472. "。" + inStr_array_0[i_inStr_array_0] + "。";
  473. }
  474. }
  475. inStr = inStr_array_0.join(split_str);
  476. for (getLocalGrammaStr_i in gLocal.grammastr) {
  477. var str_Gramma = gLocal.grammastr[getLocalGrammaStr_i].id;
  478. if (str_Gramma != "$") {
  479. str_Gramma = str_Gramma.slice(1, str_Gramma.length - 1); //剝離前後的“.”
  480. str_Gramma = "。" + str_Gramma + "。"; //完成“.”到“。”的替換
  481. var special_RE = RegExp(str_Gramma, "g");
  482. inStr = inStr.replace(
  483. special_RE,
  484. gLocal.grammastr[getLocalGrammaStr_i].value
  485. );
  486. } else {
  487. var special_RE = RegExp("。@。", "g"); //轉化為正則表達式全局變量
  488. inStr = inStr.replace(special_RE, "。·。");
  489. }
  490. }
  491. //inStr=inStr.replace(/。/g,"");
  492. return inStr;
  493. }
  494. function getLocalDictname(inStr) {
  495. if (inStr) {
  496. var LocalDictname = inStr;
  497. } else {
  498. var LocalDictname = "NaN";
  499. }
  500. for (getLocalDictname_i in gLocal.dictname) {
  501. LocalDictname = LocalDictname.replace(
  502. gLocal.dictname[getLocalDictname_i].id,
  503. gLocal.dictname[getLocalDictname_i].value
  504. );
  505. }
  506. return LocalDictname;
  507. }
  508. function getLocalFormulaStr(inGramma, inStr) {
  509. if (inStr.indexOf("[") >= 0) {
  510. return inStr;
  511. }
  512. var output = inStr;
  513. for (i in gLocal.formula) {
  514. if (gLocal.formula[i].id == inGramma) {
  515. fList = gLocal.formula[i].value.split("$");
  516. output = fList[0].replace("~", inStr);
  517. }
  518. }
  519. return output;
  520. }
  521. function getFormulaList(strGramma) {
  522. var output = new Array();
  523. //先加载用户字典里的格位公式
  524. if (myFormula.length > 0) {
  525. for (let i in myFormula) {
  526. if (myFormula[i].gramma == strGramma) {
  527. if (myFormula[i].mean && myFormula[i].mean != "") {
  528. output.push(myFormula[i].mean);
  529. }
  530. }
  531. }
  532. }
  533. for (i in gLocal.formula) {
  534. if (gLocal.formula[i].id == strGramma) {
  535. return output.concat(gLocal.formula[i].value.split("$"));
  536. }
  537. }
  538. }
  539. function getLocalParentFormulaStr(inGramma, inStr) {
  540. var output = inStr;
  541. for (i in gLocal.parent_formula) {
  542. if (gLocal.parent_formula[i].id == inGramma) {
  543. output = gLocal.parent_formula[i].value.replace("~", inStr);
  544. }
  545. }
  546. return output;
  547. }
  548. function cutString(inString, cutLen) {
  549. if (inString) {
  550. if (inString.length > cutLen) {
  551. return inString.substring(0, cutLen - 1) + "…";
  552. } else {
  553. return inString;
  554. }
  555. } else {
  556. return "";
  557. }
  558. }
  559. function getElementWH(element) {
  560. var scrW, scrH;
  561. if (element.innerHeight && element.scrollMaxY) {
  562. // Mozilla
  563. scrW = element.innerWidth + element.scrollMaxX;
  564. scrH = element.innerHeight + element.scrollMaxY;
  565. } else if (element.scrollHeight > element.offsetHeight) {
  566. // all but IE Mac
  567. scrW = element.scrollWidth;
  568. scrH = element.scrollHeight;
  569. } else if (element) {
  570. // IE Mac
  571. scrW = element.offsetWidth;
  572. scrH = element.offsetHeight;
  573. }
  574. var obj = new Object();
  575. obj.width = scrW;
  576. obj.height = scrH;
  577. return obj;
  578. }
  579. /*
  580. 函数:tab_click
  581. 功能:点击选项卡时切换选项卡
  582. 参数:
  583. panalId:选项卡对应的面板id
  584. tabid:选项卡id
  585. callback:回调函数
  586. parm:回调函数参数
  587. 返回值:无
  588. */
  589. function tab_click(panalId, tabid, callback = null, parm = null) {
  590. $("#" + tabid)
  591. .siblings()
  592. .removeClass("act");
  593. $("#" + tabid).addClass("act");
  594. if (panalId != "") {
  595. $("#" + panalId).show();
  596. $("#" + panalId)
  597. .siblings()
  598. .hide();
  599. $("#" + panalId + "_head").show();
  600. $("#" + panalId + "_head")
  601. .siblings()
  602. .hide();
  603. }
  604. if (callback != null) {
  605. if (parm != null) {
  606. callback(parm);
  607. }
  608. }
  609. guide_init();
  610. }
  611. /*
  612. 函数:tab_click_b
  613. 功能:点击选项卡时切换选项卡 一个
  614. 参数:
  615. panalId:选项卡对应的面板id
  616. tabid:选项卡id
  617. callback:回调函数
  618. parm:回调函数参数
  619. 返回值:无
  620. */
  621. function tab_click_b(panalId, tabid, callback = null, parm = null) {
  622. if ($("#" + tabid).hasClass("act")) {
  623. $("#" + tabid).removeClass("act");
  624. } else {
  625. $("#" + tabid)
  626. .siblings()
  627. .removeClass("act");
  628. $("#" + tabid).addClass("act");
  629. }
  630. if (panalId != "") {
  631. $("#" + panalId).show();
  632. $("#" + panalId)
  633. .siblings()
  634. .hide();
  635. $("#" + panalId + "_head").show();
  636. $("#" + panalId + "_head")
  637. .siblings()
  638. .hide();
  639. }
  640. if (callback != null) {
  641. if (parm != null) {
  642. callback(parm);
  643. }
  644. }
  645. }
  646. function get_string_lang(inString) {
  647. let pattern2 = new RegExp("[A-Za-z]+");
  648. if (pattern2.test(inString)) {
  649. return "en";
  650. }
  651. let pattern = new RegExp("[\u4E00-\u9FA5]+");
  652. if (pattern.test(inString)) {
  653. return "zh";
  654. }
  655. return "en";
  656. }
  657. //查询某个字符串是否在字符串数组中出现‘
  658. //@parm:str 被查询的字符串
  659. //@parm:arr 数组
  660. //@return:true 查到 false 没查到
  661. function str_in_array(str, arr) {
  662. for (let x in arr) {
  663. if (arr[x] == str) {
  664. return true;
  665. }
  666. }
  667. return false;
  668. }