[web/data] Remove broken jquery-json plugin (closes #3590335)
Conversion of Date() objects is somehow broken (don't know why beyond that it's
due to jquery-json's monkeypatched Date.toJSON() method).
Use the now-standard JSON.stringify() instead. http://caniuse.com/#feat=json
says it's supported by all browsers, and even IE going back to version 8.
--- a/doc/tools/pyjsrest.py Mon Jan 27 14:02:21 2014 +0100
+++ b/doc/tools/pyjsrest.py Fri Mar 28 14:59:33 2014 +0100
@@ -142,7 +142,6 @@
FILES_TO_IGNORE = set([
'jquery.js',
'jquery.treeview.js',
- 'jquery.json.js',
'jquery.tablesorter.js',
'jquery.timePicker.js',
'jquery.flot.js',
--- a/web/data/cubicweb.ajax.js Mon Jan 27 14:02:21 2014 +0100
+++ b/web/data/cubicweb.ajax.js Fri Mar 28 14:59:33 2014 +0100
@@ -312,7 +312,7 @@
$.extend(form, {
'fname': fname,
'pageid': pageid,
- 'arg': $.map(cw.utils.sliceList(arguments, 2), jQuery.toJSON)
+ 'arg': $.map(cw.utils.sliceList(arguments, 2), JSON.stringify)
});
return form;
}
@@ -745,7 +745,7 @@
var props = {
fname: fname,
pageid: pageid,
- arg: $.map(cw.utils.sliceList(arguments, 1), jQuery.toJSON)
+ arg: $.map(cw.utils.sliceList(arguments, 1), JSON.stringify)
};
var result = jQuery.ajax({
url: AJAX_BASE_URL,
@@ -765,7 +765,7 @@
var props = {
fname: fname,
pageid: pageid,
- arg: $.map(cw.utils.sliceList(arguments, 1), jQuery.toJSON)
+ arg: $.map(cw.utils.sliceList(arguments, 1), JSON.stringify)
};
// XXX we should inline the content of loadRemote here
var deferred = loadRemote(AJAX_BASE_URL, props, 'POST');
--- a/web/data/cubicweb.edition.js Mon Jan 27 14:02:21 2014 +0100
+++ b/web/data/cubicweb.edition.js Fri Mar 28 14:59:33 2014 +0100
@@ -26,7 +26,7 @@
var args = {
fname: 'prop_widget',
pageid: pageid,
- arg: $.map([key, varname, tabindex], jQuery.toJSON)
+ arg: $.map([key, varname, tabindex], JSON.stringify)
};
cw.jqNode('div:value:' + varname).loadxhtml(AJAX_BASE_URL, args, 'post');
}
--- a/web/data/cubicweb.js Mon Jan 27 14:02:21 2014 +0100
+++ b/web/data/cubicweb.js Fri Mar 28 14:59:33 2014 +0100
@@ -384,7 +384,7 @@
*/
strFuncCall: function(fname /* ...*/) {
return (fname + '(' +
- $.map(cw.utils.sliceList(arguments, 1), jQuery.toJSON).join(',')
+ $.map(cw.utils.sliceList(arguments, 1), JSON.stringify).join(',')
+ ')'
);
}
--- a/web/data/jquery.json.js Mon Jan 27 14:02:21 2014 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-(function($){function toIntegersAtLease(n)
-{return n<10?'0'+n:n;}
-Date.prototype.toJSON=function(date)
-{return date.getUTCFullYear()+'-'+
-toIntegersAtLease(date.getUTCMonth()+1)+'-'+
-toIntegersAtLease(date.getUTCDate());};var escapeable=/["\\\x00-\x1f\x7f-\x9f]/g;var meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'}
-$.quoteString=function(string)
-{if(escapeable.test(string))
-{return'"'+string.replace(escapeable,function(a)
-{var c=meta[a];if(typeof c==='string'){return c;}
-c=a.charCodeAt();return'\\u00'+Math.floor(c/16).toString(16)+(c%16).toString(16);})+'"'}
-return'"'+string+'"';}
-$.toJSON=function(o)
-{var type=typeof(o);if(type=="undefined")
-return"undefined";else if(type=="number"||type=="boolean")
-return o+"";else if(o===null)
-return"null";if(type=="string")
-{return $.quoteString(o);}
-if(type=="object"&&typeof o.toJSON=="function")
-return o.toJSON();if(type!="function"&&typeof(o.length)=="number")
-{var ret=[];for(var i=0;i<o.length;i++){ret.push($.toJSON(o[i]));}
-return"["+ret.join(", ")+"]";}
-if(type=="function"){throw new TypeError("Unable to convert object of type 'function' to json.");}
-ret=[];for(var k in o){var name;var type=typeof(k);if(type=="number")
-name='"'+k+'"';else if(type=="string")
-name=$.quoteString(k);else
-continue;val=$.toJSON(o[k]);if(typeof(val)!="string"){continue;}
-ret.push(name+": "+val);}
-return"{"+ret.join(", ")+"}";}
-$.evalJSON=function(src)
-{return eval("("+src+")");}
-$.secureEvalJSON=function(src)
-{var filtered=src;filtered=filtered.replace(/\\["\\\/bfnrtu]/g,'@');filtered=filtered.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']');filtered=filtered.replace(/(?:^|:|,)(?:\s*\[)+/g,'');if(/^[\],:{}\s]*$/.test(filtered))
-return eval("("+src+")");else
-throw new SyntaxError("Error parsing JSON, source is not valid.");}})(jQuery);
\ No newline at end of file
--- a/web/data/uiprops.py Mon Jan 27 14:02:21 2014 +0100
+++ b/web/data/uiprops.py Fri Mar 28 14:59:33 2014 +0100
@@ -10,7 +10,6 @@
# Javascripts files to include systematically in HTML headers
JAVASCRIPTS = [data('jquery.js'),
data('jquery-migrate.js'),
- data('jquery.json.js'),
data('cubicweb.js'),
data('cubicweb.compat.js'),
data('cubicweb.python.js'),