common.js 20 KB

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