common.js 20 KB

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