[jsword-svn] r1802 - in trunk: common jsword-web/src/web/iBD

dmsmith at www.crosswire.org dmsmith at www.crosswire.org
Fri Apr 18 08:13:26 MST 2008


Author: dmsmith
Date: 2008-04-18 08:13:25 -0700 (Fri, 18 Apr 2008)
New Revision: 1802

Modified:
   trunk/common/JSwordDictionary.txt
   trunk/jsword-web/src/web/iBD/iBD.css
   trunk/jsword-web/src/web/iBD/iBD.html
   trunk/jsword-web/src/web/iBD/iBD.js
   trunk/jsword-web/src/web/iBD/iBD.xsl
   trunk/jsword-web/src/web/iBD/tutorial.html
Log:
more changes to dwr example.

Modified: trunk/common/JSwordDictionary.txt
===================================================================
--- trunk/common/JSwordDictionary.txt	2008-04-17 14:11:34 UTC (rev 1801)
+++ trunk/common/JSwordDictionary.txt	2008-04-18 15:13:25 UTC (rev 1802)
@@ -58,7 +58,8 @@
 proxying
 markup
 unicode
+payload
 deactivate
 servlet
 remoting
-tomcat
\ No newline at end of file
+tomcat

Modified: trunk/jsword-web/src/web/iBD/iBD.css
===================================================================
--- trunk/jsword-web/src/web/iBD/iBD.css	2008-04-17 14:11:34 UTC (rev 1801)
+++ trunk/jsword-web/src/web/iBD/iBD.css	2008-04-18 15:13:25 UTC (rev 1802)
@@ -7,52 +7,50 @@
   width: 100%;
   background-color: #fafafa;
   font-family: arial, sans-serif;
-  overflow: hidden;
 }
 
-div        { padding: 0px; }
-#bibleBox  { margin: 2px; }
-#versions  { width: 200px; }
-#locateBox { margin: 2px; }
-#view      { width: 75%; }
-#searchBox { margin: 2px; }
-#search    { width: 75%; }
+div        { padding:   0px; }
+#bibleBox  { margin:    2px; }
+#versions  { width:   200px; }
+#locateBox { margin:    2px; }
+#view      { width:    75%;  }
+#searchBox { margin:    2px; }
+#search    { width:    75%;  }
 
 #display
 {
     margin: 0;
     padding: 0;
-    background-color: #FFFFEE;
+    background-color: #EEEEEE;
     height: 100%;
     border: 1 solid #FFDDDD;
     overflow: auto;
 }
 
-/*****************************************/
-/** BibleDesktop css *********************/
-A { text-decoration: none; }
-A.strongs { color: black; text-decoration: none; }
-SUB.strongs { font-size: 75%; color: red; }
-SUB.morph { font-size: 75%; color: blue; }
-SUB.lemma { font-size: 75%; color: red; }
-SUP.verse { font-size: 75%; color: gray; }
-SUP.note { font-size: 75%; color: green; }
-SPAN.jesus { color: red; }
-SPAN.speech { color: blue; }
-SPAN.strike { text-decoration: line-through; }
-SPAN.small-caps { font-variant: small-caps; }
+/** derived from BibleDesktop simple.xsl ******/
+A                { text-decoration: none; }
+A.strongs        { color: black; text-decoration: none; }
+SUB.strongs      { font-size: 75%; color: red; }
+SUB.morph        { font-size: 75%; color: blue; }
+SUB.lemma        { font-size: 75%; color: red; }
+SUP.verse        { font-size: 75%; color: gray; }
+SUP.note         { font-size: 75%; color: green; }
+SPAN.jesus       { color: red; }
+SPAN.speech      { color: blue; }
+SPAN.strike      { text-decoration: line-through; }
+SPAN.small-caps  { font-variant: small-caps; }
 SPAN.inscription { font-weight: bold; font-variant: small-caps; }
