Supplementary JavaScript Resources — Introduction and Overview
A Selection of Free JavaScript-Libraries that Augment and Complement AspectJS
T
his page is an introduction to, and overview of, a selection of free JavaScript resources provided by Dodeca Technologies as a supplement to AspectJS. Note that all the pages contained within the Supplementary section on this site also appear on Dodeca's principal web-site as the Products section.
Contents
Technology Overview
Each library can be used independently of the others, but some can also be used in conjunction with each other and with AspectJS - indeed, some were designed and developed with that product in mind. Briefly, the libraries, their functionality, and their inter-operative potential are as follows:
  • The object-member locator called FindIn is a standalone function for locating, and acting upon, members of objects contained within arbitrarily large object-structures and hierarchies. FindIn can be used with third-party technologies, and/or can be used with AspectJS to apply affixes to methods using regular-expression wildcards.
  • LoadStyleSheet complements LoadLib_STH and LoadLib_XHR, and implements a variant on the 'script-tag hack'. It loads style-sheet files dynamically and on-demand, rather than by the static use of link elements.
  • LoadLib_STH complements LoadStyleSheet, and is an alternative to LoadLib_XHR. It implements the 'script-tag hack' to load JavaScript code dynamically and on-demand, rather than by the static use of script tags. LoadLib_STH can be used in conjunction with the EventMarshaller library.
  • LoadLib_XHR complements LoadStyleSheet, and is an alternative to LoadLib_STH. It performs the same function as LoadLib_STH, except that it uses XMLHTTPRequest to communicate with the server. This allows it to conduct sychronous transactions with the server, in contrast with LoadLib_STH, which is inherently asynchronous. It is designed to be used with the XMLHTTPRequest library, but (with a little modification) can be used with any other XHR technology.
  • The EventMarshaller library facilitates the management of race conditions when working with user, code-loading and XMLHTTPRequest-based events. It can therefore be used in conjunction with the XMLHTTPRequest library and with LoadLib_STH. It can also be used with AspectJS directly, such that affix functions post events to a marshaller.
  • The XMLHTTPRequest library encapsulates and automates working with XMLHTTPRequest objects. At its simplest, it ensures that the correct XHR-type is instantiated for the platform in question. Alternatively, it can be used to generate objects that wrap an XHR object, and which automate all aspects of transacting with the server. It can be used with LoadLib_XHR and/or with the EventMarshaller library.
  • The Trace-Debugging library allows the generation of pop up windows, to which debugging messages may be directed. While a dedicated debugger will allow the tracing of a program's flow of execution, along with the determination of object values at critical points, such a tool may be unavailable on a given platform. Moreover, AspectJS swallows all exceptions that function-affixes generate, and these points suggest the need for a simple reporting-facility, which the trace debugging library satisfies.
Using these Resources
Note that the code presented in these pages is provided free of charge, is supplied 'as is', and implies no warranty or guarantees of fitness-for-purpose. Users who discover bugs, factual/typographical errors, or who have enquiries, comments and other feedback are invited to get in touch — contact details are on the home page.
To use the code listed in these pages, perform a click-drag operation with your mouse across the relevant listing, and copy the selection before pasting it into your editor. Developers who desire a minified version of a given listing should pass the code below through a minifier such as JSMin, See the AspectJS Download page for a discussion of obfuscation (scrunching) and compression issues in JavaScript.
As with the AspectJS tutorial, where JavaScript keywords, and type, object and function names appear within body text they are (or should be) rendered in a mono-spaced, sans-serif typeface, and should appear thus.
As is also the case with the AspectJS tutorial, the tutorials in this section explore aspects of JavaScript itself only incidentally, and are not a general-purpose guide to the language. Readers are therefore advised to consult a good reference on JavaScript wherever language-specific concepts that require further explanation are mentioned.
Exceptions and the ClientCallPoint Argument
The functions in these resources throw only objects of JavaScript's native Error type. This type has a message member, for which the functions in these libraries provide a detailed text string that describes the nature of the problem.
In line with this, a great proportion of the functions contained in these libraries accept an argument called ClientCallPoint. This parameter is always optional, and is always the trailing argument in any call-signature (meaning that, should you choose to use it, you may need to provide dummy parameters for any leading arguments).
To the functions concerned, it is a 'tramp variable' in that none of them actually use it, but simply incorporate it into the message member of any Error objects that are thrown. It can take any value but, if used, is at its most useful when it contains information describing the conditions under which the function was called, such as the location of the call in a given body of code.
For example in the following call to FindIn (the object-member finder), the second parameter stipulates the name of the member that the function should search for, and should be enclosed in quotes:
FindIn (MyObj, MyMember, null, 3, "MyLib.js - Line 42");
However, this will generate an Error object that will be thrown out of FindIn's scope, and whose message member will contain the following:
Error in call to FindIn - SearchTerms argument is not
a string. Client-code call point: MyLib.js - Line 42
Copyright © Dodeca Technologies Ltd. 2007