Changeset 485
- Timestamp:
- 07/02/07 15:35:07 (2 years ago)
- Files:
-
- trunk/build/manifests/jelix-lib.mn (modified) (3 diffs)
- trunk/build/manifests/jelix-lib.mn (modified) (3 diffs)
- trunk/build/manifests/jelix-modules.mn (modified) (1 diff)
- trunk/build/manifests/jelix-modules.mn (modified) (1 diff)
- trunk/demoxul/var/config/defaultconfig.ini.php.dist (modified) (1 diff)
- trunk/demoxul/var/config/defaultconfig.ini.php.dist (modified) (1 diff)
- trunk/lib/jelix-modules/jauth/install/var/config/auth.coord.ini.php (moved) (moved from trunk/lib/jelix-modules/jauth/install/var/config/auth.plugin.ini.php)
- trunk/lib/jelix-modules/jauth/install/var/config/auth.coord.ini.php (moved) (moved from trunk/lib/jelix-modules/jauth/install/var/config/auth.plugin.ini.php)
- trunk/lib/jelix-modules/jauth/install/var/config/authsw.coord.ini.php (moved) (moved from trunk/lib/jelix-modules/jauth/install/var/config/authsw.plugin.ini.php)
- trunk/lib/jelix-modules/jauth/install/var/config/authsw.coord.ini.php (moved) (moved from trunk/lib/jelix-modules/jauth/install/var/config/authsw.plugin.ini.php)
- trunk/lib/jelix-modules/jxxulapp/install/var/config/index (added)
- trunk/lib/jelix-modules/jxxulapp/install/var/config/index (added)
- trunk/lib/jelix-modules/jxxulapp/install/var/config/index/auth.coord.ini.php (moved) (moved from trunk/lib/jelix-modules/jxxulapp/install/var/config/auth.plugin.ini.php)
- trunk/lib/jelix-modules/jxxulapp/install/var/config/index/auth.coord.ini.php (moved) (moved from trunk/lib/jelix-modules/jxxulapp/install/var/config/auth.plugin.ini.php)
- trunk/lib/jelix-modules/jxxulapp/install/var/config/index/config.ini.php (moved) (moved from trunk/lib/jelix-modules/jxxulapp/install/var/config/config.classic.ini.php) (2 diffs)
- trunk/lib/jelix-modules/jxxulapp/install/var/config/index/config.ini.php (moved) (moved from trunk/lib/jelix-modules/jxxulapp/install/var/config/config.classic.ini.php) (2 diffs)
- trunk/lib/jelix-modules/jxxulapp/install/var/config/jsonrpc (added)
- trunk/lib/jelix-modules/jxxulapp/install/var/config/jsonrpc (added)
- trunk/lib/jelix-modules/jxxulapp/install/var/config/jsonrpc/auth.coord.ini.php (moved) (moved from trunk/lib/jelix-modules/jxxulapp/install/var/config/auth.plugin.jsonrpc.ini.php)
- trunk/lib/jelix-modules/jxxulapp/install/var/config/jsonrpc/auth.coord.ini.php (moved) (moved from trunk/lib/jelix-modules/jxxulapp/install/var/config/auth.plugin.jsonrpc.ini.php)
- trunk/lib/jelix-modules/jxxulapp/install/var/config/jsonrpc/config.ini.php (moved) (moved from trunk/lib/jelix-modules/jxxulapp/install/var/config/config.jsonrpc.ini.php) (2 diffs)
- trunk/lib/jelix-modules/jxxulapp/install/var/config/jsonrpc/config.ini.php (moved) (moved from trunk/lib/jelix-modules/jxxulapp/install/var/config/config.jsonrpc.ini.php) (2 diffs)
- trunk/lib/jelix-modules/jxxulapp/install/var/config/rdf (added)
- trunk/lib/jelix-modules/jxxulapp/install/var/config/rdf (added)
- trunk/lib/jelix-modules/jxxulapp/install/var/config/rdf/auth.coord.ini.php (moved) (moved from trunk/lib/jelix-modules/jxxulapp/install/var/config/auth.plugin.rdf.ini.php)
- trunk/lib/jelix-modules/jxxulapp/install/var/config/rdf/auth.coord.ini.php (moved) (moved from trunk/lib/jelix-modules/jxxulapp/install/var/config/auth.plugin.rdf.ini.php)
- trunk/lib/jelix-modules/jxxulapp/install/var/config/rdf/config.ini.php (moved) (moved from trunk/lib/jelix-modules/jxxulapp/install/var/config/config.rdf.ini.php) (2 diffs)
- trunk/lib/jelix-modules/jxxulapp/install/var/config/rdf/config.ini.php (moved) (moved from trunk/lib/jelix-modules/jxxulapp/install/var/config/config.rdf.ini.php) (2 diffs)
- trunk/lib/jelix-modules/jxxulapp/install/var/config/xul (added)
- trunk/lib/jelix-modules/jxxulapp/install/var/config/xul (added)
- trunk/lib/jelix-modules/jxxulapp/install/var/config/xul/auth.coord.ini.php (moved) (moved from trunk/lib/jelix-modules/jxxulapp/install/var/config/auth.plugin.xul.ini.php)
- trunk/lib/jelix-modules/jxxulapp/install/var/config/xul/auth.coord.ini.php (moved) (moved from trunk/lib/jelix-modules/jxxulapp/install/var/config/auth.plugin.xul.ini.php)
- trunk/lib/jelix-modules/jxxulapp/install/var/config/xul/config.ini.php (moved) (moved from trunk/lib/jelix-modules/jxxulapp/install/var/config/configxul.classic.ini.php) (2 diffs)
- trunk/lib/jelix-modules/jxxulapp/install/var/config/xul/config.ini.php (moved) (moved from trunk/lib/jelix-modules/jxxulapp/install/var/config/configxul.classic.ini.php) (2 diffs)
- trunk/lib/jelix-modules/jxxulapp/install/www/xmlrpc.php (deleted)
- trunk/lib/jelix-modules/jxxulapp/install/www/xmlrpc.php (deleted)
- trunk/lib/jelix-modules/jxxulapp/templates/login.tpl (modified) (2 diffs)
- trunk/lib/jelix-modules/jxxulapp/templates/login.tpl (modified) (2 diffs)
- trunk/lib/jelix-www/js/json.js (moved) (moved from trunk/lib/jelix-www/json.js) (1 diff)
- trunk/lib/jelix-www/js/json.js (moved) (moved from trunk/lib/jelix-www/json.js) (1 diff)
- trunk/lib/jelix-www/xul/jxulform.xml (modified) (11 diffs)
- trunk/lib/jelix-www/xul/jxulform.xml (modified) (11 diffs)
- trunk/lib/jelix/utils/jJsonRpc.class.php (modified) (1 diff)
- trunk/lib/jelix/utils/jJsonRpc.class.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/build/manifests/jelix-lib.mn
r480 r485 218 218 jelixuser.dao.xml 219 219 cd lib/jelix-modules/jauth/install/var/config 220 auth. plugin.ini.php221 authsw. plugin.ini.php220 auth.coord.ini.php 221 authsw.coord.ini.php 222 222 cd lib/jelix-modules/jauth/locales/en_US 223 223 auth.ISO-8859-1.properties … … 349 349 simple.urls.php 350 350 351 cd lib/jelix-www352 json.js353 351 cd lib/jelix-www/design 354 352 jelix.css … … 357 355 tooltip.js 358 356 jforms.js 357 json.js 359 358 cd lib/jelix-www/xul 360 359 jxulform.css trunk/build/manifests/jelix-lib.mn
r480 r485 218 218 jelixuser.dao.xml 219 219 cd lib/jelix-modules/jauth/install/var/config 220 auth. plugin.ini.php221 authsw. plugin.ini.php220 auth.coord.ini.php 221 authsw.coord.ini.php 222 222 cd lib/jelix-modules/jauth/locales/en_US 223 223 auth.ISO-8859-1.properties … … 349 349 simple.urls.php 350 350 351 cd lib/jelix-www352 json.js353 351 cd lib/jelix-www/design 354 352 jelix.css … … 357 355 tooltip.js 358 356 jforms.js 357 json.js 359 358 cd lib/jelix-www/xul 360 359 jxulform.css trunk/build/manifests/jelix-modules.mn
r469 r485 6 6 main.tpl 7 7 login.tpl 8 cd jxxulapp/install/var/config 9 auth.plugin.ini.php 10 auth.plugin.jsonrpc.ini.php 11 config.classic.ini.php 12 auth.plugin.rdf.ini.php 13 auth.plugin.xul.ini.php 14 config.jsonrpc.ini.php 15 config.rdf.ini.php 16 configxul.classic.ini.php 8 cd jxxulapp/install/var/config/index 9 auth.coord.ini.php 10 config.ini.php 11 cd jxxulapp/install/var/config/rdf 12 auth.coord.ini.php 13 config.ini.php 14 cd jxxulapp/install/var/config/jsonrpc 15 auth.coord.ini.php 16 config.ini.php 17 cd jxxulapp/install/var/config/xul 18 auth.coord.ini.php 19 config.ini.php 17 20 cd jxxulapp/install/www 18 21 jsonrpc.php 19 22 rdf.php 20 xmlrpc.php21 23 xul.php 22 24 index.php trunk/build/manifests/jelix-modules.mn
r469 r485 6 6 main.tpl 7 7 login.tpl 8 cd jxxulapp/install/var/config 9 auth.plugin.ini.php 10 auth.plugin.jsonrpc.ini.php 11 config.classic.ini.php 12 auth.plugin.rdf.ini.php 13 auth.plugin.xul.ini.php 14 config.jsonrpc.ini.php 15 config.rdf.ini.php 16 configxul.classic.ini.php 8 cd jxxulapp/install/var/config/index 9 auth.coord.ini.php 10 config.ini.php 11 cd jxxulapp/install/var/config/rdf 12 auth.coord.ini.php 13 config.ini.php 14 cd jxxulapp/install/var/config/jsonrpc 15 auth.coord.ini.php 16 config.ini.php 17 cd jxxulapp/install/var/config/xul 18 auth.coord.ini.php 19 config.ini.php 17 20 cd jxxulapp/install/www 18 21 jsonrpc.php 19 22 rdf.php 20 xmlrpc.php21 23 xul.php 22 24 index.php trunk/demoxul/var/config/defaultconfig.ini.php.dist
r451 r485 15 15 pluginsPath = lib:jelix-plugins/,app:plugins/ 16 16 modulesPath = lib:jelix-modules/,app:modules/ 17 tplpluginsPath = lib:jelix/tpl/plugins/18 17 19 18 dbProfils = dbprofils.ini.php trunk/demoxul/var/config/defaultconfig.ini.php.dist
r451 r485 15 15 pluginsPath = lib:jelix-plugins/,app:plugins/ 16 16 modulesPath = lib:jelix-modules/,app:modules/ 17 tplpluginsPath = lib:jelix/tpl/plugins/18 17 19 18 dbProfils = dbprofils.ini.php trunk/lib/jelix-modules/jxxulapp/install/var/config/index/config.ini.php
r479 r485 5 5 defaultAction = "default_index" 6 6 defaultLocale = "fr_FR" 7 defaultCharset = " ISO-8859-1"7 defaultCharset = "UTF-8" 8 8 9 9 checkTrustedModules = off … … 22 22 23 23 [plugins] 24 auth = auth.plugin.ini.php24 auth = "index/auth.coord.ini.php" 25 25 26 26 [responses] trunk/lib/jelix-modules/jxxulapp/install/var/config/index/config.ini.php
r479 r485 5 5 defaultAction = "default_index" 6 6 defaultLocale = "fr_FR" 7 defaultCharset = " ISO-8859-1"7 defaultCharset = "UTF-8" 8 8 9 9 checkTrustedModules = off … … 22 22 23 23 [plugins] 24 auth = auth.plugin.ini.php24 auth = "index/auth.coord.ini.php" 25 25 26 26 [responses] trunk/lib/jelix-modules/jxxulapp/install/var/config/jsonrpc/config.ini.php
r479 r485 5 5 defaultAction = "default_index" 6 6 defaultLocale = "fr_FR" 7 defaultCharset = " ISO-8859-1"7 defaultCharset = "UTF-8" 8 8 9 9 checkTrustedModules = off … … 21 21 22 22 [plugins] 23 auth = auth.plugin.jsonrpc.ini.php23 auth = "jsonrpc/auth.coord.ini.php" 24 24 25 25 [responses] trunk/lib/jelix-modules/jxxulapp/install/var/config/jsonrpc/config.ini.php
r479 r485 5 5 defaultAction = "default_index" 6 6 defaultLocale = "fr_FR" 7 defaultCharset = " ISO-8859-1"7 defaultCharset = "UTF-8" 8 8 9 9 checkTrustedModules = off … … 21 21 22 22 [plugins] 23 auth = auth.plugin.jsonrpc.ini.php23 auth = "jsonrpc/auth.coord.ini.php" 24 24 25 25 [responses] trunk/lib/jelix-modules/jxxulapp/install/var/config/rdf/config.ini.php
r479 r485 5 5 defaultAction = "default_index" 6 6 defaultLocale = "fr_FR" 7 defaultCharset = " ISO-8859-1"7 defaultCharset = "UTF-8" 8 8 9 9 checkTrustedModules = off … … 21 21 22 22 [plugins] 23 auth = auth.plugin.rdf.ini.php23 auth = "rdf/auth.coord.ini.php" 24 24 25 25 [responses] trunk/lib/jelix-modules/jxxulapp/install/var/config/rdf/config.ini.php
r479 r485 5 5 defaultAction = "default_index" 6 6 defaultLocale = "fr_FR" 7 defaultCharset = " ISO-8859-1"7 defaultCharset = "UTF-8" 8 8 9 9 checkTrustedModules = off … … 21 21 22 22 [plugins] 23 auth = auth.plugin.rdf.ini.php23 auth = "rdf/auth.coord.ini.php" 24 24 25 25 [responses] trunk/lib/jelix-modules/jxxulapp/install/var/config/xul/config.ini.php
r479 r485 5 5 defaultAction = "default_index" 6 6 defaultLocale = "fr_FR" 7 defaultCharset = " ISO-8859-1"7 defaultCharset = "UTF-8" 8 8 9 9 checkTrustedModules = off … … 21 21 22 22 [plugins] 23 auth = auth.plugin.xul.ini.php23 auth = "xul/auth.coord.ini.php" 24 24 25 25 [responses] trunk/lib/jelix-modules/jxxulapp/install/var/config/xul/config.ini.php
r479 r485 5 5 defaultAction = "default_index" 6 6 defaultLocale = "fr_FR" 7 defaultCharset = " ISO-8859-1"7 defaultCharset = "UTF-8" 8 8 9 9 checkTrustedModules = off … … 21 21 22 22 [plugins] 23 auth = auth.plugin.xul.ini.php23 auth = "xul/auth.coord.ini.php" 24 24 25 25 [responses] trunk/lib/jelix-modules/jxxulapp/templates/login.tpl
r386 r485 2 2 {meta_xul css 'jelix/xul/jxulform.css'} 3 3 {meta_xul ns array('jx'=>'jxbl')} 4 {meta_xul js 'jelix/js/json.js'} 4 5 5 6 <script type="application/x-javascript"><![CDATA[ … … 24 25 25 26 <jx:submission id="loginform" action="{jurl '@jsonrpc'}" method="POST" 26 format="json-rpc" 27 format="json-rpc" rpcmethod="jxauth~login_in" 27 28 onsubmit="" 28 rpcmethod="jxauth~login_in" 29 oninvalidate="alert('Saisissez un login et mot de passe')" 30 29 31 onresult="onLoginResult(this)" 30 onhttperror="alert('erreur http :' + event.errorCode)" 31 oninvalidate="alert('Saisissez un login et mot de passe')" 32 onrpcerror="alert(this.jsonResponse.error.toSource())" 33 onerror="alert(this.httpreq.responseText);" 32 onrpcerror="alert('RPC error\ncode='+this.jsonResponse.error.code + '\nmessage='+this.jsonResponse.error.string)" 33 onhttperror="alert('HTTP Error\nstatus=' + this.httpreq.status + '\nresponse='+ this.httpreq.responseText)" 34 onerror="alert('internal error, code ='+event.errorCode+'\nresponse='+ this.httpreq.responseText)" 34 35 /> 35 36 trunk/lib/jelix-modules/jxxulapp/templates/login.tpl
r386 r485 2 2 {meta_xul css 'jelix/xul/jxulform.css'} 3 3 {meta_xul ns array('jx'=>'jxbl')} 4 {meta_xul js 'jelix/js/json.js'} 4 5 5 6 <script type="application/x-javascript"><![CDATA[ … … 24 25 25 26 <jx:submission id="loginform" action="{jurl '@jsonrpc'}" method="POST" 26 format="json-rpc" 27 format="json-rpc" rpcmethod="jxauth~login_in" 27 28 onsubmit="" 28 rpcmethod="jxauth~login_in" 29 oninvalidate="alert('Saisissez un login et mot de passe')" 30 29 31 onresult="onLoginResult(this)" 30 onhttperror="alert('erreur http :' + event.errorCode)" 31 oninvalidate="alert('Saisissez un login et mot de passe')" 32 onrpcerror="alert(this.jsonResponse.error.toSource())" 33 onerror="alert(this.httpreq.responseText);" 32 onrpcerror="alert('RPC error\ncode='+this.jsonResponse.error.code + '\nmessage='+this.jsonResponse.error.string)" 33 onhttperror="alert('HTTP Error\nstatus=' + this.httpreq.status + '\nresponse='+ this.httpreq.responseText)" 34 onerror="alert('internal error, code ='+event.errorCode+'\nresponse='+ this.httpreq.responseText)" 34 35 /> 35 36 trunk/lib/jelix-www/js/json.js
r144 r485 1 1 /* 2 Copyright (c) 2005 JSON.org 2 json.js 3 2007-06-19 3 4 4 Permission is hereby granted, free of charge, to any person obtaining a copy 5 of this software and associated documentation files (the "Software"), to deal 6 in the Software without restriction, including without limitation the rights 7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 copies of the Software, and to permit persons to whom the Software is 9 furnished to do so, subject to the following conditions: 5 Public Domain 10 6 11 The Software shall be used for Good, not Evil. 7 This file adds these methods to JavaScript: 12 8 13 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 SOFTWARE. 9 array.toJSONString() 10 boolean.toJSONString() 11 date.toJSONString() 12 number.toJSONString() 13 object.toJSONString() 14 string.toJSONString() 15 These methods produce a JSON text from a JavaScript value. 16 It must not contain any cyclical references. Illegal values 17 will be excluded. 18 19 The default conversion for dates is to an ISO string. You can 20 add a toJSONString method to any date object to get a different 21 representation. 22 23 string.parseJSON(filter) 24 This method parses a JSON text to produce an object or 25 array. It can throw a SyntaxError exception. 26 27 The optional filter parameter is a function which can filter and 28 transform the results. It receives each of the keys and values, and 29 its return value is used instead of the original value. If it 30 returns what it received, then structure is not modified. If it 31 returns undefined then the member is deleted. 32 33 Example: 34 35 // Parse the text. If a key contains the string 'date' then 36 // convert the value to a date. 37 38 myData = text.parseJSON(function (key, value) { 39 return key.indexOf('date') >= 0 ? new Date(value) : value; 40 }); 41 42 It is expected that these methods will formally become part of the 43 JavaScript Programming Language in the Fourth Edition of the 44 ECMAScript standard in 2008. 45 46 This file will break programs with improper for..in loops. See 47 http://yuiblog.com/blog/2006/09/26/for-in-intrigue/ 48 49 This is a reference implementation. You are free to copy, modify, or 50 redistribute. 51 52 Use your own copy. It is extremely unwise to load untrusted third party 53 code into your pages. 20 54 */ 21 55 22 var JSON = { 23 org: 'http://www.JSON.org', 24 copyright: '(c)2005 JSON.org', 25 license: 'http://www.crockford.com/JSON/license.html', 26 stringify: function stringify(arg) { 27 var c, i, l, s = '', v; 56 /*jslint evil: true */ 28 57 29 switch (typeof arg) { 30 case 'object': 31 if (arg) { 32 if (arg.constructor == Array) { 33 for (i = 0; i < arg.length; ++i) { 34 v = this.stringify(arg[i]); 35 if (s) { 36 s += ','; 37 } 38 s += v; 39 } 40 return '[' + s + ']'; 41 } else if (typeof arg.toString != 'undefined') { 42 for (i in arg) { 43 v = arg[i]; 44 if (typeof v != 'undefined' && typeof v != 'function') { 45 v = this.stringify(v); 46 if (s) { 47 s += ','; 48 } 49 s += this.stringify(i) + ':' + v; 50 } 51 } 52 return '{' + s + '}'; 53 } 54 } 55 return 'null'; 56 case 'number': 57 return isFinite(arg) ? String(arg) : 'null'; 58 case 'string': 59 l = arg.length; 60 s = '"'; 61 for (i = 0; i < l; i += 1) { 62 c = arg.charAt(i); 63 if (c >= ' ') { 64 if (c == '\\' || c == '"') { 65 s += '\\'; 66 } 67 s += c; 68 } else { 69 switch (c) { 70 case '\b': 71 s += '\\b'; 72 break; 73 case '\f': 74 s += '\\f'; 75 break; 76 case '\n': 77 s += '\\n'; 78 break; 79 case '\r': 80 s += '\\r'; 81 break; 82 case '\t': 83 s += '\\t'; 84 break; 85 default: 86 c = c.charCodeAt(); 87 s += '\\u00' + Math.floor(c / 16).toString(16) + 88 (c % 16).toString(16); 89 } 90 } 91 } 92 return s + '"'; 93 case 'boolean': 94 return String(arg); 95 default: 96 return 'null'; 97 } 98 }, 99 parse: function (text) { 100 var at = 0; 101 var ch = ' '; 102 103 function error(m) { 104 throw { 105 name: 'JSONError', 106 message: m, 107 at: at - 1, 108 text: text 109 }; 110 } 111 112 function next() { 113 ch = text.charAt(at); 114 at += 1; 115 return ch; 116 } 117 118 function white() { 119 while (ch) { 120 if (ch <= ' ') { 121 next(); 122 } else if (ch == '/') { 123 switch (next()) { 124 case '/': 125 while (next() && ch != '\n' && ch != '\r') {} 126 break; 127 case '*': 128 next(); 129 for (;;) { 130 if (ch) { 131 if (ch == '*') { 132 if (next() == '/') { 133 next(); 134 break; 135 } 136 } else { 137 next(); 138 } 139 } else { 140 error("Unterminated comment"); 141 } 142 } 143 break; 144 default: 145 error("Syntax error"); 58 if (!Object.prototype.toJSONString) { 59 Array.prototype.toJSONString = function () { 60 var a = [], i, l = this.length, v; 61 for (i = 0; i < l; i += 1) { 62 v = this[i]; 63 switch (typeof v) { 64 case 'object': 65 if (v) { 66 if (typeof v.toJSONString === 'function') { 67 a.push(v.toJSONString()); 146 68 } 147 69 } else { 70 a.push('null'); 71 } 72 break; 73 74 case 'string': 75 case 'number': 76 case 'boolean': 77 a.push(v.toJSONString()); 78 } 79 } 80 return '[' + a.join(',') + ']'; 81 }; 82 83 Boolean.prototype.toJSONString = function () { 84 return String(this); 85 }; 86 87 Date.prototype.toJSONString = function () { 88 function f(n) { 89 return n < 10 ? '0' + n : n; 90 } 91 return '"' + this.getFullYear() + '-' + 92 f(this.getMonth() + 1) + '-' + 93 f(this.getDate()) + 'T' + 94 f(this.getHours()) + ':' + 95 f(this.getMinutes()) + ':' + 96 f(this.getSeconds()) + '"'; 97 }; 98 Number.prototype.toJSONString = function () { 99 return isFinite(this) ? String(this) : 'null'; 100 }; 101 Object.prototype.toJSONString = function () { 102 var a = [], k, v; 103 for (k in this) { 104 if (this.hasOwnProperty(k)) { 105 v = this[k]; 106 switch (typeof v) { 107 case 'object': 108 if (v) { 109 if (typeof v.toJSONString === 'function') { 110 a.push(k.toJSONString() + ':' + v.toJSONString()); 111 } 112 } else { 113 a.push(k.toJSONString() + ':null'); 114 } 148 115 break; 116 117 case 'string': 118 case 'number': 119 case 'boolean': 120 a.push(k.toJSONString() + ':' + v.toJSONString()); 149 121 } 150 122 } 151 123 } 124 return '{' + a.join(',') + '}'; 125 }; 152 126 153 function string() { 154 var i, s = '', t, u; 127 (function (s) { 128 var m = { 129 '\b': '\\b', 130 '\t': '\\t', 131 '\n': '\\n', 132 '\f': '\\f', 133 '\r': '\\r', 134 '"' : '\\"', 135 '\\': '\\\\' 136 }; 137 s.parseJSON = function (filter) { 138 var j; 155 139 156 if (ch == '"') { 157 outer: while (next()) { 158 if (ch == '"') { 159 next(); 160 return s; 161 } else if (ch == '\\') { 162 switch (next()) { 163 case 'b': 164 s += '\b'; 165 break; 166 case 'f': 167 s += '\f'; 168 break; 169 case 'n': 170 s += '\n'; 171 break; 172 case 'r': 173 s += '\r'; 174 break; 175 case 't': 176 s += '\t'; 177 break; 178 case 'u': 179 u = 0; 180 for (i = 0; i < 4; i += 1) { 181 t = parseInt(next(), 16); 182 if (!isFinite(t)) { 183 break outer; 184 } 185 u = u * 16 + t; 186 } 187 s += String.fromCharCode(u); 188 break; 189 default: 190 s += ch; 140 function walk(k, v) { 141 var i; 142 if (v && typeof v === 'object') { 143 for (i in v) { 144 if (v.hasOwnProperty(i)) { 145 v[i] = walk(i, v[i]); 191 146 } 192 } else {193 s += ch;194 147 } 195 148 } 149 return filter(k, v); 196 150 } 197 error("Bad string"); 198 } 199 200 function array() { 201 var a = []; 202 203 if (ch == '[') { 204 next(); 205 white(); 206 if (ch == ']') { 207 next(); 208 return a; 151 if (/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/.test(this. 152 replace(/\\./g, '@'). 153 replace(/"[^"\\\n\r]*"/g, ''))) { 154 j = eval('(' + this + ')'); 155 if (typeof filter === 'function') { 156 j = walk('', j); 209 157 } 210 while (ch) { 211 a.push(value()); 212 white(); 213 if (ch == ']') { 214 next(); 215 return a; 216 } else if (ch != ',') { 217 break; 158 return j; 159 } 160 throw new SyntaxError('parseJSON'); 161 }; 162 s.toJSONString = function () { 163 if (/["\\\x00-\x1f]/.test(this)) { 164 return '"' + this.replace(/([\x00-\x1f\\"])/g, function (a, b) { 165 var c = m[b]; 166 if (c) { 167 return c; 218 168 } 219 next(); 220 white(); 221 } 169 c = b.charCodeAt(); 170 return '\\u00' + 171 Math.floor(c / 16).toString(16) + 172 (c % 16).toString(16); 173 }) + '"'; 222 174 } 223 error("Bad array"); 224 } 225 226 function object() { 227 var k, o = {}; 228 229 if (ch == '{') { 230 next(); 231 white(); 232 if (ch == '}') { 233 next(); 234 return o; 235 } 236 while (ch) { 237 k = string(); 238 white(); 239 if (ch != ':') { 240 break; 241 } 242 next(); 243 o[k] = value(); 244 white(); 245 if (ch == '}') { 246 next(); 247 return o; 248 } else if (ch != ',') { 249 break; 250 } 251 next(); 252 white(); 253 } 254 } 255 error("Bad object"); 256 } 257 258 function number() { 259 var n = '', v; 260 261 if (ch == '-') { 262 n = '-'; 263 next(); 264 } 265 while (ch >= '0' && ch <= '9') { 266 n += ch; 267 next(); 268 } 269 if (ch == '.') { 270 n += '.'; 271 while (next() && ch >= '0' && ch <= '9') { 272 n += ch; 273 } 274 } 275 v = +n; 276 if (!isFinite(v)) { 277 error("Bad number"); 278 } else { 279 return v; 280 } 281 } 282 283 function word() { 284 switch (ch) { 285 case 't': 286 if (next() == 'r' && next() == 'u' && next() == 'e') { 287 next(); 288 return true; 289 } 290 break; 291 case 'f': 292 if (next() == 'a' && next() == 'l' && next() == 's' && 293 next() == 'e') { 294 next(); 295 return false; 296 } 297 break; 298 case 'n': 299 if (next() == 'u' && next() == 'l' && next() == 'l') { 300 next(); 301 &n
