aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js/display-frame.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/fg/js/display-frame.js')
-rw-r--r--ext/fg/js/display-frame.js58
1 files changed, 19 insertions, 39 deletions
diff --git a/ext/fg/js/display-frame.js b/ext/fg/js/display-frame.js
index 09bd9255..5ea376c2 100644
--- a/ext/fg/js/display-frame.js
+++ b/ext/fg/js/display-frame.js
@@ -17,65 +17,45 @@
*/
-window.displayFrame = new class extends Display {
+window.yomichan_frame = new class extends Display {
constructor() {
super($('#spinner'), $('#content'));
$(window).on('message', this.onMessage.bind(this));
}
- definitionAdd(definition, mode) {
- return apiDefinitionAdd(definition, mode);
- }
-
- definitionsAddable(definitions, modes) {
- return apiDefinitionsAddable(definitions, modes);
- }
-
- noteView(noteId) {
- return apiNoteView(noteId);
- }
-
- templateRender(template, data) {
- return apiTemplateRender(template, data);
- }
-
- kanjiFind(character) {
- return apiKanjiFind(character);
- }
-
- handleError(error) {
- if (window.yomichanOrphaned) {
- this.showOrphaned();
+ onError(error) {
+ if (window.yomichan_orphaned) {
+ this.onOrphaned();
} else {
window.alert(`Error: ${error}`);
}
}
- clearSearch() {
- window.parent.postMessage('popupClose', '*');
+ onOrphaned() {
+ $('#definitions').hide();
+ $('#error-orphaned').show();
}
- selectionCopy() {
- window.parent.postMessage('selectionCopy', '*');
+ onSearchClear() {
+ window.parent.postMessage('popupClose', '*');
}
- showOrphaned() {
- $('#content').hide();
- $('#orphan').show();
+ onSelectionCopy() {
+ window.parent.postMessage('selectionCopy', '*');
}
onMessage(e) {
const handlers = {
- showTermDefs: ({definitions, options, context}) => {
- this.showTermDefs(definitions, options, context);
+ termsShow: ({definitions, options, context}) => {
+ this.termsShow(definitions, options, context);
},
- showKanjiDefs: ({definitions, options, context}) => {
- this.showKanjiDefs(definitions, options, context);
+ kanjiShow: ({definitions, options, context}) => {
+ this.kanjiShow(definitions, options, context);
},
- showOrphaned: () => {
- this.showOrphaned();
+ orphaned: () => {
+ this.onOrphaned();
}
};
@@ -89,8 +69,8 @@ window.displayFrame = new class extends Display {
onKeyDown(e) {
const handlers = {
67: /* c */ () => {
- if (e.ctrlKey && window.getSelection().toString() === '') {
- this.selectionCopy();
+ if (e.ctrlKey && !window.getSelection().toString()) {
+ this.onSelectionCopy();
return true;
}
}