Skip to content

Commit

Permalink
vpat 37: run JS aria edits + localization (#4021)
Browse files Browse the repository at this point in the history
  • Loading branch information
abaevbog authored and dstillman committed Jun 17, 2024
1 parent 338afc2 commit f4d428c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
19 changes: 10 additions & 9 deletions chrome/content/zotero/runJS.html
Original file line number Diff line number Diff line change
@@ -1,36 +1,37 @@
<html id="run-js">
<head>
<title>Run JavaScript</title>
<title data-l10n-id="runJS-title"></title>
<link href="chrome://zotero-platform/content/zotero.css" rel="stylesheet"/>
</head>
<body>
<nav>
<button onclick="run()">Run</button>
<button data-l10n-id="runJS-run" onclick="run()"></button>
<span id="run-label"></span>
<button id="help-button" onclick="openHelp()">Help</button>
<button data-l10n-id="runJS-help" id="help-button" onclick="openHelp()"></button>
</nav>

<main>
<div class="textbox-container">
<div class="textbox-header">
<label class="textbox-label" for="editor-code">Code:</label>
<label id="run-as-async-label" for="run-as-async">
<label id="code-editor-label" data-l10n-id="runJS-editor-label" class="textbox-label"></label>
<div>
<label id="run-as-async-label" data-l10n-id="runJS-run-async" for="run-as-async"></label>
<input id="run-as-async" type="checkbox" onclick="update()">
Run as async function
</label>
</div>
</div>
<iframe
src="chrome://zotero/content/ace/ace.html"
id="editor-code"
class="editor-code"
aria-labelledby="code-editor-label"
></iframe>
</div>

<div class="textbox-container">
<div class="textbox-header">
<label id="result-label" class="textbox-label" for="result"/>
<label id="result-label" class="textbox-label" for="result" data-l10n-id="runJS-result"/>
</div>
<textarea id="result" readonly></textarea>
<textarea id="result" readonly aria-disabled="true"></textarea>
</div>
</main>

Expand Down
5 changes: 3 additions & 2 deletions chrome/content/zotero/runJS.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
function update() {
var isAsync = document.getElementById('run-as-async').checked;
var resultLabel = document.getElementById('result-label');
var val = isAsync ? 'Return value' : 'Result';
resultLabel.textContent = val + ':';
var type = isAsync ? 'async' : 'none';
resultLabel.setAttribute('data-l10n-args', `{"type":"${type}"}`);
}

async function run() {
Expand Down Expand Up @@ -85,6 +85,7 @@ window.addEventListener("load", function (e) {
return;
}

MozXULElement.insertFTLIfNeeded("zotero.ftl");
var codeWin = document.getElementById("editor-code").contentWindow;
codeEditor = codeWin.editor;
var session = codeEditor.getSession();
Expand Down
11 changes: 11 additions & 0 deletions chrome/locale/en-US/zotero/zotero.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ general-add = Add
general-remind-me-later = Remind Me Later
general-choose-file = Choose File…
general-open-settings = Open Settings
general-help = Help
menu-file-show-in-finder =
.label = Show in Finder
Expand Down Expand Up @@ -257,6 +258,16 @@ rtfScan-complete-page =
rtfScan-complete-page-description = Your document has now been scanned and processed. Please ensure that it is formatted correctly.
runJS-title = Run JavaScript
runJS-editor-label = Code:
runJS-run = Run
runJS-help = { general-help }
runJS-result = {
$type ->
[async] Return value:
*[other] Result:
}
runJS-run-async = Run as async function
bibliography-style-label = Citation Style:
bibliography-locale-label = Language:
Expand Down

0 comments on commit f4d428c

Please sign in to comment.