PageSourceSearch

https://www.nudt.edu.cn/js/script.js

js nudt.edu.cn collected 2026-10-02 10:18:41 UTC 16,897 bytes, 545 lines download raw bytes

1// 2023.05.04
2// fixNav();
3// $(window).scroll(function () {
4//     fixNav();
5// });
6// function fixNav() {
7//     var sWSon = document.documentElement.clientWidth;
8//     var sHeight = document.documentElement.clientHeight;
9//     var bodyHeight = document.body.scrollHeight;
10//     var x = $('header').next().offset().top;
11//     if (bodyHeight > sHeight + 100 && sWSon > 1024) {
12//         $(window).scroll(function () {
13//             var scrollTop = $(window).scrollTop();
14//             if (scrollTop > 100) {
15//                 $('header').addClass('currents')
16//                 $('body').css('padding-top', x)
17//             } else {
18//                 $('header').removeClass('currents')
19//                 $('body').css('padding-top', 0)
20//             }
21//         });
22//     }
23// }
24
25$(window).scroll(function () {
26	if( $(window).width() <= 996 ){
27		var scrollTop = $(window).scrollTop();
28		if (scrollTop > 100) {
29			$('#gp-serBtn4').hide()
30			$('.topMenu').addClass('fix')
31		} else {
32			$('#gp-serBtn4').show()
33			$('.topMenu').removeClass('fix')
34		}
35	}
36})
37
38$('.visible_btn').each(function(){ $(this).addClass('off') });
39$('.visible_box').each(function(){ $(this).addClass('off') });
40
41$('.visible_btn').click(function(){
42    var box = $(this).attr('visible');
43    $(this).toggleClass('on');
44    $('.visible_box[visible*="' + box + '"]').toggleClass('on off')
45});
46
47// 点击滚动到指定板块
48function q_scrollTo(tar,dis){
49    var pos = $(''+ tar).offset().top;
50    var d = dis || 0;
51    $("html,body").animate({scrollTop: pos-d}, 1000);
52}
53
54// 切换每个传入的参数
55function toggleOn(){
56    var args = arguments.length;
57    for(var i = 0; i < args; i++){
58        $(arguments[i]).toggleClass('on');
59    }
60}
61function toggleParentOn(a){ $(a).parent().toggleClass('on'); }
62
63/*回到顶部*/
64$(function(){
65	$(window).resize(function(){
66	   var h = $(window).height();
67	   $('.goTop').css('top',h-150);
68	   $(window).scroll(function(){
69		   var scrollTop = $(document).scrollTop();
70		   $('.goTop').stop().animate({
71			   top: h + scrollTop-150
72		   },300);
73	   });
74   }).resize();
75});
76//gotop
77$('.goTop').click(function(){
78   $('body,html').stop().animate({scrollTop:0});
79   return false;
80});
81
82
83// 二级页侧栏菜单
84// 如果有次级栏目,上一级栏目可选要不要链接,没有链接的话,点击上一级栏目,展开次级栏目
85$('.sub_menu a.current').each(function(){
86	$(this).parent('li').addClass('current');
87	$(this).parents('.sub_menu ul').parent('li').addClass('on');
88	$(this).parents('.sub_menu ul').slideDown(300);
89	$(this).parents('.sub_menu ul').siblings('.arrow').addClass('on');
90})
91$('.sub_menu .arrow').click(function(){
92	$(this).toggleClass('on');
93	$(this).parent('li').toggleClass('on');
94	$(this).siblings('ul').toggle(300);
95})
96$('.sub_left_title').click(function(){
97	var sWSon = document.documentElement.clientWidth;
98	if(sWSon < 992 && $('.sub_menu').length > 0 ){
99		$(this).toggleClass('on');
100		$('.sub_left').toggleClass('on');
101		$('.sub_menu .lv0').toggle(300);
102	}
103})
104
105// 2022.12.14版本
106// tab切换
107$.fn.extend({
108	tab: function (options){
109		var defaults = {             //默认参数
110			ev : 'mouseover',        //默认事件'mouseover','click'
111			til : 'h2',              //默认标签
112			box : '.tab_list',       //默认列表
113			defaultNum : 0,          //默认展示第几个
114			eachPage : 1,            //每次切换的个数
115			delay : 100,             //延迟时间
116			auto : false,             //是否自动切换 true,false
117			speed : 4000,            //自动切换间隔时间(毫秒)
118			init : function(){},     //首次加载时触发时间
119			before : function (){},  //切换前触发事件
120			after : function (){},   //切换后触发事件
121			exceed_hide: '0',        //超出隐藏
122			more : true              //是否有more,false,true
123		};
124		var options = $.extend(defaults, options);  //用户设置参数覆盖默认参数
125		
126		return this.each(function (){
127			var o = options;
128			var obj = $(this);
129			var oTil = obj.find(o.til);
130			var oBox = obj.find(o.box);
131			var oMore = null;
132			var iNum = o.defaultNum;
133			var iLen = oTil.length;
134			var iBefore = o.before;
135			var iAfter = o.after;
136			var iEach = o.eachPage;
137
138			// 判断是否为移动端
139			if(document.documentElement.clientWidth < 992){
140				o.ev = 'click';
141			}
142
143			$(oTil).each(function(){
144				if( $(this).attr('href') ){
145					$(this).attr('tab-link', $(this).attr('href'));
146					$(this).removeAttr('href');
147				}
148			});
149
150			// 默认选中第一个
151			o.init();
152			if( iNum >= 0 ){
153				change( oTil.eq(iNum) );
154			}
155			
156			//鼠标事件绑定
157			oTil.bind(o.ev , function (){
158				var _this = this;
159				if(o.ev == 'mouseover' && o.delay){
160					_this.timer = setTimeout(function (){
161						change(_this);
162					},o.delay);
163				}else{
164					change(_this);
165				}; 
166			})
167
168			oTil.bind('mouseout',function (){
169				var _this = this;
170				clearTimeout(_this.timer);
171			});
172			
173			//自动切换效果
174			(function autoPlay(){
175				var timer2 = null;
176				if(o.auto){
177					function play(){
178						iNum++;
179						if(iNum >= iLen){
180							iNum =0;
181						};
182						change(oTil.eq(iNum));
183					};
184					timer2 = setInterval(play,o.speed);
185					obj.on('mouseover',function (){
186						clearInterval(timer2);
187					})
188					obj.on('mouseout',function (){
189						timer2 = setInterval(play,o.speed);
190					})
191				};
192			})();
193			
194			function change(box){
195				iBefore(iNum,obj);
196				iNum = $(box).index() - obj.find(o.til).eq(0).index();
197				
198				oTil.removeClass('on').addClass('off');
199				oTil.eq(iNum).addClass('on').removeClass('off');
200				setTimeout(function(){
201					oTil.removeAttr('href');
202					oTil.eq(iNum).attr('href', oTil.eq(iNum).attr('tab-link'));
203				}, 100);
204
205				if(o.more){
206					oMore = obj.find('.more');
207					oMore.removeClass('on').addClass('off');
208					oMore.eq(iNum).addClass('on').removeClass('off');
209				};
210				
211				// 如果没有更多,就不用切换列表
212				oBox.removeClass('on').addClass('off');
213				if(  iEach * iNum < oBox.length && o.exceed_hide ){
214					oBox.slice( iEach * iNum , iEach * (iNum + 1) ).addClass('on').removeClass('off');
215				}
216
217				iAfter(iNum,obj);
218			}
219			
220		});
221	}
222})
223
224$('.select_link').click(function(){
225	$(this).find('.arrow').toggleClass('on');
226	$(this).find('.alert_box').toggleClass('on');
227	$(this).toggleClass('on');
228	// $('.alert_box').jScrollPane();
229})
230$('.select_link').mouseleave(function(){
231	$(this).find('.arrow').removeClass('on');
232	$(this).find('.alert_box').removeClass('on');
233	$(this).removeClass('on');
234})
235
236// 图片延迟加载
237function loadimg(imglist){
238	var i=0;
239	var run;
240	$(imglist).each(function(index, element) {
241		$(this).attr("data",$(this).attr("src"));
242		$(this).attr("src","");
243		$(this).addClass("unload");
244	});
245	run = function(img){
246		i++;
247		if($(window).scrollTop()+$(window).height()>img.offset().top){
248			img.load(function(){
249				if($("img.unload").eq(0).length > 0 && i<1000){
250					run($("img.unload").eq(0));
251				}
252			});
253			img.attr("src",img.attr("data")).removeClass("unload");
254		}
255	}
256	run($("img.unload").eq(0));
257	$(window).scroll(function(){
258		if($("img.unload").eq(0).length>0 && i<1000){
259			run($("img.unload").eq(0));
260		}
261	});
262}
263
264
265var gp = {
266	// 选项卡
267	tab: function ( tar, options){
268		var defaults = {             //默认参数
269			ev : 'mouseover',        //默认事件'mouseover','click'
270			til : 'h2',              //默认标签
271			box : '.tab_list',       //默认列表
272			tabOn: 'on',			 //选中的class
273			tabOff: 'off2',			 //未选中的class
274			defaultNum : 0,          //默认展示第几个
275			eachPage : 1,            //每次切换的个数
276			delay : 100,             //延迟时间
277			auto : false,             //是否自动切换 true,false
278			speed : 4000,            //自动切换间隔时间(毫秒)
279			funs: {					 //回调函数
280				init : function(){},     //首次加载时触发时间
281				before : function (){},  //切换前触发事件
282				after : function (){},   //切换后触发事件
283			},
284			exceed_hide: '0',        //超出隐藏
285			more : true              //是否有more,false,true
286		};
287		var options = $.extend(defaults, options);  //用户设置参数覆盖默认参数
288		$(tar).each(function (){
289			var o = options;
290			var obj = $(tar);
291			var oTil = obj.find(o.til);
292			var oBox = obj.find(o.box);
293			var oMore = null;
294			var iNum = o.defaultNum;
295			var iLen = oTil.length;
296			var iBefore = o.funs.before;
297			var iAfter = o.funs.after;
298			var iEach = o.eachPage;
299
300			// 判断是否为移动端
301			if(document.documentElement.clientWidth < 992){
302				o.ev = 'click';
303			}
304
305			$(oTil).each(function(){
306				if( $(this).attr('href') ){
307					$(this).attr('tab-link', $(this).attr('href'));
308					$(this).removeAttr('href');
309				}
310			});
311
312			// 默认选中第一个
313			o.funs.init();
314			if( iNum >= 0 ){
315				change( oTil.eq(iNum) );
316			}
317			
318			//鼠标事件绑定
319			oTil.bind(o.ev , function (){
320				var _this = this;
321				if(o.ev == 'mouseover' && o.delay){
322					_this.timer = setTimeout(function (){
323						change(_this);
324					},o.delay);
325				}else{
326					change(_this);
327				}; 
328			})
329
330			oTil.bind('mouseout',function (){
331				var _this = this;
332				clearTimeout(_this.timer);
333			});
334			
335			//自动切换效果
336			(function autoPlay(){
337				var timer2 = null;
338				if(o.auto){
339					function play(){
340						iNum++;
341						if(iNum >= iLen){
342							iNum =0;
343						};
344						change(oTil.eq(iNum));
345					};
346					timer2 = setInterval(play,o.speed);
347					obj.on('mouseover',function (){
348						clearInterval(timer2);
349					})
350					obj.on('mouseout',function (){
351						timer2 = setInterval(play,o.speed);
352					})
353				};
354			})();
355			
356			function change(box){
357				iBefore(iNum,obj);
358				iNum = $(box).index() - obj.find(o.til).eq(0).index();
359				
360				oTil.removeClass(options.tabOn).addClass(options.tabOff);
361				oTil.eq(iNum).addClass(options.tabOn).removeClass(options.tabOff);
362				setTimeout(function(){
363					oTil.removeAttr('href');
364					oTil.eq(iNum).attr('href', oTil.eq(iNum).attr('tab-link'));
365				}, 100);
366
367				if(o.more){
368					oMore = obj.find('.more');
369					oMore.removeClass(options.tabOn).addClass(options.tabOff);
370					oMore.eq(iNum).addClass(options.tabOn).removeClass(options.tabOff);
371				};
372				
373				// 如果没有更多,就不用切换列表
374				oBox.removeClass(options.tabOn).addClass(options.tabOff);
375				if(  iEach * iNum < oBox.length && o.exceed_hide ){
376					oBox.slice( iEach * iNum , iEach * (iNum + 1) ).addClass(options.tabOn).removeClass(options.tabOff);
377				}
378
379				iAfter(iNum,obj);
380			}
381			
382		});
383
384		return {
385			tar: tar,
386			options: options,
387			// nexttab: function(tar, options){
388			// 	console.log( $(this.tar).html() )
389			// }
390		};
391	}
392}
393
394// tab切换最好有个直接写在html里的,更加方便
395const GpUtils = {
396    get: function (url, data, callback) {
397        if ($.isFunction(data)) {
398            callback = data;
399            data = {};
400        }
401        data.s = Math.random();
402        $.get(url, data, function (response) {
403            if (response.status === 500) {
404                alert(response.msg);
405                $('#codebox').click();
406            } else {
407                callback(response);
408            }
409        })
410    },
411    post: function (url, data, callback) {
412        if ($.isFunction(data)) {
413            callback = data;
414        }
415        if (data) {
416            $.ajax({
417                url: url,
418                type: 'post',
419                data: GpUtils.initFormData(data),
420                contentType: false,
421                processData: false,
422                success: function (response) {
423                    if (response.status === 500) {
424                        alert(response.msg);
425                        $('#codebox').click();
426                    } else {
427                        callback(response);
428                    }
429                }
430            })
431        }
432    },
433    initFormData: function (data) {
434        let formData = new FormData();
435        for (let key in data) {
436            formData.append(key, data[key]);
437        }
438        return formData;
439    },
440    strIsNotBlank: function (str) {
441        return !(str === undefined || str == null || str === '');
442    },
443    strIsBlank: function (str) {
444        return str === undefined || str == null || str === '';
445    },
446    verifyInput: function (data) {
447        for (let key in data) {
448            if ($('#' + key).attr('gp-require') !== undefined && GpUtils.strIsBlank(data[key])) {
449                $('#' + key).focus();
450                alert($('#' + key).attr('gp-require') + '不能为空!');
451                return false;
452            } else if ($('input[name=' + key + ']').length > 0) {
453                if ($('input[name=' + key + ']:checked').length === 0) {
454                    alert($($('input[name=' + key + ']')[0]).attr('gp-require') + '不能为空!');
455                    return false;
456                }
457            }
458        }
459        return data;
460    },
461    xssFilter: function (str) {
462        if (GpUtils.strIsNotBlank(str)) {
463            return str.replace(/</g, '&lt;').replace(/>/g, '&gt;');
464        }
465        return '';
466    },
467    //data: {content:'内容',keyword:[1,2,3],channel:{title:'栏目名称'}}
468    //str: '<div>$[content]</div><div gp-repeat='$[keyword]'></div><div>$[channel.title]</div>'
469    replaceTemplate: function (data, str) {
470        let obj = str;
471        if (typeof str === 'string') {
472            obj = $(str).wrap('<div></div>').parent();
473            obj.wrap('<parent></parent>');
474        }
475        for (let key in data) {
476            if (data[key] instanceof Array) {
477                let item = obj.find('[gp-repeat="$[' + key + ']"]');
478                if (data[key].length === 0) item.remove();
479                for (let i = 0; i < data[key].length; i++) {
480                    if (i === 0) {
481                        item.text(data[key][i]);
482                    } else {
483                        let child = item.clone();
484                        child.text(data[key][i]);
485                        item.parent().append(child);
486                    }
487                }
488            } else if (data[key] instanceof Object) {
489                GpUtils.replaceTemplate(GpUtils.formatStr(key, data[key]), obj);
490            } else {
491          var a = '\\$\\['+ key + '\\]';
492		obj.html(obj.html().replace(new RegExp(a,'g'),data[key]));
493                //obj.html(obj.html().replaceAll('$[' + key + ']', data[key]));
494            }
495        }
496        return obj.html();
497    },
498    formatStr: function (key, obj) {
499        let o = {};
500        for (let k in obj) {
501            o[key + '.' + k] = obj[k];
502        }
503        return o;
504    },
505    submit: function (form, callback) {
506        form = form[0];
507        let check = true, msg = '', data = {};
508        $(form).children('input').each(function () {
509            if ($(this).attr('gp-require') !== undefined && !GpUtils.strIsNotBlank(this.value)) {
510                this.focus();
511                msg = $(this).attr('gp-require') + '不能为空!';
512                check = false;
513                return false;
514            } else {
515                data[this.name] = this.value;
516            }
517        })
518        if (check) {
519            if (form.method.toLowerCase() === 'get') {
520                $.get(form.action, data, function (response) {
521                    callback(response, undefined);
522                })
523            } else if (form.method.toLowerCase() === 'post') {
524                $.post(form.action, data, function (response) {
525                    callback(response, undefined);
526                })
527            }
528        } else {
529            callback(undefined, msg);
530        }
531    },
532    //将“2021-10-06T13:53:16.9188978 08:00” ,转换为2021-10-06 13:53:00
533    randerTime: function (time) {
534        let a = new Date(time).getTime();
535        const date = new Date(a);
536        const Y = date.getFullYear() + '-';
537        const M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
538        const D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' ';
539        const h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
540        const m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
541        const s = (date.getSeconds()<10?'0'+(date.getSeconds()):date.getSeconds());
542        const dateString = Y + M + D + h + m + s;
543        return dateString;
544    }
545};

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.