The program starts with the Mui Callback function passed to setMain(...). A minimal program could be defined like:
mui.setMain(main);
function main(mui) {
mui.showPage(["page", ["text", "Hello world"]]);
}
Mui Callbacks are the functions that are passed to Mui. They will be called, when new content are needed to be shown to the user, for example when the program starts or when the user submits a form. A Mui Callback is an unary function, taking a Mui Object as the parameter. When a callback is called, it must call a method on the Mui Object which shows new content (currently only mui.showPage(...)).
Mui Objects are only available to callbacks, and contains the following properties:
mui.sessionis an initially empty object where the application can store data, which will be available in futher callbacks in the same session.mui.storage.getItem(key)retrieve a value for a given key in a persistent storage linked to the current device.mui.storage.setItem(key, value)sets an item in the storage. The value should be JSON-serialisable.mui.loading()indicates loading activity to the user.mui.callJsonpWebservice(url, callbackParameterName, args, callback)calls a web service.urlis the url of the web service,callbackParameterNameis the parameter to the service which names the padding function,argsis an object of arguments which are to be passed to the url, andcallbackis an unary JavaScript function which will be called with result of the web service, orundefinedif the service fails or times out.mui.showPage(muiPage)displays a page that the user can interact with.mui.formValue(name)returns the content of a named form element that the user interacted with on the previous page.mui.prevPage()returns previous shown page, if applicable.mui.setHints(page, hints)add a hint text to named inputs and choices in the form, - useful for showing errors after input validating.hintsis an object with names mapping to hint-strings.
Mui Pages are user interface descriptions passed that are to showPage. They are written in JsonML array form with the addition that JavaScript-functions may also be values some of the places. Mui Pages has the following elements:
pageis the tag type of the root elements, with the following attributes:titleis shown on the top of the page, optional
sectiongroups other elementsautocontentfunction used for autoexpanded content, such as search results, - only one of these per page, as they autoexpand and loads more content, and it thus may not be possible to scroll across them. The autocontent function gets an mui object which also has anappendmethod for adding content, and amoremethod which can be used to designate a function to be called fo more content
textis displayed textinputenables the user to input a value. It has the following attributes:labeloptional label shown with the input elementtypeindicates the kind of input, - it is mandatory and must be one of the following:texta line of texttextboxsome lines of texttelephone numberemailaddress
nameis used to reference the result inmui.form, mandatoryhint- hint text added at the input
choicea collection of options, between which the user must select. Onlyoptionnodes are allowed as child elements. It has the following attributes:labeloptional label shown with the choice groupnameis used to reference the result inmui.form, mandatory
optionan option the user can choose. Must be child elements of select. It has the following attributes:valuethe value this choice will return to the program in themui.form.
buttonis a clickable button with the following attributes:fnthe Mui Callback function to invoke when the button is pressed.
Utilities for parsing and working with jsonml in array form.
More info on JsonML at jsonml.org and wikipedia
This module implements the following functions:
jsonml.fromXml(xml_string)converts a string containing xml to jsonml in array formjsonml.toXml(jsonml_array)converts jsonml in array form to xmljsonml.toObject(jsonml_array)converts jsonml in array form to an easier subscriptable objectjsonml.childReduce(jsonml_array, callback_function(accumulator, child_element), initial_value)applies the callback function to each child element of the jsonml arrayjsonml.getAttr(jsonml_array, attributename)retrieves the value of a given attribute of the jsonml array or undefined if the attribute is not defined
This overview document is README.md, and can be transformed into a printable document with markdown2pdf README.md if pandoc is installed. Implementation documentation can be generated with the command docco */*.js, given docco is installed.
