common.js 20 KB

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