diff src/main/webapp/pages/fullTextSearch.jsp @ 39:37840afb7b80

new: full text search
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Fri, 04 Dec 2015 14:28:44 +0100
parents
children 35ed4e650a53
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/webapp/pages/fullTextSearch.jsp	Fri Dec 04 14:28:44 2015 +0100
@@ -0,0 +1,604 @@
+<%@page import="de.mpiwg.gazetteer.bo.LGBranch"%>
+<%@page import="org.apache.commons.lang.StringUtils"%>
+<%@page import="de.mpiwg.gazetteer.db.DBSection"%>
+<%@page import="de.mpiwg.gazetteer.db.DBContents"%>
+<%@page import="de.mpiwg.gazetteer.bo.LGFullTextSearchFile"%>
+
+
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
+
+<jsp:useBean id="sessionBean" class="de.mpiwg.web.jsp.SessionBean" scope="session" />
+	
+
+<html>
+
+<head>
+
+	<jsp:include page="../componentes/headContent.jsp"/>	
+
+	<script>	
+		$(function() {
+		    $( "#dialogMoreInfo" ).dialog({
+		        autoOpen: false,
+		        modal: true,
+		        position: { my: "center", at: "top", of: window },
+		        
+		      });
+		    
+		    var dialogSave = $("#dialogSave").dialog(
+					{autoOpen: false}
+		  	);	   
+			$("#saveResult").button().on( "click", function() {
+				// append searchTerm into the form 		
+				$('<input>').attr({
+				    type: 'hidden',
+				    name: 'searchTerm',
+				    value: $("#searchTerm").val()
+				}).appendTo('form[name="saveTableForm"]');
+				
+				
+				dialogSave.dialog( "open" );
+			});
+			
+			var dialogViewSavedResult = $("#dialogViewSavedResult").dialog(
+					{autoOpen: false}
+		  	);	  
+			$("#viewSavedResult").button().on( "click", function() {
+				dialogViewSavedResult.dialog( "open" );
+			});
+			
+			
+		});
+		
+		// enter pressed event, we don't want to always go to "search".
+		$(document).keypress(
+			function(event){
+				if (event.which == '13') {	// enter pressed
+					// if any of the filter fields is filled in, filter first; otherwize, go to search
+					$(".filterInput" ).each(function( i ) {
+						//console.log( this.value );
+						if (this.value != "") {
+							//console.log('filtering' + i);
+							setAction('filter', 'fullTextSearchForm');
+							$("#fullTextSearchForm").submit();
+							return false;		
+						}
+						
+					});
+			    }
+		});
+		
+		$(document).ready(function(){
+			highlightKeywords();
+		})
+
+		function highlightKeywords()	// highlight keywords in content column, with class="content"
+		{	
+			if ($("#searchTerm")[0] == undefined ){
+				return;
+			}
+			var keywords = $("#searchTerm")[0].value;
+			var keywordsArray = keywords.split(", ");
+			//console.log("keywordsArray: "+keywordsArray);
+			
+			var content = $(".content");
+			for (var i = 0; i < content.length; i++) {
+				// find keywords in content[i]
+				var text = content[i].innerHTML;
+				for (var j = 0; j < keywordsArray.length; j++) {
+					var index = text.indexOf(keywordsArray[j]);
+					if (index >= 0) {
+						text = text.substring(0,index) + "<span class='highlight'>" + text.substring(index, index+keywordsArray[j].length) + "</span>" + text.substring(index+keywordsArray[j].length);
+						content[i].innerHTML = text;
+					}		
+				};
+
+			};
+		}
+		
+	</script>
+</head>
+
+<body>
+
+	<jsp:include page="../componentes/template.jsp"/>
+
+	<div id="dialogMoreInfo" title="Full Text Search Details"> </div>
+	
+	<div id="page">
+	
+		<% if(sessionBean.getUser() == null) { %>
+			<label>You must login!</label>
+		<% } else { 
+			
+			if (sessionBean.getFullTextSearchPage().getFileList() == null){ 
+				sessionBean.getFullTextSearchPage().loadParameters(request, response);
+				sessionBean.getFullTextSearchPage().forceLoadFileList();
+			}
+			
+			%>
+			
+			<div id="dialogSave" title="Save Table:">
+				<form name="saveTableForm" id="saveTableForm"
+						action="<%= sessionBean.getApplicationBean().getRootServer()%>/proxy.jsp"
+						method="post">
+						<input name="bean" type="hidden" value="fullTextSearchBean" /> 
+					<table>
+						<tr>
+							<td>
+								<input id="fileName" name="fileName" type="text" placeholder="table name"/>
+							</td>
+							<td>
+								<button onclick="setAction('save', 'saveTableForm'); document.getElementById('saveTableForm').submit();">Save</button> 
+								
+							</td>
+						</tr>						
+					</table>	
+				</form>
+			 	
+			</div>	
+			
+			<div id="dialogViewSavedResult" title="Saved Table List:">
+		
+				<table class="pageTable">
+					<tr>
+						<td class="tableTitle">Table name</td>
+						<td class="tableTitle">html</td>
+					</tr>
+					
+					<% for (LGFullTextSearchFile aFile : sessionBean.getFullTextSearchPage().getFileList() ){%>
+					<tr>
+						<td><%= aFile.getFileName() %></td>
+						<!-- getFullTextSearchFileText?fileId= &userId= -->
+						<td>
+							<a href="<%=sessionBean.getApplicationBean().getRootServer() %>/rest/text/getFullTextSearchHtmlFile?fileId=<%= aFile.getId() %>"
+										target="_blank">
+								<img alt="Show text in html" src="<%=sessionBean.getApplicationBean().getShowImage()%>"/>	
+							</a>
+						</td>
+						
+					</tr>
+					<% } %>
+					
+				</table>
+				
+		
+			</div>	
+		<label class="subTitel">Full Text Search</label> 
+
+			<form name="fullTextSearchForm" id="fullTextSearchForm"
+				action="<%=sessionBean.getApplicationBean().getRootServer()%>/proxy.jsp"
+				method="post"
+				class="contentForm">
+				<input name="bean" type="hidden" value="fullTextSearchBean" /> 
+	
+				<table style="width: 300px; margin-left: auto;margin-right: auto;">
+				<tr>
+					<td>
+						<input
+							id="searchTerm"
+							name="searchTerm"
+							type="text"
+							class="searchInput"
+							value="<%=sessionBean.getFullTextSearchPage().getSearchTerm()%>" />				
+					</td>
+					<td>
+						<input id="search"
+							type="image" 
+							onclick="setAction('search', 'fullTextSearchForm');"
+							src="<%=sessionBean.getApplicationBean().getSearchImage()%>"/>
+					</td>
+		
+				</tr>
+				
+				<tr><td><label class="label"><%= (StringUtils.isNotEmpty(sessionBean.getFullTextSearchPage().getSearchMessage())) ? sessionBean.getFullTextSearchPage().getSearchMessage() : ""%></label></td></tr>
+				<tr><td><label class="label"><%= (StringUtils.isNotEmpty(sessionBean.getFullTextSearchPage().getFilteringMessage())) ? sessionBean.getFullTextSearchPage().getFilteringMessage() : ""%></label></td></tr>
+				<tr><td>
+					<button id="saveResult" type="button" class="lgButton">Save Table</button>								
+					<button id="viewSavedResult" type="button" class="lgButton">View Saved Table(s)</button>
+				</td></tr>
+					
+				
+				</table>
+		
+		
+	
+			<%
+				if (sessionBean.getFullTextSearchPage().getCompleteList() != null) {
+			%>
+	
+			<!-- 
+			<jsp:include page="../componentes/paginator.jsp">
+				<jsp:param name="formName" value="fullTextSearchForm"/>
+			</jsp:include> 
+			-->
+			
+			<div class="tableDiv double-scroll">
+				<table class="pageTable">
+					<tbody>
+						<tr>
+							<th>
+								<table class="sortTable">
+									<tr>
+										<td><label class="tableTitle">#</label></td>
+										<td>
+											<table>
+												<tr><td>
+													<input type="image" 
+														onclick="setAction('sortByInxUp', 'fullTextSearchForm');"
+														src="<%=sessionBean.getApplicationBean().getUpImage()%>"/>										
+												</td></tr>
+												<tr><td>
+													<input type="image"
+														onclick="setAction('sortByInxDown', 'fullTextSearchForm');"
+														src="<%=sessionBean.getApplicationBean().getDownImage()%>"/>																				
+												</td></tr>
+											</table>
+										</td>
+									</tr>
+								</table>
+							</th>
+							<th>
+								<table class="sortTable">
+									<tr>
+										<td><label class="tableTitle">Book Id</label></td>
+										<td>
+											<table>
+												<tr><td>
+													<input type="image" 
+														onclick="setAction('sortByBookIdUp', 'fullTextSearchForm');"
+														src="<%=sessionBean.getApplicationBean().getUpImage()%>"/>										
+												</td></tr>
+												<tr><td>
+													<input type="image"
+														onclick="setAction('sortByBookIdDown', 'fullTextSearchForm');"
+														src="<%=sessionBean.getApplicationBean().getDownImage()%>"/>																				
+												</td></tr>
+											</table>
+										</td>
+									</tr>
+									<tr>
+										<td>
+											<input type="text" class="filterInput" name="bookIdFilter" id="bookIdFilter" value="<%= sessionBean.getFullTextSearchPage().getBookIdFilter()%>" size="8"/>
+										</td>									
+										<td>
+											<input type="image"
+												onclick="setAction('filter', 'fullTextSearchForm');"
+												src="<%=sessionBean.getApplicationBean().getFilterImage()%>"/>
+										</td>							
+									</tr>
+								</table>
+							</th>
+							<th>
+								<table class="sortTable">
+									<tr>
+										<td><label class="tableTitle">Book Name</label></td>
+										<td>
+											<table>
+												<tr><td>
+													<input type="image"
+														onclick="setAction('sortByBookNameUp', 'fullTextSearchForm');"
+														src="<%=sessionBean.getApplicationBean().getUpImage()%>"/>										
+												</td></tr>
+												<tr><td>
+													<input type="image"
+														onclick="setAction('sortByBookNameDown', 'fullTextSearchForm');"
+														src="<%=sessionBean.getApplicationBean().getDownImage()%>"/>																	
+												</td></tr>
+											</table>
+										</td>
+									</tr>
+									<tr>
+										<td>
+											<input type="text" class="filterInput" name="bookNameFilter" id="bookNameFilter" value="<%= sessionBean.getFullTextSearchPage().getBookNameFilter()%>" size="8"/>
+										</td>									
+										<td>
+											<input type="image"
+												onclick="setAction('filter', 'fullTextSearchForm');"
+												src="<%=sessionBean.getApplicationBean().getFilterImage()%>"/>
+										</td>							
+									</tr>
+								</table>					
+							</th>
+							<th>
+								<table class="sortTable">
+									<tr>
+										<td><label class="tableTitle">Level 1</label></td>
+										<td>
+											<table>
+												<tr><td>
+													<input type="image"
+														onclick="setAction('sortByLevel1Up', 'fullTextSearchForm');"
+														src="<%=sessionBean.getApplicationBean().getUpImage()%>"/>
+												</td></tr>
+												<tr><td>
+													<input type="image"
+														onclick="setAction('sortByLevel1Down', 'fullTextSearchForm');"
+														src="<%=sessionBean.getApplicationBean().getDownImage()%>"/>																				
+												</td></tr>
+											</table>
+										</td>
+									</tr>
+									<tr>
+										<td>
+											<input type="text" class="filterInput" name="level1Filter" id="level1Filter" value="<%= sessionBean.getFullTextSearchPage().getLevel1Filter()%>" size="8"/>
+										</td>									
+										<td>
+											<input type="image"
+												onclick="setAction('filter', 'fullTextSearchForm');"
+												src="<%=sessionBean.getApplicationBean().getFilterImage()%>"/>
+										</td>							
+									</tr>								
+								</table>	
+							</th>
+							<th>
+								<table class="sortTable">
+									<tr>
+										<td><label class="tableTitle">Level 2</label></td>
+										<td>
+											<table>
+												<tr><td>
+													<input type="image"
+														onclick="setAction('sortByLevel2Up', 'fullTextSearchForm');"
+														src="<%=sessionBean.getApplicationBean().getUpImage()%>"/>
+												</td></tr>
+												<tr><td>
+													<input type="image"
+														onclick="setAction('sortByLevel2Down', 'fullTextSearchForm');"
+														src="<%=sessionBean.getApplicationBean().getDownImage()%>"/>																				
+												</td></tr>
+											</table>
+										</td>
+									</tr>
+									<tr>
+										<td>
+											<input type="text" class="filterInput" name="level2Filter" id="level2Filter" value="<%= sessionBean.getFullTextSearchPage().getLevel2Filter()%>" size="8"/>
+										</td>									
+										<td>
+											<input type="image"
+												onclick="setAction('filter', 'fullTextSearchForm');"
+												src="<%=sessionBean.getApplicationBean().getFilterImage()%>"/>
+										</td>							
+									</tr>								
+								</table>
+							</th>
+							<th>
+								<table class="sortTable">
+									<tr>
+										<td><label class="tableTitle">Dynasty</label></td>
+										<td>
+											<table>
+												<tr><td>
+													<input type="image"
+														onclick="setAction('sortByDynastyUp', 'fullTextSearchForm');"
+														src="<%=sessionBean.getApplicationBean().getUpImage()%>"/>
+												</td></tr>
+												<tr><td>
+													<input type="image"
+														onclick="setAction('sortByDynastyDown', 'fullTextSearchForm');"
+														src="<%=sessionBean.getApplicationBean().getDownImage()%>"/>																				
+												</td></tr>
+											</table>
+										</td>
+									</tr>
+									<tr>
+										<td>
+											<input type="text" class="filterInput" name="dynastyFilter" id="dynastyFilter" value="<%= sessionBean.getFullTextSearchPage().getDynastyFilter()%>" size="8"/>
+										</td>									
+										<td>
+											<input type="image"
+												onclick="setAction('filter', 'fullTextSearchForm');"
+												src="<%=sessionBean.getApplicationBean().getFilterImage()%>"/>
+										</td>							
+									</tr>
+								</table>					
+							</th>
+							<th>
+								<table class="sortTable">
+									<tr>
+										<td><label class="tableTitle">Period</label></td>
+										<td>
+											<table>
+												<tr><td>
+													<input type="image"
+														onclick="setAction('sortByPeriodUp', 'fullTextSearchForm');"
+														src="<%=sessionBean.getApplicationBean().getUpImage()%>"/>										
+												</td></tr>
+												<tr><td>
+													<input type="image"
+														onclick="setAction('sortByPeriodDown', 'fullTextSearchForm');"
+														src="<%=sessionBean.getApplicationBean().getDownImage()%>"/>																				
+												</td></tr>
+											</table>
+										</td>
+									</tr>
+									<tr>
+										<td>
+											<input type="text" class="filterInput" name="periodFilter" id="periodFilter" value="<%= sessionBean.getFullTextSearchPage().getPeriodFilter()%>" size="8"/>
+										</td>									
+										<td>
+											<input type="image"
+												onclick="setAction('filter', 'fullTextSearchForm');"
+												src="<%=sessionBean.getApplicationBean().getFilterImage()%>"/>
+										</td>							
+									</tr>
+								</table>						
+							</th>
+							<th>
+								<table class="sortTable">
+									<tr>
+										<td><label class="tableTitle">Admin Type</label></td>
+										<td>
+											<table>
+												<tr><td>
+													<input type="image"
+														onclick="setAction('sortByAdminTypeUp', 'fullTextSearchForm');"
+														src="<%=sessionBean.getApplicationBean().getUpImage()%>"/>
+												</td></tr>
+												<tr><td>
+													<input type="image"
+														onclick="setAction('sortByAdminTypeDown', 'fullTextSearchForm');"
+														src="<%=sessionBean.getApplicationBean().getDownImage()%>"/>																				
+												</td></tr>
+											</table>
+										</td>
+									</tr>
+									<tr>
+										<td>
+											<input type="text" class="filterInput" name="adminTypeFilter" id="adminTypeFilter" value="<%= sessionBean.getFullTextSearchPage().getAdminTypeFilter()%>" size="8"/>
+										</td>									
+										<td>
+											<input type="image"
+												onclick="setAction('filter', 'fullTextSearchForm');"
+												src="<%=sessionBean.getApplicationBean().getFilterImage()%>"/>
+										</td>							
+									</tr>								
+								</table>	
+							</th>
+							
+							<th>
+								<table class="sortTable">
+									<tr>
+										<td><label class="tableTitle">Section Name</label></td>
+										<td>
+											<table>
+												<tr><td>
+													<input type="image"
+														onclick="setAction('sortBySectionNameUp', 'fullTextSearchForm');"
+														src="<%=sessionBean.getApplicationBean().getUpImage()%>"/>										
+												</td></tr>
+												<tr><td>
+													<input type="image"
+														onclick="setAction('sortBySectionNameDown', 'fullTextSearchForm');"
+														src="<%=sessionBean.getApplicationBean().getDownImage()%>"/>																				
+												</td></tr>
+											</table>
+										</td>
+									</tr>
+									<tr>
+										<td>
+											<input type="text" class="filterInput" name="sectionNameFilter" id="sectionNameFilter" value="<%= sessionBean.getFullTextSearchPage().getSectionNameFilter()%>" size="8"/>
+										</td>									
+										<td>
+											<input type="image"
+												onclick="setAction('filter', 'fullTextSearchForm');"
+												src="<%=sessionBean.getApplicationBean().getFilterImage()%>"/>
+										</td>							
+									</tr>
+								</table>	
+							</th>
+							<th>
+								<table class="sortTable">
+									<tr>
+										<td><label class="tableTitle">Section Pages</label></td>
+										<td>
+											<table>
+												<tr><td>
+													<input type="image"
+														onclick="setAction('sortBySectionNameUp', 'fullTextSearchForm');"
+														src="<%=sessionBean.getApplicationBean().getUpImage()%>"/>										
+												</td></tr>
+												<tr><td>
+													<input type="image"
+														onclick="setAction('sortBySectionNameDown', 'fullTextSearchForm');"
+														src="<%=sessionBean.getApplicationBean().getDownImage()%>"/>																				
+												</td></tr>
+											</table>
+										</td>
+									</tr>
+								</table>	
+							</th>
+							<th>
+								<table class="sortTable">
+									<tr>
+										<td><label class="tableTitle">Page</label></td>
+										<td>
+											<table>
+												<tr><td>
+													<input type="image"
+														onclick="setAction('sortByStartPageUp', 'fullTextSearchForm');"
+														src="<%=sessionBean.getApplicationBean().getUpImage()%>"/>										
+												</td></tr>
+												<tr><td>
+													<input type="image"
+														onclick="setAction('sortByStartPageDown', 'fullTextSearchForm');"
+														src="<%=sessionBean.getApplicationBean().getDownImage()%>"/>																				
+												</td></tr>
+											</table>
+										</td>
+									</tr>
+								</table>							
+							
+							</th>
+							<th style="min-width:300px"><label class="tableTitle">Content</label></th>
+							<th><label class="tableTitle">Select rows</th>
+						</tr>
+					
+		
+						<%
+						for (DBContents content : sessionBean.getFullTextSearchPage().getFilteredList() ) {
+						%>
+						
+						<% if ( content.isRemoved() ) { %>
+						<tr class="removedContent">	
+						<% } else { %>
+						<tr>	
+						<% } %>
+									
+							<td><%=content.getInx() %></td>
+							<td><%=content.getSection().getBook().getId() %></td>
+							<td><%=content.getSection().getBook().getName()%></td>
+							<td><%=content.getSection().getBook().getLevel1()%></td>
+							<td><%=content.getSection().getBook().getLevel2()%></td>
+							<td><%=content.getSection().getBook().getDynasty()%></td>
+							<td><%=content.getSection().getBook().getPeriod()%></td>
+							<td><%=content.getSection().getBook().getAdmin_type() %></td>
+							<td><%=content.getSection().getName() %></td>
+							<td><%=content.getSection().getPages()%></td>
+							<td><%=content.getPage() %></td>
+							<td class="content"><%=content.getContent()%></td>
+							<td>
+								<% if ( content.isRemoved() ) { %>
+	
+									<input type="image"	onclick="setAction0('recoverFocusedContent', 'fullTextSearchForm', 'focusedContentId', '<%=content.getId() %>');"	
+										src="<%=sessionBean.getApplicationBean().getCheckboxUncheckedImage()%>" width="20" height="20"/>
+										
+								<% } else { %>
+							
+									<input type="image" onclick="setAction0('removeFocusedContent', 'fullTextSearchForm', 'focusedContentId', '<%=content.getId() %>');"	
+										src="<%=sessionBean.getApplicationBean().getCheckboxCheckedImage()%>" width="20" height="20"/>
+								
+								<% } %>
+							
+									
+								
+							</td>
+							
+						</tr>
+						<%
+							}
+						%>
+						
+					</tbody>
+				</table>
+		
+				
+			<%
+				}
+			%>
+			
+			</div>
+			<!-- 
+			<jsp:include page="../componentes/paginator.jsp">
+				<jsp:param name="formName" value="fullTextSearchForm"/>
+			</jsp:include> 
+			 -->
+			 
+		</form>
+	
+		<% } %>
+		
+	</div>
+
+</body>
+</html>