common.js 20 KB

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