PageSourceSearch

https://nmc.cn/assets/js/common.js?v=20220615

js nmc.cn collected 2026-10-02 03:08:18 UTC 3,950 bytes, 152 lines download raw bytes

1
2
3 var Nmc = {
4		pageInit: function(){
5			$('.dropdown-toggle').dropdownHover();
6			$("#searchInput").autocomplete('http://www.nmc.cn/essearch/api/autocomplete', {
7				width: 445,
8				max: 10,
9				scroll: true,
10				scrollHeight: 400,
11				matchCase:true,
12				parse:function(rows){
13					var parsed = [];
14					for (var i=0; i < rows.data.length; i++) {
15						var row = rows.data[i];
16						if (row) {
17							parsed[parsed.length] = {
18								data: row,
19								value: row.split('|')[0]
20							};
21						}
22					}
23					return parsed;
24				},
25				focusEvent:function(input, event){
26					var v = $(input).val();
27					if(v == ''){
28						$('#hotCity').show();
29					} else {
30						$('#hotCity').hide();
31					}
32				},
33				formatItem: function(row) {
34					$('#hotCity').hide();
35					var arr = row.split('|');
36					return arr[1] + ' - ' + arr[2];
37				}
38			}).result(function(event, row, formatted) {
39				var arr = row.split('|');
40				$("#searchInput").val(arr[1]);
41				window.location.href = '/publish/forecast' + arr[3];
42			});
43			
44			$(document).click(function(e){
45				var obj = $(e.srcElement || e.target);
46				var c = obj.attr('class') || null;
47				var id = obj.attr('id') || null;
48				if((c != null && c == 'c') || (id != null && id == 'searchInput')) {
49					return true;
50				} else {
51					$('#hotCity').hide();
52				}
53			});
54			
55			$("#toTop").scrollToTop(800);
56		}
57};
58
59$.ajaxSetup({
60	cache: false
61});
62
63/*二级导航滑动显示*/
64$('.navbar-nav > li').hover(function(){
65	var $this = $(this);
66	$this.addClass("actived").siblings().removeClass("actived");
67	var index = $this.index('.navbar-nav > li');
68	$('#navbar_sub_' + index).show();
69},function(e){
70	var $this = $(this);
71	var index = $this.index('.navbar-nav > li');
72	$('#navbar_sub_' + index).hide();
73});
74
75$(function(){
76	$("img").lazyload();
77	
78	Nmc.pageInit();
79	Weather.bindEvent();
80	// 左侧导航手风琴效果
81	$('#leftNav > div > div.titlebg').click(function(){
82		var $this = $(this).parent();
83		$this.find('>div>em>a').text('↓');
84		var $content = $this.addClass('noborder').find('div.content');
85		$content.show();
86		$this.siblings().removeClass('noborder').addClass('bborder').find('div.content').hide();
87		$this.siblings().find('>div>em>a').text('↑');
88	});
89
90	// 左侧导航固定
91	var $window = $(window);
92	$window.scroll(function(){
93		var scrollHeight = $window.scrollTop();
94		var screenHeight = $window.height();
95		var sideHeight = $('#leftNav').height();
96		if(scrollHeight > 215){
97			$('#leftNav').css({
98				'position':'fixed',
99				'top':10
100			});
101		} else {
102			$('#leftNav').css({
103				'position':'static'
104			});
105		}
106	});
107	$window.load(function(){
108		$window.trigger('scroll');
109	});
110	$window.resize(function(){
111		$window.trigger('scroll');
112	});
113
114	// 海区预报地图
115	$("#Map area").mouseover(function(event){
116		var name = $(this).attr("name");
117		var tbody = "";
118		$.each($("#datatable tbody tr[name='"+name+"']"),function(k,v){
119			tbody += "<tr>"+$(this).html()+"</tr>";
120		});
121		$("#tbody").html(tbody);
122		$("#context").css({ top: (event.pageY - 130) + 'px', left: (event.pageX - 800) + 'px' });
123		$("#context").show("fast");
124	}).mouseout(function(){
125		$("#context").hide();
126	}).mousemove(function(event){
127		$("#context").css({ top: (event.pageY - 130) + 'px', left: (event.pageX - 800) + 'px' });
128	});
129
130	// 产品导航更多功能控制
131	$('.p-nav').each(function(k,v){
132		var width = 0;
133		var $this = $(this);
134		var ulWidth = $this.find('>ul').width();
135		$this.find(' > ul > li').each(function(key,value){
136			var $this = $(this);
137			width += $this.width();
138			if(width > ulWidth){
139				$this.parent().next().show();
140				return false;
141			}
142		})
143	});
144	
145	//首页城市搜索按钮点击
146	$("#indexSearchButton").click(function(){
147		var cityUrl = $("#searchInput").text();
148		console.log(cityUrl);
149		window.location.href=cityUrl;
150	});
151});
152

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.