Skip to content

Commit

Permalink
remove unnecessary spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
aborel committed Mar 20, 2024
1 parent a6a6dea commit 47119d5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/locale/en-US/zotero-ocr.ftl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ocr-selected-pdfs =
.label = OCR selected PDF(s)
ocr-preferences =
ocr-preferences =
.label = Zotero OCR Preferences
30 changes: 14 additions & 16 deletions src/zotero-ocr.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@ ZoteroOCR = {
rootURI: null,
initialized: false,
addedElementIDs: [],

init({ id, version, rootURI }) {
if (this.initialized) return;
this.id = id;
this.version = version;
this.rootURI = rootURI;
this.initialized = true;
},

log(msg) {
Zotero.debug("ZoteroOCR: " + msg);
},

addToWindow(window) {
let doc = window.document;

// Use Fluent for localization
window.MozXULElement.insertFTLIfNeeded("zotero-ocr.ftl");

// Add menu option
let menuitem = doc.createXULElement('menuitem');
menuitem.id = 'ocr-selected-pdfs';
Expand Down Expand Up @@ -67,22 +67,22 @@ ZoteroOCR = {
}));
*/
},

addToAllWindows() {
var windows = Zotero.getMainWindows();
for (let win of windows) {
if (!win.ZoteroPane) continue;
this.addToWindow(win);
}
},

storeAddedElement(elem) {
if (!elem.id) {
throw new Error("Element must have an id");
}
this.addedElementIDs.push(elem.id);
},

removeFromWindow(window) {
var doc = window.document;
// Remove all elements added to DOM
Expand All @@ -91,15 +91,15 @@ ZoteroOCR = {
}
doc.querySelector('[href="zotero-ocr.ftl"]').remove();
},

removeFromAllWindows() {
var windows = Zotero.getMainWindows();
for (let win of windows) {
if (!win.ZoteroPane) continue;
this.removeFromWindow(win);
}
},

async recognize(window) {

// Look for the tesseract executable in the settings and at commonly used locations.
Expand Down Expand Up @@ -221,7 +221,6 @@ ZoteroOCR = {
Zotero.logError(e);
}


var iterator = new OS.File.DirectoryIterator(dir);
var imageListArray = [];
await iterator.forEach(function onEntry(entry) {
Expand All @@ -232,7 +231,7 @@ ZoteroOCR = {
});
Zotero.debug('Files are now:')
Zotero.debug(imageListArray);

// save the list of images in a separate file
Zotero.File.putContents(Zotero.File.pathToFile(imageList), imageListArray.join('\n'));

Expand Down Expand Up @@ -267,7 +266,7 @@ ZoteroOCR = {
newNote.parentID = item.id;
await newNote.saveTx();
}

if (Zotero.Prefs.get("zoteroocr.outputHocr")) {
let contents = await Zotero.File.getContentsAsync(ocrbase + '.hocr');
// replace the absolute paths of images with relative ones
Expand Down Expand Up @@ -304,7 +303,7 @@ ZoteroOCR = {
parentItemID: item.id
});
}

if (!Zotero.Prefs.get("zoteroocr.outputPNG") && imageListArray) {
// delete image list
await Zotero.File.removeIfExists(imageList);
Expand All @@ -315,10 +314,9 @@ ZoteroOCR = {
}
}
},

async main() {
// Global properties are included automatically in Zotero 7
var host = new URL('https://foo.com/path').host;

},
};

0 comments on commit 47119d5

Please sign in to comment.