vn.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. var g_is_mobile=false;
  2. //输出调试信息
  3. function var_dump(str){
  4. document.getElementById("debug").innerHTML = str;
  5. var t=setTimeout("clearDebugMsg()",5000);
  6. }
  7. function clearDebugMsg(){
  8. document.getElementById("debug").innerHTML = "";
  9. }
  10. //页面初始字体大小 单位 %
  11. var iStartFontSize = 100;
  12. function setHitsVisibility(isVisible)
  13. {
  14. var c = getStyleClass('hit');
  15. if (isVisible)
  16. {
  17. c.style.backgroundColor = 'blue';
  18. c.style.color = 'white';
  19. }
  20. else
  21. {
  22. c.style.backgroundColor = 'white';
  23. c.style.color = 'black';
  24. }
  25. }
  26. function setPageColor(sColor)
  27. {
  28. var c = getStyleClass('mainbody');
  29. var cToc = getStyleClass('toc');
  30. switch(sColor){
  31. case 0:
  32. c.style.backgroundColor = 'white';
  33. c.style.color = 'black';
  34. cToc.style.backgroundColor = "#F1F1F1";
  35. break;
  36. case 1:
  37. c.style.backgroundColor = '#ffead7';
  38. c.style.color = '#844200';
  39. cToc.style.backgroundColor = '#fff0e4';
  40. break;
  41. case 2:
  42. c.style.backgroundColor = '#000010';
  43. c.style.color = '#e0e0e0';
  44. cToc.style.backgroundColor = '#335';
  45. break;
  46. }
  47. }
  48. //修改页面字体大小
  49. function setPageFontSize(fChange)
  50. {
  51. iStartFontSize = iStartFontSize * fChange;
  52. var myBody = document.getElementById("mbody");
  53. myBody.style.fontSize= iStartFontSize + "%";
  54. setCookie('fontsize',iStartFontSize,65)
  55. }
  56. function setFootnotesVisibility(isVisible)
  57. {
  58. getStyleClass('note').style.display = (isVisible ? 'inline' : 'none');
  59. }
  60. function setIdVisibility()
  61. {
  62. var isVisible = document.getElementById("B_Id").checked;
  63. getStyleClass('ID').style.display = (isVisible ? 'block' : 'none');
  64. }
  65. function setOrgVisibility()
  66. {
  67. var isVisible = document.getElementById("B_Org").checked;
  68. getStyleClass('org').style.display = (isVisible ? 'block' : 'none');
  69. }
  70. function setMeaningVisibility()
  71. {
  72. var isVisible = document.getElementById("B_Meaning").checked;
  73. getStyleClass('mean').style.display = (isVisible ? 'block' : 'none');
  74. }
  75. function setGrammaVisibility()
  76. {
  77. var isVisible = document.getElementById("B_Gramma").checked;
  78. getStyleClass('case').style.display = (isVisible ? 'block' : 'none');
  79. }
  80. //显示英译
  81. function setParTranEnVisibility()
  82. {
  83. var isVisible = document.getElementById("B_ParTranEn").checked;
  84. getStyleClass('tran_par_en').style.display = (isVisible ? 'block' : 'none');
  85. }
  86. //显示中译
  87. function setParTranCnVisibility()
  88. {
  89. var isVisible = document.getElementById("B_ParTranCn").checked;
  90. getStyleClass('tran_par_cn').style.display = (isVisible ? 'block' : 'none');
  91. }
  92. //显示段对译模式
  93. function setParTranShowMode()
  94. {
  95. var isVisible = document.getElementById("B_ParTranShowMode").checked;
  96. if(isVisible){ /* 上下对读 */
  97. getStyleClass('pali_par').style.width = "auto";
  98. getStyleClass('pali_par').style.float="none";
  99. getStyleClass('pali_par_gatha').style.width = "auto";
  100. getStyleClass('pali_par_gatha').style.float="none";
  101. //getStyleClass('tran_par').style.margin = "0";
  102. }
  103. else{ /* 左右对读 */
  104. getStyleClass('pali_par').style.width = "50%";
  105. getStyleClass('pali_par').style.float = "left";
  106. getStyleClass('pali_par_gatha').style.width = "50%";
  107. getStyleClass('pali_par_gatha').style.float = "left";
  108. //getStyleClass('tran_par').style.margin = "0 0 0 50%-220px";
  109. }
  110. }
  111. //显示单词表
  112. function setWordTableVisibility()
  113. {
  114. var isVisible = document.getElementById("B_WordTableShowMode").checked;
  115. document.getElementById("word_table").style.display = (isVisible ? 'block' : 'none');
  116. }
  117. function getStyle (styleName) {
  118. for (var s = 0; s < document.styleSheets.length; s++)
  119. {
  120. if(document.styleSheets[s].rules)
  121. {
  122. for (var r = 0; r < document.styleSheets[s].rules.length; r++)
  123. {
  124. if (document.styleSheets[s].rules[r].selectorText == styleName)
  125. {
  126. return document.styleSheets[s].rules[r];
  127. }
  128. }
  129. }
  130. else if(document.styleSheets[s].cssRules)
  131. {
  132. for (var r = 0; r < document.styleSheets[s].cssRules.length; r++)
  133. {
  134. if (document.styleSheets[s].cssRules[r].selectorText == styleName)
  135. return document.styleSheets[s].cssRules[r];
  136. }
  137. }
  138. }
  139. return null;
  140. }
  141. function getStyleClass (className) {
  142. for (var s = 0; s < document.styleSheets.length; s++)
  143. {
  144. if(document.styleSheets[s].rules)
  145. {
  146. for (var r = 0; r < document.styleSheets[s].rules.length; r++)
  147. {
  148. if (document.styleSheets[s].rules[r].selectorText == '.' + className)
  149. {
  150. return document.styleSheets[s].rules[r];
  151. }
  152. }
  153. }
  154. else if(document.styleSheets[s].cssRules)
  155. {
  156. for (var r = 0; r < document.styleSheets[s].cssRules.length; r++)
  157. {
  158. if (document.styleSheets[s].cssRules[r].selectorText == '.' + className)
  159. return document.styleSheets[s].cssRules[r];
  160. }
  161. }
  162. }
  163. return null;
  164. }
  165. function getCookie(c_name)
  166. {
  167. if (document.cookie.length>0)
  168. {
  169. c_start=document.cookie.indexOf(c_name + "=")
  170. if (c_start!=-1)
  171. {
  172. c_start=c_start + c_name.length+1
  173. c_end=document.cookie.indexOf(";",c_start)
  174. if (c_end==-1)
  175. c_end=document.cookie.length
  176. return unescape(document.cookie.substring(c_start,c_end))
  177. }
  178. }
  179. return ""
  180. }
  181. function setCookie(c_name,value,expiredays)
  182. {
  183. var exdate=new Date()
  184. exdate.setDate(exdate.getDate()+expiredays)
  185. document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : "; expires="+exdate.toGMTString())
  186. }
  187. //读取cookie 中的字体大小
  188. function checkCookie(){
  189. mFontSize=getCookie('fontsize')
  190. if (mFontSize!=null && mFontSize!="")
  191. {
  192. iStartFontSize = mFontSize
  193. }
  194. else
  195. {
  196. mFontSize=100
  197. iStartFontSize = 100
  198. setCookie('fontsize',mFontSize,365)
  199. }
  200. setPageFontSize(1);
  201. setPageColor(0);
  202. }
  203. function setObjectVisibilityAlone(strIdGroup , strId){
  204. var hiden = new Array();
  205. hiden=strIdGroup.split('&');
  206. for(i=0;i<hiden.length;i++){
  207. document.getElementById(hiden[i]).style.display="none";
  208. }
  209. var obj = document.getElementById(strId);
  210. obj.style.display="block";
  211. }
  212. function setObjectVisibility(strId){
  213. var obj = document.getElementById(strId);
  214. if(obj.style.display=="none"){
  215. obj.style.display="block";
  216. }
  217. else{
  218. obj.style.display="none";
  219. }
  220. }
  221. function setObjectVisibility2(ControllerId,ObjId){
  222. var isVisible = document.getElementById(ControllerId).checked;
  223. document.getElementById(ObjId).style.display = (isVisible ? 'block' : 'none');
  224. }
  225. function setNaviVisibility(){
  226. var objNave = document.getElementById('leftmenuinner');
  227. var objMainView = document.getElementById("body_mainview");
  228. if(objNave.style.display=="none"){
  229. objNave.style.display="block";
  230. //objMainView.style.margin = "0,0,0,18em";
  231. getStyleClass('mainview').style.margin = "0,0,0,42em";
  232. }
  233. else{
  234. objNave.style.display="none";
  235. //objMainView.style.margin = "0";
  236. getStyleClass('mainview').style.margin = "0";
  237. }
  238. }
  239. function windowsInit(){
  240. var strSertch = location.search;
  241. if(strSertch.length>0){
  242. strSertch = strSertch.substr(1);
  243. var sertchList=strSertch.split('&');
  244. for (x in sertchList){
  245. var item = sertchList[x].split('=');
  246. if(item[0]=="filename"){
  247. g_filename=item[1];
  248. }
  249. }
  250. }
  251. checkCookie();
  252. setUseMode("read");
  253. if(g_filename.length>0){
  254. loadxml(g_filename);
  255. }
  256. else{
  257. alert("error:没有指定文件名。");
  258. }
  259. }
  260. /*静态页面使用的初始化函数*/
  261. function windowsInitStatic(){
  262. checkCookie();
  263. setUseMode_Static("read");
  264. }
  265. function indexInit(){
  266. showUserFilaList();
  267. }
  268. function goHome(){
  269. var r=confirm("在返回前请保存文件。否则所有的更改将丢失。\n 按<确定>回到主页。按<取消>留在当前页面。");
  270. if (r==true)
  271. {
  272. window.location.assign("index.html?device="+g_device);
  273. }
  274. }