implement o/O command

This commit is contained in:
Shin'ya Ueoka 2017-08-15 22:00:05 +09:00
parent 9a808f45ed
commit 36680ed8fe
5 changed files with 39 additions and 18 deletions

View file

@ -4,6 +4,25 @@ 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;
@ -11,22 +30,15 @@ const invokeEvent = (action) => {
switch (action[0]) {
case actions.CMD_OPEN:
footer = new FooterLine(document);
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();
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);