commit c19be7d8adc0f214048e8aaf5cd583ec249a53c1
parent 7b8db1f09fc4f14f0a5b20743cf879e6b5bf45bb
Author: Dan Stillman <dstillman@zotero.org>
Date: Fri, 13 Nov 2009 07:06:14 +0000
Copy in json.org unserialize() so JSON.parse() works in Fx3
Diffstat:
2 files changed, 36 insertions(+), 2 deletions(-)
diff --git a/translators/ARTstor.js b/translators/ARTstor.js
@@ -8,7 +8,7 @@
"maxVersion":"",
"priority":100,
"inRepository":true,
- "lastUpdated":"2009-11-13 04:15:00"
+ "lastUpdated":"2009-11-13 07:10:00"
}
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){
var savedItems = new Array();
var saved = 0;
diff --git a/translators/National Library of Australia (new catalog).js b/translators/National Library of Australia (new catalog).js
@@ -8,7 +8,7 @@
"maxVersion":"",
"priority":100,
"inRepository":true,
- "lastUpdated":"2009-11-13 04:15:00"
+ "lastUpdated":"2009-11-13 07:10:00"
}
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) {
var metadata = JSON.parse(Zotero.Utilities.trimInternal(responseText));
var bibid = url.match("^.*\/Record/([0-9]+)")[1];