PageSourceSearch

http://containerizations.com/style/web/js/common/search.js

js containerizations.com collected 2026-09-30 11:32:09 UTC 59,960 bytes, 1,761 lines download raw bytes

1var language = $('#language').val();
2//figPage 图检索;滚动提交多次,避免提交重复页码(重复数据)
3var figPage = 0;
4//loadingFlag 图检索:判断数据是否渲染完成,渲染成瀑布流样式
5var loadingFlag = false;
6/**
7 * 快速元数据检索
8 * @param $scope
9 * @param $http
10 * @returns
11 */
12app.controller('search-article-result', function($scope, $http, $filter, $timeout) {
13	$scope.loadEnd=false
14	$scope.yearsShowNum = 10;
15	var oldSearchType = $("input[name='oldSearchType']").val();
16	var url = "";
17	
18	//页面第一次加载
19	setTimeout(function() { 
20		$scope.searchData(0);
21	});
22	
23	//输入页码加载
24	$scope.enterEvent = function (e) {
25		if(loadCommonPagesEnter(e)){
26			$scope.searchData(1);
27			$(document).scrollTop(0);
28		}
29    };
30    
31    //点击页码加载
32	$scope.gotopage = function(page) {
33		if(isNull(page)){
34			$scope.searchData(1);
35		}else{
36			$('#pageNum').val(page);
37			$scope.searchData(0);
38		}
39		$(document).scrollTop(0);
40	};
41	
42	//点击分页加载
43	$("#gotoLimit").change(function(){
44		var limit =$(this).children('option:selected').val(); 
45		var pagelimit = $('#limit').val();
46		if(!isNull(pagelimit) && pagelimit != limit){
47			$('#limit').val(limit);
48			$scope.searchData(0);
49		}
50	})
51	
52	$scope.sortSearch = function(type) {
53		if(type == '0'){
54			$("a[name='publishDate']").val("");
55			$("a[name='pdfDownloadCount']").val("")
56			$("a[name='relevance']").addClass("active").siblings().removeClass("active");
57		}else if(type == '1'){
58			$("a[name='publishDate']").val("DESC");
59			$("a[name='pdfDownloadCount']").val("");
60			$("a[name='publishDate']").addClass("active").siblings().removeClass("active");
61		}else if(type == '2'){
62			$("a[name='publishDate']").val("");
63			$("a[name='pdfDownloadCount']").val("DESC");
64			$("a[name='pdfDownloadCount']").addClass("active").siblings().removeClass("active");
65		}
66		$scope.searchData(0);
67	};
68    
69    //点击右侧聚类加载
70	$scope.rightFilters = function (e,rightType) {
71		if(rightType == "year"){
72			//点击年
73			var yearVal = $(e.target).html();
74			$("input[name='year']").val(yearVal);
75			$("#filterCondYear").html(yearVal);
76			$("#rightSearchFilter").show();
77			$(".filterCondYear").show();
78		}else if(rightType == "author"){
79			//点击作者
80			var authorVal = "";
81			if($(e.target).is('a')){
82				authorVal = $(e.target).html();
83			}else{
84				authorVal = $(e.target).parent("a.authorfacetVal").html();
85			}
86			$("input[name='authorName']").val(authorVal);
87			$("#filterCondAuthor").html(authorVal);
88			$("#rightSearchFilter").show();
89			$(".filterCondAuthor").show();
90		}else if(rightType == "keyword"){
91			//点击关键词
92			var keywordVal = "";
93			if($(e.target).is('a')){
94				keywordVal = $(e.target).html();
95			}else{
96				keywordVal = $(e.target).parent("a.keywordfacetVal").html();
97			}
98			$("input[name='keyword']").val(keywordVal);
99			$("#filterCondKeyword").html(keywordVal);
100			$("#rightSearchFilter").show();
101			$(".filterCondKeyword").show();
102		}else if(rightType == "classify"){
103			//点击栏目
104			var journalVal =  $(e.target).html();
105			$("input[name='publisherId']").val(classifyVal);
106			$("#filterCondJournal").html(keywordVal);
107			$("#rightSearchFilter").show();
108			$(".filterCondJournal").show();
109		}else if(rightType == "journal"){
110			//点击期刊
111			var journalName = $(e.target).html();
112			$("input[name='journalName']").val(journalName);
113			$("#filterCondJournal").html(journalName);
114			$("#rightSearchFilter").show();
115			$(".filterCondJournal").show();
116		}
117		$scope.searchData(0);
118    };
119    
120    $scope.changeOrder = false;
121    $scope.changeY = false;
122    $scope.rightFiterYearOrder = function(e,key){
123    	$scope.changeY = true;
124    	$scope.changeOrder = !$scope.changeOrder;
125    	$scope.years=$filter('orderBy')($scope.years,key,$scope.changeOrder);
126    	$(e.target).addClass('active').siblings().removeClass('active');
127    	console.log($(e.target).find('span'),'aaa')
128    	$(e.target).find('span').css({'display':'block'})
129    	$(e.target).siblings().find('span').css({'display':'none'})
130    	
131    }
132    $scope.changeOrder2 = true;
133    $scope.rightFiterCountOrder = function(e,docCount){
134    	$scope.changeOrder2 = !$scope.changeOrder2;
135    	$scope.years=$filter('orderBy')($scope.years,docCount,$scope.changeOrder2);
136    	$(e.target).addClass('active').siblings().removeClass('active');
137    	$(e.target).find('span').css({'display':'block'})
138    	$(e.target).siblings().find('span').css({'display':'none'})
139    	
140    }   
141    
142    $scope.selectYearMore = function(){
143    	$scope.moreJia = $scope.moreJia + 1;
144    	$scope.yearsShowNum = 10*$scope.moreJia;
145    	
146    }
147    $scope.selectYearLess = function(){
148    	$scope.moreJia = 1;
149    	$scope.yearsShowNum = 10*$scope.moreJia;
150    }
151    
152    
153    //叉掉右侧聚类点击的过滤条件
154    $scope.closeFilterConds = function(type) {
155		if(type == 'year'){
156			$("input[name='year']").val('');
157			$("#filterCondYear").html('');
158			$(".filterCondYear").hide();
159		}else if(type == "author"){
160			$("input[name='authorName']").val('');
161			$("#filterCondAuthor").html('');
162			$(".filterCondAuthor").hide();
163		}else if(type == "keyword"){
164			$("input[name='keyword']").val('');
165			$("#filterCondKeyword").html('');
166			$(".filterCondKeyword").hide();
167		}else if(type == "classify"){
168			$("input[name='classifyinfo']").val('');
169			$("#filterCondClassify").html('');
170			$(".filterCondClassify").hide();
171		}else if(type == "journal"){
172			$("input[name='journalName']").val('');
173			$("#filterCondJournal").html('');
174			$(".filterCondJournal").hide();
175		}
176		if(isNull($("input[name='year']").val()) && 
177			isNull($("input[name='authorName']").val()) && 
178			isNull($("input[name='keyword']").val()) && 
179			isNull($("input[name='classifyinfo']").val()) && 
180			isNull($("input[name='journalName']").val())){
181			$("#rightSearchFilter").hide();
182		}
183		$scope.searchData(0);
184	};
185	$scope.enterEventSearch = function (e) {
186		var keycode = window.event ? e.keyCode : e.which;
187        if(keycode==13){
188        	$scope.submitSearch();
189        }
190    };
191    
192    //点击检索提交
193	$scope.submitSearch = function() {
194		if(!isNull($(".search-condition input[name='q']").val())){
195			var searchType = $("input[name='searchType']:checked").val();
196			$("#pageNum").val(1);
197			if(oldSearchType == searchType){
198				$scope.searchData(0);
199			}else{
200				//分别处理不同搜索类型,跳到不同的页面
201				goSearchPage();
202			}
203		}else{
204			if(language == "en"){
205				alert("please enter the search word");
206			}else{
207				alert("请输入检索词");
208			}
209		}
210	};
211	
212	//图瀑布流提交
213    $scope.submitFigureSearch = function() {
214    	var figureFlag = false;
215    	//figPage 滚动提交多次,避免提交重复页码(重复数据)
216    	//loadingFlag 判断数据是否渲染完成,渲染成瀑布流样式后,进行二次翻页内容加载
217    	if(figPage == 0){
218    		figPage = $('#pageNum').val();
219    		figureFlag = true;
220    		loadingFlag = true;
221    	}else{
222    		//图检索limit 默认为5条
223    		var pageCount =  Math.ceil(Number($('#amount').val())/5);
224    		var currentPage = Number($('#pageNum').val());
225    		if(Number(figPage) + 1 != currentPage && pageCount >= Number(currentPage) + 1){
226    			figureFlag = true;
227    			figPage = Number(figPage) + 1;
228    		}
229    	}
230    	if(figureFlag && loadingFlag){
231    		loadingFlag = false;
232	    	setTimeout(function() { 
233	    		$scope.searchData(2);
234	    	}, 1000);
235    	}
236	};
237	
238	//图详情页面跳转
239	$scope.hrefFigDetail = function(articleId,figTag) {
240		 var url = local_host + "search-figure-detail";
241		 figTabDetailCommon(articleId,figTag,url);
242	 }
243	
244	//表详情页面跳转
245	$scope.hrefTabDetail = function(articleId,tabTag) {
246		 var url = local_host + "search-table-detail";
247		 figTabDetailCommon(articleId,tabTag,url);
248	 }
249	
250	$scope.searchData = function(type) {
251		
252		var searchType = $(".search-condition  input[name='searchType']:checked").val();
253		var searchField = $(".search-condition  select[name='searchField']").val();
254		var language = $('#language').val();
255		//只有图不是用这个搜索方法
256		if(searchType != "4"){
257			url = local_host+"search-data"
258		}
259		var searchWord = $(".search-condition input[name='q']").val();
260		if(searchWord == undefined){
261			searchWord = '';
262		}
263		var currentpage = "";
264		var limit = 12;
265		if(searchType == 3){
266			limit = 5;
267		}
268		if(type == 1){
269			currentpage = $("input.inputpagenum").val();
270		}else if(type == 2){
271			//图查询滚动翻页
272			$('#pageNum').val(Number($('#pageNum').val()) + 1);
273			currentpage = $('#pageNum').val();
274		}else{
275			currentpage = $('#pageNum').val();
276		}
277		var pn = currentpage;
278		
279		var publisherId =  $('#publisherId').val();
280		if(publisherId == "index"){
281			publisherId = "";
282		}
283		
284		var sortJson = new Array();
285		var aggreFields = "";
286		var filtersJson = new Array();
287		if(searchType == "0" || searchType == "1"){
288			//处理三种排序 默认desc倒序
289			
290			var publishDate = $("a[name='publishDate']").val();
291			if(!isNull(publishDate)){
292				sortJson.push(new sortVo("publishDate","DESC"));
293			}
294			var pdfDownloadCount = $("a[name='pdfDownloadCount']").val();
295			if(!isNull(pdfDownloadCount)){
296				sortJson.push(new sortVo("pdfDownloadCount","DESC"));
297			}
298			
299			
300			
301			//聚类字段 默认
302			if(language == "en"){
303				aggreFields = "year;authors.authorNameEn;keywords.keywordEn;classifyinfoEn;journalMeta.titleEn;publishDate";
304			}else{
305				aggreFields = "year;authors.authorNameCn;keywords.keywordCn;classifyinfoCn;journalMeta.titleCn;publishDate";
306			}
307			
308			//处理右侧聚类点击后的字段fiters
309			var year = $("input[name='year']").val();
310			if(!isNull(year)){
311				filtersJson.push(new FilterConditionVo("year",year,"AND"));
312			}
313			var authorName = $("input[name='authorName']").val();
314			if(!isNull(authorName) && language == "en"){
315				filtersJson.push(new FilterConditionVo("authors.authorNameEn",authorName,"AND"));
316			}else if(!isNull(authorName) && language == "cn"){
317				filtersJson.push(new FilterConditionVo("authors.authorNameCn",authorName,"AND"));
318			}
319			var keyword = $("input[name='keyword']").val();
320			if(!isNull(keyword) && language == "en"){
321				filtersJson.push(new FilterConditionVo("keywords.keywordEn",keyword,"AND"));
322			}else if(!isNull(keyword) && language == "cn"){
323				filtersJson.push(new FilterConditionVo("keywords.keywordCn",keyword,"AND"));
324			}
325			var classifyinfo = $("input[name='classifyinfo']").val();
326			if(!isNull(classifyinfo) && language == "en"){
327				filtersJson.push(new FilterConditionVo("classifyinfoEn",classifyinfo,"AND"));
328			}else if(!isNull(classifyinfo) && language == "cn"){
329				filtersJson.push(new FilterConditionVo("classifyinfoCn",classifyinfo,"AND"));
330			}
331			var journalName = $("input[name='journalName']").val();
332			if(!isNull(journalName) && language == "en"){
333				filtersJson.push(new FilterConditionVo("journalMeta.titleEn",
333journalName,"AND"));
334			}else if(!isNull(journalName) && language == "cn"){
335				filtersJson.push(new FilterConditionVo("journalMeta.titleCn",journalName,"AND"));
336			}
337		}
338		
339		//高亮字段 ; 号分割---------统一处理一些搜索不必要传的字段
340		var highField = "";
341		if(searchType == "1"){
342			searchField = "secs.title;secs.paras.paraContent";
343			highField = "secs.title;secs.paras.paraContent";
344		}else if(searchType == "2"){
345			if(language == "en"){
346				searchField = "figs.titleEn;figs.altEn";
347				highField = "figs.titleEn;figs.altEn";
348			}else{
349				searchField = "figs.titleCn;figs.altCn";
350				highField = "figs.titleCn;figs.altCn";
351			}
352		}else if(searchType == "3"){
353			if(language == "en"){
354				searchField = "tables.titleEn;tables.altEn";
355				highField = "tables.titleEn;tables.altEn";
356			}else{
357				searchField = "tables.titleCn;tables.altCn";
358				highField = "tables.titleCn;tables.altCn";
359			}
360		}else if(!isNull(searchField) && searchType == "0"){
361			highField = searchField;
362		}else if(searchType == "0"){
363			if(language == "en"){
364				searchField =  "titleEn;authors.authorNameEn;keywords.keywordEn;abstractinfoEn;doi";
365				highField = "titleEn;authors.authorNameEn;keywords.keywordEn;abstractinfoEn";
366			}else{
367				searchField = "titleCn;authors.authorNameCn;keywords.keywordCn;abstractinfoCn;doi;authors.authorNameEn;keywords.keywordEn";
368				highField = "titleCn;authors.authorNameCn;keywords.keywordCn;abstractinfoCn";
369			}
370			
371			//优化查询的类型
372			/*$http.jsonp("http://analyze.xml-journal.net/getWordType?jsonp=JSON_CALLBACK&input"+searchWord)
373			.success(function(data){
374				console.log(data);
375			})*/
376			/*$http.post('http://analyze.xml-journal.net/getWordType',{'input':searchWord},{'Content-Type':'application/x-www-form-urlencoded'}).success(function(data){
377				console.log(data);
378			});*/
379		}
380		
381		$http({
382			 method:'post',
383	         url:url,
384	         params:{'publisherId':publisherId,'searchField':searchField,'q':searchWord,
385	        	 'searchType':searchType,'language':language,'pn':pn,'limit':limit,
386	        	 'filters':JSON.stringify(filtersJson),'sorts':JSON.stringify(sortJson),
387	        	 'highlightFields':highField,'aggreFields':aggreFields}
388	     }).then(function(response){
389	    	 try{
390	    	 //成功时执行
391	    	 var dataMap = response.data;
392	    	 $scope.articles = dataMap.resultlist;
393	    	 if(searchType == "0" || searchType == "1"){
394		    	 $scope.years = dataMap.aggreMap["year"];
395		    	 $scope.yearsNum = dataMap.aggreMap["year"].length;
396		    	 $scope.moreJia = 1;
397		    	 $scope.publishDate = dataMap.aggreMap["publishDate"];
398		    	 
399		    	 if(language == "en"){
400		    		 $scope.journals = dataMap.aggreMap["journalMeta.titleEn"];
401		    		 $scope.authors = dataMap.aggreMap["authors.authorNameEn"];
402		    		 $scope.keywords = dataMap.aggreMap["keywords.keywordEn"];
403		    		 $scope.classifyinfos = dataMap.aggreMap["classifyinfoEn"];
404		    	 }else{
405		    		 $scope.journals = dataMap.aggreMap["journalMeta.titleCn"];
406		    		 $scope.authors = dataMap.aggreMap["authors.authorNameCn"];
407		    		 $scope.keywords = dataMap.aggreMap["keywords.keywordCn"];
408		    		 $scope.classifyinfos = dataMap.aggreMap["classifyinfoCn"];
409		    	 }
410	    	 }else if(searchType == "2"){
411	    		 var figs = new Array();
412	    		 for(var i = 0;i<dataMap.resultlist.length;i++){
413	    			 var article = dataMap.resultlist[i];
414	    			 var figureLists = article.figs;
415	    			 if(figureLists.length > 0){
416	    				 for(var j=0;j<figureLists.length;j++){
417	    					//获取文章数据,用于展示
418	    					 figureLists[j].articleId = article.id;
419	    					 figureLists[j].doi = article.doi;
420	    					 figureLists[j].articleTitleCn = article.titleCn;
421	    					 figureLists[j].articleTitleEn = article.titleEn;
422	    					 figureLists[j].dataPath = article.filePath;
423	    					 figureLists[j].articleState = article.articleState;
424	    					 figureLists[j].articleStateNameCn = article.articleStateNameCn;
425	    					 figureLists[j].articleStateNameEn = article.articleStateNameEn;
426	    					 figureLists[j].year = article.year;
427	    					 figureLists[j].volume = article.volume;
428	    					 figureLists[j].issue = article.issue;
429	    					 figureLists[j].fpage = article.fpage;
430	    					 figureLists[j].lpage = article.lpage;
431	    					 if(language == 'cn'){
432	    						 figureLists[j].journalName = article.journalMeta.titleCn;
433	    					 }else{
434	    						 figureLists[j].journalName = article.journalMeta.titleEn;
435	    					 }
436	    					 figs.push(figureLists[j]);
437	    				 }
438	    			 }
439	    		 }
440	    		 if(type == 2){
441	    			 $scope.figsList = figs;
442	    		 }else{
443	    			 $scope.figs = figs;
444	    		 }
445	    	 }else if(searchType == "3"){
446	    		 var tables = new Array();
447	    		 for(var i = 0;i<dataMap.resultlist.length;i++){
448	    			 var article = dataMap.resultlist[i];
449	    			 var tableLists = article.tables;
450	    			 if(tableLists.length > 0){
451	    				 for(var j=0;j<tableLists.length;j++){
452	    					 //获取文章数据,用于展示
453                             //处理表格名称<p></p>的bug
454                             if (tableLists[j].titleCn.endWith("</p>")&&tableLists[j].titleCn.startWith("<p>")){
455                                 tableLists[j].titleCn = tableLists[j].titleCn.substring(3,tableLists[j].titleCn.length-4);
456                             }
457                             if (tableLists[j].titleEn.endWith("</p>")&&tableLists[j].titleEn.startWith("<p>")){
458                                 tableLists[j].titleEn = tableLists[j].titleEn.substring(3,tableLists[j].titleEn.length-4);
459                             }
460                             tableLists[j].articleId = article.id;
461                             tableLists[j].articleTitleCn = article.titleCn;
462                             tableLists[j].articleTitleEn = article.titleEn;
463	    					 tableLists[j].doi = article.doi;
464	    					 tableLists[j].dataPath = article.filePath;
465	    					 tableLists[j].articleState = article.articleState;
466	    					 tableLists[j].articleStateNameCn = article.articleStateNameCn;
467	    					 tableLists[j].articleStateNameEn = article.articleStateNameEn;
468	    					 tableLists[j].year = article.year;
469	    					 tableLists[j].volume = article.volume;
470	    					 tableLists[j].issue = article.issue;
471	    					 tableLists[j].fpage = article.fpage;
472	    					 tableLists[j].lpage = article.lpage;
473	    					 var content = tableLists[j].content;
474	    					 tableLists[j].content = content.replace("src=\"","src=\""+article.filePath);
475	    					 tables.push(tableLists[j]);
476	    				 }
477	    			 }
478	    		 }
479	    		 $scope.tables = tables;
480	    	 }
481	    	 
482	    	 $('.articleCount').html(dataMap.totalCount);
483	    	 var count = dataMap.totalCount;
484	    	 currentpage = dataMap.currentPage;
485			 $('#amount').val(count);
486			 $('#pageNum').val(currentpage);
487			 var totalpage = Math.ceil(count/limit);
488    		 $scope.count =  count;
489    		 $scope.totalpage =  totalpage;
490    		 $scope.currentpage =  Number(currentpage);
491    		 $scope.pageList = new Array();
492    		 $scope.pageList = loadCommonPages(count,totalpage,currentpage,20);
493    		 $timeout(function(){
494 	             MathJax.Hub.Queue(["Typeset", MathJax.Hub]);
495    		 },100); 
496    		 $('#amount').val(count);
497    		 $('#totalpage').val(totalpage);
498			 $('.loading-show').hide();
499	     }catch(e){}
500	     },function(response){
501	         //失败时执行 
502	         console.log(response.data.message);
503	     });
504		$(document).scrollTop(0);
505	}
506});
507
508app.filter('orderByYearFilter',function($filter){
509	return function(text){
510		return $filter('orderBy')(text,'key',false);
511	}
512})
513
514
515function goSearchPage(){
516	var searchType = $("input[name='searchType']:checked").val();
517	var searchVal = $(".search-condition input[name='q']").val();
518	var language = $("#language").val();
519	var searchField = "";
520	if(searchType == "0"){
521		searchField = $("select[name='searchField']").val();
522		url =local_host+"search";
523	}else if(searchType == "1"){
524		searchField = "secs.title;secs.paras.paraContent";
525		url =local_host+"search-fulltext";
526	}else if(searchType == "2"){
527		if(language == "en"){
528			searchField = "figs.titleEn;figs.altEn";
529		}else{
530			searchField = "figs.titleCn;figs.altCn";
531		}
532		url =local_host+"search-figure";
533	}else if(searchType == "3"){
534		if(language == "en"){
535			searchField = "tables.titleEn;tables.altEn";
536			highField = "tables.titleEn;tables.altEn";
537		}else{
538			searchField = "tables.titleCn;tables.altCn";
539			highField = "tables.titleCn;tables.altCn";
540		}
541		url =local_host+"search-table";
542	}else if(searchType == "4"){
543		url =local_host+"search-news";
544	}else if(searchType == "5"){
545		url =local_host+"search-common";
546	}
547	searchCommon(searchField,searchVal,url);
548}
549
550//首页或头部检索方法入口
551function searchEntrance(){
552	var searchVal = $(".search-entrance input[name='q']").val()
553	var searchField = $(".search-entrance select[name='searchField']").val();
554	var url = local_host.replace("/en/","/")+"search";
555	searchCommon(searchField,searchVal,url);
556}
557
558//首页或头部检索方法入口 手机
559function searchEntranceApp(){
560	var searchVal = $(".search-entrance-app input[name='q']").val()
561	var searchField = $(".search-entrance-app select[name='searchField']").val();
562	var url = local_host.replace("/en/","/")+"search";
563	searchCommon(searchField,searchVal,url);
564}
565
566//公共调用快速检索方法
567function searchCommon(searchField,searchVal,url){
568	var language = $('#language').val();
569	if(!isNull(searchVal)){
570		var publisherId = $('#publisherId').val();
571		if(isNull(searchField)){
572			if(language == "en"){
573				searchField =  "titleEn;authors.authorNameEn;keywords.keywordEn;abstractinfoEn,doi";
574			}else{
575				searchField = "titleCn;authors.authorNameCn;keywords.keywordCn;abstractinfoCn,doi";
576			}
577		}
578		//拼装form提交数据
579		var tempform = document.createElement("form");
580		tempform.action = url;
581		tempform.method = "post";  
582		tempform.style.display="none";
583		tempform.id="rhQuickSearchForm";
584	    var searchFieldOpt = document.createElement("input");  
585		searchFieldOpt.name = "searchField";  
586		searchFieldOpt.value = searchField;  
587		tempform.appendChild(searchFieldOpt);  
588		var searchWordOpt = document.createElement("input");  
589		searchWordOpt.name = "q";  
590		searchWordOpt.value = searchVal;  
591		tempform.appendChild(searchWordOpt);
592		
593		if(!isNull(publisherId) && publisherId != "index"){
594			var searchJournalOpt = document.createElement("input");  
595			searchJournalOpt.name = "publisherId";  
596			searchJournalOpt.value = publisherId;  
597			tempform.appendChild(searchJournalOpt);
598		}
599		
600		var searchLanguageOpt = document.createElement("input");  
601		searchLanguageOpt.name = "language";  
602		searchLanguageOpt.value = language;  
603		tempform.appendChild(searchLanguageOpt);
604		
605	    var opt = document.createElement("input");  
606	    opt.type = "submit";  
607	    tempform.appendChild(opt);  
608	    document.body.appendChild(tempform);  
609	    tempform.submit();
610	}else{
611		if(language = "en"){
612			alert("please enter the search word");
613		}else{
614			alert("请输入检索词");
615		}
616	}
617	
618}
619
620//首页或头部高级检索方法入口
621function advanceSearchEntrance(){
622	var publisherId = $('#publisherId').val();
623	var language = $('#language').val();
624	var tempform = document.createElement("form");
625	tempform.action = local_host.replace("/en/","/")+"advanced-search";
626	tempform.method = "post";  
627	tempform.style.display="none";
628	tempform.id="rhQuickSearchForm";
629	
630	if(!isNull(publisherId) && publisherId != "index"){
631		var searchJournalOpt = document.createElement("input");  
632		searchJournalOpt.name = "publisherId";  
633		searchJournalOpt.value = publisherId;  
634		tempform.appendChild(searchJournalOpt);
635	}
636	
637	var searchLanguageOpt = document.createElement("input");  
638	searchLanguageOpt.name = "language";  
639	searchLanguageOpt.value = language;  
640	tempform.appendChild(searchLanguageOpt);
641	
642    var opt = document.createElement("input");  
643    opt.type = "submit";  
644    tempform.appendChild(opt);  
645    document.body.appendChild(tempform);  
646    tempform.submit();
647}
648
649/**
650 * 循环后,渲染图片瀑布流
651 * @returns
652 */
653//app.directive('repeatFinishFigs',function(){
654//	var flag = 0;
655//    return {
656//        link: function(scope,element,attr){
657//        	if(scope.$last){
658//            	setTimeout(function() { 
659//            		var $container = $('#masonry');
660//        			if($container.length > 0){
661//        				$container.imagesLoaded( function(){
662//        		            $container.masonry({
663//        		                itemSelector : '.box',
664//        		                gutterWidth : 20,
665//        		                isAnimated: true
666//        		            });
667//        		        });
668//        			}
669//        			loadingFlag = true;
670//	        	}, 100);
671//            }
672//        }
673//    }
674//})
675
676//app.directive('repeatFinishFigsAppend',function(){
677//	var flag = 0;
678//    return {
679//        link: function(scope,element,attr){
680//        	if(scope.$last){
681//            	setTimeout(function() { 
682//            		//renderFigure();
683//            		var $container = $('#masonry');
684//            		$("#masonry .box").removeClass("box2");
685//            		var newHtml = $("#masonryHidden").html();
686//            		$container.append(newHtml);
687//            		var newElems = $("#masonry .box2");
688//            		$container.imagesLoaded( function(){
689//            			$container.masonry( 'appended', newElems, true );
690//            		});
691//            		loadingFlag = true;
692//	        	}, 500);
693//            }
694//        }
695//    }
696//})
697
698function FilterConditionVo(filterField,filterVal,filterType){
699	this.filterField = filterField;
700	this.filterVal = filterVal;
701	this.filterType = filterType;
702}
703
704function sortVo(sortField,sortType){
705	this.sortField = sortField;
706	this.sortType = sortType;
707}
708
709//公共跳转图详情,表详情方法
710function figTabDetailCommon(articleId,tagId,url){
711	var publisherId = $('#publisherId').val();
712	//拼装form提交数据
713	var tempform = document.createElement("form");
714	tempform.action = url;
715	tempform.method = "post";  
716	tempform.style.display="none";
717	tempform.id="figTabSearchForm";
718	tempform.target="_blank";
719    var searchFieldOpt = document.createElement("input");  
720	searchFieldOpt.name = "articleId";  
721	searchFieldOpt.value = articleId;  
722	tempform.appendChild(searchFieldOpt);  
723	var searchWordOpt = document.createElement("input");  
724	searchWordOpt.name = "tagId";  
725	searchWordOpt.value = tagId;  
726	tempform.appendChild(searchWordOpt);
727	
728	var qOpt = document.createElement("input");  
729	qOpt.name = "q";  
730	qOpt.value = tagId;  
731	tempform.appendChild(qOpt);
732	
733	if(!isNull(publisherId) && publisherId != "index"){
734		var searchJournalOpt = document.createElement("input");  
735		searchJournalOpt.name = "publisherId";  
736		searchJournalOpt.value = publisherId;  
737		tempform.appendChild(searchJournalOpt);
738	}
739	
740	var searchLanguageOpt = document.createElement("input");  
741	searchLanguageOpt.name = "language";  
742	searchLanguageOpt.value = $('#language').val();  
743	tempform.appendChild(searchLanguageOpt);
744	
745    var opt = document.createElement("input");  
746    opt.type = "submit";  
747    tempform.appendChild(opt);  
748    document.body.appendChild(tempform);  
749    tempform.submit();
750	
751}
752
753/**
754 * 图详情
755 * @param $scope
756 * @param $http
757 * @returns
758 */
759app.controller('search-figure-detail', function($scope, $http) {
760	var publisherId = $('#publisherId').val();
761	if(isNull(publisherId) || publisherId == "index"){
762		publisherId = "";
763	}
764	$http({
765		 method:'post',
766         url:local_host +"figure-detail-data",
767         params:{'publisherId':publisherId,'articleId':$('#articleId').val(),
768        	 'tagId':$('#tagId').val(),'language':$('#language').val()}
769     }).then(function(response){
770    	 if(response.data.article.length > 0){
771    		 //所属文章
772    		 $scope.article = response.data.article[0];
773    		 var articleFigs = new Array();
774    		 for(var i=0;i<$scope.article.figs.length;i++){
775    			 var figure = $scope.article.figs[i];
776    			 figure.articleId = $scope.article.id;
777    			 if(figure.tagId == $('#tagId').val()){
778    				 $scope.figure = figure;
779        		 }else{
780        			 articleFigs.push(figure);
781        		 }
782    		 }
783    		 //本文其他图
784    		 $scope.articleFigs = articleFigs;
785    	 }
786    	 //相关图
787    	 var relatedFigs = new Array();
788		 var articleList = response.data.relatedArticles;
789		 for(var i = 0;i<articleList.length;i++){
790			 var relatedArticle = articleList[i];
791			 for(var j = 0; j < relatedArticle.figs.length;j++){
792				 var figure = relatedArticle.figs[j];
793				 figure.articleId = relatedArticle.id;
794				 figure.doi = relatedArticle.doi;
795				 figure.articleTitleCn = relatedArticle.titleCn;
796				 figure.articleTitleEn = relatedArticle.titleEn;
797				 figure.dataPath = relatedArticle.filePath;
798				 figure.articleState = relatedArticle.articleState;
799				 figure.articleStateNameCn = relatedArticle.articleStateNameCn;
800				 figure.articleStateNameEn = relatedArticle.articleStateNameEn;
801				 figure.year = relatedArticle.year;
802				 figure.volume = relatedArticle.volume;
803				 figure.issue = relatedArticle.issue;
804				 figure.fpage = relatedArticle.fpage;
805				 figure.lpage = relatedArticle.lpage;
806				 relatedFigs.push(figure);
807			 }
808		 }
809		 $scope.relatedFigs = relatedFigs;
810     },function(response){
811         //失败时执行 
812         console.log(response.data.message);
813     });
814	
815	$scope.downloadImg = function(tabTag,articleId) {
816		downloadImg(tabTag,articleId);
817	}
818	
819	$scope.downloadPPT = function(tabTag,articleId) {
820		downloadPPT(tabTag,articleId);
821	}
822	
823});
824
825/**
826 * 表详情
827 * @param $scope
828 * @param $http
829 * @returns
830 */
831app.controller('search-table-detail', function($scope, $http) {
832	var publisherId = $('#publisherId').val();
833	if(isNull(publisherId) || publisherId == "index"){
834		publisherId = "";
835	}
836	$http({
837		 method:'post',
838         url:local_host +"table-detail-data",
839         params:{'publisherId':publisherId,'articleId':$('#articleId').val(),
840        	 'tagId':$('#tagId').val(),'language':$('#language').val()}
841     }).then(function(response){
842    	 //成功时执行
843    	 if(response.data.article.length > 0){
844    		 //所属文章
845    		 $scope.article = response.data.article[0];
846    		 var articleTabs = new Array();
847    		 for(var i=0;i<$scope.article.tables.length;i++){
848    			 var table = $scope.article.tables[i];
849    			 table.articleId = $scope.article.id;
850    			 if(table.tagId == $('#tagId').val()){
851    				 var content = table.content;
852    				 table.content = content.replace("src=\"","src=\""+$scope.article.filePath);
853    				 $scope.table = table;
854        		 }else{
855        			 articleTabs.push(table);
856        		 }
857    		 }
858    		 //本文其他图
859    		 $scope.articleTabs = articleTabs;
860    	 }
861    	 //相关表
862    	 var relatedTabs = new Array();
863		 var articleList = response.data.relatedArticles;
864		 for(var i = 0;i<articleList.length;i++){
865			 var relatedArticle = articleList[i];
866			 for(var j = 0; j < relatedArticle.tables.length;j++){
867				 var table = relatedArticle.tables[j];
868				 table.articleId = relatedArticle.id;
869				 table.articleTitleCn = relatedArticle.titleCn;
870				 table.articleTitleEn = relatedArticle.titleEn;
871				 table.doi = relatedArticle.doi;
872				 table.dataPath = relatedArticle.filePath;
873				 table.articleState = relatedArticle.articleState;
874				 table.articleStateNameCn = relatedArticle.articleStateNameCn;
875				 table.articleStateNameEn = relatedArticle.articleStateNameEn;
876				 table.year = relatedArticle.year;
877				 table.volume = relatedArticle.volume;
878				 table.issue = relatedArticle.issue;
879				 table.fpage = relatedArticle.fpage;
880				 table.lpage = relatedArticle.lpage;
881				 relatedTabs.push(table);
882			 }
883		 }
884		 $scope.relatedTabs = relatedTabs;
885     },function(response){
886         //失败时执行 
887         console.log(response.data);
888     });
889	
890	$scope.downloadCsv = function(tabTag,articleId) {
891		 downloadCsv(articleId,tabTag);
892	 }
893	
894});
895
896//加载搜索 新闻数据
897app.controller('search-news-result', function($scope, $http) {
898	//页面第一次加载
899	setTimeout(function() { 
900		$scope.paginationData(0);
901	});
902	//点击页码加载
903	$scope.gotopage = function(page) {
904		if(isNull(page)){
905			$scope.paginationData(1);
906		}else{
907			$('#pageNum').val(page);
908			$scope.paginationData(0);
909		}
910		$(document).scrollTop(0);
911	}
912	//输入页码加载
913	$scope.enterEvent = function (e) {
914		if(loadCommonPagesEnter(e)){
915			$scope.paginationData(1);
916			$(document).scrollTop(0);
917		}
918    };
919    
920    $scope.submitSearch = function() {
921    	var oldSearchType = $("input[name='oldSearchType']").val();
922    	var searchType = $("input[name='searchType']:checked").val();
923    	if(oldSearchType == searchType){
924    		$scope.paginationData(0);
925		}else{
926			//分别处理不同搜索类型,跳到不同的页面
927			goSearchPage();
928		}
929    }
930    
931    $scope.enterEventSearch = function (e) {
932    	 var keycode = window.event ? e.keyCode : e.which;
933         if(keycode==13){
934        	 if(!isNull($(".search-condition input[name='q']").val())){
935         		$scope.paginationData(0);
936         	}else{
937         		if($('#language').val() == "en"){
938    				alert("please enter the search word");
939    			}else{
940    				alert("请输入检索词");
941    			}
942         	}
943        	 
944         }
945    };
946	
947	$scope.paginationData = function(type) {
948		var currentpage = "";
949		var searchWord = $(".search-condition input[name='q']").val();
950		if(type == 1){
951			currentpage = $("input.inputpagenum").val();
952		}else{
953			currentpage = $('#pageNum').val();
954		}
955		var publisherId = $('#publisherId').val();
956		if(isNull(publisherId) || publisherId == "index"){
957			publisherId = "";
958		}
959		$http({
960			 method:'post',
961	         url:local_host +"search-news-data",
962	         params:{'publisherId':publisherId,'searchWord':searchWord,'language':$('#language').val(),
963	        	 'currentpage':currentpage,'limit':10}
964	     }).then(function(response){
965	    	 //成功时执行
966    		 $scope.newsResult =  response.data.newsResult;
967    		 var count = response.data.newsResult.totalrecord;
968    		 var totalpage = Math.ceil(count/20);
969    		 $scope.count =  count;
970    		 $scope.totalpage =  totalpage;
971    		 $scope.currentpage =  Number(currentpage);
972    		 $scope.pageList = new Array();
973    		 $scope.pageList = loadCommonPages(count,totalpage,currentpage,20);
974    		 
975    		 $('#amount').val(count);
976    		 $('#totalpage').val(totalpage);
977    		 $('.loading-show').hide();
978	     },function(response){
979	         //失败时执行 
980	         //console.log(response.data.message);
981	     });
982	}
983});
984
985function checkSearch(form){
986	var searchText = $(form).find("input[name='q']").val().replace(" ","");
987	if(isNull($("#language").val()) || $("#language").val()=="cn"){
988		if(typeof(searchText) == "undefined" || searchText == "" || searchText == "请输入检索词!"){
989			alert("请输入检索词!");
990			return false;
991		}
992	}else if($("#language").val()=="en"){
993		if(typeof(searchText) == "undefined" || searchText == "" || searchText == "Please enter the search word"){
994			alert("Please enter the search word");
995			return false;
996		}
997	}
998//	var searchType = $('input[name="searchType1"]:checked').val();
999//	if(isNull(searchType)){
1000//		searchType = $('#searchType1').val();
1001//	}
1002//	if(!isNull(searchType)){
1003//		if(searchType == 0){
1004//			var articleUrl = local_host + "search"
1005//			$(".topSearchForm").attr("action",articleUrl);
1006//		}else if(searchType == 1){
1007//			var fullTextUrl = local_host + "to_search-fulltext"
1008//			$(".topSearchForm").attr("action",fullTextUrl);
1009//		}else if(searchType == 2){
1010//			var figureUrl = local_host + "to_search-figure"
1011//			$(".topSearchForm").attr("action",figureUrl);
1012//		}else if(searchType == 3){
1013//			var tableUrl = local_host + "to_search-table"
1014//			$(".topSearchForm").attr("action",tableUrl);
1015//		}else if(searchType == 4){
1016//			var newsUrl = local_host + "to_search-news"
1017//			$(".topSearchForm").attr("action",newsUrl);
1018//		}
1019//	}
1020	return true;
1021}
1022
1023//-----------------------------高级检索--------------------------------------
1024function addSearchCondGroup(){
1025	var newGroup = $(".adv-form-group").last().clone();
1026	$(".adv-form-group").last().after(newGroup);
1027	var n = $(".adv-form-group").length - 1;
1028	$(".search-wrap .adv-form-group:last .searchField option:eq("+n+")").attr("selected",true);
1029}
1030
1031function deleteSearchCondGroup(){
1032	var condGroup = $(".adv-form-group");
1033	if(condGroup.length > 2){
1034		$(".adv-form-group").last().remove();
1035	}
1036}
1037
1038/**
1039 * 高级检索表单提交前校验查询条件,并拼接为搜索引擎json参数格式
1040 * @return
1041 */
1042function subAdvanceResult(){
1043	//高级检索条件是否都为空
1044	var searchFlag = false;
1045	$(".searchFieldVal").each(function(i,e){
1046		if(!isNull($(e).val())){
1047			searchFlag = true;
1048		}
1049	})
1050	if(searchFlag == false){
1051		alert("检索词不能为空");
1052		return false;
1053	}
1054	/*检索条件验证*/
1055	$(".adv-form-group").each(function(i,e){
1056		var searchFieldVal = $(e).find('.searchFieldVal').val();
1057		if(!isNull(searchFieldVal)){
1058			var yearfield = $(e).find('.searchField').val();
1059			if(yearfield == 'year'){
1060				var ret = /^[1-2]{1}[0-9]{3}$/;
1061				var retrang = /^[1-2]{1}[0-9]{3}-[1-2]{1}[0-9]{3}$/;
1062				if(ret.test(searchFieldVal) || retrang.test(searchFieldVal)){
1063					
1064				}else{
1065					alert("期刊 “年” 格式不正确");
1066					searchFlag = false;
1067					return false;
1068				}
1069			}
1070		}
1071	})
1072	return searchFlag;
1073}
1074
1075function submitAdvanceSearch(){
1076	if(!subAdvanceResult()){
1077		return false;
1078	};
1079	$.post(
1080		"advancesearch",
1081		{
1082			page:$("#page").val(),
1083			searchCondition:$("#searchCondition").val(),
1084			searchType:$("#searchType").val(),
1085			year:$("input[name='year']").val(),
1086			authorName:$("input[name='authorNameCn']").val(),
1087			keyword:$("input[name='keywordCn']").val()
1088		},function (data){
1089			$("#advance_search_detail").empty();
1090			console.log(data);
1091			$("#advance_search_detail").append(data);
1092			//搜索摘要,显示出来
1093			if($("#searchCondition").val().search("abstractinfo") != -1){
1094				$(".search-abstract").attr("style","display:block;");
1095			}
1096			//渲染数学公式
1097    	    MathJax.Hub.Queue(["Typeset", MathJax.Hub]);
1098			loadAdvanceFacet();
1099		}
1100	);
1101}
1102
1103/**
1104 * 高级检索
1105 * @param $scope
1106 * @param $http
1107 * @returns
1108 */
1109app.controller('advanced-search-result', function($scope, $http, $filter) {
1110	$scope.yearsShowNum = 10;
1111	//页面第一次加载
1112//	setTimeout(function() { 
1113//		$scope.searchData(0);
1114//	});
1115	
1116	//输入页码加载
1117	$scope.enterEvent = function (e) {
1118		if(loadCommonPagesEnter(e)){
1119			$scope.searchData(1);
1120			$(document).scrollTop(0);
1121		}
1122    };
1123    
1124    //点击页码加载
1125	$scope.gotopage = function(page) {
1126		if(isNull(page)){
1127			$scope.searchData(1);
1128		}else{
1129			$('#pageNum').val(page);
1130			$scope.searchData(0);
1131		}
1132		$(document).scrollTop(0);
1133	};
1134	
1135	//点击分页加载
1136	$("#gotoLimit").change(function(){
1137		var limit =$(this).children('option:selected').val(); 
1138		var pagelimit = $('#limit').val();
1139		if(!isNull(pagelimit) && pagelimit != limit){
1140			$('#limit').val(limit);
1141			$scope.searchData(0);
1142		}
1143	})
1144	
1145	//点击排序方法搜索
1146	$scope.sortSearch = function(type) {
1147		if(type == '0'){
1148			$("a[name='publishDate']").val("");
1149			$("a[name='pdfDownloadCount']").val("")
1150			$("a[name='relevance']").addClass("active").siblings().removeClass("active");
1151		}else if(type == '1'){
1152			$("a[name='publishDate']").val("DESC");
1153			$("a[name='pdfDownloadCount']").val("");
1154			$("a[name='publishDate']").addClass("active").siblings().removeClass("active");
1155		}else if(type == '2'){
1156			$("a[name='publishDate']").val("");
1157			$("a[name='pdfDownloadCount']").val("DESC");
1158			$("a[name='pdfDownloadCount']").addClass("active").siblings().removeClass("active");
1159		}
1160		$scope.searchData(0);
1161	};
1162    
1163    //点击右侧聚类加载
1164	$scope.rightFilters = function (e,rightType) {
1165		if(rightType == "year"){
1166			//点击年
1167			var yearVal = $(e.target).html();
1168			$("input[name='year']").val(yearVal);
1169			$("#filterCondYear").html(yearVal);
1170			$("#rightSearchFilter").show();
1171			$(".filterCondYear").show();
1172		}else if(rightType == "author"){
1173			//点击作者
1174			var authorVal = "";
1175			if($(e.target).is('a')){
1176				authorVal = $(e.target).html();
1177			}else{
1178				authorVal = $(e.target).parent("a.authorfacetVal").html();
1179			}
1180			$("input[name='authorName']").val(authorVal);
1181			$("#filterCondAuthor").html(authorVal);
1182			$("#rightSearchFilter").show();
1183			$(".filterCondAuthor").show();
1184		}else if(rightType == "keyword"){
1185			//点击关键词
1186			var keywordVal = "";
1187			if($(e.target).is('a')){
1188				keywordVal = $(e.target).html();
1189			}else{
1190				keywordVal = $(e.target).parent("a.keywordfacetVal").html();
1191			}
1192			$("input[name='keyword']").val(keywordVal);
1193			$("#filterCondKeyword").html(keywordVal);
1194			$("#rightSearchFilter").show();
1195			$(".filterCondKeyword").show();
1196		}else if(rightType == "classify"){
1197			//点击栏目
1198			var journalVal =  $(e.target).html();
1199			$("input[name='publisherId']").val(classifyVal);
1200			$("#filterCondJournal").html(keywordVal);
1201			$("#rightSearchFilter").show();
1202			$(".filterCondJournal").show();
1203		}else if(rightType == "journal"){
1204			//点击期刊
1205			var journalName = $(e.target).html();
1206			$("input[name='journalName']").val(journalName);
1207			$("#filterCondJournal").html(journalName);
1208			$("#rightSearchFilter").show();
1209			$(".filterCondJournal").show();
1210		}
1211		$scope.searchData(0);
1212    };
1213    
1214    //叉掉右侧聚类点击的过滤条件
1215    $scope.closeFilterConds = function(type) {
1216		if(type == 'year'){
1217			$("input[name='year']").val('');
1218			$("#filterCondYear").html('');
1219			$(".filterCondYear").hide();
1220		}else if(type == "author"){
1221			$("input[name='authorName']").val('');
1222			$("#filterCondAuthor").html('');
1223			$(".filterCondAuthor").hide();
1224		}else if(type == "keyword"){
1225			$("input[name='keyword']").val('');
1226			$("#filterCondKeyword").html('');
1227			$(".filterCondKeyword").hide();
1228		}else if(type == "classify"){
1229			$("input[name='classifyinfo']").val('');
1230			$("#filterCondClassify").html('');
1231			$(".filterCondClassify").hide();
1232		}else if(type == "journal"){
1233			$("input[name='journalName']").val('');
1234			$("#filterCondJournal").html('');
1235			$(".filterCondJournal").hide();
1236		}
1237		if(isNull($("input[name='year']").val()) && 
1238			isNull($("input[name='authorName']").val()) && 
1239			isNull($("input[name='keyword']").val()) && 
1240			isNull($("input[name='classifyinfo']").val()) && 
1241			isNull($("input[name='journalName']").val())){
1242			$("#rightSearchFilter").hide();
1243		}
1244		$scope.searchData(0);
1245	};
1246//	$scope.enterEventSearch = function (e) {
1247//		var keycode = window.event ? e.keyCode : e.which;
1248//        if(keycode==13){
1249//        	$scope.submitSearch();
1250//        }
1251//    };
1252    
1253    //点击检索提交
1254	$scope.submitAdvanceSearch = function() {
1255		$scope.searchData(0);
1256	};
1257	
1258	$scope.searchData = function(type) {
1259		/*if(!subAdvanceResult()){
1260			return false;
1261		};*/
1262		
1263		var _searchUiIndex=[],_searchRelations=[],_searchFields = [],_searchFieldVals = [],_searchTypes = [];
1264		$(".adv-form-group").each(function(i,e){
1265			var searchFieldVal = $(e).find('.searchFieldVal').val();
1266			if(!isNull(searchFieldVal)){
1267				_searchUiIndex.push(i);
1268				var searchRelation = $(e).find('.searchRelation').val();
1269				if(isNull(searchRelation)){
1270					searchRelation = "OR";
1271				}
1272				_searchRelations.push(searchRelation);
1273				_searchFields.push($(e).find('.searchField').val());
1274				_searchFieldVals.push(searchFieldVal);
1275				_searchTypes.push($(e).find('.searchType').val());
1276			}
1277		})
1278		
1279		//刊publisherId
1280		
1281		//年范围
1282		var begin_year = $("input[name='begin_year']").val();
1283		var end_year = $("input[name='end_year']").val();
1284		if(isNull(end_year)){
1285			end_year = "2021";
1286		}
1287		if(!isNull(begin_year)){
1288			_searchUiIndex.push(_searchUiIndex.length+1);
1289			_searchRelations.push("AND");
1290			_searchFields.push("year");
1291			_searchFieldVals.push(begin_year+"-"+end_year);
1292			_searchTypes.push("RANGE_NUMBER");
1293		}
1294		//卷
1295		var volume = $("input[name='volume']").val();
1296		if(!isNull(volume)){
1297			_searchUiIndex.push(_searchUiIndex.length+1);
1298			_searchRelations.push("AND");
1299			_searchFields.push("volume");
1300			_searchFieldVals.push(volume);
1301			_searchTypes.push("EQUAL");
1302		}
1303		//期
1304		var issue = $("input[name='issue']").val();
1305		if(!isNull(issue)){
1306			_searchUiIndex.push(_searchUiIndex.length+1);
1307			_searchRelations.push("AND");
1308			_searchFields.push("issue");
1309			_searchFieldVals.push(issue);
1310			_searchTypes.push("EQUAL");
1311		}
1312		//页码
1313		var fpage = $("input[name='page']").val();
1314		if(!isNull(fpage)){
1315			_searchUiIndex.push(_searchUiIndex.length+1);
1316			_searchRelations.push("AND");
1317			_searchFields.push("fpage");
1318			_searchFieldVals.push(fpage);
1319			_searchTypes.push("LIKE");
1320			
1321			_searchUiIndex.push(_searchUiIndex.length+1);
1322			_searchRelations.push("AND");
1323			_searchFields.push("lpage");
1324			_searchFieldVals.push(fpage);
1325			_searchTypes.push("LIKE");
1326		}
1327		
1328		var _searchObjArr = [];
1329		for(var i=0;i<_searchFieldVals.length;i++){
1330			var relation = _searchRelations[i];
1331			if(_searchFieldVals.length == 1 || i == 0){
1332				relation = "AND";
1333			}
1334			var _searchObj = '{"searchField":"'+_searchFields[i]+'","searchVal":"'+ _searchFieldVals[i]  +'","searchType":"'+_searchTypes[i]+'","searchRelation":"'+relation+'"}';
1335			if(null != _searchFieldVals[i] && _searchFieldVals[i] != ""){
1336				_searchObjArr.push(_searchObj);
1337			}
1338		}
1339		$('.searchCondition').val(_searchObjArr.join(','));
1340		
1341		//var conditions = $("#searchCondition").val()
1342		var language = $('#language').val();
1343		
1344		var currentpage = "";
1345		var limit = $('#limit').val();;
1346		if(isNull(limit)){
1347			limit = 10;
1348		}
1349		if(type == 1){
1350			currentpage = $("input.inputpagenum").val();
1351		}else{
1352			currentpage = $('#pageNum').val();
1353		}
1354		var pn = currentpage;
1355		
1356		var publisherId =  $('#publisherId').val();
1357		if(publisherId == "index"){
1358			publisherId = "";
1359		}
1360		
1361		var sortJson = new Array();
1362		var aggreFields = "";
1363		var filtersJson = new Array();
1364		
1365		//处理三种排序 默认desc倒序
1366		var publishDate = $("a[name='publishDate']").val();
1367		if(!isNull(publishDate)){
1368			sortJson.push(new sortVo("publishDate","DESC"));
1369		}
1370		var pdfDownloadCount = $("a[name='pdfDownloadCount']").val();
1371		if(!isNull(pdfDownloadCount)){
1372			sortJson.push(new sortVo("pdfDownloadCount","DESC"));
1373		}
1374			
1375		//聚类字段 默认
1376		if(language == "en"){
1377			aggreFields = "year;authors.authorNameEn;keywords.keywordEn;classifyinfoEn;journalMeta.titleEn";
1378		}else{
1379			aggreFields = "year;authors.authorNameCn;keywords.keywordCn;classifyinfoCn;journalMeta.titleCn";
1380		}
1381		
1382		//处理右侧聚类点击后的字段fiters
1383		var year = $("input[name='year']").val();
1384		if(!isNull(year)){
1385			filtersJson.push(new FilterConditionVo("year",year,"AND"));
1386		}
1387		var authorName = $("input[name='authorName']").val();
1388		if(!isNull(authorName) && language == "en"){
1389			filtersJson.push(new FilterConditionVo("authors.authorNameEn",authorName,"AND"));
1390		}else if(!isNull(authorName) && language == "cn"){
1391			filtersJson.push(new FilterConditionVo("authors.authorNameCn",authorName,"AND"));
1392		}
1393		var keyword = $("input[name='keyword']").val();
1394		if(!isNull(keyword) && language == "en"){
1395			filtersJson.push(new FilterConditionVo("keywords.keywordEn",keyword,"AND"));
1396		}else if(!isNull(keyword) && language == "cn"){
1397			filtersJson.push(new FilterConditionVo("keywords.keywordCn",keyword,"AND"));
1398		}
1399		var classifyinfo = $("input[name='classifyinfo']").val();
1400		if(!isNull(classifyinfo) && language == "en"){
1401			filtersJson.push(new FilterConditionVo("classifyinfoEn",classifyinfo,"AND"));
1402		}else if(!isNull(classifyinfo) && language == "cn"){
1403			filtersJson.push(new FilterConditionVo("classifyinfoCn",classifyinfo,"AND"));
1404		}
1405		var journalName = $("input[name='journalName']").val();
1406		if(!isNull(journalName) && language == "en"){
1407			filtersJson.push(new FilterConditionVo("journalMeta.titleEn",journalName,"AND"));
1408		}else if(!isNull(journalName) && language == "cn"){
1409			filtersJson.push(new FilterConditionVo("journalMeta.titleCn",journalName,"AND"));
1410		}
1411		
1412		//高亮字段 ; 号分割---------统一处理一些搜索不必要传的字段
1413		var highField = "";
1414		if(language == "en"){
1415			searchField =  "titleEn;authors.authorNameEn;keywords.keywordEn;abstractinfoEn,doi";
1416			highField = "titleEn;authors.authorNameEn;keywords.keywordEn;abstractinfoEn";
1417		}else{
1418			searchField = "titleCn;authors.authorNameCn;keywords.keywordCn;abstractinfoCn,doi";
1419			highField = "titleCn;authors.authorNameCn;keywords.keywordCn;abstractinfoCn";
1420		}
1421		
1422		$http({
1423			 method:'post',
1424	         url:local_host+"/advanced-search-data",
1425	         params:{'publisherId':publisherId,'conditions':"["+_searchObjArr+"]",'language':language,
1426	        	 'pn':pn,'limit':limit,'filters':JSON.stringify(filtersJson),'sorts':JSON.stringify(sortJson),
1427	        	 'highlightFields':highField,'aggreFields':aggreFields}
1428	     }).then(function(response){
1429	    	 //成功时执行
1430	    	 var dataMap = response.data;
1431	    	 $scope.articles = dataMap.resultlist;
1432	    	 $scope.years = dataMap.aggreMap["year"];
1433	    	 $scope.yearsNum = dataMap.aggreMap["year"].length;
1434	    	 $scope.moreJia = 1;	    	 
1435	    	 $scope.publishDate = dataMap.aggreMap["publishDate"];	    	 
1436	    	
1437	    	 if(language == "en"){
1438	    		 $scope.journals = dataMap.aggreMap["journalMeta.titleEn"];
1439	    		 $scope.authors = dataMap.aggreMap["authors.authorNameEn"];
1440	    		 $scope.keywords = dataMap.aggreMap["keywords.keywordEn"];
1441	    		 $scope.classifyinfos = dataMap.aggreMap["classifyinfoEn"];
1442	    	 }else{
1443	    		 $scope.journals = dataMap.aggreMap["journalMeta.titleCn"];
1444	    		 $scope.authors = dataMap.aggreMap["authors.authorNameCn"];
1445	    		 $scope.keywords = dataMap.aggreMap["keywords.keywordCn"];
1446	    		 $scope.classifyinfos = dataMap.aggreMap["classifyinfoCn"];
1447	    	 }
1448	    	 
1449	    	 $('#search-result').show();
1450	    	 $('.articleCount').html(dataMap.totalCount);
1451	    	 var count = dataMap.totalCount;
1452	    	 currentpage = dataMap.currentPage;
1453			 $('#amount').val(count);
1454			 $('#pageNum').val(currentpage);
1455			 var totalpage = Math.ceil(count/limit);
1456    		 $scope.count =  count;
1457    		 $scope.totalpage =  totalpage;
1458    		 $scope.currentpage =  Number(currentpage);
1459    		 $scope.pageList = new Array();
1460    		 $scope.pageList = loadCommonPages(count,totalpage,currentpage,20);
1461    		 
1462    		 $('#amount').val(count);
1463    		 $('#totalpage').val(totalpage);
1464			 $('.loading-show').hide();
1465	     },function(response){
1466	         //失败时执行 
1467	         console.log(response.data.message);
1468	     });
1469		$(document).scrollTop(0);
1470	}
1471	
1472    $scope.changeOrder = false;
1473    $scope.changeY = false;
1474    $scope.rightFiterYearOrder = function(e,key){
1475    	$scope.changeY = true;
1476    	$scope.changeOrder = !$scope.changeOrder;
1477    	$scope.years=$filter('orderBy')($scope.years,key,$scope.changeOrder);
1478    	$(e.target).addClass('active').siblings().removeClass('active');
1479    	console.log($(e.target).find('span'),'aaa')
1480    	$(e.target).find('span').css({'display':'block'})
1481    	$(e.target).siblings().find('span').css({'display':'none'})
1482    	
1483    }
1484    $scope.changeOrder2 = true;
1485    $scope.rightFiterCountOrder = function(e,docCount){
1486    	$scope.changeOrder2 = !$scope.changeOrder2;
1487    	$scope.years=$filter('orderBy')($scope.years,docCount,$scope.changeOrder2);
1488    	$(e.target).addClass('active').siblings().removeClass('active');
1489    	$(e.target).find('span').css({'display':'block'})
1490    	$(e.target).siblings().find('span').css({'display':'none'})
1491    	
1492    }   
1493    
1494    $scope.selectYearMore = function(){
1495    	$scope.moreJia = $scope.moreJia + 1;
1496    	$scope.yearsShowNum = 10*$scope.moreJia;
1497    	
1498    }
1499    $scope.selectYearLess = function(){
1500    	$scope.moreJia = 1;
1501    	$scope.yearsShowNum = 10*$scope.moreJia;
1502    }	
1503	
1504	
1505	
1506	
1507});
1508
1509
1510app.controller('search-common-result', function($scope, $http, $filter) {
1511	var oldSearchType = $("input[name='oldSearchType']").val();
1512	var url = "";
1513	
1514	//页面第一次加载
1515	setTimeout(function() { 
1516		$scope.searchData(0);
1517	});
1518	
1519	//输入页码加载
1520	$scope.enterEvent = function (e) {
1521		if(loadCommonPagesEnter(e)){
1522			$scope.searchData(1);
1523			$(document).scrollTop(0);
1524		}
1525    };
1526    
1527    //点击页码加载
1528	$scope.gotopage = function(page) {
1529		if(isNull(page)){
1530			$scope.searchData(1);
1531		}else{
1532			$('#pageNum').val(page);
1533			$scope.searchData(0);
1534		}
1535		$(document).scrollTop(0);
1536	};
1537	
1538	//点击分页加载
1539	$("#gotoLimit").change(function(){
1540		var limit =$(this).children('option:selected').val(); 
1541		var pagelimit = $('#limit').val();
1542		if(!isNull(pagelimit) && pagelimit != limit){
1543			$('#limit').val(limit);
1544			$scope.searchData(0);
1545		}
1546	})
1547    
1548	$scope.enterEventSearch = function (e) {
1549		var keycode = window.event ? e.keyCode : e.which;
1550        if(keycode==13){
1551        	$scope.submitSearch();
1552        }
1553    };
1554    
1555    //点击检索提交
1556	$scope.submitSearch = function() {
1557		if(!isNull($(".search-condition input[name='q']").val())){
1558			var searchType = $("input[name='searchType']:checked").val();
1559			if(oldSearchType == searchType){
1560				$scope.searchData(0);
1561			}else{
1562				//分别处理不同搜索类型,跳到不同的页面
1563				goSearchPage();
1564			}
1565		}else{
1566			if(language = "en"){
1567				alert("please enter the search word");
1568			}else{
1569				alert("请输入检索词");
1570			}
1571		}
1572	};
1573
1574	$scope.searchData = function(type) {
1575		
1576		var searchType = $(".search-condition  input[name='searchType']:checked").val();
1577		var searchField = $(".search-condition  select[name='searchField']").val();
1578		searchField = "titleCn";
1579		var language = $('#language').val();
1580		url = local_host+"search-common-data"
1581		var searchWord = $(".search-condition input[name='q']").val();
1582		
1583		var currentpage = "";
1584		var limit = 10;
1585		if(type == 1){
1586			currentpage = $("input.inputpagenum").val();
1587		}else if(type == 2){
1588			//图查询滚动翻页
1589			$('#pageNum').val(Number($('#pageNum').val()) + 1);
1590			currentpage = $('#pageNum').val();
1591		}else{
1592			currentpage = $('#pageNum').val();
1593		}
1594		var pn = currentpage;
1595		
1596		var publisherId =  $('#publisherId').val();
1597		if(publisherId == "index"){
1598			publisherId = "";
1599		}
1600		
1601		var sortJson = new Array();
1602		var aggreFields = "";
1603		var filtersJson = new Array();
1604		//高亮字段 ; 号分割---------统一处理一些搜索不必要传的字段
1605		var highField = "";
1606		
1607		$http({
1608			 method:'post',
1609	         url:url,
1610	         params:{'publisherId':publisherId,'searchField':searchField,'searchWord':searchWord,
1611	        	 'searchType':searchType,'language':language,'pn':pn,'limit':limit,
1612	        	 'filters':JSON.stringify(filtersJson),'sorts':JSON.stringify(sortJson),
1613	        	 'highlightFields':JSON.stringify(highField),'aggreFields':aggreFields}
1614	     }).then(function(response){
1615	    	 //成功时执行
1616	    	 var dataMap = response.data;
1617	    	 var searchCommons = dataMap.resultlist;
1618	    	 for(var i =0; i < searchCommons.length; i++){
1619	    		 var searchCommon = searchCommons[i];
1620	    		 if(searchCommon.type == "0" && !isNull(searchCommon.publisherId)){
1621	    			 searchCommons[i].publisherId = searchCommon.publisherId.replace(/,/g,"")
1622	    		 }
1623	    	 }
1624	    	 $scope.searchCommons = searchCommons;
1625	    	 $('.commonCount').html(dataMap.totalCount);
1626	    	 var count = dataMap.totalCount;
1627	    	 currentpage = dataMap.currentPage;
1628			 $('#amount').val(count);
1629			 $('#pageNum').val(currentpage);
1630			 var totalpage = Math.ceil(count/limit);
1631    		 $scope.count =  count;
1632    		 $scope.totalpage =  totalpage;
1633    		 $scope.currentpage =  Number(currentpage);
1634    		 $scope.pageList = new Array();
1635    		 $scope.pageList = loadCommonPages(count,totalpage,currentpage,20);
1636    		 
1637    		 $('#amount').val(count);
1638    		 $('#totalpage').val(totalpage);
1639			 $('.loading-show').hide();
1640	     },function(response){
1641	         //失败时执行 
1642	         console.log(response.data.message);
1643	     });
1644	}
1645
1646	
1647	
1648	
1649	
1650});
1651
1652app.directive('searchFigs',function(){
1653    return {
1654        link: function(scope,element,attr){      	
1655            if((scope.$index+1) %3 == 0){
1656            	$(".search-new-con .box").eq(scope.$index).after("<div  class='borderp' style='clear:both;width:100%;'></div>").addClass("float-r");
1657            }
1658            if(scope.$last == true){
1659    		    setTimeout(function(){
1660    				$(".search-new-con .borderp").each(function(i,e){
1661    					var temp = [];
1662    					var temp1 = $(this).prev();
1663    					var temp2 = temp1.prev();
1664    					var temp3 = temp2.prev();
1665    					temp.push(temp1.outerHeight(),temp2.outerHeight(),temp3.outerHeight());
1666    					var maxHeight = Math.max.apply(null, temp);
1667    					$(temp1).css("height",maxHeight);
1668    					$(temp2).css("height",maxHeight);
1669    					$(temp3).css("height",maxHeight);
1670    				})
1671    			
1672    		    },200);
1673            }           
1674        }
1675    }
1676})
1677
1678
1679$(function(){
1680    //公共点击作者,关键词 搜索方法
1681	$("body").on('click','.search-like',function(){
1682		var searchVal = $(this).attr("data");
1683		var searchField = $(this).attr("type");
1684		var url = local_host.replace("/en/","/")+"search";
1685		searchCommon(searchField,searchVal,url);
1686	})
1687	
1688	//搜索摘要展示与隐藏方法
1689	$("body").on('click','.show-search-abstract',function(){
1690		var id = $(this).attr("data");
1691		$("div[id='"+id+"'] .search-abstract").toggle();
1692		var flag = $(this).data('flag');
1693		if($("#language").val() == "en"){
1694			$(this).text(!flag ? '[Abstract -]' : '[Abstract +]').data('flag', !flag);
1695		}else{
1696			$(this).text(!flag ? '[摘要 -]' : '[摘要 +]').data('flag', !flag);
1697		}
1698	})
1699	
1700	//
1701//	if($("input[name='searchType']:checked").val() != "0"){
1702//		 $(".form-control-1-box").hide();
1703//		 $(".paddingLeftNone").css({"width":"400px"});
1704//	}else{
1705//		$(".form-control-1-box").show();
1706//		$(".paddingLeftNone").css({"width":"250px"});
1707//	}
1708	$("input[name='searchType']").click(function(){
1709		var searchType = $("input[name='searchType']:checked").val();
1710		if(searchType != "0"){
1711			 $(".form-control-1-box").hide();
1712			// $(".paddingLeftNone").css({"width":"400px"});
1713			 if($(window).width()>767){
1714                 $(".search-wrap .inputText.paddingLeftNone").css({"width":"482px"});
1715             }else{
1716             	$(".inputText").css({"width":"100%","margin":"0"}); 
1717                 $(".search-wrap .inputText.paddingLeftNone").css({"width":"100%"}); 
1718             }
1719		}else{
1720			$(".form-control-1-box").show();
1721			//$(".paddingLeftNone").css({"width":"250px"});
1722			 if($(window).width()>767){
1723             	$(".search-wrap .inputText.paddingLeftNone").css({"width":"365px"});
1724             }else{
1725             	$(".inputText.paddingLeftNone").css({"width":"71%","margin":"0 0 0 2%"}); 
1726             }
1727		}
1728	})
1729	if($("input[name='searchType']:checked").val() != "0"){
1730		$(".form-control-1").hide();
1731		if($(window).width()>767){
1732			$(".search-wrap .inputText.paddingLeftNone").css({"width":"482px"});
1733		}else{
1734			$(".search-wrap .inputText.paddingLeftNone").css({"width":"100%"}); 
1735		}
1736	}else{
1737		$(".form-control-1").show();
1738		if($(window).width()>767){
1739			$(".search-wrap .inputText.paddingLeftNone").css({"width":"365px","margin":"0 30px 0 0"});
1740		}else{
1741			$(".search-wrap .inputText.paddingLeftNone").css({"width":"71%","margin":"0 0 0 2%"});
1742		}
1743	}
1744	
1745	
1746	$(document).keyup(function(event){
1747	    if(event.keyCode ==13){
1748	    	if($(this).is('input')){
1749				alert(111);
1750			}else{
1751				if($(this).parent("div.search-entrance").length > 0){
1752					//console.log(0);
1753				}
1754			}
1755	    }
1756	});
1757	$('.glyphicon-remove').on('click',function(){
1758		$(this).siblings('#q').val('');
1759	})
1760})
1761

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.