view src/main/webapp/pages/fullTextSearch.jsp @ 69:dd2fcc5f5deb

new: saved table in full text search page: new layout and sorting by time
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Wed, 10 Aug 2016 13:00:19 +0200
parents 0a9937b06cc3
children b27a99201cbe
line wrap: on
line source

<%@page import="org.apache.commons.lang.StringUtils"%>
<%@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,
					position: { my: "left+100px", at: "top", of: $("#saveResult") },
				}
		  	);	   
			$("#saveResult").button().on( "click", function() {
				// append searchTerm into the form 		
				$('<input>').attr({
				    type: 'hidden',
				    name: 'searchTerm',
				    value: $("#searchTerm").val()
				}).appendTo('form[name="saveTableForm"]');
				
				if ($("#fileName").val() == "") {
					$("#fileName").val($("#searchTerm").val());		// set the default table name to be the searched term if no fileName
				}
				
				dialogSave.dialog( "open" );
			});
			
			
			
			$("#prompToSaveResult").click( function () {
				$("#saveResult").click();
			});
		
			
			var dialogViewSavedResult = $("#dialogViewSavedResult").dialog(
				{
					autoOpen: false,
					//position: { my: "left+100px", at: "top", of: $("#viewSavedResult") },
					position: { my: "center", at: "top+200px", of: $("#viewSavedResult") },	// TODO
					width: "850px",
				}
		  	);
			var dialogViewSavedResult2 = $("#dialogViewSavedResult2").dialog(
					{
						autoOpen: false,
						//position: { my: "left+100px", at: "top", of: $("#viewSavedResult") },
						position: { my: "center", at: "top+200px", of: $("#viewSavedResult2") },
						width: 600, height: 1000
					
					}
			  	);
			
			$("#viewSavedResult").button().on( "click", function() {
				dialogViewSavedResult.dialog( "open" );
			});
			
			$("#viewSavedResult2").button().on( "click", function() {
				dialogViewSavedResult2.dialog( "open" );
			});
			
			
			
			$("#bookIdFilter").autocomplete({
				source : function(request, response) {
					$.ajax({
						url : "<%=sessionBean.getApplicationBean().getRootServer()%>/methods/fullTextSearchBookIdAutocomplete.jsp",
						type : "POST",
						dataType : "json",
						data : {
							term : request.term
						},
						success : function(data) {
							response($.map(data, function(item) {
								return {
									label : item.name,
									value : item.value,
								}
							}));
						},
						error : function(error) {
							alert('error: ' + error);
						}
					});
				},
				minLength : 0
			});	
			$("#bookNameFilter").autocomplete({
				source : function(request, response) {
					$.ajax({
						url : "<%=sessionBean.getApplicationBean().getRootServer()%>/methods/fullTextSearchBookNameAutocomplete.jsp",
						type : "POST",
						dataType : "json",
						data : {
							term : request.term
						},
						success : function(data) {
							response($.map(data, function(item) {
								return {
									label : item.name,
									value : item.value,
								}
							}));
						},
						error : function(error) {
							alert('error: ' + error);
						}
					});
				},
				minLength : 0
			});	
			$("#level1Filter").autocomplete({
				source : function(request, response) {
					$.ajax({
						url : "<%=sessionBean.getApplicationBean().getRootServer()%>/methods/fullTextSearchLevel1Autocomplete.jsp",
						type : "POST",
						dataType : "json",
						data : {
							term : request.term
						},
						success : function(data) {
							response($.map(data, function(item) {
								return {
									label : item.name,
									value : item.value,
								}
							}));
						},
						error : function(error) {
							alert('error: ' + error);
						}
					});
				},
				minLength : 0
			});	
			$("#level2Filter").autocomplete({
				source : function(request, response) {
					$.ajax({
						url : "<%=sessionBean.getApplicationBean().getRootServer()%>/methods/fullTextSearchLevel2Autocomplete.jsp",
						type : "POST",
						dataType : "json",
						data : {
							term : request.term
						},
						success : function(data) {
							response($.map(data, function(item) {
								return {
									label : item.name,
									value : item.value,
								}
							}));
						},
						error : function(error) {
							alert('error: ' + error);
						}
					});
				},
				minLength : 0
			});	
			$("#dynastyFilter").autocomplete({
				source : function(request, response) {
					$.ajax({
						url : "<%=sessionBean.getApplicationBean().getRootServer()%>/methods/fullTextSearchDynastyAutocomplete.jsp",
						type : "POST",
						dataType : "json",
						data : {
							term : request.term
						},
						success : function(data) {
							response($.map(data, function(item) {
								return {
									label : item.name,
									value : item.value,
								}
							}));
						},
						error : function(error) {
							alert('error: ' + error);
						}
					});
				},
				minLength : 0
			});	
			$("#periodFilter").autocomplete({
				source : function(request, response) {
					$.ajax({
						url : "<%=sessionBean.getApplicationBean().getRootServer()%>/methods/fullTextSearchPeriodAutocomplete.jsp",
						type : "POST",
						dataType : "json",
						data : {
							term : request.term
						},
						success : function(data) {
							response($.map(data, function(item) {
								return {
									label : item.name,
									value : item.value,
								}
							}));
						},
						error : function(error) {
							alert('error: ' + error);
						}
					});
				},
				minLength : 0
			});	
			$("#adminTypeFilter").autocomplete({
				source : function(request, response) {
					$.ajax({
						url : "<%=sessionBean.getApplicationBean().getRootServer()%>/methods/fullTextSearchAdminTypeAutocomplete.jsp",
						type : "POST",
						dataType : "json",
						data : {
							term : request.term
						},
						success : function(data) {
							response($.map(data, function(item) {
								return {
									label : item.name,
									value : item.value,
								}
							}));
						},
						error : function(error) {
							alert('error: ' + error);
						}
					});
				},
				minLength : 0
			});	
			$("#sectionNameFilter").autocomplete({
				source : function(request, response) {
					$.ajax({
						url : "<%=sessionBean.getApplicationBean().getRootServer()%>/methods/fullTextSearchSectionNameAutocomplete.jsp",
						type : "POST",
						dataType : "json",
						data : {
							term : request.term
						},
						success : function(data) {
							response($.map(data, function(item) {
								return {
									label : item.name,
									value : item.value,
								}
							}));
						},
						error : function(error) {
							alert('error: ' + error);
						}
					});
				},
				minLength : 0
			});	
			
		});
		
		// 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;		
						}
						
					});
			    }
		});
		
		function setMousePos(){
			var x = event.clientX;
			var y = event.clientY;
			$("#mouseX").val(x);
			$("#mouseY").val(y);
		}
		
		$(document).ready(function(){
			highlightKeywords();
			scrollPage();
		})

		function scrollPage() {
			var id = $("#focusedId").val();		
			if (id == undefined || $("#content_"+id).offset() == undefined) return;
			
			//$('html,body').animate({scrollTop: $("#content_"+id).offset().top}, 'fast');

			var x = $("#mouseX").val();
			var y = $("#mouseY").val();
			var offsetInElement = $("#content_"+id).height() / 2;

			//console.log("y: " + y + ", top: " + $("#content_"+id).offset().top + ", offsetInElement: " + offsetInElement);	
			if (y == undefined) return;
			
			//$('html,body').animate({scrollTop: $("#content_"+id).offset().top - y + offsetInElement}, 'fast');
			$('html,body').scrollTop($("#content_"+id).offset().top - y + offsetInElement); 
			
		}
		
		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 class="subTitel">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"
							value="<%=sessionBean.getFullTextSearchPage().getFileName()%>" />
						</td>
						<td>
							<button
								onclick="setAction('save', 'saveTableForm'); document.getElementById('saveTableForm').submit();">Save
								All</button>

							<button
								onclick="setAction('saveFiltered', 'saveTableForm'); document.getElementById('saveTableForm').submit();">Save
								Filtered</button>

						</td>
					</tr>
				</table>
			</form>

		</div>


		<div id="dialogViewSavedResult" title="Saved Table(s)">
	
			<div class="label">This week:</div>
			<table class="savedResultTable">
				<tr>
					<%
						for (LGFullTextSearchFile aFile : sessionBean
									.getFullTextSearchPage().getWeekFileList()) {
					%>
					<td>
						<div><%=aFile.getFileName()%></div>
						<button type="button" class="lgButton"
							onclick="setAction0('loadFile', 'fullTextSearchForm', 'fileId', <%=aFile.getId()%>); document.getElementById('fullTextSearchForm').submit();">load</button>

						<!-- getFullTextSearchFileText?fileId= &userId= --> <!-- click searching result to open it in the same table of full-text-search result -->
						<a
						href="<%=sessionBean.getApplicationBean().getRootServer()%>/rest/text/getFullTextSearchHtmlFile?fileId=<%=aFile.getId()%>"
						target="_blank"> <img title="Show text in html"
							src="<%=sessionBean.getApplicationBean().getShowImage()%>" />
					</a> <!-- download csv file --> <a
						href="<%=sessionBean.getApplicationBean().getRootServer()%>/rest/text/downloadFullTextSearchCsvFile?file=<%=aFile.getUserId().toString()%>_<%=aFile.getFileName()%>.csv"
						target="_blank"> <img title="Download CSV"
							src="<%=sessionBean.getApplicationBean()
							.getDownloadImage()%>" />
					</a> <!-- view on LGMap --> <!--  
					href="<%=sessionBean.getApplicationBean().getLGMapUrl()%>&file=<%=aFile.getUserId().toString()%>_<%=aFile.getFileName()%>.csv&name=<%=aFile.getFileName()%>"
					Use file name instead as the name in the link to LGMap.
					--> <a
						href="<%=sessionBean.getApplicationBean().getLGMapUrl()%>&file=<%=aFile.getUserId().toString()%>_<%=aFile.getFileName()%>.csv&name=<%=aFile.getFileName()%>"
						target="_blank"> <img title="View on LGMap"
							src="<%=sessionBean.getApplicationBean().getViewOnMap()%>" />
					</a> <input type="image" title="Delete it"
						onclick="<%=sessionBean.getApplicationBean()
							.getJSConfirmationDelete()%> setAction0('deleteFile', 'fullTextSearchForm', 'fileId','<%=aFile.getId()%>'); document.getElementById('fullTextSearchForm').submit();"
						src="<%=sessionBean.getApplicationBean().getDeleteImage()%>" />

					</td>

					<%
						}
					%>
				</tr>
			</table>

			<div class="label">This month:</div>
			<table class="savedResultTable">
				<tr>
					<%
						for (LGFullTextSearchFile aFile : sessionBean.getFullTextSearchPage().getMonthFileList()) {
					%>
					<td>
						<div><%=aFile.getFileName()%></div>
						<button type="button" class="lgButton"
							onclick="setAction0('loadFile', 'fullTextSearchForm', 'fileId', <%=aFile.getId()%>); document.getElementById('fullTextSearchForm').submit();">load</button>

						<!-- getFullTextSearchFileText?fileId= &userId= --> <!-- click searching result to open it in the same table of full-text-search result -->
						<a
						href="<%=sessionBean.getApplicationBean().getRootServer()%>/rest/text/getFullTextSearchHtmlFile?fileId=<%=aFile.getId()%>"
						target="_blank"> <img title="Show text in html"
							src="<%=sessionBean.getApplicationBean().getShowImage()%>" />
						</a> <!-- download csv file --> <a
							href="<%=sessionBean.getApplicationBean().getRootServer()%>/rest/text/downloadFullTextSearchCsvFile?file=<%=aFile.getUserId().toString()%>_<%=aFile.getFileName()%>.csv"
							target="_blank"> <img title="Download CSV"
								src="<%=sessionBean.getApplicationBean()
								.getDownloadImage()%>" />
						</a> <!-- view on LGMap --> <a
							href="<%=sessionBean.getApplicationBean().getLGMapUrl()%>&file=<%=aFile.getUserId().toString()%>_<%=aFile.getFileName()%>.csv&name=<%=aFile.getFileName()%>"
							target="_blank"> <img title="View on LGMap"
								src="<%=sessionBean.getApplicationBean().getViewOnMap()%>" />
						</a> <input type="image" title="Delete it"
							onclick="<%=sessionBean.getApplicationBean()
								.getJSConfirmationDelete()%> setAction0('deleteFile', 'fullTextSearchForm', 'fileId','<%=aFile.getId()%>'); document.getElementById('fullTextSearchForm').submit();"
							src="<%=sessionBean.getApplicationBean().getDeleteImage()%>" />

					</td>

					<% } %>
				</tr>
			</table>

			<div class="label">Older...</div>
			<table class="savedResultTable">
				<tr>
					<%
						for (LGFullTextSearchFile aFile : sessionBean.getFullTextSearchPage().getOlderFileList()) {
					%>
					<td>
						<div><%=aFile.getFileName()%></div>
						<button type="button" class="lgButton"
							onclick="setAction0('loadFile', 'fullTextSearchForm', 'fileId', <%=aFile.getId()%>); document.getElementById('fullTextSearchForm').submit();">load</button>

						<!-- getFullTextSearchFileText?fileId= &userId= --> <!-- click searching result to open it in the same table of full-text-search result -->
						<a
							href="<%=sessionBean.getApplicationBean().getRootServer()%>/rest/text/getFullTextSearchHtmlFile?fileId=<%=aFile.getId()%>"
							target="_blank"> <img title="Show text in html"
								src="<%=sessionBean.getApplicationBean().getShowImage()%>" />
						</a> <!-- download csv file --> <a
							href="<%=sessionBean.getApplicationBean().getRootServer()%>/rest/text/downloadFullTextSearchCsvFile?file=<%=aFile.getUserId().toString()%>_<%=aFile.getFileName()%>.csv"
							target="_blank"> <img title="Download CSV"
								src="<%=sessionBean.getApplicationBean()
								.getDownloadImage()%>" />
						</a> <!-- view on LGMap --> <a
							href="<%=sessionBean.getApplicationBean().getLGMapUrl()%>&file=<%=aFile.getUserId().toString()%>_<%=aFile.getFileName()%>.csv&name=<%=aFile.getFileName()%>"
							target="_blank"> <img title="View on LGMap"
								src="<%=sessionBean.getApplicationBean().getViewOnMap()%>" />
						</a> <input type="image" title="Delete it"
							onclick="<%=sessionBean.getApplicationBean()
								.getJSConfirmationDelete()%> setAction0('deleteFile', 'fullTextSearchForm', 'fileId','<%=aFile.getId()%>'); document.getElementById('fullTextSearchForm').submit();"
							src="<%=sessionBean.getApplicationBean().getDeleteImage()%>" />

					</td>
					<% } %>
					
				</tr>
			</table>


		</div>
		
		<div id="dialogViewSavedResult2" title="Saved Table(s) *Test a new layout and sort by time:)">

			<!-- TODO records in the table sorted by (1) saved time or (2) alphabet  -->
	
			<div class="label">This week:</div>
			<table class="savedResultTable2">
				<%
					for (LGFullTextSearchFile aFile : sessionBean.getFullTextSearchPage().getWeekFileList()) {
				%>
				<tr>	
					<td>
						<div><%=aFile.getFileName()%></div>
					</td>
					<td>
						<button type="button" class="lgButton"
							onclick="setAction0('loadFile', 'fullTextSearchForm', 'fileId', <%=aFile.getId()%>); document.getElementById('fullTextSearchForm').submit();">load</button>

						<!-- getFullTextSearchFileText?fileId= &userId= --> <!-- click searching result to open it in the same table of full-text-search result -->
						<a
						href="<%=sessionBean.getApplicationBean().getRootServer()%>/rest/text/getFullTextSearchHtmlFile?fileId=<%=aFile.getId()%>"
						target="_blank"> <img title="Show text in html"
							src="<%=sessionBean.getApplicationBean().getShowImage()%>" />
						</a> 
						<!-- download csv file --> 
						<a
						href="<%=sessionBean.getApplicationBean().getRootServer()%>/rest/text/downloadFullTextSearchCsvFile?file=<%=aFile.getUserId().toString()%>_<%=aFile.getFileName()%>.csv"
						target="_blank"> <img title="Download CSV"
							src="<%=sessionBean.getApplicationBean()
							.getDownloadImage()%>" />
						</a> 
				
						<!-- view on LGMap --> <!--  
						href="<%=sessionBean.getApplicationBean().getLGMapUrl()%>&file=<%=aFile.getUserId().toString()%>_<%=aFile.getFileName()%>.csv&name=<%=aFile.getFileName()%>"
						Use file name instead as the name in the link to LGMap.
						--> 
						<a
							href="<%=sessionBean.getApplicationBean().getLGMapUrl()%>&file=<%=aFile.getUserId().toString()%>_<%=aFile.getFileName()%>.csv&name=<%=aFile.getFileName()%>"
							target="_blank"> <img title="View on LGMap"
								src="<%=sessionBean.getApplicationBean().getViewOnMap()%>" />
						</a> <input type="image" title="Delete it"
							onclick="<%=sessionBean.getApplicationBean()
								.getJSConfirmationDelete()%> setAction0('deleteFile', 'fullTextSearchForm', 'fileId','<%=aFile.getId()%>'); document.getElementById('fullTextSearchForm').submit();"
							src="<%=sessionBean.getApplicationBean().getDeleteImage()%>" />

					</td>

				</tr>
				<% } %>
			</table>

			<div class="label">This month:</div>
			<table class="savedResultTable2">
				<%
					for (LGFullTextSearchFile aFile : sessionBean
								.getFullTextSearchPage().getMonthFileList()) {
				%>
				<tr>
					<td>
						<div><%=aFile.getFileName()%></div>
					</td>
					<td>
						<button type="button" class="lgButton"
							onclick="setAction0('loadFile', 'fullTextSearchForm', 'fileId', <%=aFile.getId()%>); document.getElementById('fullTextSearchForm').submit();">load</button>

						<!-- getFullTextSearchFileText?fileId= &userId= --> <!-- click searching result to open it in the same table of full-text-search result -->
						<a
						href="<%=sessionBean.getApplicationBean().getRootServer()%>/rest/text/getFullTextSearchHtmlFile?fileId=<%=aFile.getId()%>"
						target="_blank"> <img title="Show text in html"
							src="<%=sessionBean.getApplicationBean().getShowImage()%>" />
					</a> <!-- download csv file --> <a
						href="<%=sessionBean.getApplicationBean().getRootServer()%>/rest/text/downloadFullTextSearchCsvFile?file=<%=aFile.getUserId().toString()%>_<%=aFile.getFileName()%>.csv"
						target="_blank"> <img title="Download CSV"
							src="<%=sessionBean.getApplicationBean()
							.getDownloadImage()%>" />
					</a> <!-- view on LGMap --> <a
						href="<%=sessionBean.getApplicationBean().getLGMapUrl()%>&file=<%=aFile.getUserId().toString()%>_<%=aFile.getFileName()%>.csv&name=<%=aFile.getFileName()%>"
						target="_blank"> <img title="View on LGMap"
							src="<%=sessionBean.getApplicationBean().getViewOnMap()%>" />
					</a> <input type="image" title="Delete it"
						onclick="<%=sessionBean.getApplicationBean()
							.getJSConfirmationDelete()%> setAction0('deleteFile', 'fullTextSearchForm', 'fileId','<%=aFile.getId()%>'); document.getElementById('fullTextSearchForm').submit();"
						src="<%=sessionBean.getApplicationBean().getDeleteImage()%>" />

					</td>

					
				</tr>
				<% } %>
			</table>

			<div class="label">Older...</div>
			<table class="savedResultTable2">
				<%
					for (LGFullTextSearchFile aFile : sessionBean.getFullTextSearchPage().getOlderFileList()) {
				%>
				
				<tr>
					<td>
						<div><%=aFile.getFileName()%></div>
					</td>
					<td>
						<button type="button" class="lgButton"
							onclick="setAction0('loadFile', 'fullTextSearchForm', 'fileId', <%=aFile.getId()%>); document.getElementById('fullTextSearchForm').submit();">load</button>

						<!-- getFullTextSearchFileText?fileId= &userId= --> <!-- click searching result to open it in the same table of full-text-search result -->
						<a
						href="<%=sessionBean.getApplicationBean().getRootServer()%>/rest/text/getFullTextSearchHtmlFile?fileId=<%=aFile.getId()%>"
						target="_blank"> <img title="Show text in html"
							src="<%=sessionBean.getApplicationBean().getShowImage()%>" />
					</a> <!-- download csv file --> <a
						href="<%=sessionBean.getApplicationBean().getRootServer()%>/rest/text/downloadFullTextSearchCsvFile?file=<%=aFile.getUserId().toString()%>_<%=aFile.getFileName()%>.csv"
						target="_blank"> <img title="Download CSV"
							src="<%=sessionBean.getApplicationBean()
							.getDownloadImage()%>" />
					</a> <!-- view on LGMap --> <a
						href="<%=sessionBean.getApplicationBean().getLGMapUrl()%>&file=<%=aFile.getUserId().toString()%>_<%=aFile.getFileName()%>.csv&name=<%=aFile.getFileName()%>"
						target="_blank"> <img title="View on LGMap"
							src="<%=sessionBean.getApplicationBean().getViewOnMap()%>" />
					</a> <input type="image" title="Delete it"
						onclick="<%=sessionBean.getApplicationBean()
							.getJSConfirmationDelete()%> setAction0('deleteFile', 'fullTextSearchForm', 'fileId','<%=aFile.getId()%>'); document.getElementById('fullTextSearchForm').submit();"
						src="<%=sessionBean.getApplicationBean().getDeleteImage()%>" />

					</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" /> <input
				id="focusedId" type="hidden"
				value="<%=sessionBean.getFullTextSearchPage()
						.getFocusedContentId()%>" />

			<input id="mouseX" name="mouseX" type="hidden"
				value="<%=sessionBean.getFullTextSearchPage().getMouseX()%>" /> <input
				id="mouseY" name="mouseY" type="hidden"
				value="<%=sessionBean.getFullTextSearchPage().getMouseY()%>" />

			<table style="width: 300px; margin-left: auto; margin-right: auto;">
				<tr>
					<td><input id="searchTerm" name="searchTerm" type="text"
						placeholder='if multiple terms, use "," to separate them.'
						class="searchInput"
						value="<%=sessionBean.getFullTextSearchPage().getSearchTerm()%>" />
					</td>
					<td><input id="search" type="image"
						onclick="setAction('search', 'fullTextSearchForm');"
						src="<%=sessionBean.getApplicationBean().getSearchImage()%>" /></td>

				</tr>

				<!-- batching querying -->
				<!-- for batching, query keyword sets separated by ";" and within each keyword set, keywords separated by "," -->

				<%
					if (StringUtils.equals(sessionBean.getUserName(), "admin")) { // || StringUtils.equals(sessionBean.getUserName(), "silk")) {
				%>
				<tr>
					<td><input id="batchSearchTerm" name="batchSearchTerm"
						type="text" placeholder="(TODO plz Don't use this to search)"
						class="searchInput"
						value="<%=sessionBean.getFullTextSearchPage()
							.getBatchSearchTerm()%>" />
					</td>
					<td><input id="search" type="image"
						onclick="setAction('searchBatch', '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><label class="label"><%=(StringUtils.isNotEmpty(sessionBean
						.getFullTextSearchPage().getSelectedContentMessage())) ? sessionBean
						.getFullTextSearchPage().getSelectedContentMessage()
						: ""%></label></td>
				</tr>

				<tr>
					<td>
						<button id="saveResult" type="button" class="lgButton">Save Table</button>
						<button id="viewSavedResult" type="button" class="lgButton">View/Load Saved Table(s)</button>
					</td>
				</tr>
				<tr>
					<td>
						<span>*Test:</span>
						<button id="viewSavedResult2" type="button" class="lgButton">View/Load Saved Table(s): new layout and sorting by time:)</button>
					
					</td>
				</tr>
				<tr>
					<td>
						<!-- for view on LGMap, prompt to save if it's not saved. After saving, it could be shown on LGMap -->
						<%
							if (sessionBean.getFullTextSearchPage().getFile() != null) {
									LGFullTextSearchFile theFile = sessionBean
											.getFullTextSearchPage().getFile();
						%> 
						<a
							href="<%=sessionBean.getApplicationBean().getLGMapUrl()%>&file=<%=theFile.getUserId().toString()%>_<%=theFile.getFileName()%>.csv&name=<%=theFile.getFileName()%>"
							target="_blank">View on LGMap </a> <!-- download csv file --> <a
							href="<%=sessionBean.getApplicationBean().getRootServer()%>/rest/text/downloadFullTextSearchCsvFile?file=<%=theFile.getUserId().toString()%>_<%=theFile.getFileName()%>.csv"
							target="_blank"> <img title="Download CSV"
								src="<%=sessionBean.getApplicationBean()
								.getDownloadImage()%>" />
						</a> 
						<%
					 		} else if (sessionBean.getFullTextSearchPage().getCompleteList() != null) {
						%>
						<!-- prompt to save --> <!-- A click icon for Save Table, showing the text as bellow -->
						<button id="prompToSaveResult" type="button" class="lgButton">View
							on LGMap?</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><label class="tableTitle">Load Text</label></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">

								<table class="sortTable">
									<tr>
										<td><label class="tableTitle">Content</label></td>
										<td></td>
									</tr>
									<tr>
										<td><input type="text" class="filterInput"
											name="contentFilter" id="contentFilter"
											value="<%=sessionBean.getFullTextSearchPage()
							.getContentFilter()%>"
											size="8" /></td>
										<td><input type="image"
											onclick="setAction('filter', 'fullTextSearchForm');"
											src="<%=sessionBean.getApplicationBean().getFilterImage()%>" />
										</td>
									</tr>

								</table>

							</th>
							<th><label class="tableTitle">Select rows</label></th>
						</tr>


						<%
							for (DBContents content : sessionBean
											.getFullTextSearchPage().getDisplayList()) {
						%>

						<%
							if (content.isRemoved()) {
						%>
						<tr class="removedContent">
							<%
								} else {
							%>
						
						<tr>
							<%
								}
							%>

							<td><%=content.getInx()%></td>
							<td><%=content.getBookId()%></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>

							<!-- View text in Ext-Interface -->
							<td><a href="#" title="Show Section in Extraction Interface"
								onclick="sectionInExtractionInterface('<%=content.getSection().getId()%>', '<%=content.getSection().getName()%>', '<%=content.getSection().getBook().getId()%>', '<%=content.getSection().getBook().getName()%>', '<%=sessionBean.getTopicListPage()
								.getCompleteTopicList().get(0).getId()%>', '<%=sessionBean.getUser().getId()%>', '<%=sessionBean.getApplicationBean()
								.getExtractionInterfaceUrl()%>');">
									<img title="Show Section in Extraction Interface"
									src="<%=sessionBean.getApplicationBean()
								.getShowImage()%>">
							</a></td>


							<td><%=content.getPage()%></td>
							<td class="content"><%=content.getContent()%></td>
							<td id="content_<%=content.getId()%>">
								<%
									if (content.isRemoved()) {
								%> <input type="image"
								onclick="setMousePos(); setAction0('recoverFocusedContent', 'fullTextSearchForm', 'focusedContentId', '<%=content.getId()%>');"
								src="<%=sessionBean.getApplicationBean()
									.getCheckboxUncheckedImage()%>"
								width="20" height="20" /> <%
 	} else {
 %> <input type="image"
								onclick="setMousePos(); 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>