[sword-svn] r253 - in trunk/webapp: . layouts
scribe at crosswire.org
scribe at crosswire.org
Mon May 22 04:23:17 MST 2006
Author: scribe
Date: 2006-05-22 04:23:16 -0700 (Mon, 22 May 2006)
New Revision: 253
Modified:
trunk/webapp/layouts/base-layout.jsp
trunk/webapp/swordweb.js
trunk/webapp/wordsearchresults.jsp
Log:
Added support for onPageLoad function
Added support for 1-click lemma search from lex entry
Added support for lemma colorizing on search result
Modified: trunk/webapp/layouts/base-layout.jsp
===================================================================
--- trunk/webapp/layouts/base-layout.jsp 2006-05-22 02:12:13 UTC (rev 252)
+++ trunk/webapp/layouts/base-layout.jsp 2006-05-22 11:23:16 UTC (rev 253)
@@ -37,7 +37,7 @@
<script type="text/javascript" src="swordweb.js"></script>
</head>
- <body>
+ <body onload="onPageLoad();">
<%-- include header --%>
<tiles:insert attribute="header" />
<tiles:insert attribute="pintro" />
Modified: trunk/webapp/swordweb.js
===================================================================
--- trunk/webapp/swordweb.js 2006-05-22 02:12:13 UTC (rev 252)
+++ trunk/webapp/swordweb.js 2006-05-22 11:23:16 UTC (rev 253)
@@ -147,12 +147,52 @@
}
}
+function colorLemmas(wordnum, key, morph) {
+ spans = document.getElementsByTagName('span');
+ for (i = 0; i < curspans.length; i++) {
+ curspans[i].className='';
+ }
+ curspans.length = 0;
+ for (i = 0; i < spans.length; i++) {
+ ocf = spans[i].getAttribute('onclick');
+ if (ocf) {
+ oc = ocf.toString();
+ fb = oc.indexOf('p(');
+ if (fb >= 0) {
+ fe = oc.indexOf(')', fb);
+ wdf = 'wd'+oc.substring(fb+1, fe+1);
+ wdata = eval(wdf);
+ if (wd_wnum == wordnum) {
+ curspans[curspans.length] = spans[i];
+ spans[i].className='curWord';
+ }
+ else if (wd_strong == key) {
+ if (wd_morph == morph) {
+ curspans[curspans.length] = spans[i];
+ spans[i].className='sameLemmaMorph';
+ }
+ else { curspans[curspans.length] = spans[i];
+ spans[i].className='sameLemma';
+ }
+ }
+ }
+ }
+ }
+}
-function p(mod, key, wordnum, extratext, fnnum) {
+function p(mod, key, wordnum, extratext, fnnum, srcMod) {
+
+ skeyPre=""
/* check for aliases */
- if (mod == "G") mod = "StrongsGreek";
- if (mod == "H") mod = "StrongsHebrew";
+ if (mod == "G") {
+ skeyPre="G";
+ mod = "StrongsGreek";
+ }
+ if (mod == "H") {
+ skeyPre="H";
+ mod = "StrongsHebrew";
+ }
b=document.getElementById("onlywlayer");
if (b==null) {
@@ -170,7 +210,7 @@
b.innerHTML="Please wait...";
showhide("onlywlayer", "visible");
url = "fetchdata.jsp?mod="+mod+"&key="+encodeURIComponent(key);
- if (fnnum != null)
+ if ((fnnum != null) && (fnnum != ''))
url += "&fn="+encodeURIComponent(fnnum);
xmlhttp.open("GET", url, true);
xmlhttp.onreadystatechange=function() {
@@ -178,15 +218,20 @@
if (mod != "betacode") {
resultBody="<div class=\"verse\">"+xmlhttp.responseText + "<br/>"+"<div id=\"dm\">";
if ((extratext != null) && (extratext.length > 0)) {
- resultBody += "<a href=\"#\" onclick=\"pd('"+extratext+"');return false;\">"+extratext+"</a></div></div>";
+ resultBody += "<a href=\"#\" onclick=\"pd('"+extratext+"');return false;\">"+extratext+"</a>";
}
+ resultBody += "<dl>";
+ resultBody += "<dt><a href=\"wordsearchresults.jsp?mod="+srcMod+"&searchTerm=lemma:"+skeyPre+encodeURIComponent(key)+"&colorKey="+encodeURIComponent(key)+"&colorMorph="+encodeURIComponent(extratext)+"\">Search for "+key+" in "+srcMod+"</a></dt>";
+ resultBody += "</dl>";
+ resultBody += "</div></div>";
b.innerHTML=resultBody;
}
else {
resultBody ="<div class=\"verse\">"+xmlhttp.responseText + "<br/>"+"<div id=\"dm\">";
if ((extratext != null) && (extratext.length > 0)) {
- resultBody += "<a href=\"#\" onclick=\"pe('"+extratext+"');return false;\">"+extratext+"</a></div></div>";
+ resultBody += "<a href=\"#\" onclick=\"pe('"+extratext+"');return false;\">"+extratext+"</a>";
}
+ resultBody += "</div></div>";
b.innerHTML=resultBody;
}
lastword = wordnum;
@@ -194,36 +239,7 @@
}
xmlhttp.send(null);
if (mod.substring(0,12) == 'StrongsGreek') {
- spans = document.getElementsByTagName('span');
- for (i = 0; i < curspans.length; i++) {
- curspans[i].className='';
- }
- curspans.length = 0;
- for (i = 0; i < spans.length; i++) {
- ocf = spans[i].getAttribute('onclick');
- if (ocf) {
- oc = ocf.toString();
- fb = oc.indexOf('p(');
- if (fb >= 0) {
- fe = oc.indexOf(')', fb);
- wdf = 'wd'+oc.substring(fb+1, fe+1);
- wdata = eval(wdf);
- if (wd_wnum == wordnum) {
- curspans[curspans.length] = spans[i];
- spans[i].className='curWord';
- }
- else if (wd_strong == key) {
- if (wd_morph == extratext) {
- curspans[curspans.length] = spans[i];
- spans[i].className='sameLemmaMorph';
- }
- else { curspans[curspans.length] = spans[i];
- spans[i].className='sameLemma';
- }
- }
- }
- }
- }
+ colorLemmas(wordnum, key, extratext);
}
}
}
@@ -260,3 +276,6 @@
l.style.visibility = vis;
}
+function onPageLoad() {
+// empty function redefined in a page that cares
+}
Modified: trunk/webapp/wordsearchresults.jsp
===================================================================
--- trunk/webapp/wordsearchresults.jsp 2006-05-22 02:12:13 UTC (rev 252)
+++ trunk/webapp/wordsearchresults.jsp 2006-05-22 11:23:16 UTC (rev 253)
@@ -1,6 +1,8 @@
<%@ include file="init.jsp" %>
<%
+ String colorKey = request.getParameter("colorKey");
+ String colorMorph = request.getParameter("colorMorph");
String resetModule = request.getParameter("mod");
String lastModType = (String) session.getAttribute("lastModType");
String activeModuleName = (resetModule != null)?resetModule : ((String) session.getAttribute(("GBS".equals(lastModType))?"gbsBook":"ActiveModule"));
@@ -44,13 +46,27 @@
if ((tmp != null) && (!tmp.equals("1")))
soptions = 0;
%>
-
<tiles:insert beanName="basic" flush="true" >
<tiles:put name="title" type="string">
Search results for <%= new String(activeSearchTerm.getBytes("iso8859-1"), "UTF-8") %>
</tiles:put>
- <tiles:put name="pintro" type="string" ><div></div></tiles:put>
-
+ <tiles:put name="pintro" type="string" >
+<div>
+<%
+ if (colorKey != null) {
+%>
+ <script type="text/javascript" language="JavaScript">
+<!--
+function onPageLoad() {
+ colorLemmas('x','<%=colorKey%>','<%=colorMorph%>');
+}
+// -->
+ </script>
+<%
+ }
+%>
+</div>
+</tiles:put>
<tiles:put name="sidebar_left" type="string">
<div id="translations">
<h2><t:t>Translations:</t:t></h2>
@@ -170,10 +186,7 @@
<%
}
}
- %>
-
- <%
- int lastPage = (results.length / resultLimit.intValue()) + ((results.length % resultLimit.intValue()) > 0 ? 1 : 0) -1;
+ int lastPage = (results.length / resultLimit.intValue()) + ((results.length % resultLimit.intValue()) > 0 ? 1 : 0) -1;
if (navEnd < lastPage) {
%>
<li> [...] <a href="wordsearchresults.jsp?start=<%= lastPage*resultLimit.intValue() %>" title="Last page (<%= results[lastPage].key %>) of search results"><%= lastPage+1 %></a></li>
More information about the sword-cvs
mailing list