diff options
Diffstat (limited to 'live/js')
-rw-r--r-- | live/js/mootools/mootools.v1.11.js | 71 | ||||
-rw-r--r-- | live/js/mootools/readme.mootools.config | 9 |
2 files changed, 76 insertions, 4 deletions
diff --git a/live/js/mootools/mootools.v1.11.js b/live/js/mootools/mootools.v1.11.js index b6c0cd6..ad6bfeb 100644 --- a/live/js/mootools/mootools.v1.11.js +++ b/live/js/mootools/mootools.v1.11.js @@ -4375,6 +4375,77 @@ Element.extend({ }); /* +Script: Json.js + Simple Json parser and Stringyfier, See: <http://www.json.org/> + +License: + MIT-style license. +*/ + +/* +Class: Json + Simple Json parser and Stringyfier, See: <http://www.json.org/> +*/ + +var Json = { + + /* + Property: toString + Converts an object to a string, to be passed in server-side scripts as a parameter. Although its not normal usage for this class, this method can also be used to convert functions and arrays to strings. + + Arguments: + obj - the object to convert to string + + Returns: + A json string + + Example: + (start code) + Json.toString({apple: 'red', lemon: 'yellow'}); '{"apple":"red","lemon":"yellow"}' + (end) + */ + + toString: function(obj){ + switch($type(obj)){ + case 'string': + return '"' + obj.replace(/(["\\])/g, '\\$1') + '"'; + case 'array': + return '[' + obj.map(Json.toString).join(',') + ']'; + case 'object': + var string = []; + for (var property in obj) string.push(Json.toString(property) + ':' + Json.toString(obj[property])); + return '{' + string.join(',') + '}'; + case 'number': + if (isFinite(obj)) break; + case false: + return 'null'; + } + return String(obj); + }, + + /* + Property: evaluate + converts a json string to an javascript Object. + + Arguments: + str - the string to evaluate. if its not a string, it returns false. + secure - optionally, performs syntax check on json string. Defaults to false. + + Credits: + Json test regexp is by Douglas Crockford <http://crockford.org>. + + Example: + >var myObject = Json.evaluate('{"apple":"red","lemon":"yellow"}'); + >//myObject will become {apple: 'red', lemon: 'yellow'} + */ + + evaluate: function(str, secure){ + return (($type(str) != 'string') || (secure && !str.test(/^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/))) ? null : eval('(' + str + ')'); + } + +}; + +/* Script: Tips.js Tooltips, BubbleTips, whatever they are, they will appear on mouseover diff --git a/live/js/mootools/readme.mootools.config b/live/js/mootools/readme.mootools.config index dccaf42..edc3cef 100644 --- a/live/js/mootools/readme.mootools.config +++ b/live/js/mootools/readme.mootools.config @@ -19,10 +19,11 @@ live. In order to obtain the right mootools configuration follow these steps: - Scroll down to the bottom of the page and select the following options towards the top of the download page in this order: 1. Tips - 2. Ajax - 3. Drag.Move - 4. Window.DomReady - 5. Element.Selectors + 2. Json + 3. Ajax + 4. Drag.Move + 5. Window.DomReady + 6. Element.Selectors - Then open 'Choose compression type' and select 'No Compression' to have fully documented mootools source. This helps when developing |