diff options
author | Alex Yatskov <alex@foosoft.net> | 2017-07-01 18:27:49 -0700 |
---|---|---|
committer | Alex Yatskov <alex@foosoft.net> | 2017-07-01 18:27:49 -0700 |
commit | d57c5530b7ad56a7cc89782b4d186d8fddb55d86 (patch) | |
tree | 09cce1fded053b04ea716c2d4d44fb4676b24800 /ext/bg/js | |
parent | 390cb12896607144fcd1046950f3a2aa680db71b (diff) |
view added notes
Diffstat (limited to 'ext/bg/js')
-rw-r--r-- | ext/bg/js/anki-connect.js | 16 | ||||
-rw-r--r-- | ext/bg/js/anki-null.js | 4 | ||||
-rw-r--r-- | ext/bg/js/display-window.js | 4 | ||||
-rw-r--r-- | ext/bg/js/templates.js | 12 | ||||
-rw-r--r-- | ext/bg/js/yomichan.js | 8 |
5 files changed, 32 insertions, 12 deletions
diff --git a/ext/bg/js/anki-connect.js b/ext/bg/js/anki-connect.js index 9759c8f5..173feefd 100644 --- a/ext/bg/js/anki-connect.js +++ b/ext/bg/js/anki-connect.js @@ -26,7 +26,7 @@ class AnkiConnect { } addNote(note) { - return this.checkVersion().then(() => this.ankiInvoke('addNote', {note}, null)); + return this.checkVersion().then(() => this.ankiInvoke('addNote', {note})); } canAddNotes(notes) { @@ -34,15 +34,19 @@ class AnkiConnect { } getDeckNames() { - return this.checkVersion().then(() => this.ankiInvoke('deckNames', {}, null)); + return this.checkVersion().then(() => this.ankiInvoke('deckNames', {})); } getModelNames() { - return this.checkVersion().then(() => this.ankiInvoke('modelNames', {}, null)); + return this.checkVersion().then(() => this.ankiInvoke('modelNames', {})); } getModelFieldNames(modelName) { - return this.checkVersion().then(() => this.ankiInvoke('modelFieldNames', {modelName}, null)); + return this.checkVersion().then(() => this.ankiInvoke('modelFieldNames', {modelName})); + } + + guiBrowse(query) { + return this.checkVersion().then(() => this.ankiInvoke('guiBrowse', {query})); } checkVersion() { @@ -60,13 +64,13 @@ class AnkiConnect { ankiInvoke(action, params, pool) { return new Promise((resolve, reject) => { - if (pool !== null && this.asyncPools.hasOwnProperty(pool)) { + if (pool && this.asyncPools.hasOwnProperty(pool)) { this.asyncPools[pool].abort(); } const xhr = new XMLHttpRequest(); xhr.addEventListener('loadend', () => { - if (pool !== null) { + if (pool) { delete this.asyncPools[pool]; } diff --git a/ext/bg/js/anki-null.js b/ext/bg/js/anki-null.js index 99dc2f30..8dad6915 100644 --- a/ext/bg/js/anki-null.js +++ b/ext/bg/js/anki-null.js @@ -37,4 +37,8 @@ class AnkiNull { getModelFieldNames(modelName) { return Promise.resolve([]); } + + guiBrowse(query) { + return Promise.resolve([]); + } } diff --git a/ext/bg/js/display-window.js b/ext/bg/js/display-window.js index ae97cd36..64e56f72 100644 --- a/ext/bg/js/display-window.js +++ b/ext/bg/js/display-window.js @@ -37,6 +37,10 @@ window.displayWindow = new class extends Display { return instYomi().definitionsAddable(definitions, modes).catch(() => []); } + noteView(noteId) { + return instYomi().noteView(noteId); + } + templateRender(template, data) { return instYomi().templateRender(template, data); } diff --git a/ext/bg/js/templates.js b/ext/bg/js/templates.js index f10134ee..50686ed4 100644 --- a/ext/bg/js/templates.js +++ b/ext/bg/js/templates.js @@ -315,10 +315,10 @@ templates['fields.html'] = template({"1":function(container,depth0,helpers,parti templates['kanji.html'] = template({"1":function(container,depth0,helpers,partials,data) { var stack1, helper, alias1=depth0 != null ? depth0 : {}; - return "<div class=\"entry\" data-type=\"kanji\">\n <div class=\"actions\">\n <img src=\"/mixed/img/entry-current.png\" class=\"current\" title=\"Current entry (Alt + Up/Down/Home/End/PgUp/PgDn)\" alt>\n" + return "<div class=\"entry\" data-type=\"kanji\">\n <div class=\"actions\">\n" + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.addable : depth0),{"name":"if","hash":{},"fn":container.program(2, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.source : depth0),{"name":"if","hash":{},"fn":container.program(4, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + " </div>\n\n <div class=\"glyph\">" + + " <img src=\"/mixed/img/entry-current.png\" class=\"current\" title=\"Current entry (Alt + Up/Down/Home/End/PgUp/PgDn)\" alt>\n </div>\n\n <div class=\"glyph\">" + container.escapeExpression(((helper = (helper = helpers.character || (depth0 != null ? depth0.character : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(alias1,{"name":"character","hash":{},"data":data}) : helper))) + "</div>\n\n <div class=\"reading\">\n <table>\n <tr>\n <th>Kunyomi:</th>\n <td>\n" + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.kunyomi : depth0),{"name":"each","hash":{},"fn":container.program(6, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") @@ -332,7 +332,7 @@ templates['kanji.html'] = template({"1":function(container,depth0,helpers,partia + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.debug : depth0),{"name":"if","hash":{},"fn":container.program(18, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + "</div>\n"; },"2":function(container,depth0,helpers,partials,data) { - return " <a href=\"#\" class=\"action-add-note pending disabled\" data-mode=\"kanji\"><img src=\"/mixed/img/add-kanji.png\" title=\"Add Kanji (Alt + K)\" alt></a>\n"; + return " <a href=\"#\" class=\"action-view-note pending disabled\"><img src=\"/mixed/img/view-note.png\" title=\"View added note (Alt + V)\" alt></a>\n <a href=\"#\" class=\"action-add-note pending disabled\" data-mode=\"kanji\"><img src=\"/mixed/img/add-kanji.png\" title=\"Add Kanji (Alt + K)\" alt></a>\n"; },"4":function(container,depth0,helpers,partials,data) { return " <a href=\"#\" class=\"source-term\"><img src=\"/mixed/img/source-term.png\" title=\"Source term (Alt + B)\" alt></a>\n"; },"6":function(container,depth0,helpers,partials,data) { @@ -486,10 +486,10 @@ templates['terms.html'] = template({"1":function(container,depth0,helpers,partia },"12":function(container,depth0,helpers,partials,data) { var stack1, alias1=depth0 != null ? depth0 : {}; - return "<div class=\"entry\" data-type=\"term\">\n <div class=\"actions\">\n <img src=\"/mixed/img/entry-current.png\" class=\"current\" title=\"Current entry (Alt + Up/Down/Home/End/PgUp/PgDn)\" alt>\n" + return "<div class=\"entry\" data-type=\"term\">\n <div class=\"actions\">\n" + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.addable : depth0),{"name":"if","hash":{},"fn":container.program(13, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.playback : depth0),{"name":"if","hash":{},"fn":container.program(15, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + " </div>\n\n" + + " <img src=\"/mixed/img/entry-current.png\" class=\"current\" title=\"Current entry (Alt + Up/Down/Home/End/PgUp/PgDn)\" alt>\n </div>\n\n" + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.reading : depth0),{"name":"if","hash":{},"fn":container.program(17, data, 0),"inverse":container.program(20, data, 0),"data":data})) != null ? stack1 : "") + "\n" + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.reasons : depth0),{"name":"if","hash":{},"fn":container.program(22, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") @@ -499,7 +499,7 @@ templates['terms.html'] = template({"1":function(container,depth0,helpers,partia + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.debug : depth0),{"name":"if","hash":{},"fn":container.program(34, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + "</div>\n"; },"13":function(container,depth0,helpers,partials,data) { - return " <a href=\"#\" class=\"action-add-note pending disabled\" data-mode=\"term-kanji\"><img src=\"/mixed/img/add-term-kanji.png\" title=\"Add expression (Alt + E)\" alt></a>\n <a href=\"#\" class=\"action-add-note pending disabled\" data-mode=\"term-kana\"><img src=\"/mixed/img/add-term-kana.png\" title=\"Add reading (Alt + R)\" alt></a>\n"; + return " <a href=\"#\" class=\"action-view-note pending disabled\"><img src=\"/mixed/img/view-note.png\" title=\"View added note (Alt + V)\" alt></a>\n <a href=\"#\" class=\"action-add-note pending disabled\" data-mode=\"term-kanji\"><img src=\"/mixed/img/add-term-kanji.png\" title=\"Add expression (Alt + E)\" alt></a>\n <a href=\"#\" class=\"action-add-note pending disabled\" data-mode=\"term-kana\"><img src=\"/mixed/img/add-term-kana.png\" title=\"Add reading (Alt + R)\" alt></a>\n"; },"15":function(container,depth0,helpers,partials,data) { return " <a href=\"#\" class=\"action-play-audio\"><img src=\"/mixed/img/play-audio.png\" title=\"Play audio (Alt + P)\" alt></a>\n"; },"17":function(container,depth0,helpers,partials,data) { diff --git a/ext/bg/js/yomichan.js b/ext/bg/js/yomichan.js index b4beb179..e0bdabc3 100644 --- a/ext/bg/js/yomichan.js +++ b/ext/bg/js/yomichan.js @@ -157,6 +157,10 @@ window.yomichan = new class { }); } + noteView(noteId) { + return this.anki.guiBrowse(`nid:${noteId}`); + } + templateRender(template, data) { return Promise.resolve(handlebarsRender(template, data)); } @@ -211,6 +215,10 @@ window.yomichan = new class { definitionsAddable: ({definitions, modes, callback}) => { promiseCallback(this.definitionsAddable(definitions, modes), callback); + }, + + noteView: ({noteId}) => { + promiseCallback(this.noteView(noteId), callback); } }; |