diff options
Diffstat (limited to 'ext/mixed/js')
| -rw-r--r-- | ext/mixed/js/api.js | 8 | ||||
| -rw-r--r-- | ext/mixed/js/display.js | 23 | 
2 files changed, 23 insertions, 8 deletions
| diff --git a/ext/mixed/js/api.js b/ext/mixed/js/api.js index 0ab07039..feec94df 100644 --- a/ext/mixed/js/api.js +++ b/ext/mixed/js/api.js @@ -53,12 +53,12 @@ function apiKanjiFind(text, optionsContext) {      return _apiInvoke('kanjiFind', {text, optionsContext});  } -function apiDefinitionAdd(definition, mode, context, optionsContext) { -    return _apiInvoke('definitionAdd', {definition, mode, context, optionsContext}); +function apiDefinitionAdd(definition, mode, context, details, optionsContext) { +    return _apiInvoke('definitionAdd', {definition, mode, context, details, optionsContext});  } -function apiDefinitionsAddable(definitions, modes, optionsContext) { -    return _apiInvoke('definitionsAddable', {definitions, modes, optionsContext}); +function apiDefinitionsAddable(definitions, modes, context, optionsContext) { +    return _apiInvoke('definitionsAddable', {definitions, modes, context, optionsContext});  }  function apiNoteView(noteId) { diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js index 4a71efe0..2f456c3e 100644 --- a/ext/mixed/js/display.js +++ b/ext/mixed/js/display.js @@ -752,15 +752,16 @@ class Display {          try {              this.setSpinnerVisible(true); -            const context = {}; +            const details = {};              if (this.noteUsesScreenshot(mode)) {                  const screenshot = await this.getScreenshot();                  if (screenshot) { -                    context.screenshot = screenshot; +                    details.screenshot = screenshot;                  }              } -            const noteId = await apiDefinitionAdd(definition, mode, context, this.getOptionsContext()); +            const context = await this._getNoteContext(); +            const noteId = await apiDefinitionAdd(definition, mode, context, details, this.getOptionsContext());              if (noteId) {                  const index = this.definitions.indexOf(definition);                  const adderButton = this.adderButtonFind(index, mode); @@ -908,12 +909,17 @@ class Display {      async getDefinitionsAddable(definitions, modes) {          try { -            return await apiDefinitionsAddable(definitions, modes, this.getOptionsContext()); +            const context = await this._getNoteContext(); +            return await apiDefinitionsAddable(definitions, modes, context, this.getOptionsContext());          } catch (e) {              return [];          }      } +    async getDocumentTitle() { +        return document.title; +    } +      static indexOf(nodeList, node) {          for (let i = 0, ii = nodeList.length; i < ii; ++i) {              if (nodeList[i] === node) { @@ -934,6 +940,15 @@ class Display {          return (typeof key === 'string' ? (key.length === 1 ? key.toUpperCase() : key) : '');      } +    async _getNoteContext() { +        const documentTitle = await this.getDocumentTitle(); +        return { +            document: { +                title: documentTitle +            } +        }; +    } +      async _getAudioUri(definition, source) {          const optionsContext = this.getOptionsContext();          return await apiAudioGetUri(definition, source, optionsContext); |