[sword-svn] r452 - trunk/webapp

scribe at crosswire.org scribe at crosswire.org
Fri Jul 27 03:10:18 MST 2018


Author: scribe
Date: 2018-07-27 03:10:18 -0700 (Fri, 27 Jul 2018)
New Revision: 452

Modified:
   trunk/webapp/simplelookup.jsp
Log:
snap to last verse if verse is greater than versemax for the chapter


Modified: trunk/webapp/simplelookup.jsp
===================================================================
--- trunk/webapp/simplelookup.jsp	2018-07-23 21:03:30 UTC (rev 451)
+++ trunk/webapp/simplelookup.jsp	2018-07-27 10:10:18 UTC (rev 452)
@@ -7,6 +7,16 @@
 <%@ page import="java.net.URLEncoder" %>
 <%@ page import="java.net.URL" %>
 <%
+	final int VERSEKEY_TESTAMENT  = 0;
+	final int VERSEKEY_BOOK       = 1;
+	final int VERSEKEY_CHAPTER    = 2;
+	final int VERSEKEY_VERSE      = 3;
+	final int VERSEKEY_CHAPTERMAX = 4;
+	final int VERSEKEY_VERSEMAX   = 5;
+	final int VERSEKEY_BOOKNAME   = 6;
+	final int VERSEKEY_OSISREF    = 7;
+	final int VERSEKEY_SHORTTEXT  = 8;
+	final int VERSEKEY_BOOKABBREV = 9;
 
 	String requestURI = request.getRequestURI();
 	int pe = requestURI.lastIndexOf('/', requestURI.length()-2);
@@ -41,9 +51,17 @@
 
 	activeModule.setKeyText("="+activeKey);
 	activeKey = activeModule.getKeyText(); 	// be sure it is formatted nicely
-	String book = activeModule.getKeyChildren()[6];
-	int chapter = Integer.parseInt(activeModule.getKeyChildren()[2]);
-	int verse = Integer.parseInt(activeModule.getKeyChildren()[3]);
+	String book = activeModule.getKeyChildren()[VERSEKEY_BOOKNAME];
+	String bookAbbrev = activeModule.getKeyChildren()[VERSEKEY_BOOKABBREV];
+	int chapter = Integer.parseInt(activeModule.getKeyChildren()[VERSEKEY_CHAPTER]);
+	int verse = Integer.parseInt(activeModule.getKeyChildren()[VERSEKEY_VERSE]);
+	int verseMax = Integer.parseInt(activeModule.getKeyChildren()[VERSEKEY_VERSEMAX]);
+	if (verse > verseMax) {
+		activeKey = bookAbbrev + "." + chapter + "." + verseMax;
+		verse = verseMax;
+		activeModule.setKeyText("="+activeKey);
+		activeKey = activeModule.getKeyText(); 	// be sure it is formatted nicely
+	}
 	String specialFont = activeModule.getConfigEntry("Font");
 	if (specialFont.equalsIgnoreCase("<swnull>")) {
 		specialFont = null;
@@ -68,7 +86,7 @@
 					String keyText = activeModule.getKeyText();
 					String keyProps[] = activeModule.getKeyChildren();
 					// book and chapter intros
-					boolean intro = (keyProps[2].equals("0") || keyProps[3].equals("0"));
+					boolean intro = (keyProps[VERSEKEY_CHAPTER].equals("0") || keyProps[VERSEKEY_VERSE].equals("0"));
 					if (eusVs != null) {
 						myEusNum = "";
 						if (!intro) {
@@ -89,9 +107,9 @@
 			<%
 						first = false;
 					}
-					int curVerse = Integer.parseInt(keyProps[3]);
-					int curChapter = Integer.parseInt(keyProps[2]);
-					if (!book.equals(keyProps[6]) || curChapter > chapter) {
+					int curVerse = Integer.parseInt(keyProps[VERSEKEY_VERSE]);
+					int curChapter = Integer.parseInt(keyProps[VERSEKEY_CHAPTER]);
+					if (!book.equals(keyProps[VERSEKEY_BOOKNAME]) || curChapter > chapter) {
 						break;
 					}
 					mgr.setGlobalOption("Strong's Numbers",
@@ -133,7 +151,7 @@
 			%>
 					<span class="versenum">
 					<a target="_blank" <%= (curVerse == anchorVerse)?"id=\"cv\"":"" %> href="#" onclick="lookup('<%= keyText%>');return false;">
-						<%= keyProps[3] %></a>
+						<%= keyProps[VERSEKEY_VERSE] %></a>
 					</span>
 			<%
 					}
@@ -163,7 +181,7 @@
 			%>
 					<span class="versenum">
 						<a target="_blank" <%= (curVerse == anchorVerse)?"id=\"cv\"":"" %> href="#" onclick="lookup('<%= keyText%>');return false;">
-						<%= keyProps[3] %></a>
+						<%= keyProps[VERSEKEY_VERSE] %></a>
 					</span>
 			<%
 					}




More information about the sword-cvs mailing list