PageSourceSearch

https://mohe.gov.cn/mohe/xhtml/static/2023/js/common.js

js mohe.gov.cn collected 2026-10-02 17:08:22 UTC 9,288 bytes, 319 lines download raw bytes

1$(document).ready(function () {
2    //选项卡
3    if ($(".js-tab").length > 0) {
4        $(".js-tab").slide({
5			titCell: ".js-hd li",
6			mainCell: ".js-bd",
7            delayTime: 0,
8            triggerTime: 0,
9            targetCell: ".js-more a"
10        });
11    }
12    if ($(".js-tab-hs").length > 0) {
13        $(".js-tab-hs").slide({
14			titCell: ".js-hd li.hs",
15			mainCell: ".js-bd",
16            delayTime: 0,
17            triggerTime: 0,
18            targetCell: ".js-more a"
19        });
20    }
21	
22	if ($(".pagelist").length > 0) {
23	    addLine();
24	}
25	
26	if($('.set-emline').length > 0){
27	  setEmline();
28	  $(window).resize(function(){
29		setEmline();
30	  });	
31	}
32    
33	//返回顶部
34    $(".gotop").click(function(e){
35        e.preventDefault();
36        scrollToTop(500);
37    });
38    function scrollToTop(time){
39        var time = time || 0;
40        $("html,body").animate({scrollTop:0}, time);
41    }
42	
43    //easybtn
44    $(".easybtn dl").hover(function(){
45        $(this).addClass("on");
46        $(this).find("dd").show();
47        $(this).find(".share").stop().animate({width:"241px"},500);
48    },function(){
49        $(this).removeClass("on");
50        $(this).find("dd").hide();
51        $(this).find(".share").stop().animate({width:"0"},500);
52    })
53    // 当网页向下滑动200px 侧边栏出现"返回顶部" 按钮
54    window.onscroll = function() {scrollFunction()};
55    function scrollFunction() {
56        if (document.body.scrollTop > 200 || document.documentElement.scrollTop > 200) {
57            $("#goTop").slideDown("fast");
58			$("#toggle").removeClass("show");
59        } else {
60            $("#goTop").slideUp("fast");
61			$("#toggle").addClass("show");
62        }
63		var a = document.documentElement.scrollTop,
64			c = Number($(".header").height());
65		a > c ? $(".easybtn").addClass("fixed") : $(".easybtn").removeClass("fixed") ;
66    }
67	
68	
69	$("#easybtnToggle").click(function(e){
70      $(".easybtn").toggleClass("easybtnOpened");
71	  if($('.dl-gotop').css("display") == 'block'){
72		$("#toggle").removeClass("show");
73	  }else{
74		$("#toggle").addClass("show");  
75	  }
76      e.stopPropagation(); 
77    });
78
79    $("#quickPanel").click(function(e){
80      e.stopPropagation(); 
81    });
82
83    //非政府网站跳转提示: 点击外链询问离开
84    //截取URL域名部份
85    var getHost = function (url) {
86        var host = "null";
87        if (typeof url == "undefined" || null == url) url = window.location.href;
88        var regex = /.*\:\/\/([^\/]*).*/;
89        var match = url.match(regex);
90        if (typeof match != "undefined" && null != match) host = match[1];
91        return host;
92    };
93    //外链跳转弹框
94    _outHtml = '<div class="alert-warning"><div class="alert-delete"><span id="closets">X</span></div><div class="alert-wzsm"><P>您即将访问非政府网站链接,是否继续?</P></div><div class="alert-footer"><span class="continue">继续访问</span><span class="fangqi">放弃</span></div></div><div class="alert-mengban"></div>', $("body").append(_outHtml);
95
96    $(document).on('click', 'a', function (e) {
97        if ($(this).hasClass('selflink')) return;
98        var o = $(this),
99            host, ckhost;
100        var href = o.attr('href');
101        if (href && !/^(?=javascript:)/.test(href) && /^(?=http)/.test(href)) {
102            host = getHost(href);
103            ckhost = host.indexOf('gov.cn');
104        }
105        if (href && host) {
106            if (host != document.domain) {
107                o.attr('target', '_blank');
108                if (ckhost <= 0 && o.data('ask') != '1') {
109                    $(".alert-mengban").fadeIn("fast");
110                    $(".alert-warning").fadeIn("fast");
111                    $("#closets,.fangqi, .alert-mengban").click(function () {
112                        $(".alert-warning").fadeOut(300);
113                        $(".alert-mengban").fadeOut(300);
114                    });
115                    $(".continue").one("click", function () {
116                        $(".alert-warning").fadeOut(300);
117                        $(".alert-mengban").fadeOut(200);
118                        o.data('ask', '1');
119                        o[0].click();
120                        $("#closets").click();
121                    });
122                    return false;
123                }
124            }
125        }
126    });
127
128});
129function tab(event,obj1,obj2,obj3){
130  $(obj1).on(event,function(){
131    if($(this).hasClass('on')){return;}
132    var index = $(this).index();
133    $(this).addClass('on').siblings().removeClass('on');
134    if(obj2){
135      $(obj2).eq(index).addClass('on').siblings().removeClass('on');
136    }
137    
138    if(obj3){
139      $(obj3).eq(index).addClass('on').siblings().removeClass('on');
140    }
141  })
142}
143function AddFavorite(sTitle,sURL){
144  try{
145	  window.external.addFavorite(sURL, sTitle);
146  }catch (e){
147	  try{
148		  window.sidebar.addPanel(sTitle, sURL, "");
149	  }
150	  catch (e){
151		  alert("加入收藏失败,请使用Ctrl+D进行添加");
152	  }
153  }
154}
155//日期格式化
156function timestampToTime(time) {
157  var date = new Date(time * 1000);//时间戳为10位需*1000,时间戳为13位的话不需乘1000
158  Y = date.getFullYear() + '-';
159  M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
160  D = (date.getDate() < 10 ? '0'+(date.getDate()) : date.getDate()) + ' ';
161  h = date.getHours() + ':';
162  m = date.getMinutes() + ':';
163  s = date.getSeconds();
164  return Y+M+D;
165}
166
167
168//设置每5个<li>就用一个<ul>包裹住
169function addLine(){
170  var li5n = $(".pagelist li.item:nth-child(5n)");
171  li5n.each(function(i) {
172	$(".pagelist li.item").slice(i*5,i*5+5).wrapAll("<ul class='addline clearfix'></ul>");
173  });
174  $(".pagelist li.item").slice(li5n.length * 5).wrapAll("<ul class='addline clearfix'></ul>");
175}
176
177//设备判断方法
178function getClientType(){
179	var type = new Array("Android","iPhone","Windows Phone","iPod","BlackBerry","MeeGo","SymbianOS");
180	var info = navigator.userAgent;
181	for(var i=0; i<type.length; i++){
182		if(info.indexOf(type[i])>0){
183			return "Mobile";
184		}
185	}
186	return "PC";
187}
188
189// IE9及以下版本
190// isie9();
191isie9();
192function isie9(flag){
193  var isIe9 = false;
194  if(flag){
195    if(navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion.split(";")[1].replace(/[ ]/g, "").replace("MSIE",""))<10){
196      isIe9 = true;
197    }
198    return isIe9;
199  }else{
200    var ua = navigator.userAgent.toLocaleLowerCase();
201    if (ua.match(/msie/) != null || ua.match(/trident/) != null) { 
202      var browserVersion = ua.match(/msie ([\d.]+)/) != null ? ua.match(/msie ([\d.]+)/)[1] : ua.match(/rv:([\d.]+)/)[1];
203      var $htm = document.getElementsByTagName('html')[0];
204      
205      var ishasIe = hasClass ($htm, 'ie');
206      if(!ishasIe){
207        $htm.className += 'ie';
208      }
209
210      if(parseInt(browserVersion)<10){
211        var ishasLt10 = hasClass ($htm, 'ie9');
212		$htm.className += ' setIE';
213        if(!ishasLt10){
214          $htm.className += ' ie' + parseInt(browserVersion);
215        }
216      }
217    }
218  }
219
220  function hasClass (ele, className) {
221    var reg = new RegExp('(^|\\s)' + className + '(\\s|$)')
222    return reg.test(ele.className)
223  }
224}
225
226//根据参数名获得该参数  pname等于想要的参数名
227function getParam(pname) {
228  var params = location.search.substr(1); //  获取参数并且去掉?
229  var ArrParam = params.split('&');
230  if (ArrParam.length == 1) {
231	//只有一个参数的情况
232	return params.split('=')[1];
233  }
234  else {
235	//多个参数参数的情况
236	for (var i = 0; i < ArrParam.length; i++) {
237	  if (ArrParam[i].split('=')[0] == pname) {
238		return ArrParam[i].split('=')[1];
239	  }
240	}
241  }
242}
243
244// 阻止冒泡
245function stopPropagation(e){
246  e=window.event||e;
247  if(document.all){  //只有ie识别
248	e.cancelBubble=true;
249  }else{
250	e.stopPropagation();
251  }
252}
253
254/*栏目选中效果*/
255if($(".current-menu").length > 0){
256  $(".current-menu a").each(function(){
257	if($.trim($(this).attr("id"))== "menuId_" + codeName){
258	  $(this).addClass("on");
259	}
260  });
261}
262
263/*设置修饰线*/
264function setEmline(){
265  $('.set-emline .hd').each(function() {
266	$(this).find('i').css({
267	  width: ($(this).width() - $(this).find('.currentname').outerWidth()) / 2
268	});
269	$(this).find('.hr').css({
270	  width: ($(this).width() - $(this).find('.currentname').outerWidth())
271	});
272  });
273}
274
275//导航定位
276$(function(){
277//一级页面导航nav添加on
278function func1(arg){
279  $(arg).each(function() {
280    var lmcode = $('meta[name="ColumnName"]').attr('content');
281    var lmmc = $(this).text().replace(/\s+/g, "");
282if(lmcode == undefined){
283}else{
284if(lmcode.indexOf(lmmc) != -1 && lmmc != '') {
285      $(arg).removeClass('on');
286      $(this).addClass('on');
287    }
288}
289    
290  });
291}
292func1('.mainnav ul li');
293//非一级页面导航nav添加on,根据当前位置
294function func2(arg,arg1){
295  $(arg).each(function() {
296    var lmcode = $(arg1).text().replace(/\s+/g,"");
297    var lmmc = $(this).text().replace(/\s+/g,"");
298
299if(lmcode.indexOf(lmmc)!=-1 && lmmc != '') {
300      $(arg).removeClass('on');
301      $(this).addClass('on');
302    }
303    
304  });
305}
306func2('.nav li','.dqwz');
307//同级栏目侧边导航添加on
308function func3(arg){
309  $(arg).each(function() {
310    var lmcode = $('meta[name="ColumnName"]').attr('content');
311    var lmmc = $(this).text();
312    if(lmcode==lmmc) {
313      $(arg).removeClass('on');
314      $(this).addClass('on');
315    }
316  });
317}
318func3('.listnav li');
319});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.