An AJAX enabled bible readerHandbookThis is a small documentation for the online available Bible Reader at http://www.mathertel.de/AJAXEngine/S03_AJAXControls/BiblePage.aspx. The reader can be started just by opening a window with the given URL. The page loads completely and starts with one of the available versions (of course) on the first book, first chapter, first verse: "In the beginning...". You can select one of the server-side installed bibles by using the first select box:
Yes, it's right to left - Does it look right? In the second select box you can choose one of the available book. Some bibles provide names for the books, others don't and you have to use the given numbers. The New Testament starts with book 40. In the third select box you can choose the chapter you want to read and in the forth select box you can finally choose the verse. As you change the values of these select boxes you will see that the select lists will be updated automatically so that only valid entries are available. If you choose a book, the list of chapters will be updated, If you choose a chapter, the list of verses will be updated... In the big text box below the text of the selected verse will be shown. It is possible to change the version without changing the selected book, chapter and verse so you can easily switch between German and English or different English versions. Below the text boxes are 2 buttons that enables the forward and backward navigation cross all book and chapter boundaries in a given version. You navigate across multiple 5 MByte sized books. Fast ! TechnologyThe published web page available at http://www.mathertel.de/AJAXEngine/S03_AJAXControls/BiblePage.aspx is already a AJAX application and more than just a small technology driven demo page that shows how to use a specific control or piece of code. I started working on this application to show how it all works together and to see where we need common functionality and what features we need within the controls. Cascading Select ElementsThe 4 select boxes at the top of the page are dynamically linked together by raising and listening to some page-level data connections. Together they form the cascading 4-level specification of the available verses. Here, the AJAX Select box control is used together with a AJAX action and some JavaScript code. The chapter select box is defined by <ajax:Select id="ChapterSelect" runat="server" pageproperty="chapter" style="width: 120px"> </ajax:Select> and the JavaScript code just below it reacts on changes of the version or the book. The AJAX Action is used to fetch all the Chapters from the server by using the BibleData WebService and the ListChapters method. <script defer="defer" type="text/javascript">
var obj = document.getElementById("ChapterSelect");
obj.GetValue = function(prop, value) {
if (((prop == "version") || (prop == "book")) && (jcl.DataConnections.GetPropValue(prop) != value)) {
ajax.Start(this.ChapterAction, this);
}
}; // GetValue
jcl.DataConnections.RegisterConsumer(obj, "*");
obj.ChapterAction = {
delay: 10,
prepare: function(obj) {
key = jcl.DataConnections.GetPropValue("version")
+ ";" + jcl.DataConnections.GetPropValue("book");
return (key); },
call: proxies.BibleData.ListChapters,
finish: function (value, obj) {
obj.CreateOptions(value);
if (obj.selLast == true)
obj.options[obj.options.length-1].selected = true;
obj.selLast = false;
},
onException: proxies.alertException
}; // ChapterAction
</script>
Very similar scripts can be found for the other 2 cascaded select boxes. Retrieving the Vers TextTo fetch the vers text, another AJAX action, named VersTextAction is used. The 4 properties version, book, chapter and vers are retrieved and passed to the BibleData WebService and the GetVers function. The returned text is then written into the text area. obj.VersTextAction = {
delay: 10,
prepare:
function(obj) {
key = jcl.DataConnections.GetPropValue("version")
+ ";" + jcl.DataConnections.GetPropValue("book")
+ ";" + jcl.DataConnections.GetPropValue("chapter")
+ ";" + jcl.DataConnections.GetPropValue("vers");
return (key);
}, // prepare
call:
proxies.BibleData.GetVers,
finish:
function (value, obj) {
obj.style.direction = ((jcl.DataConnections.GetPropValue("version") == "biblehebr") ? "rtl" : "ltr");
obj.innerHTML = value;
},
onException:
proxies.alertException
}; // VersTextAction
A very similar AJAX Action is used to look for a Prolog Text that might be describing the current book. The rest of JavaScript programming is for the sequential navigation through the verses, chapters and books. On the Server a ASP.NET WebService, written in C# with 5 methods is used to deliver all the data that is needed by the Bible Reader Web page. see: http://www.mathertel.de/AJAXEngine/S03_AJAXControls/BibleData.asmx That's all. All the source you need for this application has only about 15 kByte of text. You might not get any application of this functionality with less coding. Programming AJAX Web Applications can be easy and without a lot of source code if you choose the right technology and level of programming. Powerpoint Slides on AJAXI had to give a speech at the Karlsruher Software Council about AJAX some days ago. Now I've posted the Powerpoint slides titled "AJAX – Hype and Reality" on my site at PowerPoint Slides on AJAX There are really a lot of low level articles on AJAX that explain how to use te xmlhttp object. My summary on that: Have a look at the productiviy of yourself or your programmers and find a useful level of abstraction above the native xmlhttp objects. Maybe you find the slides useful. JavaScript Proxies for WebServices extendedI updated the bits on the AJAX Engine site some days ago. There are some new features I want to let you know:
|
The bookThe book "Aspects of AJAX" is available in PDF format at: Sample WebSiteThe samples as well as the complete source code can be found on this web site:
http://www.mathertel.de/ DownloadsAJAX.zip (180 kByte) This Zip-File contains the ASP.NET 2.0 web project that builds this side. All samples and Controls are included. AJAXEngine.zip (80 kByte) This Zip-File contains the core files of the AJAX engine and the AJAX controls. License
Recent posts:How to read cookie values in JavaScript Extending the initialization sequence of JavaScrip... How to set up a web project using the AjaxEngine –... Calling WCF and SOAP based webservices from AJAX How to setup a new AjaxEngine web project OpenAjax Call-to-Action to Ajax Developers for Bro... Data bound fields for Ajax forms Building menus with OpenAjax events More OpenAjax compatible components Archives
Tags: Ajax Javascript webservices soap wsdl xmlhttp |