Fx60: Fix Scaffold

Fixes #1727
This commit is contained in:
Dan Stillman 2019-08-28 07:44:35 -04:00
parent 2a613258e0
commit f0e9c8bfba
3 changed files with 50 additions and 47 deletions

View file

@ -0,0 +1,9 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" src="chrome://scaffold/content/ace/ace.js"></script>
<script type="text/javascript" src="chrome://scaffold/content/ace/mode-javascript.js"></script>
<script type="text/javascript" src="chrome://scaffold/content/aceWrapper.js"></script>
</head>
<body id="body"></body>
</html>

View file

@ -190,7 +190,7 @@
</menupopup>
</toolbarbutton>
</hbox>
<iframe src="data:text/html,%3C!DOCTYPE%20html%20PUBLIC%20%22-//W3C//DTD%20XHTML%201.1//EN%22%20%22http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd%22%3E%3Chtml%20xmlns=%22http://www.w3.org/1999/xhtml%22%3E%3Chead%3E%3Cscript%20type=%22text/javascript%22%20src=%22chrome://scaffold/content/ace/ace.js%22%3E%3C/script%3E%3Cscript%20type=%22text/javascript%22%20src=%22chrome://scaffold/content/ace/mode-javascript.js%22%3E%3C/script%3E%3Cscript%20type=%22text/javascript%22%20src=%22chrome://scaffold/content/aceWrapper.js%22%3E%3C/script%3E%3C/head%3E%3Cbody%20id=%22body%22%3E%3C/body%3E%3C/html%3E" id="editor-code" flex="1"/>
<iframe src="chrome://scaffold/content/ace/ace.html" id="editor-code" flex="1"/>
<hbox id="editor-external-box" align="center">
<checkbox id="checkbox-editor-external"/>
<label class="label-metadata" value="&scaffold.editor.external.label;" control="checkbox-editor-external"/>
@ -198,10 +198,10 @@
</vbox>
</tabpanel>
<tabpanel flex="1" id="tabpanel-import">
<iframe src="data:text/html,%3C!DOCTYPE%20html%20PUBLIC%20%22-//W3C//DTD%20XHTML%201.1//EN%22%20%22http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd%22%3E%3Chtml%20xmlns=%22http://www.w3.org/1999/xhtml%22%3E%3Chead%3E%3Cscript%20type=%22text/javascript%22%20src=%22chrome://scaffold/content/ace/ace.js%22%3E%3C/script%3E%3Cscript%20type=%22text/javascript%22%20src=%22chrome://scaffold/content/ace/mode-javascript.js%22%3E%3C/script%3E%3Cscript%20type=%22text/javascript%22%20src=%22chrome://scaffold/content/aceWrapper.js%22%3E%3C/script%3E%3C/head%3E%3Cbody%20id=%22body%22%3E%3C/body%3E%3C/html%3E" id="editor-import" flex="1"/>
<iframe src="chrome://scaffold/content/ace/ace.html" id="editor-import" flex="1"/>
</tabpanel>
<tabpanel flex="1" id="tabpanel-tests">
<iframe src="data:text/html,%3C!DOCTYPE%20html%20PUBLIC%20%22-//W3C//DTD%20XHTML%201.1//EN%22%20%22http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd%22%3E%3Chtml%20xmlns=%22http://www.w3.org/1999/xhtml%22%3E%3Chead%3E%3Cscript%20type=%22text/javascript%22%20src=%22chrome://scaffold/content/ace/ace.js%22%3E%3C/script%3E%3Cscript%20type=%22text/javascript%22%20src=%22chrome://scaffold/content/ace/mode-javascript.js%22%3E%3C/script%3E%3Cscript%20type=%22text/javascript%22%20src=%22chrome://scaffold/content/aceWrapper.js%22%3E%3C/script%3E%3C/head%3E%3Cbody%20id=%22body%22%3E%3C/body%3E%3C/html%3E" id="editor-tests" flex="1"/>
<iframe src="chrome://scaffold/content/ace/ace.html" id="editor-tests" flex="1"/>
</tabpanel>
<tabpanel flex="1" id="tabpanel-testing">
<vbox flex="1"><hbox><description>&scaffold.testing.description;</description></hbox>

View file

@ -22,52 +22,46 @@ var Scaffold_Translators = {
var dir = this.getDirectory();
var numLoaded = 0;
var deletedTranslators = new Set(this._translatorFiles.keys());
await Zotero.File.iterateDirectory(dir, function* (iterator) {
while (true) {
let entries = yield iterator.nextBatch(50);
if (!entries.length) break;
for (let entry of entries) {
if (entry.isDir || entry.name.startsWith('.') || !entry.name.endsWith('.js')) {
continue;
}
deletedTranslators.delete(entry.name);
try {
let fmtime;
if ('winLastWriteDate' in entry) {
fmtime = entry.winLastWriteDate.getTime();
}
else {
fmtime = (yield OS.File.stat(entry.path)).lastModificationDate.getTime();
}
let translatorID = this._translatorFiles.get(entry.name);
let loadFile = true;
// If translator is already loaded, see if mtime has changed
if (translatorID) {
let mtime = this._translators.get(translatorID).mtime;
if (mtime == fmtime) {
loadFile = false;
}
}
if (loadFile) {
let translator = yield Zotero.Translators.loadFromFile(entry.path);
this._translators.set(
translator.translatorID,
{
translator,
filename: entry.name,
mtime: fmtime,
}
);
this._translatorFiles.set(entry.name, translator.translatorID);
numLoaded++;
}
}
catch (e) {
Zotero.logError(e);
await Zotero.File.iterateDirectory(dir, async function (entry) {
if (entry.isDir || entry.name.startsWith('.') || !entry.name.endsWith('.js')) {
return;
}
deletedTranslators.delete(entry.name);
try {
let fmtime;
if ('winLastWriteDate' in entry) {
fmtime = entry.winLastWriteDate.getTime();
}
else {
fmtime = (await OS.File.stat(entry.path)).lastModificationDate.getTime();
}
let translatorID = this._translatorFiles.get(entry.name);
let loadFile = true;
// If translator is already loaded, see if mtime has changed
if (translatorID) {
let mtime = this._translators.get(translatorID).mtime;
if (mtime == fmtime) {
loadFile = false;
}
}
if (loadFile) {
let translator = await Zotero.Translators.loadFromFile(entry.path);
this._translators.set(
translator.translatorID,
{
translator,
filename: entry.name,
mtime: fmtime,
}
);
this._translatorFiles.set(entry.name, translator.translatorID);
numLoaded++;
}
}
catch (e) {
Zotero.logError(e);
}
}.bind(this));