From b3da19e96df1b0e0f0db49984dc897051db9037c Mon Sep 17 00:00:00 2001 From: aurimasv Date: Mon, 30 Dec 2013 23:00:56 -0600 Subject: [PATCH] [Retrieve Metadata] Recognize HTTP 503 code as Google Scholar CAPTCHA + other tweaks. * Stop metadata retrieval when cancelled * Display CAPTCHA dialog * Don't close window on blur * Use Zotero.Utilities.cleanISBN to validate ISBNs --- chrome/content/zotero/captcha.js | 52 ++++++ chrome/content/zotero/captcha.xul | 21 +++ chrome/content/zotero/recognizePDF.js | 168 +++++++++++++------ chrome/locale/en-US/zotero/zotero.dtd | 4 + chrome/locale/en-US/zotero/zotero.properties | 2 +- 5 files changed, 199 insertions(+), 48 deletions(-) create mode 100644 chrome/content/zotero/captcha.js create mode 100644 chrome/content/zotero/captcha.xul diff --git a/chrome/content/zotero/captcha.js b/chrome/content/zotero/captcha.js new file mode 100644 index 000000000..72432cd64 --- /dev/null +++ b/chrome/content/zotero/captcha.js @@ -0,0 +1,52 @@ +/* + ***** BEGIN LICENSE BLOCK ***** + + Copyright © 2009 Center for History and New Media + George Mason University, Fairfax, Virginia, USA + http://zotero.org + + This file is part of Zotero. + + Zotero is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Zotero is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with Zotero. If not, see . + + ***** END LICENSE BLOCK ***** +*/ + +var Zotero_Captcha = new function() { + this._io; + + this.onLoad = function() { + this._io = window.arguments[0]; + document.getElementById('zotero-captcha-image').src = this._io.dataIn.imgUrl; + document.getElementById('zotero-captcha-input').focus(); + } + + this.imageOnLoad = function() { + window.sizeToContent(); + } + + this.resolve = function() { + var result = document.getElementById('zotero-captcha-input'); + if(!result.value) return; + + this._io.dataOut = { + captcha: result.value + }; + window.close(); + } + + this.cancel = function() { + window.close(); + } +} \ No newline at end of file diff --git a/chrome/content/zotero/captcha.xul b/chrome/content/zotero/captcha.xul new file mode 100644 index 000000000..3893b7b7f --- /dev/null +++ b/chrome/content/zotero/captcha.xul @@ -0,0 +1,21 @@ + + + + + + +