Improved translation page.

Ylian Saint-Hilaire committed Jun 1, 2021 at 11:18 UTC 2cae2101795043bbfb3bc36900cd8e9fe7893871
1 file changed +26 -9
public/translator.htm
+26 -9
@@ -57,8 +57,8 @@
57 </div>
58 <div>
59 <input id="OpenFileButton" type=button value="Open File..." onclick="openfile()" style="display:none">
60 - <input id="SaveServerButton" type=button value="Save to Server..." onclick="saveServerTranslations()">
61 - <input id="SaveFileButton" type=button value="Save to File..." onclick="saveToFile()">
60 + <input id="SaveServerButton" title="Ctrl-S" type=button value="Save to Server (F3)" onclick="saveServerTranslations()">
61 + <input id="SaveFileButton" title="Ctrl-Shift-S" type=button value="Save to File (F4)" onclick="saveToFile()">
62 <select id="langSelector" onchange="langSelectorChange()">
63 <option value="ar">Arabic (ar)</option>
64 <option value="fi">Finnish (fi)</option>
@@ -98,14 +98,14 @@
98 </div>
99 <div id=deskarea4 class="areaFoot">
100 <div class="toright2">
101 - <input id="CopySource" type=button value="Copy English" onclick="copySource()">
102 - <input id="PrevButton" type=button value="Prev" onclick="prev()">
103 - <input id="NextButton" type=button value="Next" onclick="next()">
101 + <input id="CopySource" type=button value="Copy English (F5)" onclick="copySource()">
102 + <input id="PrevButton" type=button value="Prev (PgUp)" onclick="prev()">
103 + <input id="NextButton" type=button value="Next (PgDn)" onclick="next()">
104 </div>
105 <div style="height:22px">
106 &nbsp;
107 - <input id="SetButton" type=button value="Set" onclick="setTranslation()">
108 - <input id="CancelButton" type=button value="Cancel" onclick="cancelTranslation()">
107 + <input id="SetButton" type=button value="Set (F1)" onclick="setTranslation()">
108 + <input id="CancelButton" type=button value="Cancel (F2)" onclick="cancelTranslation()">
109 </div>
110 </div>
111 </div>
@@ -141,6 +141,8 @@
141 document.ondragover = ondragover;
142 document.ondragleave = ondragleave;
143 document.onkeypress = onkeypress;
144 + document.onkeydown = onkeydown;
145 + document.onkeyup = onkeyup;
146 updateMainList();
147 loadServerTranslations();
148 QE('SaveServerButton', false);
@@ -203,6 +205,21 @@
205 //if (e.key == ' ') { togglePause(); haltEvent(e); }
206 }
207
208 + function onkeydown(e) {
209 + if (xxdialogMode) return;
210 + if (e.key == 'F1') { setTranslation(); haltEvent(e); return false; } // Set translation
211 + if (e.key == 'F2') { cancelTranslation(); haltEvent(e); return false; } // Cancel translation
212 + if (e.key == 'F3') { saveServerTranslations(); haltEvent(e); return false; } // Save to server
213 + if (e.key == 'F4') { saveToFile(); haltEvent(e); return false; } // Save to file
214 + if (e.key == 'F5') { copySource(); haltEvent(e); return false; } // Copy source
215 + }
216 +
217 + function onkeyup(e) {
218 + if (xxdialogMode) return;
219 + if (e.key == 'PageUp') { setTranslation(); prev(); haltEvent(e); return false; } // Save and move to previous
220 + if (e.key == 'PageDown') { setTranslation(); next(); haltEvent(e); return false; } // Save and move to next
221 + }
222 +
223 function deskAdjust() {
224
225 }
@@ -287,8 +304,8 @@
304 updateButtons();
305 }
306
290 - function next() { select(selectedItem + 1, true); }
291 - function prev() { select(selectedItem - 1, true); }
307 + function next() { if (selectedItem < (translations.length - 1)) { select(selectedItem + 1, true); } }
308 + function prev() { if (selectedItem > 0) { select(selectedItem - 1, true); } }
309 function copySource() { Q('translatedTextArea').value = translations[selectedItem].en; Q('translatedTextArea').focus(); }
310
311 function updateButtons() {