This commit is contained in:
Alex Yatskov 2017-07-22 23:19:38 -07:00
parent 611b4420af
commit edf1c0ff6d
5 changed files with 25 additions and 25 deletions

View File

@ -35,7 +35,7 @@
<script src="/mixed/js/audio.js"></script> <script src="/mixed/js/audio.js"></script>
<script src="/mixed/js/display.js"></script> <script src="/mixed/js/display.js"></script>
<script src="/fg/js/dictionary.js"></script> <script src="/fg/js/dictionary.js"></script>
<script src="/fg/js/background.js"></script> <script src="/fg/js/api.js"></script>
<script src="/fg/js/display-frame.js"></script> <script src="/fg/js/display-frame.js"></script>
</body> </body>
</html> </html>

View File

@ -17,7 +17,7 @@
*/ */
function bgInvoke(action, params={}) { function apiInvoke(action, params={}) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
try { try {
chrome.runtime.sendMessage({action, params}, ({result, error}) => { chrome.runtime.sendMessage({action, params}, ({result, error}) => {
@ -34,30 +34,30 @@ function bgInvoke(action, params={}) {
}); });
} }
function bgOptionsGet() { function apiOptionsGet() {
return bgInvoke('optionsGet'); return apiInvoke('optionsGet');
} }
function bgTermsFind(text) { function apiTermsFind(text) {
return bgInvoke('termsFind', {text}); return apiInvoke('termsFind', {text});
} }
function bgKanjiFind(text) { function apiKanjiFind(text) {
return bgInvoke('kanjiFind', {text}); return apiInvoke('kanjiFind', {text});
} }
function bgTemplateRender(template, data) { function apiTemplateRender(template, data) {
return bgInvoke('templateRender', {data, template}); return apiInvoke('templateRender', {data, template});
} }
function bgDefinitionsAddable(definitions, modes) { function apiDefinitionsAddable(definitions, modes) {
return bgInvoke('definitionsAddable', {definitions, modes}).catch(() => null); return apiInvoke('definitionsAddable', {definitions, modes}).catch(() => null);
} }
function bgDefinitionAdd(definition, mode) { function apiDefinitionAdd(definition, mode) {
return bgInvoke('definitionAdd', {definition, mode}); return apiInvoke('definitionAdd', {definition, mode});
} }
function bgNoteView(noteId) { function apiNoteView(noteId) {
return bgInvoke('noteView', {noteId}); return apiInvoke('noteView', {noteId});
} }

View File

@ -24,23 +24,23 @@ window.displayFrame = new class extends Display {
} }
definitionAdd(definition, mode) { definitionAdd(definition, mode) {
return bgDefinitionAdd(definition, mode); return apiDefinitionAdd(definition, mode);
} }
definitionsAddable(definitions, modes) { definitionsAddable(definitions, modes) {
return bgDefinitionsAddable(definitions, modes); return apiDefinitionsAddable(definitions, modes);
} }
noteView(noteId) { noteView(noteId) {
return bgNoteView(noteId); return apiNoteView(noteId);
} }
templateRender(template, data) { templateRender(template, data) {
return bgTemplateRender(template, data); return apiTemplateRender(template, data);
} }
kanjiFind(character) { kanjiFind(character) {
return bgKanjiFind(character); return apiKanjiFind(character);
} }
handleError(error) { handleError(error) {

View File

@ -28,7 +28,7 @@ window.yomichanFrontend = new class {
this.pendingLookup = false; this.pendingLookup = false;
this.options = null; this.options = null;
bgOptionsGet().then(options => { apiOptionsGet().then(options => {
this.options = options; this.options = options;
window.addEventListener('mouseover', this.onMouseOver.bind(this)); window.addEventListener('mouseover', this.onMouseOver.bind(this));
window.addEventListener('mousedown', this.onMouseDown.bind(this)); window.addEventListener('mousedown', this.onMouseDown.bind(this));
@ -175,7 +175,7 @@ window.yomichanFrontend = new class {
searchTerms(textSource) { searchTerms(textSource) {
textSource.setEndOffset(this.options.scanning.length); textSource.setEndOffset(this.options.scanning.length);
return bgTermsFind(textSource.text()).then(({definitions, length}) => { return apiTermsFind(textSource.text()).then(({definitions, length}) => {
if (definitions.length === 0) { if (definitions.length === 0) {
return false; return false;
} else { } else {
@ -203,7 +203,7 @@ window.yomichanFrontend = new class {
searchKanji(textSource) { searchKanji(textSource) {
textSource.setEndOffset(1); textSource.setEndOffset(1);
return bgKanjiFind(textSource.text()).then(definitions => { return apiKanjiFind(textSource.text()).then(definitions => {
if (definitions.length === 0) { if (definitions.length === 0) {
return false; return false;
} else { } else {

View File

@ -18,7 +18,7 @@
"fg/js/document.js", "fg/js/document.js",
"fg/js/source-range.js", "fg/js/source-range.js",
"fg/js/source-element.js", "fg/js/source-element.js",
"fg/js/background.js", "fg/js/api.js",
"fg/js/popup.js", "fg/js/popup.js",
"fg/js/frontend.js" "fg/js/frontend.js"
], ],