view src/main/webapp/pages/search.jsp @ 37:ed215307f426

new: show all existing branches in the searching result page of search for sections
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Fri, 20 Nov 2015 15:18:28 +0100
parents eab47936591a
children 37840afb7b80
line wrap: on
line source

<%@page import="de.mpiwg.gazetteer.bo.LGBranch"%>
<%@page import="org.apache.commons.lang.StringUtils"%>
<%@page import="de.mpiwg.gazetteer.db.DBSection"%>
<%@ 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 },
		        hide: {
		          effect: "explode",
		          duration: 1000
		        }
		      });
		   
			$( ".moreInfo" ).click(function() {
				var sectionId = $( this ).data('section-id');
				
				var url0 = "<%=sessionBean.getApplicationBean().getRootServer()%>/methods/sectionTableDetails.jsp?sectionId=" + sectionId;
				
				$.ajax( url0 )
				.done(function(data) {
					$( "#dialogMoreInfoTable" ).replaceWith(data);
					$( "#dialogMoreInfo" ).dialog( "open" );
				})
			  	.fail(function() {
			    	console.error("Error calling: " + query);
			  	})
				
				
				
		    });			
			
			$("#searchTerm").autocomplete({
				source : function(request, response) {
					var radioButton0 = $("input[type='radio'][name='searchIn']:checked");
					var searchInVal = (radioButton0) ? radioButton0.val() : 0;
				$.ajax({
					url : "<%=sessionBean.getApplicationBean().getRootServer()%>/methods/searchAutocomplete.jsp",
						type : "POST",
						dataType : "json",
						data : {
							term : request.term,
							searchIn : searchInVal
						},
						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/dynastyAutocomplete.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/level1Autocomplete.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/adminTypeAutocomplete.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
			});		
				
		});
	</script>
</head>

<body>
	<jsp:include page="../componentes/template.jsp"/>

	<div id="dialogMoreInfo" title="Section Details">
	  <div id="dialogMoreInfoTable">XXXX</div>
	</div>
 

	<div id="page">
	
		<% if(sessionBean.getUser() == null) { %>
			<label>You must login!</label>
		<% } else { %>
			
		<label class="subTitel">Search for Sections</label>
		
		<form name="searchForm"
			action="<%=sessionBean.getApplicationBean().getRootServer()%>/proxy.jsp"
			method="post"
			class="contentForm">
			<input name="bean" type="hidden" value="searchBean" /> 
			
			
			<table style="width: 300px; margin-left: auto;margin-right: auto;">
				<tr>
					<td>
						<input
							id="searchTerm"
							name="searchTerm"
							type="text"
							class="searchInput"
							value="<%=sessionBean.getSearchPage().getSearchTerm()%>" />				
					</td>
					<td>
						<input
							type="image" 
							onclick="setAction('search', 'searchForm');"
							src="<%=sessionBean.getApplicationBean().getSearchImage()%>"/>
					</td>
				</tr>
				<tr>
					<td>
						<label>Search in:</label>
						<input type="radio" name="searchIn" value="0" <%= (sessionBean.getSearchPage().getSearchIn() == 0) ? "checked" : "" %>><label>Section Name</label>
						<input type="radio" name="searchIn" value="1" <%= (sessionBean.getSearchPage().getSearchIn() == 1) ? "checked" : "" %>/><label>Book Name</label>
					</td>
				</tr>
				<tr><td><label class="label"><%= (StringUtils.isNotEmpty(sessionBean.getSearchPage().getSearchMessage())) ? sessionBean.getSearchPage().getSearchMessage() : ""%></label></td></tr>
				<tr><td><label class="label"><%= (StringUtils.isNotEmpty(sessionBean.getSearchPage().getFilteringMessage())) ? sessionBean.getSearchPage().getFilteringMessage() : ""%></label></td></tr>
			</table>
	
	
			<%
				if (sessionBean.getSearchPage().getCompleteSectionList() != null) {
			%>
	
	
			<jsp:include page="../componentes/paginator.jsp">
				<jsp:param name="formName" value="searchForm"/>
			</jsp:include> 
				
			<div class="tableDiv double-scroll">
				<table class="pageTable">
					<tbody>
						<tr>
							<th>
								<table class="sortTable">
									<tr>
										<td><label class="tableTitle">Book Id</label></td>
										<td>
											<table>
												<tr><td>
													<input type="image" 
														onclick="setAction('sortByBookIdUp', 'searchForm');"
														src="<%=sessionBean.getApplicationBean().getUpImage()%>"/>										
												</td></tr>
												<tr><td>
													<input type="image"
														onclick="setAction('sortByBookIdDown', 'searchForm');"
														src="<%=sessionBean.getApplicationBean().getDownImage()%>"/>																				
												</td></tr>
											</table>
										</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', 'searchForm');"
														src="<%=sessionBean.getApplicationBean().getUpImage()%>"/>										
												</td></tr>
												<tr><td>
													<input type="image"
														onclick="setAction('sortByBookNameDown', 'searchForm');"
														src="<%=sessionBean.getApplicationBean().getDownImage()%>"/>																	
												</td></tr>
											</table>
										</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', 'searchForm');"
														src="<%=sessionBean.getApplicationBean().getUpImage()%>"/>
												</td></tr>
												<tr><td>
													<input type="image"
														onclick="setAction('sortByLevel1Down', 'searchForm');"
														src="<%=sessionBean.getApplicationBean().getDownImage()%>"/>																				
												</td></tr>
											</table>
										</td>
									</tr>
									<tr>
										<td>
											<input type="text" name="level1Filter" id="level1Filter" value="<%= sessionBean.getSearchPage().getLevel1Filter()%>"/>
										</td>									
										<td>
											<input type="image"
												onclick="setAction('filter', 'searchForm');"
												src="<%=sessionBean.getApplicationBean().getFilterImage()%>"/>
										</td>							
									</tr>								
								</table>	
							</th>
							<th><label class="tableTitle">Level 2</label></th>
							<th>
								<table class="sortTable">
									<tr>
										<td><label class="tableTitle">Dynasty</label></td>
										<td>
											<table>
												<tr><td>
													<input type="image"
														onclick="setAction('sortByDynastyUp', 'searchForm');"
														src="<%=sessionBean.getApplicationBean().getUpImage()%>"/>
												</td></tr>
												<tr><td>
													<input type="image"
														onclick="setAction('sortByDynastyDown', 'searchForm');"
														src="<%=sessionBean.getApplicationBean().getDownImage()%>"/>																				
												</td></tr>
											</table>
										</td>
									</tr>
									<tr>
										<td>
											<input type="text" name="dynastyFilter" id="dynastyFilter" value="<%= sessionBean.getSearchPage().getDynastyFilter()%>"/>
										</td>									
										<td>
											<input type="image"
												onclick="setAction('filter', 'searchForm');"
												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', 'searchForm');"
														src="<%=sessionBean.getApplicationBean().getUpImage()%>"/>										
												</td></tr>
												<tr><td>
													<input type="image"
														onclick="setAction('sortByPeriodDown', 'searchForm');"
														src="<%=sessionBean.getApplicationBean().getDownImage()%>"/>																				
												</td></tr>
											</table>
										</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', 'searchForm');"
														src="<%=sessionBean.getApplicationBean().getUpImage()%>"/>
												</td></tr>
												<tr><td>
													<input type="image"
														onclick="setAction('sortByAdminTypeDown', 'searchForm');"
														src="<%=sessionBean.getApplicationBean().getDownImage()%>"/>																				
												</td></tr>
											</table>
										</td>
									</tr>
									<tr>
										<td>
											<input type="text" name="adminTypeFilter" id="adminTypeFilter" value="<%= sessionBean.getSearchPage().getAdminTypeFilter()%>"/>
										</td>									
										<td>
											<input type="image"
												onclick="setAction('filter', 'searchForm');"
												src="<%=sessionBean.getApplicationBean().getFilterImage()%>"/>
										</td>							
									</tr>								
								</table>	
							</th>
							<!-- 
							<th>
								<table class="sortTable">
									<tr>
										<td><label class="tableTitle">Volume</label></td>
										<td>
											<table>
												<tr><td>
													<input type="image"
														onclick="setAction('sortByVolumeUp', 'searchForm');"
														src="<%=sessionBean.getApplicationBean().getUpImage()%>"/>										
												</td></tr>
												<tr><td>
													<input type="image"
														onclick="setAction('sortByVolumeDown', 'searchForm');"
														src="<%=sessionBean.getApplicationBean().getDownImage()%>"/>																				
												</td></tr>
											</table>
										</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', 'searchForm');"
														src="<%=sessionBean.getApplicationBean().getUpImage()%>"/>										
												</td></tr>
												<tr><td>
													<input type="image"
														onclick="setAction('sortBySectionNameDown', 'searchForm');"
														src="<%=sessionBean.getApplicationBean().getDownImage()%>"/>																				
												</td></tr>
											</table>
										</td>
									</tr>
								</table>	
							</th>
							<th>
								<table class="sortTable">
									<tr>
										<td><label class="tableTitle">Pages</label></td>
										<td>
											<table>
												<tr><td>
													<input type="image"
														onclick="setAction('sortByStartPageUp', 'searchForm');"
														src="<%=sessionBean.getApplicationBean().getUpImage()%>"/>										
												</td></tr>
												<tr><td>
													<input type="image"
														onclick="setAction('sortByStartPageDown', 'searchForm');"
														src="<%=sessionBean.getApplicationBean().getDownImage()%>"/>																				
												</td></tr>
											</table>
										</td>
									</tr>
								</table>							
							
							</th>
							<th><label class="tableTitle">View Page Text</label></th>
							<th><label class="tableTitle">Existing Branches</label></th>
						</tr>
					
		
						<%
							for (DBSection section : sessionBean.getSearchPage().getDisplaySectionList()) {
						%>
						<tr>
							<td>
								<a href="<%=sessionBean.getApplicationBean().getTocInterfaceUrl()%>/check_sections_details.php?book_id=<%=section.getBook().getId() %>&amp;count=100&amp;sessionId=<%= session.getId()%>" target="blank">
									<%=section.getBook().getId()%>
								</a>	
								<img alt="More Information" src="<%=sessionBean.getApplicationBean().getMoreInfoImage()%>" data-section-id="<%=section.getId()%>" class="moreInfo"/>
							</td>
							<td><%=section.getBook().getName()%></td>
							<td><%=section.getBook().getLevel1()%></td>
							<td><%=section.getBook().getLevel2()%></td>
							<td><%=section.getBook().getDynasty()%></td>
							<td><%=section.getBook().getPeriod()%></td>
							<td><%=section.getBook().getAdmin_type() %></td>
							<td><%=section.getName()%></td>
							<td><%=section.getPages()%></td>
							<td>
								<a	href="#"
									title="Show Section in Extraction Interface" 
								 	onclick="sectionInExtractionInterface('<%=section.getId() %>', '<%=section.getName() %>', '<%=section.getBook().getId() %>', '<%=section.getBook().getName() %>', '<%=sessionBean.getUser().getId() %>', '<%=sessionBean.getApplicationBean().getExtractionInterfaceUrl()%>');">
								 	<img alt="Show Section in Extraction Interface" src="<%=sessionBean.getApplicationBean().getShowImage()%>">
								</a>
							</td>
							<td style="max-width:300px;">
								<% if(section.getBranches() != null && !section.getBranches().isEmpty()) { %>
									<table style="width:100%">
										<% for(LGBranch branch : section.getBranches()) { %>
											<tr>
												<td>
													<table style="width:100%">
													<tr><td><%=branch.getFomattedLastChange() %></td></tr>
													<tr><td><%=branch.getLabel() %></td></tr>
													</table>
												</td>
												<td style="max-width:150px">
													<% if (branch.hasContributor(sessionBean.getUser().getId())) { %>
													<a href="<%=sessionBean.getApplicationBean().getRootServer() %>/pages/branchPage.jsp?branchId=<%=branch.getId() %>" >
														<img alt="Manage Branch" src="<%=sessionBean.getApplicationBean().getEditBranchImage()%>"/>
													</a>												
													<% } else { %>
														<label>Contributors: <%=branch.getContributorsNameList() %></label>
													<% } %>
												</td>
											</tr>
										<% } %>
									</table>
								<% } %>
							</td>
			
						</tr>
						<%
							}
						%>
					</tbody>
				</table>
		
				
			<%
				}
			%>
			
			</div>
			
			<jsp:include page="../componentes/paginator.jsp">
				<jsp:param name="formName" value="searchForm"/>
			</jsp:include> 
			
		</form>
	
		<% } %>
		
	</div>

</body>
</html>