common.js 20 KB

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