Mercurial > hg > LGServices
diff src/main/webapp/pages/fullTextSearch.jsp @ 95:b27a99201cbe
New feature: new full text search with MySQL ngram parser (5.7.6 above)
author | Calvin Yeh <cyeh@mpipw-berlin.mpg.com> |
---|---|
date | Mon, 03 Jul 2017 23:48:53 +0200 |
parents | dd2fcc5f5deb |
children | 6a508b605b5f |
line wrap: on
line diff
--- a/src/main/webapp/pages/fullTextSearch.jsp Mon Jul 03 23:43:44 2017 +0200 +++ b/src/main/webapp/pages/fullTextSearch.jsp Mon Jul 03 23:48:53 2017 +0200 @@ -1,5 +1,5 @@ <%@page import="org.apache.commons.lang.StringUtils"%> -<%@page import="de.mpiwg.gazetteer.db.DBContents"%> +<%@page import="de.mpiwg.gazetteer.db.*"%> <%@page import="de.mpiwg.gazetteer.bo.LGFullTextSearchFile"%> @@ -15,45 +15,45 @@ <jsp:include page="../componentes/headContent.jsp" /> -<script> - - +<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 + // 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, @@ -68,20 +68,20 @@ //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({ @@ -105,7 +105,7 @@ }); }, minLength : 0 - }); + }); $("#bookNameFilter").autocomplete({ source : function(request, response) { $.ajax({ @@ -129,7 +129,7 @@ }); }, minLength : 0 - }); + }); $("#level1Filter").autocomplete({ source : function(request, response) { $.ajax({ @@ -153,7 +153,7 @@ }); }, minLength : 0 - }); + }); $("#level2Filter").autocomplete({ source : function(request, response) { $.ajax({ @@ -177,7 +177,7 @@ }); }, minLength : 0 - }); + }); $("#dynastyFilter").autocomplete({ source : function(request, response) { $.ajax({ @@ -201,7 +201,7 @@ }); }, minLength : 0 - }); + }); $("#periodFilter").autocomplete({ source : function(request, response) { $.ajax({ @@ -225,7 +225,7 @@ }); }, minLength : 0 - }); + }); $("#adminTypeFilter").autocomplete({ source : function(request, response) { $.ajax({ @@ -249,7 +249,7 @@ }); }, minLength : 0 - }); + }); $("#sectionNameFilter").autocomplete({ source : function(request, response) { $.ajax({ @@ -273,10 +273,10 @@ }); }, minLength : 0 - }); - + }); + }); - + // enter pressed event, we don't want to always go to "search". $(document).keypress( function(event){ @@ -288,52 +288,52 @@ //console.log('filtering' + i); setAction('filter', 'fullTextSearchForm'); $("#fullTextSearchForm").submit(); - return false; + 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(); + 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); + //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); - + $('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] @@ -343,21 +343,21 @@ 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" /> + <jsp:include page="../componentes/template2.jsp" /> <div id="dialogMoreInfo" title="Full Text Search Details"></div> @@ -366,7 +366,7 @@ <% if (sessionBean.getUser() == null) { %> - <label class="subTitel">You must login!</label> + <label class="subTitel">Please login or create a new account above</label> <% } else { @@ -407,7 +407,7 @@ <div id="dialogViewSavedResult" title="Saved Table(s)"> - + <div class="label">This week:</div> <table class="savedResultTable"> <tr> @@ -425,12 +425,12 @@ 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 + </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> --> <!-- 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 @@ -466,12 +466,12 @@ 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 + </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 + </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()%>" /> @@ -502,12 +502,12 @@ 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 + </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 + </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()%>" /> @@ -518,23 +518,23 @@ </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> + <tr> <td> <div><%=aFile.getFileName()%></div> </td> @@ -547,19 +547,19 @@ 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> + <!-- 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>--> + + <!-- 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" @@ -594,12 +594,12 @@ 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 + </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 + </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()%>" /> @@ -610,7 +610,7 @@ </td> - + </tr> <% } %> </table> @@ -620,7 +620,7 @@ <% for (LGFullTextSearchFile aFile : sessionBean.getFullTextSearchPage().getOlderFileList()) { %> - + <tr> <td> <div><%=aFile.getFileName()%></div> @@ -634,12 +634,12 @@ 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 + </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 + </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()%>" /> @@ -656,10 +656,10 @@ </div> - - - - + + + + <label class="subTitel">Full Text Search</label> <form name="fullTextSearchForm" id="fullTextSearchForm" action="<%=sessionBean.getApplicationBean().getRootServer()%>/proxy.jsp" @@ -737,7 +737,7 @@ <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> @@ -747,21 +747,21 @@ 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 + 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> + </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> + on LGMap?</button> <% } %> </td> @@ -1081,7 +1081,7 @@ </table> </th> - <!-- + <!-- <th> <table class="sortTable"> <tr> @@ -1091,17 +1091,17 @@ <tr><td> <input type="image" onclick="setAction('sortBySectionNameUp', 'fullTextSearchForm');" - src="<%=sessionBean.getApplicationBean().getUpImage()%>"/> + src="<%=sessionBean.getApplicationBean().getUpImage()%>"/> </td></tr> <tr><td> <input type="image" onclick="setAction('sortBySectionNameDown', 'fullTextSearchForm');" - src="<%=sessionBean.getApplicationBean().getDownImage()%>"/> + src="<%=sessionBean.getApplicationBean().getDownImage()%>"/> </td></tr> </table> </td> </tr> - </table> + </table> </th> --> <th><label class="tableTitle">Load Text</label></th> @@ -1156,18 +1156,24 @@ <% - for (DBContents content : sessionBean - .getFullTextSearchPage().getDisplayList()) { - %> - <% + long userId = sessionBean.getUser().getId(); + long userDefaultTopicId = sessionBean.getTopicListPage().getDefaultTopicId(userId); + String extractionInterfaceUrl = sessionBean.getApplicationBean().getExtractionInterfaceUrl(); + DBSection aDBSection = null; + DBBook aDBBook = null; + for (DBContents content : sessionBean.getFullTextSearchPage().getDisplayList()) { + + aDBSection = content.getSection(); + aDBBook = aDBSection.getBook(); + if (content.isRemoved()) { %> <tr class="removedContent"> <% } else { %> - + <tr> <% } @@ -1175,23 +1181,19 @@ <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> + <td><%=aDBBook.getName()%></td> + <td><%=aDBBook.getLevel1()%></td> + <td><%=aDBBook.getLevel2()%></td> + <td><%=aDBBook.getDynasty()%></td> + <td><%=aDBBook.getPeriod()%></td> + <td><%=aDBBook.getAdmin_type()%></td> + <td><%=aDBSection.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()%>');"> + onclick="sectionInExtractionInterface('<%=aDBSection.getId()%>', '<%=aDBSection.getName()%>', '<%=aDBBook.getId()%>', '<%=aDBBook.getName()%>', '<%=userDefaultTopicId%>', '<%=userId%>', '<%=extractionInterfaceUrl%>');"> <img title="Show Section in Extraction Interface" - src="<%=sessionBean.getApplicationBean() - .getShowImage()%>"> + src="<%=sessionBean.getApplicationBean().getShowImage()%>"> </a></td> @@ -1202,14 +1204,12 @@ if (content.isRemoved()) { %> <input type="image" onclick="setMousePos(); setAction0('recoverFocusedContent', 'fullTextSearchForm', 'focusedContentId', '<%=content.getId()%>');" - src="<%=sessionBean.getApplicationBean() - .getCheckboxUncheckedImage()%>" + src="<%=sessionBean.getApplicationBean().getCheckboxUncheckedImage()%>" width="20" height="20" /> <% } else { %> <input type="image" onclick="setMousePos(); setAction0('removeFocusedContent', 'fullTextSearchForm', 'focusedContentId', '<%=content.getId()%>');" - src="<%=sessionBean.getApplicationBean() - .getCheckboxCheckedImage()%>" + src="<%=sessionBean.getApplicationBean().getCheckboxCheckedImage()%>" width="20" height="20" /> <% } %>