|
YOUR FEEDBACK
Did you read today's front page stories & breaking news?
SYS-CON.TV |
TOP LINKS YOU MUST CLICK ON Book Excerpt AjaxWord: An Open Source Web Word Processor
AjaxWord: An Open Source Web Word Processor
By: Coach Wei
Mar. 18, 2007 02:00 PM
The Code The JavaScript/DHTML toolkit defines all the UI widgets. By separating UI widgets from the application, it's easier to develop and maintain the application code. Because of the level of richness required by AjaxWord and the limited availability of AJAX toolkits in the late 1990s, this entire toolkit was written from scratch. It would have been easier to build AjaxWord today by leveraging some of the available toolkits that have emerged in the last 12 months.
A Generic DHTML/JavaScript Toolkit In Figure 10, the left items are available with Web browsers. All other items aren't available in browsers and have to be built from scratch. In addition to UI elements, the toolkit provides a systematic way of managing UI events and doing asynchronous communications. When the application was written, the popular XmlHttpRequest object wasn't available in browsers, so AjaxWord actually uses hidden frames to asynchronously communicate. Instead of elaborating on how each component is built, we will use the "window" object as an example. The window object that we are referring to is a draggable, resizable window that resides inside a standard browser window, giving the look-and-feel of a multiple document interface. It is a basic component for desktop application user interfaces, but isn't available for Web applications.
Creating a "Window" Widget
Defining the View Each window area is defined by a "DIV" tag. For the four corners and four edges, each DIV tag contains an image. Each of the four window controls also contain an image. When necessary, these images can be changed according to style requirements. Some of DIV tags have event handlers defined too so that the window can respond to events. The view definition code is shown in Listing 1.
Defining the Controller
Window Initialization
Window Event Handling
Window Widget API
AjaxWord Client Application Logic The abstraction of UI widgets into a generic AJAX toolkit certainly helps code maintenance. AjaxWord also uses an object-oriented, event-driven approach to develop the application's client-side logic to manage and maintain the client-side code. All client-side logic resides in two JavaScript files: nwWord.js and nwWordMenuListener.js. The first JavaScript file defines the application-wide logic while the second one responds to menu and toolbar events.
Loading the Application AjaxWord requires a significant amount of initial download (several hundred kilobytes, dozens of HTML and JavaScript files, and many image files). This download process can take anywhere from a few seconds on a fast connection to 40 seconds on a slow dialup connection. To engage the user and improve perceived performance, AjaxWord uses a progress bar to indicate the loading progress so that the user knows the status and gets constant visual feedback, as shown in Figure 13 AjaxWord uses the code snippet below to update the progress bar and the status message. This code snippet follows each JavaScript file declaration statement so the "loadProgress1()" method will be executed every time a new file finishes loading: <SCRIPT TYPE="text/JavaScript">loadProgress1();</script> This way the user sees the progress being made as the application loads. Listing 4 is the loading page for AjaxWord. ENTERPRISE OPEN SOURCE MAGAZINE LATEST STORIES . . .
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
|
SYS-CON FEATURED WHITEPAPERS MOST READ THIS WEEK |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||