From 2b0b66d06d756f97feac3bf6326d3746086018d9 Mon Sep 17 00:00:00 2001 From: rolux Date: Sat, 2 Jun 2012 11:21:54 +0200 Subject: [PATCH] update documentation example --- examples/documentation/js/example.js | 116 +++++++++++++++++++++------ 1 file changed, 92 insertions(+), 24 deletions(-) diff --git a/examples/documentation/js/example.js b/examples/documentation/js/example.js index ed1559aa..f20c58ea 100644 --- a/examples/documentation/js/example.js +++ b/examples/documentation/js/example.js @@ -19,55 +19,123 @@ section definition. Here, we mark a section named 'Primitives'. */ //@ Primitives -//@ My.REQUEST_TIMEOUT Request timeout, in seconds -My.REQUEST_TIMEOUT = 60; +//@ My.REQUEST_TIMEOUT Request timeout, in milliseconds +My.REQUEST_TIMEOUT = 60000; /*@ -My.MAGIC_CONSTANT Magic constant needed for HTTP requests +My.MAGIC_CONSTANT Magic constant, needed for HTTP requests Please note that the value for `MAGIC_CONSTANT` is browser-dependent. */ My.MAGIC_CONSTANT = navigator.userAgent.length % 2 == 0 ? 23 : 42; //@ Objects +/* +*/ /*@ My.favorites ... - array My favorite array - boolean My favorite boolean value - date My favorite date - element My favorite HTML element - number My favorite number - object My favorite object - regexp My favorite regular expression - string My favorite string + # Properties -------------------------------------------------------------- + array My favorite array + boolean My favorite boolean value + date My favorite date + error My favorite error + function My favorite function + arguments My favorite arguments + htmlelement My favorite HTML element + nodelist My favorite nodelist + number My favorite number + object My favorite object + regexp My favorite regular expression + string My favorite string + undefined Undefined is an all-time favorite + window ... + other <+> ... + any <*> Favorite of the day + # Events ------------------------------------------------------------------- + event Fires when My.favorite['function'] is called */ -My.favorites = { - array: [], - boolean: false, - date: new Date(0), - element: document.createElement('a'), - number: 0, - object: {}, - regexp: new RegExp(''), - string: '' +My.favorites = (function() { + var favorites = { + array: [], + boolean: false, + date: new Date(), + error: new Error(), + 'function': function() { + My.triggerEvent(this, 'event'); + }, + arguments: (function() { return arguments; }()), + htmlelement: document.createElement('a'), + nodelist: document.getElementsByTagName('a'), + number: 0, + object: {}, + regexp: new RegExp(), + string: '', + 'undefined': void 0, + 'window': window, + other: document + }, + keys = Object.keys(favorites); + return Ox.extend(favorites, {any: favorites[keys[Ox.random(keys.length)]]}); +}()); + +/*@ + replace ... + 0 ... + 1 replace +*/ +My.HTMLUtils = { + entities: { + '"': '"', '&': '&', "'": ''', '<': '<', '>': '>' + }, + replace: { + namedEntity: [ + new RegExp('(' + Ox.values(this.entities).join('|') + ')', 'g'), + function(match) { + return Ox.keyOf(this.entities, match); + } + ], + numericEntity: [ + /&#([0-9A-FX]+);/gi, + function(match, code) { + return Ox.char( + /^X/i.test(code) + ? parseInt(code.slice(1), 16) + : parseInt(code, 10) + ); + } + ], + } }; /*@ -My.place Default place object +My.defaultPlace Default place object + geometry + bounds .. + northEast + lat + lng + southWest + lat + lng + types <[s]> name Localized place names short Short place name de Short German name en Short English name fr Short French name long Long place name - de Short German name - en Short English name - fr Short French name + de Long German name + en Long English name + fr Long French name points <[o]> Points of interest lat Latitude lng Longitude @*/ My.place = { + bounds: { + northEast: {lat: 0, lng: 0}, + southWest: {lat: 0, lng: 0} + }, name: { short: { de: 'BrĂ¼ssel',