UB-Mannheim / zotero-ocr

Zotero Plugin for OCR
GNU Affero General Public License v3.0
553 stars 40 forks source link

Add preferences #10

Closed zuphilip closed 5 years ago

zuphilip commented 5 years ago

This solves #9 and also give an simple option for indicating another language as in #8.

However, the current behavior is very strange: The first time one can click on the "Zotero OCR Preferences" in the Tools menu and everything works find. But one cannot open the preferences a second time, there is an error showing up

[JavaScript Error: "NS_ERROR_NOT_AVAILABLE: " {file: "chrome://zoteroocr/content/zoteroocr.js" line: 11}]
Zotero.OCR</this.openPreferenceWindow@chrome://zoteroocr/content/zoteroocr.js:11:3
oncommand@chrome://zotero/content/standalone/standalone.xul:1:1

@dstillman: Have you any idea what this error message means exactly?

Moreover, we maybe want to give some default values to the preferences as long as they are not set differently. I have to check how this is usually done.

dstillman commented 5 years ago

You're running zoteroocr.js again in the prefs window, which tries to set Zotero.OCR even though it already exists on the global Zotero object provided by include.js. I'm not sure why that's resulting in this error, but you should be able to just drop the <script src="chrome://zoteroocr/content/zoteroocr.js"/> line in preferences.xul.

Moreover, we maybe want to give some default values to the preferences as long as they are not set differently.

Example: https://github.com/jlegewie/zotfile/blob/master/defaults/preferences/defaults.js

zuphilip commented 5 years ago

Oh, yeah, that seems to work! Thank you very much! :bowing_man: Now, I only need to understand why it works. Is the following correct: The zoteroocr.js is loaded on every start of Zotero because it is part of the overlay.xul?

For the default values of the preferences: Is it enough to have such a file in that subfolder, i.e. is this called automatically by Zotero then?

zuphilip commented 5 years ago

Okay, I just tried and out and it seems that it is enough to simply add the preferences in a file in this directory.

dstillman commented 5 years ago

The zoteroocr.js is loaded on every start of Zotero because it is part of the overlay.xul?

Yes, that's right.

Is it enough to have such a file in that subfolder, i.e. is this called automatically by Zotero then?

Yes.

zuphilip commented 5 years ago

Thank you very much @dstillman for the help and useful information!