Copy in json.org unserialize() so JSON.parse() works in Fx3
This commit is contained in:
parent
7b8db1f09f
commit
c19be7d8ad
|
@ -8,7 +8,7 @@
|
||||||
"maxVersion":"",
|
"maxVersion":"",
|
||||||
"priority":100,
|
"priority":100,
|
||||||
"inRepository":true,
|
"inRepository":true,
|
||||||
"lastUpdated":"2009-11-13 04:15:00"
|
"lastUpdated":"2009-11-13 07:10:00"
|
||||||
}
|
}
|
||||||
|
|
||||||
function detectWeb(doc, url) {
|
function detectWeb(doc, url) {
|
||||||
|
@ -21,6 +21,23 @@ function doWeb(doc, url) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Remove this when we drop support for Fx3
|
||||||
|
if (!JSON) {
|
||||||
|
var JSON = new function() {
|
||||||
|
this.parse = function (arg) {
|
||||||
|
var j;
|
||||||
|
if (/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/.test(arg.
|
||||||
|
replace(/\\./g, '@').
|
||||||
|
replace(/"[^"\\\n\r]*"/g, ''))) {
|
||||||
|
// Friendly AMO reviewer: This is the official json.org library and is safe.
|
||||||
|
j = eval('(' + arg + ')');
|
||||||
|
return j;
|
||||||
|
}
|
||||||
|
throw new SyntaxError('parseJSON');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function scrape(doc, url){
|
function scrape(doc, url){
|
||||||
var savedItems = new Array();
|
var savedItems = new Array();
|
||||||
var saved = 0;
|
var saved = 0;
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
"maxVersion":"",
|
"maxVersion":"",
|
||||||
"priority":100,
|
"priority":100,
|
||||||
"inRepository":true,
|
"inRepository":true,
|
||||||
"lastUpdated":"2009-11-13 04:15:00"
|
"lastUpdated":"2009-11-13 07:10:00"
|
||||||
}
|
}
|
||||||
|
|
||||||
function detectWeb(doc, url) {
|
function detectWeb(doc, url) {
|
||||||
|
@ -59,6 +59,23 @@ function computeFormat(format){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Remove this when we drop support for Fx3
|
||||||
|
if (!JSON) {
|
||||||
|
var JSON = new function() {
|
||||||
|
this.parse = function (arg) {
|
||||||
|
var j;
|
||||||
|
if (/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/.test(arg.
|
||||||
|
replace(/\\./g, '@').
|
||||||
|
replace(/"[^"\\\n\r]*"/g, ''))) {
|
||||||
|
// Friendly AMO reviewer: This is the official json.org library and is safe.
|
||||||
|
j = eval('(' + arg + ')');
|
||||||
|
return j;
|
||||||
|
}
|
||||||
|
throw new SyntaxError('parseJSON');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function load_item(responseText, url, format) {
|
function load_item(responseText, url, format) {
|
||||||
var metadata = JSON.parse(Zotero.Utilities.trimInternal(responseText));
|
var metadata = JSON.parse(Zotero.Utilities.trimInternal(responseText));
|
||||||
var bibid = url.match("^.*\/Record/([0-9]+)")[1];
|
var bibid = url.match("^.*\/Record/([0-9]+)")[1];
|
||||||
|
|
Loading…
Reference in New Issue
Block a user