diff --git a/chrome/content/zotero/xpcom/commons.js b/chrome/content/zotero/xpcom/commons.js index 2477a231f..9dc39748a 100644 --- a/chrome/content/zotero/xpcom/commons.js +++ b/chrome/content/zotero/xpcom/commons.js @@ -45,6 +45,30 @@ Zotero.Commons = new function() { return Zotero.Prefs.get("commons.secretKey"); }); + this.RDF_TRANSLATOR = { + 'label': 'Zotero RDF', + 'target': 'rdf', + 'translatorID': '14763d24-8ba0-45df-8f52-b8d1108e7ac9', + 'displayOptions': { + 'exportFileData': true, + 'exportNotes': true + } + }; + + this.RDF_IMPORT_TRANSLATOR = { + 'translatorID': '5e3ad958-ac79-463d-812b-a86a9235c28f', + } + + this.ERROR_BUCKET_EXISTS = 1; + + this.refreshNeeded = true; + + var _buckets = {}; + var _bucketsLoading = false; + var _bucketsLoaded = false; + var _requestingItems = false; + + this.getBuckets = function (callback) { if (!this.enabled) { return _buckets; @@ -148,30 +172,8 @@ Zotero.Commons = new function() { return _buckets; }; - this.RDF_TRANSLATOR = { - 'label': 'Zotero RDF', - 'target': 'rdf', - 'translatorID': '14763d24-8ba0-45df-8f52-b8d1108e7ac9', - 'displayOptions': { - 'exportFileData': true, - 'exportNotes': true - } - }; - - this.RDF_IMPORT_TRANSLATOR = { - 'translatorID': '5e3ad958-ac79-463d-812b-a86a9235c28f', - } - - this.ERROR_BUCKET_EXISTS = 1; - - this.refreshNeeded = true; - - var _buckets = {}; - var _bucketsLoading = false; - var _bucketsLoaded = false; - var _requestingItems = false; - + // outdated this.createBucket = function (item, onBucketQueued, onBucketCreated, waitForCreation) { var headers = { "x-archive-auto-make-bucket":"1", @@ -290,99 +292,6 @@ Zotero.Commons = new function() { } - this.getNewBucketName = function () { - return "zc-" + this.accessKey + "-" + Zotero.ID.getBigInt(9999999999); - } - - - this.getBucketFromItem = function (item) { - return this.getBucketFromItemID(item.id); - } - - - this.getBucketFromItemID = function (itemID) { - for each(var bucket in _buckets) { - if (bucket.item.id == itemID) { - return bucket; - } - } - return false; - } - - - this.uploadItems = function (ids) { - var items = Zotero.Items.get(ids); - if (!items) { - Zotero.debug("No items to upload"); - return; - } - - var itemsToUpload = false; - for (var i=0, len=items.length; i 1) { - throw ("Commons: More than one local item linked to remote bucket " + this.name); - } - var item = Zotero.URI.getURIItem(rels[0].subject); - if (!item) { - Zotero.debug("Linked local item not found for URI " + this.uri, 2); - return; - } - - // Get array of possible attachment names - var pdfFileNames = []; - var pdfTitles = []; - var ids = item.getAttachments(); - for each(var id in ids) { - var attachment = Zotero.Items.get(id); - var fileName = attachment.getFilename(); - if (!fileName || !fileName.match(/.+\.pdf$/)) { - continue; - } - pdfFileNames.push(fileName); - pdfTitles.push(attachment.getField('title')); - } - - if (this._requestingItems) { - throw ("Commons: Already requesting items for bucket"); - } - - this._requestingItems = true; - - var self = this; - - // Check for a full-text ("derived" in IA terms) OCRed version of the PDF, - // and if found add it as an attachment to the corresponding Zotero client item - Zotero.Utilities.HTTP.doGet(this.apiURI, function(xmlhttp) { - if (xmlhttp.status != 200) { - Zotero.debug(xmlhttp.status); - Zotero.debug(xmlhttp.responseText); - alert("Error loading data from the Internet Archive"); - self._requestingItems = false; - return; - } - - Zotero.debug(xmlhttp.responseText); - - // TODO: replace original PDF? - - var contents = xmlhttp.responseXML.getElementsByTagName("Contents"); - - // loop through files listed in bucket contents file - for(var i=0, len=contents.length; i