diff options
Diffstat (limited to 'src/content/index.js')
-rw-r--r-- | src/content/index.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/content/index.js b/src/content/index.js index 03efc5e..17ab308 100644 --- a/src/content/index.js +++ b/src/content/index.js @@ -1,12 +1,45 @@ import * as scrolls from './scrolls'; +import FooterLine from './footer-line'; import * as actions from '../shared/actions'; +var footer = null; + +const createFooterLine = (initial = '') => { + footer = new FooterLine(document, initial); + footer.onPromptChange((e) => { + let request = { + type: 'event.cmd.suggest', + text: e.target.value + }; + browser.runtime.sendMessage(request); + }); + footer.onEntered((e) => { + let request = { + type: 'event.cmd.enter', + text: e.target.value + }; + browser.runtime.sendMessage(request); + }); + footer.focus(); +} + const invokeEvent = (action) => { if (typeof action === 'undefined' || action === null) { return; } switch (action[0]) { + case actions.CMD_OPEN: + createFooterLine(); + break; + case actions.CMD_TABS_OPEN: + if (action[1] || false) { + // alter url + createFooterLine('open ' + window.location.href); + } else { + createFooterLine('open '); + } + break; case actions.SCROLL_UP: scrolls.scrollUp(window, action[1] || 1); break; |