PageSourceSearch

https://aas.net.cn/style/web/js/public/rhhz.js?t=1790750281028

js aas.net.cn collected 2026-10-02 14:47:12 UTC 13,488 bytes, 368 lines download raw bytes

1/**
2 * rhhz.js ---仁和软件前端插件js集合
3 * tools{
4 * 	subTextMax:文本内容按长度设置截取,
5 * 	menuView:按照页面设置进行页面菜单对应高亮
6 * }
7 * function{
8 * 	hasChinese:判断当前对象中是否包含中文字符,
9 * 	trim:解决IE 对jquery Trim方法的兼容性,
10 * 	startWith:判断当前对象是否以字符开始,
11 * 	endWith:判断字符串是否以字符结束,
12 *  getFileUrl:获取本地资源文件的路径,
13 *  preImg:预览本地图片,
14 *  getUrlParam:获取URL参数列表,
15 *  getRefSupIndex:获取参考文献引用索引,
16 *  isNull:判断对象是否为空,
17 *  formatDateToEn:将日期转换成英文格式 2016-1-1 --> 01 Jan 2016
18 *  GetRandomNum:获取随机数
19 *  dateStr:获取网页顶部显示需要的日期信息 参数,type 1:中文  2英文 3英文简写 ( 2017-1-11 星期三;  Wednesday, 11 January, 2017 ;Jan 20th, Wednesday
20 * 	shareTools(type,obj):分享工具,qzone,sina,weixin,renren,google+,facebook,linkedin,twitter
21 * }
22 * 
23 * @version     v1.0
24 * @date 		2016-09-30
25 */
26
27+function ($) {
28	//设置字符串截取默认参数
29	var subTextDefaluts = {
30		add_title:true,      //默认截取后设置全内容title
31        trim:true,//默认截取后去除首尾空及换行,感觉没啥用,后面考虑取消
32        content_type:'html',//默认处理内容为html标签,如设置为text会清除原有标签
33        keep_len:10//默认截取保留10个字符,建议采用配置方式或者在标签中设置
34	};
35	
36	//设置菜单高亮默认参数
37	var menuDefaults = {
38		defaultPage:'index',			//默认获取不到页面索引,设置为首页
39		pageViewId:'pageViewId',		//页面索引取值ID
40		hightLightTag:'li',				//需要设置高亮的标签
41		highLightClass:'current',		//当前页选中高亮class
42		pageRelAttr:'rel_page',			//菜单列表中索引属性标识
43		pageRelTag:'li span'			//菜单列表中索引取值标签,默认取text().trim(),pageRelTag和pageRelAttr不需要同时存在
44	}
45	
46	$.fn.subTextMax = function(options) {
47		var opts = $.extend({}, subTextDefaluts, options); 
48		return this.each(function(){
49		var keepindex = parseInt($(this).attr("keep_len") == undefined ? opts.keep_len : $(this).attr("keep_len"));//超出keep值需要截取
50		var contentHtml = $(this).html().replace(/&nbsp;/ig, '').replace(/\s+/g, ' ').replace(/\t|\r|\n/g,"").replace('<sec> <b>','<sec><b>').replace(/<br[ ]*[/]{0,1}>/g,"<br/>").trim();
51		var contentText = $(this).text().replace(/&nbsp;/ig, '').replace(/\s+/g, ' ').replace(/\t|\r|\n/g,"").trim();
52		if(contentText.length > keepindex){
53	       //如果需要,可加title,title为全部文本内容
54		   if(opts.add_title){
55			   if($(this).attr("title")==''||$(this).attr("title") == undefined){
56				   $(this).attr("title",contentText);
57		      }
58		    }
59		    contentText = contentText.substr(0,keepindex);
60		    if(opts.content_type == 'text'){
61		        $(this).html(contentText + "...");
62		    }else{
63		        //对HTML标签内容进行截取分为四个步骤1存储原有标签  2按照text进行截取  3对截取后的text进行标签插入  4补全未闭合标签
64		        //1.处理原有标签
65		        //获取当前内容中的各个标签及所在位置
66		        var rgx = /<[^<^>]+>/; //标签匹配正则
67		        var index = 0;
68		        var tags = new Array();
69		        while(rgx.test(contentHtml)){
70		            var t = new Object();
71		            //标签出现的位置
72		            t.index = index + contentHtml.search(rgx);
73		            //标签内容
74		            t.tag = contentHtml.match(rgx).toString();
75		            //每次匹配第一个标签,匹配完删除此标签,同时索引位置加当前标签的长度
76		            var len = contentHtml.search(/<[^<^>]+>/) + contentHtml.match(/<[^<^>]+>/)[0].length;
77		            contentHtml = contentHtml.substr(len);
78		            index += len;
79		            tags.push(t);
80		        }
81		        //2.截取text内容,上面已经截取过了
82		        //3.填充原有标签
83		        if(tags.length > 0){
84		            $.each(tags,function(i,e){
85		                if(e.index > contentText.length){
86		                //如果当前节点的开始位置大于当前返回字符串的长度则不再继续判断
87		                tags = tags.slice(0,i);
88		                return false;
89		                }else{
90		                //将原有标签插入原位置
91		                contentText = contentText.substr(0,e.index) + e.tag + contentText.substr(e.index,contentText.length);
92		                }
93		            })
94		        }
95		        //4.闭合标签
96		        //获取未闭合标签,标签填充时不需要填充的标签都被slice过滤掉了,所以剩下的都是已经在内容中的标签了,需要进行判断闭合处理
97		        var insertTags = new Array();//已正确插入标签
98		        var uncloseTags = new Array();//未闭合标签
99		        if(tags.length > 0){
100		            $.each(tags,function(i,e){
101		            //先将所有插入的标签放到插入和未闭合列表中
102		            uncloseTags.push(e.tag);
103		            insertTags.push(e.tag);
104		            })
105		            $.each(insertTags,function(i,e){
106		                //自闭合标签不需要补全,删除如<br/>
107		                if(/<[^<^>^\/]+\/>/.test(e)){
108		                    uncloseTags.splice($.inArray(e,uncloseTags),1);
109		                    return true;
110		                }
111		                //对左标签进行闭合判断,如果同时存在一组左右标签,则同时删除即可,由于成组的删除,所以不用考虑多个<div>对应一个</div>的情况,我们只需要按照顺序获取到未闭合的列表即可
112		                if(/<[^<^>^\/]+>/.test(e)){
113		                    var tagClosed = "";
114		                       if(e.indexOf(" ") > 0){
115		                        tagClosed = "</" + e.substring(1, e.indexOf(" ")) + ">";
116		                    }else{
117		                        tagClosed = "</" + e.substring(1, e.length);
118		                    }
119		                    //同时存在闭合标签
120		                    if($.inArray(tagClosed,uncloseTags) != -1){
121		                        uncloseTags.splice($.inArray(e,uncloseTags),1);
122		                        uncloseTags.splice($.inArray(tagClosed,uncloseTags),1);
123		                       }
124		                }
125		            })
126		        }
127		        //此时uncloseTags已经是未闭合的标签列表了
128		        //生成闭合标签,根据标签嵌套规则,右标签和左标签对应,如<div><p>   --  </p></div>,所以先将未闭合标签数组逆序
129		        if(uncloseTags.length > 0){
130		            var closeTagStr = "";
131		            uncloseTags.reverse();
132		            $.each(uncloseTags,function(i,e){
133		                if(e.indexOf(" ") > 0){
134		                    closeTagStr += "</" + e.substring(1, e.indexOf(" ")) + ">";
135		                }else{
136		                    closeTagStr += "</" + e.substring(1, e.length);
137		                }
138		            })
139		            contentText += "..." + closeTagStr;
140		        }else{
141		            contentText += "...";
142		        }
143		        //拼接完成
144		        $(this).html(contentText);
145	       	}
146	        
147    		}
148	    })
149   }
150}(jQuery);
151
152/**
153 * 自定义字符串结尾判定方法,以s结尾返回true,否则返回false
154 * @param s
155 * @return
156 */
157String.prototype.endWith = function(s) {
158	if (s == null || s == "" || this.length == 0 || s.length > this.length)
159		return false;
160	if (this.substring(this.length - s.length) == s)
161		return true;
162	else
163		return false;
164	return true;
165}
166
167/**
168 * 自定义字符串开始判定方法,以s开始返回true,否则返回false
169 * @param s
170 * @return
171 */
172String.prototype.startWith = function(s) {
173	if (s == null || s == "" || this.length == 0 || s.length > this.length)
174		return false;
175	if (this.substr(0, s.length) == s)
176		return true;
177	else
178		return false;
179	return true;
180}
181
182/**
183 * IE浏览器兼容jquery trim方法
184 * @return
185 */
186String.prototype.trim=function(){
187  	return this.replace(/(^\s*)|(\s*$)/g, "");
188}
189/**
190 * 获取地址栏url参数
191 * @param name
192 * @return
193 */
194function getUrlParam(name){
195     var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
196     var r = window.location.search.substr(1).match(reg);
197     if(r!=null)return  unescape(r[2]); return null;
198	//return $("#language").val();
199}
200
201/**
202 * 从参考文献引用信息中提取参考文献索引
203 * 支持格式"[1,3,5-8,11,13-18,19]"
204 * @param refSup
205 * @return
206 */
207function getRefSupIndex(refSup){
208	if(!isNull(refSup)){
209		refSup = refSup.replace(/[\[|\]]/g, '').trim();
210		var chars = ['~','—','–',',','-','−','⁃'];
211		$.each(chars,function(ind,val){
212			refSup = refSup.replace(val,'&');
213		});
214		var refIndexs = [] ;
215		$.each(refSup.split(","),function(i,e){
216			if(isNaN(e)){
217				var startEnd = e.split("&");
218				var start = parseInt(startEnd[0]);
219				var end = parseInt(startEnd[1]);
220				for(var i = start ; i <= end ; i++){
221					refIndexs.push(i);
222				}
223			}else{
224				refIndexs.push(e);
225			}
226		})
227		//alert(refIndexs);
228		return refIndexs;
229	}
230	return null;
231}
232
233/**
234 * 封装判断对象为空方法
235 * @param object
236 * @return
237 */
238function isNull(object){
239	return typeof(object) == "undefined" || object == null || object == ""; 
240}
241
242/**
243 * 获取随机数
244 * @param Min
245 * @param Max
246 * @return
247 */
248function GetRandomNum(Min,Max){   
249	var Range = Max - Min;   
250	var Rand = Math.random();   
251	return(Min + Math.round(Rand * Range));   
252} 
253
254/**
255 * 获取网页顶部显示需要的日期信息
256 * @param type 1:中文  2英文 3英文简写
257 * 	  2017-1-11 星期三
258 * 	  Wednesday, 11 January, 2017 
259 *    Jan 20th, Wednesday
260 * @return
261 */
262function dateStr(type){
263	var date = new Date();
264	return parseInt(type) == 1 ? 
265		formatDate(date,type) + " "+ getTodayWeek(type) : 
266		getTodayWeek(type) + ", " +formatDate(date,type)  ;
267}
268
269
270/**
271 * 将日期格式化成英文格式
272 * 2017-1-11
273 * 11 January, 2017
274 * Jan 11, 2017
275 * @param date
276 * */
277function formatDate(date,type){
278	if(!isNull(date)){
279		var dateStr = JSON.stringify(date).substring(1,11);
280		var dateVal = dateStr.split("-");
281		var month = dateVal[1];
282		if(month.charAt(0)== 0){month = month.charAt(1);}
283		var monthArray = new Array
284        ("January","February","March","April","May","June","July","August",
285        "September","October","November","December");
286		var monthArraySimple = new Array
287        ("Jan","Feb","Mar","Apr","May","June","July","Aug",
288        "Sep","Oct","Nov","Dec");
289        switch (type) { 
290		    case 1 : 
291	            return dateStr;
292		    case 2 : 
293		    	return dateVal[2]+" "+monthArray[month-1]+", "+dateVal[0];
294		    case 3 : 
295		    	return monthArraySimple[month-1]+" "+dateVal[2]+", "+dateVal[0];
296		}
297 	}
298}
299
300/**
301 * 获取星期几
302 * @param type 1:中文  2英文 3英文简写
303 * @return
304 */
305function getTodayWeek(type){
306	var chinese = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六");  
307	var english = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");  
308	var englishSigle = new Array("Sun.","Mon.", "Tues.", "Wed.", "Thur.", "Fri.", "Sat.");  
309	var week = new Date().getDay(); 
310	switch (type) { 
311	    case 1 : 
312            return chinese[week];
313	    case 2 : 
314	    	return english[week];
315	    case 3 : 
316	    	return englishSigle[week];
317	}  
318}
319
320/**
321 * 分享工具方法
322 * @param type
323 * @return
324 */
325function shareTools(type,obj){
326	var url = window.location;
327	var title = $("title").text();
328	var description = $("meta[name='abstract']").attr("content") || $("meta[name='description']").attr("content") || $("meta[name='dc.description']").attr("content") || $("meta[http-equiv='description']").attr("content");
329	var shareUrl = "";
330	switch (type)
331	{
332		case 'qzone':
333			shareUrl = "http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url="+url+"&title="+title;
334			break;
335		case 'sina':
336			shareUrl = "http://service.weibo.com/share/share.php?title="+title+"&url="+url+"&pic=";
337			break;
338		case 'weixin':
339			shareUrl = local_host + "util/QrcodeServlet?url="+url;
340			break;
341		case 'renren':
342			shareUrl = "http://widget.renren.com/dialog/share?resourceUrl="+url+"&srcUrl="+url+"&title="+title+"&pic=&description="+description;
343			break;
344		case 'google+':
345			shareUrl = "https://plus.google.com/share?url="+url+"&t="+title;
346			break;
347		case 'facebook':
348			shareUrl = "http://www.facebook.com/sharer.php?s=100&p[title]="+title+"&p[summary]="+description+"&p[url]="+url+"&p[images]=";
349			break;
350		case 'linkedin':
351			shareUrl = "http://www.linkedin.com/shareArticle?armin=armin&ro=true&mini=true&url="+url+"&source=&title="+title+"&summary="+description;
352			break;
353		case 'twitter':
354			shareUrl = "https://twitter.com/intent/tweet?text="+title+"&url="+url;
355			break;
356		default:
357			shareUrl = "http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url="+url+"&title="+title;
358			break;
359	}
360	if("weixin" == type){
361		$(".weixinQrcode").attr("src",shareUrl);
362	}else{
363		window.open(shareUrl, "_blank");
364	}
365}
366function closeWeiXinBox(obj){
367	$(obj).parent().hide();
368}

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.