[sword-svn] r410 - trunk/webapp

scribe at crosswire.org scribe at crosswire.org
Mon Sep 23 15:43:06 MST 2013


Author: scribe
Date: 2013-09-23 15:43:05 -0700 (Mon, 23 Sep 2013)
New Revision: 410

Modified:
   trunk/webapp/fetchdata.jsp
   trunk/webapp/simplegadget.jsp
   trunk/webapp/simplelookup.jsp
   trunk/webapp/swordweb.js
Log:
updated to allow perseus lookups for strongs


Modified: trunk/webapp/fetchdata.jsp
===================================================================
--- trunk/webapp/fetchdata.jsp	2013-07-27 08:45:58 UTC (rev 409)
+++ trunk/webapp/fetchdata.jsp	2013-09-23 22:43:05 UTC (rev 410)
@@ -18,21 +18,35 @@
 	mgr.setGlobalOption("Footnotes", "Off");
 	mgr.setGlobalOption("Cross-references", "Off");
 
+	String mods[] = modName.split("\\|");
 
 	if (ks != null) {
 		String parts[] = ks.split("\\|");
 		for (int i = 0; i < parts.length; i++) {
+
+			if (i < mods.length) modName = mods[i];
+
 			String key = parts[i];
+
+			if ("betacode".equals(modName)) {
+				key = new String(key.getBytes("iso8859-1"), "UTF-8");
+			}
+
 			if (i > 0) out.print("<br/>__________________<br/><br/>");
 			// hack until LXXM morph is cleaned up -----
 			if ("Packard".equals(modName)) {
 				while (key.indexOf("  ") > -1) key = key.replaceAll("  ", " ");
 			}
 			// end of LXXM Packard hack ----------------
+			if ("ls".equals(modName)) {
+				SWModule greekLemma = mgr.getModuleByName("GreekStrongToLem");
+				greekLemma.setKeyText(ks);
+				key = greekLemma.getRawEntry();
+				modName = "betacode";
+			}
 
 			// ------ betacode lookup from perseus ------------------------------------------------
 			if ("betacode".equals(modName)) {
-				key = new String(key.getBytes("iso8859-1"), "UTF-8");
 				String ls = org.crosswire.swordweb.PerseusUtils.getLiddellScottDef(key);
 				if (ls.length() > 0) {
 %>
@@ -87,8 +101,8 @@
 							if (block != null) {
 								block = block.getBlock("image");
 								if (block != null) {
-									thumbURL = block.getAttribute("thumburi");
-									imageURL = block.getAttribute("uri");
+									thumbURL = block.getAttribute("thumburl");
+									imageURL = block.getAttribute("webfriendlyurl");
 								}
 							}
 							block = p.getBlock("transcriptions");
@@ -263,11 +277,17 @@
 <%
 								}
 								if ("strip".equals(format)) {
-
 %>
 <%= book.getStripText() %>
 <%
 								}
+								else if ("plain".equals(format)) {
+									String raw = book.getRawEntry();
+// assume our modules are OSIS for now (should change output format of mgr or have a second mgr for this one.
+%>
+<%= mgr.filterText("OSISPlain", raw) %>
+<%
+								}
 								else {
 								// --------------------------------------------
 %>

Modified: trunk/webapp/simplegadget.jsp
===================================================================
--- trunk/webapp/simplegadget.jsp	2013-07-27 08:45:58 UTC (rev 409)
+++ trunk/webapp/simplegadget.jsp	2013-09-23 22:43:05 UTC (rev 410)
@@ -21,7 +21,7 @@
 	description="Bible Viewer"
 	screenshot="http://crosswire.org/images/crosswire.gif"
 	thumbnail="http://crosswire.org/images/crosswire.gif"
-	scrolling="true"
+	scrolling="false"
    >
   <Optional feature="dynamic-height"/>
   <Optional feature="pubsub-2">
@@ -34,6 +34,13 @@
   </Param>
 </Optional>
 </ModulePrefs>
+<UserPref name="height" datatype="enum" display_name="Gadget Height" default_value="600">
+     <EnumValue value="200" display_value="Short"/>
+     <EnumValue value="300" display_value="Medium"/>
+     <EnumValue value="400" display_value="Tall"/>
+     <EnumValue value="-1" display_value="Dynamic"/>
+</UserPref>
+
 <UserPref name="swordModule" datatype="enum" display_name="Bible Text" default_value="WHNU">
 <%
 	ModInfo[] modInfo = mgr.getModInfoList();
@@ -49,15 +56,11 @@
 <Content type="html">
 <![CDATA[
 <head>
-<!--
-        <link rel="stylesheet" type="text/css" href="../../js/jquery-ui/jquery-ui-1.8.16.css">
-        <script type="text/javascript" src="../../js/jquery/jquery-1.6.4.min.js"></script>
-        <script type="text/javascript" src="../../js/jquery-ui/jquery-ui-1.8.16.min.js"></script>
--->
         <link rel="stylesheet" type="text/css" href="<%=baseURL%>/sandy.css">
         <link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css">
         <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
         <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
+	
 
 <script type="text/javascript">
         $(document).ready(function() {
@@ -66,6 +69,20 @@
 
         });
 </script>
+<style>
+
+.currentWord {
+	color : red;
+	cursor : pointer;
+}
+
+
+.currentSelectedWord {
+	color : blue;
+	cursor : pointer;
+}
+
+</style>
 </head>
 
 <body>
@@ -80,7 +97,7 @@
 			Quick Lookup: <input name="verseRef" style="width:100%" id="verseRef" onKeyPress="return keyPress('verseRef', event);"/><span id="currentVerse" style="float:right;display:inline-block;"></span>
 			<div style="clear:both;"></div>
 		</div>
-		<div id="chapterContent">
+		<div style="overflow:auto; border: none 0px; width:100%;" class="fillPage" id="chapterContent">
 		</div>
 	</div>
 
@@ -89,7 +106,7 @@
 			Search Text: <input name="searchText" style="width:100%" id="searchText" onKeyPress="return keyPress('searchText', event);"/><span id="searchResultsCount" style="float:right;display:inline-block;"></span>
 			<div style="clear:both;"></div>
 		</div>
-		<div id="searchContent">
+		<div style="overflow:auto; border: none 0px; width:100%;" class="fillPage" id="searchContent">
 		</div>
 	</div>
 </div>
@@ -98,6 +115,8 @@
 <script>
 
 var swordModule = "WHNU";
+var MARGIN = 8;
+var preferredHeight = -1;
 
 function keyPress(field, event) {
 	var i = document.getElementById(field);
@@ -114,32 +133,40 @@
 	else return true;
 }
 
+
 function search_callback(o) {
 	var results = o.text.split('%%%');
-	content = document.getElementById('searchResultsCount');
-	content.innerHTML = '';
-	content.innerHTML = results[0];
-	content = document.getElementById('searchContent');
-	content.innerHTML = '';
-	content.innerHTML = results[1];
+	clearExpandFillPageClients();
+	$('#searchResultsCount').html(results[0]);
+	$('#searchContent').html(results[1]);
+	if (gadgets.util.hasFeature('dynamic-height') && preferredHeight == -1) gadgets.window.adjustHeight();
+	setTimeout(function() {
+		if (gadgets.util.hasFeature('dynamic-height') && preferredHeight == -1) gadgets.window.adjustHeight();
+		expandFillPageClients();
+	}, 100);
+
 }
 
 function lookup_callback(o) {
 	var results = o.text.split('%%%');
-	content = document.getElementById('currentVerse');
-	content.innerHTML = '';
-	content.innerHTML = results[0];
+	clearExpandFillPageClients();
+	$('#currentVerse').html(results[0]);
 	$('#verseRef').val(results[0]);
-	content = document.getElementById('chapterContent');
-	content.innerHTML = '';
-	content.innerHTML = results[1];
+	$('#chapterContent').html(results[1]);
 
-	var new_position = $('#cv').offset();
-	if (new_position) {
-		window.scrollTo(new_position.left,new_position.top);
-	}
-	if (gadgets.util.hasFeature('pubsub-2')) gadgets.Hub.publish("interedition.biblicalcontent.selected", results[0]);
+	if (gadgets.util.hasFeature('dynamic-height') && preferredHeight == -1) gadgets.window.adjustHeight();
+	setTimeout(function() {
+		if (gadgets.util.hasFeature('dynamic-height') && preferredHeight == -1) gadgets.window.adjustHeight();
+		expandFillPageClients();
+		var new_position = $('#cv').offset();
 
+		if (new_position) {
+			// for some reason, offset() and position() don't take into account that we have a div above for quick lookup
+			$('#chapterContent').scrollTop(new_position.top-$('#chapterContent').offset().top + $($('#chapterContent').parent().children()[0]).height());
+		}
+		if (gadgets.util.hasFeature('pubsub-2')) gadgets.Hub.publish("interedition.biblicalcontent.selected", results[0]);
+	}, 100);
+
 }
 
 function lookup(verse) {
@@ -201,21 +228,103 @@
 	}
 }
 
+
+function word_hover_callback(topic, data, subscriberData) {
+	$('.currentverse').find('span').removeClass('currentWord');
+	for (var i = 0; i < data.wordNum.length; ++i) {
+		var spanNum = data.wordNum[i] + 1; // for versenum span
+		if (data.wordNum[i] > -1 && $('.currentverse').find('span').length > spanNum) {
+			$($('.currentverse').find('span')[spanNum]).addClass('currentWord');
+		}
+	};
+}
+
+
+function findWordSpan(wordID) {
+	var found = false;
+	$('span').each(function() {
+		var p = this.getAttribute('onclick');
+		if (p && p.indexOf('p(') == 0) {
+			if (p.indexOf("'"+wordID+"'") > -1) {
+				found = $(this);
+				return false;
+			}
+		}
+	});
+	return found;
+}
+
+
+var lastWordData = {};
+function p(mod, key, word, morph, noop, thisMod) {
+	var data = {
+		strongNum : key,
+		wordID : word,
+		morph : morph,
+		fromMod : swordModule
+	};
+	lastWordData = data;
+	$('.currentverse').find('span').removeClass('currentSelectedWord');
+	$(findWordSpan(word)).addClass('currentSelectedWord');
+	if (gadgets.util.hasFeature('pubsub-2')) gadgets.Hub.publish("interedition.word.selected", data);
+}
+
+
+function word_selected_callback(topic, data, subscriberData) {
+
+	// assert we're not hearing an echo
+	if (data.fromMod && data.fromMod == swordModule && data.wordID == lastWordData.wordID) return;
+
+	for (var i = 0; i < data.wordNum.length; ++i) {
+		var spanNum = data.wordNum[i] + 1; // for versenum span
+		if (data.wordNum[i] > -1 && $('.currentverse').find('span').length > spanNum) {
+			$($('.currentverse').find('span')[spanNum]).trigger('click');
+			break;
+		}
+	};
+}
+
+
 function loaded() {
 	var prefs = new gadgets.Prefs();
 	swordModule = prefs.getString('swordModule');
-	gadgets.window.adjustHeight(500);
+     preferredHeight = parseInt(prefs.getString('height'));
+     if (gadgets.util.hasFeature('dynamic-height')) gadgets.window.adjustHeight(preferredHeight == -1 ? 500 : preferredHeight);
+     $('#searchContent').css('overflow', (gadgets.util.hasFeature('dynamic-height') && preferredHeight == -1) ? 'visible' : 'auto');
+     $('#chapterContent').css('overflow', (gadgets.util.hasFeature('dynamic-height') && preferredHeight == -1) ? 'visible' : 'auto');
+
 	positionFromURLParams();
+	$(window).resize(function() {
+		clearExpandFillPageClients();
+		expandFillPageClients();
+	});
+
+	var tabLabel = (swordModule == 'WHNU') ? 'NA28' : swordModule;
+	var tab = $("#tabs").find(".ui-tabs-nav li:eq(0)").children('a').text(tabLabel);
 }
 
 if (gadgets.util.hasFeature('pubsub-2')) {
 	gadgets.HubSettings.onConnect = function(hum, suc, err) {
 		subId = gadgets.Hub.subscribe("interedition.page.selected", page_select_callback);
+		subId = gadgets.Hub.subscribe("interedition.word.hover", word_hover_callback);
+		subId = gadgets.Hub.subscribe("interedition.word.selected", word_selected_callback);
 		loaded();
 	};
 }
 else gadgets.util.registerOnLoadHandler(loaded);
 
+function clearExpandFillPageClients() {
+     $('.fillPage').each(function () {
+          $(this).css('height', '');
+     });
+}
+function expandFillPageClients() {
+     $('.fillPage').each(function () {
+          $(this).height(gadgets.window.getViewportDimensions().height - $(this).offset().top - MARGIN);
+     });
+}
+
+
 </script>
 
 ]]>

Modified: trunk/webapp/simplelookup.jsp
===================================================================
--- trunk/webapp/simplelookup.jsp	2013-07-27 08:45:58 UTC (rev 409)
+++ trunk/webapp/simplelookup.jsp	2013-09-23 22:43:05 UTC (rev 410)
@@ -15,6 +15,7 @@
 	URL appBaseURL = new URL(request.getScheme(), request.getServerName(), request.getServerPort(), "/study/");
 
 	SWMgr mgr = SwordOrb.getSWMgrInstance(request);
+	mgr.setJavascript(true);
 
 	String activeModuleName = request.getParameter("mod");
 	if (activeModuleName == null) activeModuleName = "WHNU";
@@ -123,7 +124,7 @@
 					if (!intro) {
 			%>
 					<span class="versenum">
-					<a target="_blank" <%= (curVerse == anchorVerse)?"id=\"cv\"":"" %> href="<%= baseURL %>/passagestudy.jsp?key=<%= URLEncoder.encode(keyText)+"#cv" %>">
+					<a target="_blank" <%= (curVerse == anchorVerse)?"id=\"cv\"":"" %> href="#" onclick="lookup('<%= keyText%>');return false;">
 						<%= keyProps[3] %></a>
 					</span>
 			<%
@@ -153,7 +154,7 @@
 					if (!intro) {
 			%>
 					<span class="versenum">
-						<a target="_blank" <%= (curVerse == anchorVerse)?"id=\"cv\"":"" %> href="<%= baseURL %>/passagestudy.jsp?key=<%= URLEncoder.encode(keyText)+"#cv" %>">
+						<a target="_blank" <%= (curVerse == anchorVerse)?"id=\"cv\"":"" %> href="#" onclick="lookup('<%= keyText%>');return false;">
 						<%= keyProps[3] %></a>
 					</span>
 			<%

Modified: trunk/webapp/swordweb.js
===================================================================
--- trunk/webapp/swordweb.js	2013-07-27 08:45:58 UTC (rev 409)
+++ trunk/webapp/swordweb.js	2013-09-23 22:43:05 UTC (rev 410)
@@ -209,7 +209,7 @@
 	/* check for aliases */
 	if (mod == "G") {
 		skeyPre="G";
-		mod = "StrongsGreek";
+		mod = "StrongsGreek|ls";
 	}
 	if (mod == "H") {
 		skeyPre="H";
@@ -236,7 +236,9 @@
 	else {
 		b.innerHTML="<t:t>Please wait...</t:t>";
 		showhide("onlywlayer", "visible");
-		url = "fetchdata.jsp?mod="+mod+"&key="+encodeURIComponent(key);
+		var keyData = encodeURIComponent(key);
+		if (mod.indexOf('|') > 0) keyData += '|' + encodeURIComponent(key);
+		url = "fetchdata.jsp?mod="+mod+"&key="+keyData;
 		if ((fnnum != null) && (fnnum != ''))
 			url += "&fn="+encodeURIComponent(fnnum);
 		xmlhttp.open("GET", url, true);
@@ -316,7 +318,7 @@
 	p(mod, key, 'fn'+key+fnnum, extratext, fnnum);
 }
 
-function showhide (layer, vis, dontReposition) {
+function showhide(layer, vis, dontReposition) {
 
     var l = document.getElementById(layer);
     var shim = document.getElementById('DivShim');
@@ -349,6 +351,7 @@
         if (mouseClientY < (winH/2))
             cy = cy + 50;
         else cy = cy - (l.clientHeight + 50);
+	   if (cy < 10) cy = 10;
 
         if (dontReposition == true) {
 	}




More information about the sword-cvs mailing list