Changeset 17679
- Timestamp:
- 04/21/2011 10:21:27 PM (13 years ago)
- Location:
- trunk/wp-includes
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/js/json2.dev.js
r11911 r17679 1 1 /* 2 2 http://www.JSON.org/json2.js 3 20 09-08-173 2011-02-23 4 4 5 5 Public Domain. … … 8 8 9 9 See http://www.JSON.org/js.html 10 11 12 This code should be minified before deployment. 13 See http://javascript.crockford.com/jsmin.html 14 15 USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO 16 NOT CONTROL. 17 10 18 11 19 This file creates a global JSON object containing two methods: stringify … … 137 145 This is a reference implementation. You are free to copy, modify, or 138 146 redistribute. 139 140 This code should be minified before deployment.141 See http://javascript.crockford.com/jsmin.html142 143 USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO144 NOT CONTROL.145 147 */ 146 148 147 /*jslint evil: true */149 /*jslint evil: true, strict: false, regexp: false */ 148 150 149 151 /*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply, … … 154 156 */ 155 157 156 "use strict";157 158 158 159 // Create a JSON object only if one does not already exist. We create the 159 160 // methods in a closure to avoid creating global variables. 160 161 161 if (!this.JSON) { 162 this.JSON = {}; 162 var JSON; 163 if (!JSON) { 164 JSON = {}; 163 165 } 164 166 165 167 (function () { 168 "use strict"; 166 169 167 170 function f(n) { … … 175 178 176 179 return isFinite(this.valueOf()) ? 177 this.getUTCFullYear()+ '-' +178 179 180 181 182 180 this.getUTCFullYear() + '-' + 181 f(this.getUTCMonth() + 1) + '-' + 182 f(this.getUTCDate()) + 'T' + 183 f(this.getUTCHours()) + ':' + 184 f(this.getUTCMinutes()) + ':' + 185 f(this.getUTCSeconds()) + 'Z' : null; 183 186 }; 184 187 185 String.prototype.toJSON =186 Number.prototype.toJSON=187 Boolean.prototype.toJSON = function (key) {188 return this.valueOf();189 };188 String.prototype.toJSON = 189 Number.prototype.toJSON = 190 Boolean.prototype.toJSON = function (key) { 191 return this.valueOf(); 192 }; 190 193 } 191 194 … … 214 217 215 218 escapable.lastIndex = 0; 216 return escapable.test(string) ? 217 '"' + string.replace(escapable, function (a) { 218 var c = meta[a]; 219 return typeof c === 'string' ? c : 220 '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); 221 }) + '"' : 222 '"' + string + '"'; 219 return escapable.test(string) ? '"' + string.replace(escapable, function (a) { 220 var c = meta[a]; 221 return typeof c === 'string' ? c : 222 '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); 223 }) + '"' : '"' + string + '"'; 223 224 } 224 225 … … 303 304 // brackets. 304 305 305 v = partial.length === 0 ? '[]' : 306 gap ? '[\n' + gap + 307 partial.join(',\n' + gap) + '\n' + 308 mind + ']' : 309 '[' + partial.join(',') + ']'; 306 v = partial.length === 0 ? '[]' : gap ? 307 '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' : 308 '[' + partial.join(',') + ']'; 310 309 gap = mind; 311 310 return v; … … 317 316 length = rep.length; 318 317 for (i = 0; i < length; i += 1) { 319 k = rep[i];320 if (typeof k === 'string') {318 if (typeof rep[i] === 'string') { 319 k = rep[i]; 321 320 v = str(k, value); 322 321 if (v) { … … 330 329 331 330 for (k in value) { 332 if (Object. hasOwnProperty.call(value, k)) {331 if (Object.prototype.hasOwnProperty.call(value, k)) { 333 332 v = str(k, value); 334 333 if (v) { … … 342 341 // and wrap them in braces. 343 342 344 v = partial.length === 0 ? '{}' : 345 gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' +346 mind + '}' :'{' + partial.join(',') + '}';343 v = partial.length === 0 ? '{}' : gap ? 344 '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' : 345 '{' + partial.join(',') + '}'; 347 346 gap = mind; 348 347 return v; … … 385 384 if (replacer && typeof replacer !== 'function' && 386 385 (typeof replacer !== 'object' || 387 386 typeof replacer.length !== 'number')) { 388 387 throw new Error('JSON.stringify'); 389 388 } … … 415 414 if (value && typeof value === 'object') { 416 415 for (k in value) { 417 if (Object. hasOwnProperty.call(value, k)) {416 if (Object.prototype.hasOwnProperty.call(value, k)) { 418 417 v = walk(value, k); 419 418 if (v !== undefined) { … … 433 432 // incorrectly, either silently deleting them, or treating them as line endings. 434 433 434 text = String(text); 435 435 cx.lastIndex = 0; 436 436 if (cx.test(text)) { … … 454 454 // ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval. 455 455 456 if (/^[\],:{}\s]*$/ .457 test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@'). 458 replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']'). 459 replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {456 if (/^[\],:{}\s]*$/ 457 .test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@') 458 .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']') 459 .replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) { 460 460 461 461 // In the third stage we use the eval function to compile the text into a … … 479 479 } 480 480 }()); 481 -
trunk/wp-includes/js/json2.js
r17286 r17679 1 "use strict";if(!this.JSON){this.JSON={}}(function(){function f(n){return n<10?"0"+n:n}if(typeof Date.prototype.toJSON!=="function"){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf()}}var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==="string"?c:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+string+'"'}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==="object"&&typeof value.toJSON==="function"){value=value.toJSON(key)}if(typeof rep==="function"){value=rep.call(holder,key,value)}switch(typeof value){case"string":return quote(value);case"number":return isFinite(value)?String(value):"null";case"boolean":case"null":return String(value);case"object":if(!value){return"null"}gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==="[object Array]"){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||"null"}v=partial.length===0?"[]":gap?"[\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"]":"["+partial.join(",")+"]";gap=mind;return v}if(rep&&typeof rep==="object"){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==="string"){v=str(k,value);if(v){partial.push(quote(k)+(gap?": ":":")+v)}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?": ":":")+v)}}}}v=partial.length===0?"{}":gap?"{\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"}":"{"+partial.join(",")+"}";gap=mind;return v}}if(typeof JSON.stringify!=="function"){JSON.stringify=function(value,replacer,space){var i;gap="";indent="";if(typeof space==="number"){for(i=0;i<space;i+=1){indent+=" "}}else{if(typeof space==="string"){indent=space}}rep=replacer;if(replacer&&typeof replacer!=="function"&&(typeof replacer!=="object"||typeof replacer.length!=="number")){throw new Error("JSON.stringify")}return str("",{"":value})}}if(typeof JSON.parse!=="function"){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==="object"){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v}else{delete value[k]}}}}return reviver.call(holder,key,value)}cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})}if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){j=eval("("+text+")");return typeof reviver==="function"?walk({"":j},""):j}throw new SyntaxError("JSON.parse")}}}());1 var JSON;if(!JSON){JSON={}}(function(){function f(n){return n<10?"0"+n:n}if(typeof Date.prototype.toJSON!=="function"){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf()}}var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==="string"?c:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+string+'"'}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==="object"&&typeof value.toJSON==="function"){value=value.toJSON(key)}if(typeof rep==="function"){value=rep.call(holder,key,value)}switch(typeof value){case"string":return quote(value);case"number":return isFinite(value)?String(value):"null";case"boolean":case"null":return String(value);case"object":if(!value){return"null"}gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==="[object Array]"){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||"null"}v=partial.length===0?"[]":gap?"[\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"]":"["+partial.join(",")+"]";gap=mind;return v}if(rep&&typeof rep==="object"){length=rep.length;for(i=0;i<length;i+=1){if(typeof rep[i]==="string"){k=rep[i];v=str(k,value);if(v){partial.push(quote(k)+(gap?": ":":")+v)}}}}else{for(k in value){if(Object.prototype.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?": ":":")+v)}}}}v=partial.length===0?"{}":gap?"{\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"}":"{"+partial.join(",")+"}";gap=mind;return v}}if(typeof JSON.stringify!=="function"){JSON.stringify=function(value,replacer,space){var i;gap="";indent="";if(typeof space==="number"){for(i=0;i<space;i+=1){indent+=" "}}else{if(typeof space==="string"){indent=space}}rep=replacer;if(replacer&&typeof replacer!=="function"&&(typeof replacer!=="object"||typeof replacer.length!=="number")){throw new Error("JSON.stringify")}return str("",{"":value})}}if(typeof JSON.parse!=="function"){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==="object"){for(k in value){if(Object.prototype.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v}else{delete value[k]}}}}return reviver.call(holder,key,value)}text=String(text);cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})}if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){j=eval("("+text+")");return typeof reviver==="function"?walk({"":j},""):j}throw new SyntaxError("JSON.parse")}}}()); -
trunk/wp-includes/script-loader.php
r17662 r17679 244 244 $scripts->add( 'comment-reply', "/wp-includes/js/comment-reply$suffix.js", false, '20090102'); 245 245 246 $scripts->add( 'json2', "/wp-includes/js/json2$suffix.js", false, '2011 0113');246 $scripts->add( 'json2', "/wp-includes/js/json2$suffix.js", false, '2011-02-23'); 247 247 248 248 $scripts->add( 'imgareaselect', "/wp-includes/js/imgareaselect/jquery.imgareaselect$suffix.js", array('jquery'), '0.9.1-20110113' );
Note: See TracChangeset
for help on using the changeset viewer.