(trunk web) migrate from json.js to json2.js. <http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/>
This commit is contained in:
parent
e6b8b0339e
commit
dd2033107f
|
@ -25,7 +25,7 @@
|
||||||
<script type="text/javascript" src="./javascript/jquery/jquery.contextmenu.min.js"></script>
|
<script type="text/javascript" src="./javascript/jquery/jquery.contextmenu.min.js"></script>
|
||||||
<script type="text/javascript" src="./javascript/menu.js"></script>
|
<script type="text/javascript" src="./javascript/menu.js"></script>
|
||||||
<script type="text/javascript" src="./javascript/jquery/jquery.form.min.js"></script>
|
<script type="text/javascript" src="./javascript/jquery/jquery.form.min.js"></script>
|
||||||
<script type="text/javascript" src="./javascript/jquery/json.min.js"></script>
|
<script type="text/javascript" src="./javascript/jquery/json2.min.js"></script>
|
||||||
<script type="text/javascript" src="./javascript/common.js"></script>
|
<script type="text/javascript" src="./javascript/common.js"></script>
|
||||||
<script type="text/javascript" src="./javascript/transmission.remote.js"></script>
|
<script type="text/javascript" src="./javascript/transmission.remote.js"></script>
|
||||||
<script type="text/javascript" src="./javascript/transmission.js"></script>
|
<script type="text/javascript" src="./javascript/transmission.js"></script>
|
||||||
|
|
|
@ -5,4 +5,4 @@ dist_data_DATA = \
|
||||||
jquery.form.js \
|
jquery.form.js \
|
||||||
jquery.form.min.js \
|
jquery.form.min.js \
|
||||||
jquery.transmenu.min.js \
|
jquery.transmenu.min.js \
|
||||||
json.min.js
|
json2.min.js
|
||||||
|
|
|
@ -1,96 +0,0 @@
|
||||||
(function ($) {
|
|
||||||
var m = {
|
|
||||||
'\b': '\\b',
|
|
||||||
'\t': '\\t',
|
|
||||||
'\n': '\\n',
|
|
||||||
'\f': '\\f',
|
|
||||||
'\r': '\\r',
|
|
||||||
'"' : '\\"',
|
|
||||||
'\\': '\\\\'
|
|
||||||
},
|
|
||||||
s = {
|
|
||||||
'array': function (x) {
|
|
||||||
var a = ['['], b, f, i, l = x.length, v;
|
|
||||||
for (i = 0; i < l; i += 1) {
|
|
||||||
v = x[i];
|
|
||||||
f = s[typeof v];
|
|
||||||
if (f) {
|
|
||||||
v = f(v);
|
|
||||||
if (typeof v == 'string') {
|
|
||||||
if (b) {
|
|
||||||
a[a.length] = ',';
|
|
||||||
}
|
|
||||||
a[a.length] = v;
|
|
||||||
b = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
a[a.length] = ']';
|
|
||||||
return a.join('');
|
|
||||||
},
|
|
||||||
'boolean': function (x) {
|
|
||||||
return String(x);
|
|
||||||
},
|
|
||||||
'null': function (x) {
|
|
||||||
return "null";
|
|
||||||
},
|
|
||||||
'number': function (x) {
|
|
||||||
return isFinite(x) ? String(x) : 'null';
|
|
||||||
},
|
|
||||||
'object': function (x) {
|
|
||||||
if (x) {
|
|
||||||
if (x instanceof Array) {
|
|
||||||
return s.array(x);
|
|
||||||
}
|
|
||||||
var a = ['{'], b, f, i, v;
|
|
||||||
for (i in x) {
|
|
||||||
v = x[i];
|
|
||||||
f = s[typeof v];
|
|
||||||
if (f) {
|
|
||||||
v = f(v);
|
|
||||||
if (typeof v == 'string') {
|
|
||||||
if (b) {
|
|
||||||
a[a.length] = ',';
|
|
||||||
}
|
|
||||||
a.push(s.string(i), ':', v);
|
|
||||||
b = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
a[a.length] = '}';
|
|
||||||
return a.join('');
|
|
||||||
}
|
|
||||||
return 'null';
|
|
||||||
},
|
|
||||||
'string': function (x) {
|
|
||||||
if (/["\\\x00-\x1f]/.test(x)) {
|
|
||||||
x = x.replace(/([\x00-\x1f\\"])/g, function(a, b) {
|
|
||||||
var c = m[b];
|
|
||||||
if (c) {
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
c = b.charCodeAt();
|
|
||||||
return '\\u00' +
|
|
||||||
Math.floor(c / 16).toString(16) +
|
|
||||||
(c % 16).toString(16);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return '"' + x + '"';
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
$.toJSON = function(v) {
|
|
||||||
var f = isNaN(v) ? s[typeof v] : s['number'];
|
|
||||||
if (f) return f(v);
|
|
||||||
};
|
|
||||||
|
|
||||||
$.parseJSON = function(v, safe) {
|
|
||||||
if (safe === undefined) safe = $.parseJSON.safe;
|
|
||||||
if (safe && !/^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/.test(v))
|
|
||||||
return undefined;
|
|
||||||
return eval('('+v+')');
|
|
||||||
};
|
|
||||||
|
|
||||||
$.parseJSON.safe = false;
|
|
||||||
|
|
||||||
})(jQuery);
|
|
|
@ -1,13 +0,0 @@
|
||||||
|
|
||||||
(function($){var m={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},s={'array':function(x){var a=['['],b,f,i,l=x.length,v;for(i=0;i<l;i+=1){v=x[i];f=s[typeof v];if(f){v=f(v);if(typeof v=='string'){if(b){a[a.length]=',';}
|
|
||||||
a[a.length]=v;b=true;}}}
|
|
||||||
a[a.length]=']';return a.join('');},'boolean':function(x){return String(x);},'null':function(x){return"null";},'number':function(x){return isFinite(x)?String(x):'null';},'object':function(x){if(x){if(x instanceof Array){return s.array(x);}
|
|
||||||
var a=['{'],b,f,i,v;for(i in x){v=x[i];f=s[typeof v];if(f){v=f(v);if(typeof v=='string'){if(b){a[a.length]=',';}
|
|
||||||
a.push(s.string(i),':',v);b=true;}}}
|
|
||||||
a[a.length]='}';return a.join('');}
|
|
||||||
return'null';},'string':function(x){if(/["\\\x00-\x1f]/.test(x)){x=x.replace(/([\x00-\x1f\\"])/g,function(a,b){var c=m[b];if(c){return c;}
|
|
||||||
c=b.charCodeAt();return'\\u00'+
|
|
||||||
Math.floor(c/16).toString(16)+
|
|
||||||
(c%16).toString(16);});}
|
|
||||||
return'"'+x+'"';}};$.toJSON=function(v){var f=isNaN(v)?s[typeof v]:s['number'];if(f)return f(v);};$.parseJSON=function(v,safe){if(safe===undefined)safe=$.parseJSON.safe;if(safe&&!/^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/.test(v))
|
|
||||||
return undefined;return eval('('+v+')');};$.parseJSON.safe=false;})(jQuery);
|
|
|
@ -1,7 +1,6 @@
|
||||||
alert('IMPORTANT: Remove this line from json2.js before deployment.');
|
|
||||||
/*
|
/*
|
||||||
http://www.JSON.org/json2.js
|
http://www.JSON.org/json2.js
|
||||||
2010-08-25
|
2011-02-23
|
||||||
|
|
||||||
Public Domain.
|
Public Domain.
|
||||||
|
|
||||||
|
@ -147,7 +146,7 @@ alert('IMPORTANT: Remove this line from json2.js before deployment.');
|
||||||
redistribute.
|
redistribute.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*jslint evil: true, strict: false */
|
/*jslint evil: true, strict: false, regexp: false */
|
||||||
|
|
||||||
/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
|
/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
|
||||||
call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
|
call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
|
||||||
|
@ -160,11 +159,13 @@ alert('IMPORTANT: Remove this line from json2.js before deployment.');
|
||||||
// Create a JSON object only if one does not already exist. We create the
|
// Create a JSON object only if one does not already exist. We create the
|
||||||
// methods in a closure to avoid creating global variables.
|
// methods in a closure to avoid creating global variables.
|
||||||
|
|
||||||
if (!this.JSON) {
|
var JSON;
|
||||||
this.JSON = {};
|
if (!JSON) {
|
||||||
|
JSON = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
function f(n) {
|
function f(n) {
|
||||||
// Format integers to have at least two digits.
|
// Format integers to have at least two digits.
|
||||||
|
@ -215,13 +216,11 @@ if (!this.JSON) {
|
||||||
// sequences.
|
// sequences.
|
||||||
|
|
||||||
escapable.lastIndex = 0;
|
escapable.lastIndex = 0;
|
||||||
return escapable.test(string) ?
|
return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
|
||||||
'"' + string.replace(escapable, function (a) {
|
|
||||||
var c = meta[a];
|
var c = meta[a];
|
||||||
return typeof c === 'string' ? c :
|
return typeof c === 'string' ? c :
|
||||||
'\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
|
'\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
|
||||||
}) + '"' :
|
}) + '"' : '"' + string + '"';
|
||||||
'"' + string + '"';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -304,10 +303,8 @@ if (!this.JSON) {
|
||||||
// Join all of the elements together, separated with commas, and wrap them in
|
// Join all of the elements together, separated with commas, and wrap them in
|
||||||
// brackets.
|
// brackets.
|
||||||
|
|
||||||
v = partial.length === 0 ? '[]' :
|
v = partial.length === 0 ? '[]' : gap ?
|
||||||
gap ? '[\n' + gap +
|
'[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' :
|
||||||
partial.join(',\n' + gap) + '\n' +
|
|
||||||
mind + ']' :
|
|
||||||
'[' + partial.join(',') + ']';
|
'[' + partial.join(',') + ']';
|
||||||
gap = mind;
|
gap = mind;
|
||||||
return v;
|
return v;
|
||||||
|
@ -318,8 +315,8 @@ if (!this.JSON) {
|
||||||
if (rep && typeof rep === 'object') {
|
if (rep && typeof rep === 'object') {
|
||||||
length = rep.length;
|
length = rep.length;
|
||||||
for (i = 0; i < length; i += 1) {
|
for (i = 0; i < length; i += 1) {
|
||||||
|
if (typeof rep[i] === 'string') {
|
||||||
k = rep[i];
|
k = rep[i];
|
||||||
if (typeof k === 'string') {
|
|
||||||
v = str(k, value);
|
v = str(k, value);
|
||||||
if (v) {
|
if (v) {
|
||||||
partial.push(quote(k) + (gap ? ': ' : ':') + v);
|
partial.push(quote(k) + (gap ? ': ' : ':') + v);
|
||||||
|
@ -331,7 +328,7 @@ if (!this.JSON) {
|
||||||
// Otherwise, iterate through all of the keys in the object.
|
// Otherwise, iterate through all of the keys in the object.
|
||||||
|
|
||||||
for (k in value) {
|
for (k in value) {
|
||||||
if (Object.hasOwnProperty.call(value, k)) {
|
if (Object.prototype.hasOwnProperty.call(value, k)) {
|
||||||
v = str(k, value);
|
v = str(k, value);
|
||||||
if (v) {
|
if (v) {
|
||||||
partial.push(quote(k) + (gap ? ': ' : ':') + v);
|
partial.push(quote(k) + (gap ? ': ' : ':') + v);
|
||||||
|
@ -343,9 +340,9 @@ if (!this.JSON) {
|
||||||
// Join all of the member texts together, separated with commas,
|
// Join all of the member texts together, separated with commas,
|
||||||
// and wrap them in braces.
|
// and wrap them in braces.
|
||||||
|
|
||||||
v = partial.length === 0 ? '{}' :
|
v = partial.length === 0 ? '{}' : gap ?
|
||||||
gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' +
|
'{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' :
|
||||||
mind + '}' : '{' + partial.join(',') + '}';
|
'{' + partial.join(',') + '}';
|
||||||
gap = mind;
|
gap = mind;
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
@ -416,7 +413,7 @@ if (!this.JSON) {
|
||||||
var k, v, value = holder[key];
|
var k, v, value = holder[key];
|
||||||
if (value && typeof value === 'object') {
|
if (value && typeof value === 'object') {
|
||||||
for (k in value) {
|
for (k in value) {
|
||||||
if (Object.hasOwnProperty.call(value, k)) {
|
if (Object.prototype.hasOwnProperty.call(value, k)) {
|
||||||
v = walk(value, k);
|
v = walk(value, k);
|
||||||
if (v !== undefined) {
|
if (v !== undefined) {
|
||||||
value[k] = v;
|
value[k] = v;
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
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)}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")}}}());
|
var JSON;if(!JSON){JSON={}}(function(){function str(a,b){var c,d,e,f,g=gap,h,i=b[a];if(i&&typeof i==="object"&&typeof i.toJSON==="function"){i=i.toJSON(a)}if(typeof rep==="function"){i=rep.call(b,a,i)}switch(typeof i){case"string":return quote(i);case"number":return isFinite(i)?String(i):"null";case"boolean":case"null":return String(i);case"object":if(!i){return"null"}gap+=indent;h=[];if(Object.prototype.toString.apply(i)==="[object Array]"){f=i.length;for(c=0;c<f;c+=1){h[c]=str(c,i)||"null"}e=h.length===0?"[]":gap?"[\n"+gap+h.join(",\n"+gap)+"\n"+g+"]":"["+h.join(",")+"]";gap=g;return e}if(rep&&typeof rep==="object"){f=rep.length;for(c=0;c<f;c+=1){if(typeof rep[c]==="string"){d=rep[c];e=str(d,i);if(e){h.push(quote(d)+(gap?": ":":")+e)}}}}else{for(d in i){if(Object.prototype.hasOwnProperty.call(i,d)){e=str(d,i);if(e){h.push(quote(d)+(gap?": ":":")+e)}}}}e=h.length===0?"{}":gap?"{\n"+gap+h.join(",\n"+gap)+"\n"+g+"}":"{"+h.join(",")+"}";gap=g;return e}}function quote(a){escapable.lastIndex=0;return escapable.test(a)?'"'+a.replace(escapable,function(a){var b=meta[a];return typeof b==="string"?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function f(a){return a<10?"0"+a:a}"use strict";if(typeof Date.prototype.toJSON!=="function"){Date.prototype.toJSON=function(a){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(a){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;if(typeof JSON.stringify!=="function"){JSON.stringify=function(a,b,c){var d;gap="";indent="";if(typeof c==="number"){for(d=0;d<c;d+=1){indent+=" "}}else if(typeof c==="string"){indent=c}rep=b;if(b&&typeof b!=="function"&&(typeof b!=="object"||typeof b.length!=="number")){throw new Error("JSON.stringify")}return str("",{"":a})}}if(typeof JSON.parse!=="function"){JSON.parse=function(text,reviver){function walk(a,b){var c,d,e=a[b];if(e&&typeof e==="object"){for(c in e){if(Object.prototype.hasOwnProperty.call(e,c)){d=walk(e,c);if(d!==undefined){e[c]=d}else{delete e[c]}}}}return reviver.call(a,b,e)}var j;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")}}})()
|
||||||
|
|
|
@ -107,7 +107,7 @@ TransmissionRemote.prototype =
|
||||||
contentType: 'json',
|
contentType: 'json',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
cache: false,
|
cache: false,
|
||||||
data: $.toJSON(data),
|
data: JSON.stringify(data),
|
||||||
beforeSend: function(XHR){ remote.appendSessionId(XHR); },
|
beforeSend: function(XHR){ remote.appendSessionId(XHR); },
|
||||||
error: function(request, error_string, exception){ remote.ajaxError(request, error_string, exception, ajaxSettings); },
|
error: function(request, error_string, exception){ remote.ajaxError(request, error_string, exception, ajaxSettings); },
|
||||||
success: callback,
|
success: callback,
|
||||||
|
|
Loading…
Reference in New Issue