-SPAN.divineName { font-variant: small-caps; }
-SPAN.normal { font-variant: normal; }
-SPAN.caps { text-transform: uppercase; }
-H1.level { text-align: center; font-size: 115%; color: #000000; }
-H2.level { text-align: center; font-size: 110%; color: #000000; }
-H3.level { text-align: center; font-size: 100%; }
-H4.level { text-align: center; font-size: 90%; }
-H5.level { text-align: center; font-size: 85%; }
-H6.level { text-align: center; font-size: 80%; }
-H3.heading { font-size: 110%; color: #666699; font-weight: bold; }
-H2.heading { font-size: 115%; color: #669966; font-weight: bold; }
-div.margin { font-size:90%; }
-TD.notes { width:20%; background:#f4f4e8; }
-TD.text { width:80%; }
+SPAN.divineName  { font-variant: small-caps; }
+SPAN.normal      { font-variant: normal; }
+SPAN.caps        { text-transform: uppercase; }
+H1.level         { text-align: center; font-size: 115%; color: #000000; }
+H2.level         { text-align: center; font-size: 110%; color: #000000; }
+H3.level         { text-align: center; font-size: 100%; }
+H4.level         { text-align: center; font-size: 90%; }
+H5.level         { text-align: center; font-size: 85%; }
+H6.level         { text-align: center; font-size: 80%; }
+H3.heading       { font-size: 110%; color: #666699; font-weight: bold; }
+H2.heading       { font-size: 115%; color: #669966; font-weight: bold; }
+div.margin       { font-size:90%; }
+TD.notes         { width:20%; background:#f4f4e8; }
+TD.text          { width:80%; }

Modified: trunk/jsword-web/src/web/iBD/iBD.html
===================================================================
--- trunk/jsword-web/src/web/iBD/iBD.html	2008-04-17 14:11:34 UTC (rev 1801)
+++ trunk/jsword-web/src/web/iBD/iBD.html	2008-04-18 15:13:25 UTC (rev 1802)
@@ -28,12 +28,12 @@
     </div>
 
     <div id="locateBox" align="left">
-      <input type="text" id="passageRequest" style="width:75%" onkeypress="DWRUtil.onReturn(event, locate)"/>
+      <input type="text" id="passageRequest" style="width:75%" onkeypress="dwr.util.onReturn(event, locate)"/>
       <button type="button" onclick="locate()">Locate</button>
     </div>
 
     <div id="searchBox" align="left">
-      <input type="text" id="searchRequest" style="width:75%" onkeypress="DWRUtil.onReturn(event, search)"/>
+      <input type="text" id="searchRequest" style="width:75%" onkeypress="dwr.util.onReturn(event, search)"/>
       <button type="button" onclick="search()">Search</button>
     </div>
 

Modified: trunk/jsword-web/src/web/iBD/iBD.js
===================================================================
--- trunk/jsword-web/src/web/iBD/iBD.js	2008-04-17 14:11:34 UTC (rev 1801)
+++ trunk/jsword-web/src/web/iBD/iBD.js	2008-04-18 15:13:25 UTC (rev 1802)
@@ -1,4 +1,32 @@
+/**
+ * Distribution License:
+ * JSword is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License, version 2.1 as published by
+ * the Free Software Foundation. This program is distributed in the hope
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the
+ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU Lesser General Public License for more details.
+ *
+ * The License is available on the internet at:
+ *       http://www.gnu.org/copyleft/lgpl.html
+ * or by writing to:
+ *      Free Software Foundation, Inc.
+ *      59 Temple Place - Suite 330
+ *      Boston, MA 02111-1307, USA
+ *
+ * Copyright: 2008
+ *     The copyright to this program is held by it's authors.
+ *
+ * ID: $Id: simple.xsl 1767 2008-02-17 14:25:49Z dmsmith $
+ * 
+ * @see gnu.lgpl.License for license details.
+ *      The copyright to this program is held by it's authors.
+ * @author DM Smith [dmsmith555 at yahoo dot com]
+ */
+// Define how the OSIS document that is returned from JSword is styled.
 var stylesheet = "iBD.xsl";
+
+// Prevent the server from being hammered.
 var verseLimit = 100;
 
 /**
@@ -6,23 +34,33 @@
  */
 function init()
 {
-    DWRUtil.useLoadingMessage();
-    JSword.getInstalledBooks("bookCategory=Bible", loadBooks);
-    window.onresize = ibdResize;
+  // Use a Google styled "Loading" message in the upper right corner
+  dwr.util.useLoadingMessage();
+
+  // Display the current SWORD path as a diagnostic.
+  //JSword.getSwordPath(loadDiagnostic);
+
+  // Populate the books dropdown.
+  // The last argument is an asynchronous callback
+  JSword.getInstalledBooks("bookCategory=Bible", loadBooks);
+
+  // Constrain the display area to be within the boundary of the window.
+  window.onresize = ibdResize;
+  ibdResize();
 }
 
 /*
  * Resize the height of the display area.
- * I tried pixels but it does not work for IE.
  */
 function ibdResize()
 {
-    var top = $("searchBox");
-    var bottom = $("display");
-    var offset = top.offsetTop + top.offsetHeight + 1;
-    var windowHeight = document.body.clientHeight;
-    var newHeight = windowHeight - offset;
-    bottom.style.height = (newHeight/windowHeight)*100 + "%";
+  var top             = $("searchBox");
+  var bottom          = $("display");
+  var offset          = top.offsetTop + top.offsetHeight + 1;
+  var windowHeight    = document.body.clientHeight;
+  var newHeight       = windowHeight - offset;
+  // I tried pixels but it does not work for IE.
+  bottom.style.height = (newHeight / windowHeight) * 100 + "%";
 }
 
 /**
@@ -30,25 +68,35 @@
  */
 function loadBooks(data)
 {
-  DWRUtil.removeAllOptions("books");
-  DWRUtil.addOptions("books", data, "0", "1");
+  // Empty the list.
+  dwr.util.removeAllOptions("books");
+  // Then populate it with data, using column "0" as the key and "1" as the display value
+  // Use "0", "0" to only show the books "initials"
+  dwr.util.addOptions("books", data, "0", "1");
 }
 
 /**
- * Called when view data has been fetched
+ * Called when book data has been fetched
  */
 function loadDisplay(data)
 {
+  // Get an XSLT processor that can use xslDoc to do the transform
   var processor = new XSLTProcessor();
 
+  // Load the stylesheet so that we can transform the document
   var xslDoc    = Sarissa.getDomDocument();
+  // Synchronously load the stylesheet do that it is immediately available.
+  // Otherwise, this will fail.
   xslDoc.async  = false;
   xslDoc.load(stylesheet);
 
   processor.importStylesheet(xslDoc);
 
+  // Now take the answer from the locate and parse it into DOM
   var parser    = new DOMParser();
   var dom       = parser.parseFromString(data, "text/xml");
+
+  // Finally, transform and display the results in one fell swoop.
   Sarissa.updateContentFromNode(dom, $("display"), processor);
 }
 
@@ -57,6 +105,8 @@
  */
 function pick()
 {
+  // When the book changes, take what ever is in locate and get it.
+  // If that doesn't work then try what ever is in search.
   locate() || search();
 }
 
@@ -69,6 +119,9 @@
   var ref  = getPassage();
   if (book && ref)
   {
+    // Get the OSIS representation from the book for the reference
+    // But limit the number of verses
+    // Arrange for asynchronous loading of the display
     JSword.getOSISString(book, ref, verseLimit, loadDisplay);
     return true;
   }
@@ -84,6 +137,8 @@
   var search = getSearch();
   if (book && search)
   {
+    // Get the reference for the search
+    // and asynchrounously load it in to the locate box
     JSword.search(book, search, setPassage);
     return true;
   }
@@ -95,7 +150,7 @@
  */
 function getSearch()
 {
-  return DWRUtil.getValue("searchRequest");
+  return dwr.util.getValue("searchRequest");
 }
 
 /**
@@ -103,8 +158,12 @@
  */
 function setSearch(query)
 {
-  DWRUtil.setValue("searchRequest", query);
+  // Whenever we stuff a value into search request
+  dwr.util.setValue("searchRequest", query);
+  // do the search
   search();
+  // Allow this to be used in an anchor that ignores its href
+  return false;
 }
 
 /**
@@ -112,7 +171,7 @@
  */
 function getPassage()
 {
-  return DWRUtil.getValue("passageRequest");
+  return dwr.util.getValue("passageRequest");
 }
 
 /**
@@ -120,8 +179,13 @@
  */
 function setPassage(ref)
 {
-  DWRUtil.setValue("passageRequest", ref);
+  // whenever we stuff a value in locate
+  // Note: search merely stuffs a value here.
+  dwr.util.setValue("passageRequest", ref);
+  // go get the content.
   locate();
+  // Allow this to be used in an anchor that ignores its href
+  return false;
 }
 
 /**
@@ -129,7 +193,7 @@
  */
 function getBook()
 {
-  return DWRUtil.getValue("books");
+  return dwr.util.getValue("books");
 }
 
 /**
@@ -137,6 +201,20 @@
  */
 function setBook(book)
 {
-  DWRUtil.setValue("books", book);
+  // When ever a book is set
+  dwr.util.setValue("books", book);
+  // See if there is something we can locate or search.
   pick();
+  // Allow this to be used in an anchor that ignores its href
+  return false;
 }
+
+function loadDiagnostic(data)
+{
+  var html = "";
+  for (var i = 0; i < data.length; i++)
+  {
+    html += data[i] + ":";
+  }
+  DWRUtil.setValue("diagnostic", html);
+}

Modified: trunk/jsword-web/src/web/iBD/iBD.xsl
===================================================================
--- trunk/jsword-web/src/web/iBD/iBD.xsl	2008-04-17 14:11:34 UTC (rev 1801)
+++ trunk/jsword-web/src/web/iBD/iBD.xsl	2008-04-18 15:13:25 UTC (rev 1802)
@@ -15,7 +15,7 @@
  *      59 Temple Place - Suite 330
  *      Boston, MA 02111-1307, USA
  *
- * Copyright: 2005
+ * Copyright: 2008
  *     The copyright to this program is held by it's authors.
  *
  * ID: $Id: simple.xsl 1767 2008-02-17 14:25:49Z dmsmith $
@@ -793,7 +793,7 @@
   <xsl:template match="reference">
     <xsl:choose>
       <xsl:when test="$XRef = 'true'">
-        <a href="bible://{@osisRef}"><xsl:apply-templates/></a>
+        <a href="bible://{@osisRef}" onclick="return setPassage('{@osisRef}');"><xsl:apply-templates/></a>
       </xsl:when>
       <xsl:otherwise>
         <xsl:apply-templates/>
@@ -804,7 +804,7 @@
   <xsl:template match="reference" mode="jesus">
     <xsl:choose>
       <xsl:when test="$XRef = 'true'">
-        <a href="bible://{@osisRef}"><xsl:apply-templates mode="jesus"/></a>
+        <a href="bible://{@osisRef}" onclick="return setPassage('{@osisRef}');"><xsl:apply-templates mode="jesus"/></a>
       </xsl:when>
       <xsl:otherwise>
         <xsl:apply-templates mode="jesus"/>

Modified: trunk/jsword-web/src/web/iBD/tutorial.html
===================================================================
--- trunk/jsword-web/src/web/iBD/tutorial.html	2008-04-17 14:11:34 UTC (rev 1801)
+++ trunk/jsword-web/src/web/iBD/tutorial.html	2008-04-18 15:13:25 UTC (rev 1802)
@@ -3,7 +3,7 @@
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
   <head>
-    <title>JSword - Direct Web Remoting</title>
+    <title>JSword on the Web</title>
   </head>
 
   <body>
@@ -126,13 +126,13 @@
 
     &lt;!-- A text entry and a button both call locate -->
     &lt;div id="locateBox" align="left">
-      &lt;input type="text" id="passageRequest" onkeypress="DWRUtil.onReturn(event, locate)"/>
+      &lt;input type="text" id="passageRequest" onkeypress="dwr.util.onReturn(event, locate)"/>
       &lt;button type="button"  id="passageButton" onclick="locate();">Locate&lt;/button>
     &lt;/div>
 
     &lt;!-- A text entry and a button both call search -->
     &lt;div id="searchbox">
-      &lt;input type="text" id="searchRequest" onclick="DWRUtil.onReturn(event, search)"/>
+      &lt;input type="text" id="searchRequest" onclick="dwr.util.onReturn(event, search)"/>
       &lt;button type="button" id="searchButton" onclick="search();">Search&lt;/button>
     &lt;/div>
 
@@ -160,11 +160,16 @@
 function init()
 {
   // Use a Google styled "Loading" message in the upper right corner
-  DWRUtil.useLoadingMessage();
+  dwr.util.useLoadingMessage();
+
+  // Display the current SWORD path as a diagnostic.
+  //JSword.getSwordPath(loadDiagnostic);
+
   // Populate the books dropdown.
   // The last argument is an asynchronous callback
   JSword.getInstalledBooks("bookCategory=Bible", loadBooks);
-  // This may not be necessary, but make the display area as tall as it can be.
+
+  // Constrain the display area to be within the boundary of the window.
   window.onresize = ibdResize;
 }
 
@@ -174,12 +179,12 @@
  */
 function ibdResize()
 {
-  var top = $("searchBox");
-  var bottom = $("display");
-  var offset = top.offsetTop + top.offsetHeight + 1;
-  var windowHeight = document.body.clientHeight;
-  var newHeight = windowHeight - offset;
-  bottom.style.height = (newHeight/windowHeight)*100 + "%";
+  var top             = $("searchBox");
+  var bottom          = $("display");
+  var offset          = top.offsetTop + top.offsetHeight + 1;
+  var windowHeight    = document.body.clientHeight;
+  var newHeight       = windowHeight - offset;
+  bottom.style.height = (newHeight / windowHeight) * 100 + "%";
 }
 
 /**
@@ -188,28 +193,33 @@
 function loadBooks(data)
 {
   // Empty the list.
-  DWRUtil.removeAllOptions("books");
+  dwr.util.removeAllOptions("books");
   // Then populate it with data, using column "0" as the key and "1" as the display value
-  DWRUtil.addOptions("books", data, "0", "1");
+  // Use "0", "0" to only show the books "initials"
+  dwr.util.addOptions("books", data, "0", "1");
 }
 
 /**
- * Called when view data has been fetched
+ * Called when book data has been fetched
  */
 function loadDisplay(data)
 {
+  // Get an XSLT processor that can use xslDoc to do the transform
+  var processor = new XSLTProcessor();
+
   // Load the stylesheet so that we can transform the document
   var xslDoc    = Sarissa.getDomDocument();
+  // Synchronously load the stylesheet do that it is immediately available.
+  // Otherwise, this will fail.
   xslDoc.async  = false;
   xslDoc.load(stylesheet);
 
-  // Get an XSLT processor that can use xslDoc to do the transform
-  var processor = new XSLTProcessor();
   processor.importStylesheet(xslDoc);
 
   // Now take the answer from the locate and parse it into DOM
   var parser    = new DOMParser();
   var dom       = parser.parseFromString(data, "text/xml");
+
   // Finally, transform and display the results in one fell swoop.
   Sarissa.updateContentFromNode(dom, $("display"), processor);
 }
@@ -264,7 +274,7 @@
  */
 function getSearch()
 {
-  return DWRUtil.getValue("searchRequest");
+  return dwr.util.getValue("searchRequest");
 }
 
 /**
@@ -273,9 +283,11 @@
 function setSearch(query)
 {
   // Whenever we stuff a value into search request
-  DWRUtil.setValue("searchRequest", query);
+  dwr.util.setValue("searchRequest", query);
   // do the search
   search();
+  // Allow this to be used in an anchor that ignores its href
+  return false;
 }
 
 /**
@@ -283,7 +295,7 @@
  */
 function getPassage()
 {
-  return DWRUtil.getValue("passageRequest");
+  return dwr.util.getValue("passageRequest");
 }
 
 /**
@@ -293,9 +305,11 @@
 {
   // whenever we stuff a value in locate
   // Note: search merely stuffs a value here.
-  DWRUtil.setValue("passageRequest", ref);
+  dwr.util.setValue("passageRequest", ref);
   // go get the content.
   locate();
+  // Allow this to be used in an anchor that ignores its href
+  return false;
 }
 
 /**
@@ -303,7 +317,7 @@
  */
 function getBook()
 {
-  return DWRUtil.getValue("books");
+  return dwr.util.getValue("books");
 }
 
 /**
@@ -312,11 +326,48 @@
 function setBook(book)
 {
   // When ever a book is set
-  DWRUtil.setValue("books", book);
+  dwr.util.setValue("books", book);
   // See if there is something we can locate or search.
   pick();
+  // Allow this to be used in an anchor that ignores its href
+  return false;
 }
 
 </pre>
+
+<p>
+  <strong>JSword.js</strong> is generated on demand by DWR, reflecting a JavaScript representation of DwrBridge
+  and it has the following content:
+</p>
+<!-- TODO(dms): Change this to pull it in from the web-server into an iframe or div -->
+<pre xml:space="preserve">
+// Provide a default path to dwr.engine
+if (dwr == null) var dwr = {};
+if (dwr.engine == null) dwr.engine = {};
+if (DWREngine == null) var DWREngine = dwr.engine;
+
+if (JSword == null) var JSword = {};
+JSword._path = '/jsword/dwr';
+JSword.search = function(p0, p1, callback) {
+  dwr.engine._execute(JSword._path, 'JSword', 'search', p0, p1, callback);
+}
+JSword.match = function(p0, p1, p2, callback) {
+  dwr.engine._execute(JSword._path, 'JSword', 'match', p0, p1, p2, callback);
+}
+JSword.isIndexed = function(p0, callback) {
+  dwr.engine._execute(JSword._path, 'JSword', 'isIndexed', p0, callback);
+}
+JSword.getInstalledBooks = function(p0, callback) {
+  dwr.engine._execute(JSword._path, 'JSword', 'getInstalledBooks', p0, callback);
+}
+JSword.getOSISString = function(p0, p1, p2, callback) {
+  dwr.engine._execute(JSword._path, 'JSword', 'getOSISString', p0, p1, p2, callback);
+}
+JSword.getSwordPath = function(callback) {
+  dwr.engine._execute(JSword._path, 'JSword', 'getSwordPath', callback);
+}
+
+</pre>
+
   </body>
 </html>




More information about the jsword-svn mailing list