update documentation example

This commit is contained in:
rolux 2012-06-02 11:21:54 +02:00
parent 0cefbe1997
commit 2b0b66d06d

View file

@ -19,55 +19,123 @@ section definition. Here, we mark a section named 'Primitives'.
*/
//@ Primitives
//@ My.REQUEST_TIMEOUT <number> Request timeout, in seconds
My.REQUEST_TIMEOUT = 60;
//@ My.REQUEST_TIMEOUT <number> Request timeout, in milliseconds
My.REQUEST_TIMEOUT = 60000;
/*@
My.MAGIC_CONSTANT <number> Magic constant needed for HTTP requests
My.MAGIC_CONSTANT <number> 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 <object> ...
array <a> My favorite array
boolean <b> My favorite boolean value
date <d> My favorite date
element <e> My favorite HTML element
number <n> My favorite number
object <o> My favorite object
regexp <r> My favorite regular expression
string <s> My favorite string
# Properties --------------------------------------------------------------
array <a> My favorite array
boolean <b> My favorite boolean value
date <d> My favorite date
error <e> My favorite error
function <f> My favorite function
arguments <g> My favorite arguments
htmlelement <h> My favorite HTML element
nodelist <l> My favorite nodelist
number <n> My favorite number
object <o> My favorite object
regexp <r> My favorite regular expression
string <s> My favorite string
undefined <u> Undefined is an all-time favorite
window <w> ...
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 <array> ...
0 <regexp> ...
1 <string> replace
*/
My.HTMLUtils = {
entities: {
'"': '&quot;', '&': '&amp;', "'": '&apos;', '<': '&lt;', '>': '&gt;'
},
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 <o> Default place object
My.defaultPlace <o> Default place object
geometry <o>
bounds <o> ..
northEast <o>
lat <n>
lng <n>
southWest <o>
lat <n>
lng <n>
types <[s]>
name <o> Localized place names
short <o> Short place name
de <s> Short German name
en <s> Short English name
fr <s> Short French name
long <o> Long place name
de <s> Short German name
en <s> Short English name
fr <s> Short French name
de <s> Long German name
en <s> Long English name
fr <s> Long French name
points <[o]> Points of interest
lat <n> Latitude
lng <n> Longitude
@*/
My.place = {
bounds: {
northEast: {lat: 0, lng: 0},
southWest: {lat: 0, lng: 0}
},
name: {
short: {
de: 'Brüssel',