[sword-cvs] swordweb init.jsp,1.8,1.9 preferences.jsp,1.9,1.10

sword@www.crosswire.org sword@www.crosswire.org
Tue, 11 Nov 2003 15:40:32 -0700


Update of /usr/local/cvsroot/swordweb
In directory www:/tmp/cvs-serv23260

Modified Files:
	init.jsp preferences.jsp 
Log Message:
Added dynamic tab list and hide/show options


Index: init.jsp
===================================================================
RCS file: /usr/local/cvsroot/swordweb/init.jsp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- init.jsp	10 Nov 2003 22:52:37 -0000	1.8
+++ init.jsp	11 Nov 2003 22:40:30 -0000	1.9
@@ -13,6 +13,8 @@
 	static Vector styleNames = null;
 	static Vector styleFiles = null;
 	static Vector styleDescriptions = null;
+	static Vector tabNames = null;
+	static Vector tabLinks = null;
 %>
 
 <%
@@ -31,6 +33,25 @@
 
 			styleNames.add("Parchment");
 			styleFiles.add("parchment.css");
+
+			tabNames = new Vector();
+			tabLinks = new Vector();
+			tabNames.add("Home");
+			tabLinks.add("index.jsp");
+			tabNames.add("Passage Study");
+			tabLinks.add("passagestudy.jsp");
+			tabNames.add("Parallel");
+			tabLinks.add("parallelstudy.jsp");
+			tabNames.add("Search");
+			tabLinks.add("powersearch.jsp");
+			tabNames.add("Devotionals");
+			tabLinks.add("dailydevotion.jsp");
+			tabNames.add("Library");
+			tabLinks.add("fulllibrary.jsp");
+			tabNames.add("Preferences");
+			tabLinks.add("preferences.jsp");
+			tabNames.add("About");
+			tabLinks.add("about.jsp");
 		}
 	}
 
@@ -76,6 +97,7 @@
 	Vector prefBibles = (Vector)session.getAttribute("PrefBibles");
 	Vector prefCommentaries = (Vector)session.getAttribute("PrefCommentaries");
 	Vector parDispModules = (Vector)session.getAttribute("ParDispModules");
+
 	String prefStyle = (String)request.getParameter("setStyle");
 	if (prefStyle == null)
 		prefStyle = (String)session.getAttribute("PrefStyle");
@@ -86,6 +108,42 @@
 		response.addCookie(c);
 	}
 
+	Vector showTabs = (Vector)session.getAttribute("showTabs");
+	if (showTabs == null) {
+		showTabs = new Vector();
+		for (int i = 0; i < tabNames.size(); i++) {
+			showTabs.add("true");
+		}
+	}
+	String[] showTab = request.getParameterValues("showTab");
+	if (showTab != null) {
+		for (int i = 0; i < showTab.length; i++) {
+			try {
+				int tabNum = Integer.parseInt(showTab[i]);
+				showTabs.set(tabNum, "true");
+				Cookie c = new Cookie("showTab"+Integer.toString(tabNum), "t");
+				c.setMaxAge(java.lang.Integer.MAX_VALUE);
+				c.setPath("/");
+				response.addCookie(c);
+			}
+			catch(Exception e) {}
+		}
+	}
+	showTab = request.getParameterValues("hideTab");
+	if (showTab != null) {
+		for (int i = 0; i < showTab.length; i++) {
+			try {
+				int tabNum = Integer.parseInt(showTab[i]);
+				showTabs.set(tabNum, "false");
+				Cookie c = new Cookie("showTab"+Integer.toString(tabNum), "f");
+				c.setMaxAge(java.lang.Integer.MAX_VALUE);
+				c.setPath("/");
+				response.addCookie(c);
+			}
+			catch(Exception e) {}
+		}
+	}
+
 
 	Cookie[] cookies = request.getCookies();
 	if ((prefBibles == null) && (cookies != null)) {
@@ -94,7 +152,14 @@
 			int start, end;
 			String field;
 			String line;
-			if (cookies[i].getName().equals("PrefStyle")) {
+			if (cookies[i].getName().startsWith("showTab")) {
+				try {
+					int tabNum = Integer.parseInt(cookies[i].getName().substring(8));
+					showTabs.set(tabNum, ("t".equals(cookies[i].getValue()))?"true":"false");
+				}
+				catch (Exception e) {}
+			}
+			else if (cookies[i].getName().equals("PrefStyle")) {
 				prefStyle = cookies[i].getValue();
 			}
 			else if (cookies[i].getName().equals("PrefBibles")) {
@@ -153,6 +218,7 @@
 	session.setAttribute("PrefCommentaries", prefCommentaries);
 	session.setAttribute("ParDispModules", parDispModules);
 	session.setAttribute("PrefStyle", prefStyle);
+	session.setAttribute("showTabs", showTabs);
 /*
 	// kept around in case we ever need it again
 				// de-serialize from cookie

Index: preferences.jsp
===================================================================
RCS file: /usr/local/cvsroot/swordweb/preferences.jsp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- preferences.jsp	10 Nov 2003 21:12:46 -0000	1.9
+++ preferences.jsp	11 Nov 2003 22:40:30 -0000	1.10
@@ -139,6 +139,18 @@
 <% } %>
 		</ul>
 
+		<h2>Tabs</h2>
+		<ul>
+<% for (int i = 0; i < tabNames.size(); i++) {
+	boolean visible = !"false".equals(showTabs.get(i));
+	String n = (String)tabNames.get(i);
+	String l = (String)tabLinks.get(i);
+	if (!"preferences.jsp".equals(l)) {
+ %>
+			<li><a href="preferences.jsp?<%=(visible)?"hide":"show"%>Tab=<%= Integer.toString(i)%>" title="<%= ((visible)?"Hide ":"Show ") + n %> Tab"><%= ((visible)?"Hide ":"Show ") + n %> Tab</a></li>
+<% }} %>
+		</ul>
+
 </div>
 	</tiles:put>
 </tiles:insert>