From 78a88f749f0ae1854c13c6df884612a818218150 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 17 Dec 2009 09:25:43 +0000 Subject: [PATCH] Pushed Google Books --- translators/Google Books.js | 66 ++++++++++++++++++++++++++----------- 1 file changed, 47 insertions(+), 19 deletions(-) diff --git a/translators/Google Books.js b/translators/Google Books.js index 000448c08..d82c5e36f 100644 --- a/translators/Google Books.js +++ b/translators/Google Books.js @@ -8,7 +8,7 @@ "maxVersion":"", "priority":100, "inRepository":true, - "lastUpdated":"2009-09-20 03:15:00" + "lastUpdated":"2009-12-17 08:15:00" } @@ -39,8 +39,9 @@ function doWeb(doc, url) { if(m) { newUris.push("http://books.google.com/books/feeds/volumes/"+m[2]); } else { - var items = getItemArrayGB(doc, doc, 'http://'+prefix+'\\.google\\.' + suffix + '/books\\?id=([^&]+)', '^(?:All matching pages|About this Book|Table of Contents|Index)'); + var items = getItemArrayGB(doc, doc, 'google\\.' + suffix + '/books\\?id=([^&]+)', '^(?:All matching pages|About this Book|Table of Contents|Index)'); // Drop " - Page" thing + //Zotero.debug(items); for(var i in items) { items[i] = items[i].replace(/- Page [0-9]+\s*$/, ""); } @@ -112,7 +113,7 @@ function doWeb(doc, url) { } /** - * Grabs items based on URLs + * Grabs items based on URLs, modified for Google Books * * @param {Document} doc DOM document object * @param {Element|Element[]} inHere DOM element(s) to process @@ -122,6 +123,11 @@ function doWeb(doc, url) { * Zotero.selectItems from within a translator */ function getItemArrayGB (doc, inHere, urlRe, rejectRe) { + var namespace = doc.documentElement.namespaceURI; + var nsResolver = namespace ? function(prefix) { + if (prefix == 'x') return namespace; else return null; + } : null; + var availableItems = new Object(); // Technically, associative arrays are objects // Require link to match this @@ -148,23 +154,45 @@ function getItemArrayGB (doc, inHere, urlRe, rejectRe) { } for(var j=0; j-elements, scrape title from alt-attribute, href-link from parent -element + for(var i=0; i