国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

129 lines
3.3KB

  1. function showHide(objname, o)
  2. {
  3. //只对主菜单设置cookie
  4. var obj = document.getElementById(objname);
  5. var objsun = document.getElementById('sun'+objname);
  6. if(objname.indexOf('_1')<0 || objname.indexOf('_10')>0)
  7. {
  8. if(obj.style.display == 'block' || obj.style.display =='')
  9. {
  10. obj.style.display = 'none';
  11. o.querySelector("i").className = "fa fa-angle-right"
  12. } else {
  13. obj.style.display = 'block';
  14. o.querySelector("i").className = "fa fa-angle-down"
  15. }
  16. return true;
  17. }
  18. //正常设置cookie
  19. var ckstr = getCookie('menuitems');
  20. var ckstrs = null;
  21. var okstr ='';
  22. var ischange = false;
  23. if(ckstr==null) ckstr = '';
  24. ckstrs = ckstr.split(',');
  25. objname = objname.replace('items','');
  26. if(obj.style.display == 'block' || obj.style.display =='')
  27. {
  28. obj.style.display = 'none';
  29. for(var i=0; i < ckstrs.length; i++)
  30. {
  31. if(ckstrs[i]=='') continue;
  32. if(ckstrs[i]==objname){ ischange = true; }
  33. else okstr += (okstr=='' ? ckstrs[i] : ','+ckstrs[i] );
  34. }
  35. o.querySelector("i").className = "fa fa-angle-right"
  36. } else {
  37. obj.style.display = 'block';
  38. ischange = true;
  39. for(var i=0; i < ckstrs.length; i++)
  40. {
  41. if(ckstrs[i]==objname) { ischange = false; break; }
  42. }
  43. if(ischange)
  44. {
  45. ckstr = (ckstr==null ? objname : ckstr+','+objname);
  46. setCookie('menuitems',ckstr,7);
  47. }
  48. o.querySelector("i").className = "fa fa-angle-down"
  49. }
  50. }
  51. //读写cookie函数
  52. function getCookie(c_name)
  53. {
  54. if (document.cookie.length > 0)
  55. {
  56. c_start = document.cookie.indexOf(c_name + "=")
  57. if (c_start != -1)
  58. {
  59. c_start = c_start + c_name.length + 1;
  60. c_end = document.cookie.indexOf(";",c_start);
  61. if (c_end == -1)
  62. {
  63. c_end = document.cookie.length;
  64. }
  65. return unescape(document.cookie.substring(c_start,c_end));
  66. }
  67. }
  68. return null
  69. }
  70. function setCookie(c_name,value,expiredays)
  71. {
  72. var exdate = new Date();
  73. exdate.setDate(exdate.getDate() + expiredays);
  74. document.cookie = c_name + "=" +escape(value) + ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString()); //使设置的有效时间正确。增加toGMTString()
  75. }
  76. //检查以前用户展开的菜单项
  77. var totalitem = 12;
  78. function CheckOpenMenu()
  79. {
  80. var ckstr = getCookie('menuitems');
  81. var curitem = '';
  82. var curobj = null;
  83. if(ckstr==null)
  84. {
  85. ckstr='1_1,2_1,3_1';
  86. setCookie('menuitems',ckstr,7);
  87. }
  88. ckstr = ','+ckstr+',';
  89. for(i=0;i<totalitem;i++)
  90. {
  91. curitem = i+'_'+curopenItem;
  92. curobj = document.getElementById('items'+curitem);
  93. if(ckstr.indexOf(curitem) > 0 && curobj != null)
  94. {
  95. curobj.style.display = 'block';
  96. } else {
  97. if(curobj != null) curobj.style.display = 'none';
  98. }
  99. }
  100. }
  101. var curitem = 1;
  102. function ShowMainMenu(n)
  103. {
  104. var curLink = $DE('link'+curitem);
  105. var targetLink = $DE('link'+n);
  106. var curCt = $DE('ct'+curitem);
  107. var targetCt = $DE('ct'+n);
  108. if(curitem==n) return false;
  109. if(targetCt.innerHTML!='')
  110. {
  111. curCt.style.display = 'none';
  112. targetCt.style.display = 'block';
  113. curLink.className = 'menu-item';
  114. targetLink.className = 'menu-active';
  115. curitem = n;
  116. } else {
  117. fetch("index_menu_load.php?openitem="+n).then(resp=>resp.text()).then((d)=>{
  118. targetCt.innerHTML = d;
  119. if(targetCt.innerHTML!='')
  120. {
  121. curCt.style.display = 'none';
  122. targetCt.style.display = 'block';
  123. curLink.className = 'menu-item';
  124. targetLink.className = 'menu-active';
  125. curitem = n;
  126. }
  127. });
  128. }
  129. }