diff options
Diffstat (limited to 'src/console')
-rw-r--r-- | src/console/console-frame.js | 2 | ||||
-rw-r--r-- | src/console/console-frame.scss | 1 | ||||
-rw-r--r-- | src/console/console.html | 2 | ||||
-rw-r--r-- | src/console/console.js | 29 |
4 files changed, 26 insertions, 8 deletions
diff --git a/src/console/console-frame.js b/src/console/console-frame.js index dc67650..aabb96a 100644 --- a/src/console/console-frame.js +++ b/src/console/console-frame.js @@ -2,7 +2,7 @@ import './console-frame.scss'; import * as messages from '../shared/messages'; export default class ConsoleFrame { - constructor(win, initial = '') { + constructor(win) { let element = window.document.createElement('iframe'); element.src = browser.runtime.getURL('build/console.html'); element.className = 'vimvixen-console-frame'; diff --git a/src/console/console-frame.scss b/src/console/console-frame.scss index 1bab2b0..33bfff3 100644 --- a/src/console/console-frame.scss +++ b/src/console/console-frame.scss @@ -8,4 +8,5 @@ position: fixed; z-index: 10000; border: none; + pointer-events:none; } diff --git a/src/console/console.html b/src/console/console.html index 228660b..2eb445d 100644 --- a/src/console/console.html +++ b/src/console/console.html @@ -8,7 +8,7 @@ <body class='vimvixen-console'> <p id='vimvixen-console-error' class='vimvixen-console-error'></p> - <div> + <div id='vimvixen-console-command'> <p class='vimvixen-console-title'></p> <div class='vimvixen-console-command'> <i class='vimvixen-console-command-prompt'></i><input diff --git a/src/console/console.js b/src/console/console.js index 2db9d29..a171ecc 100644 --- a/src/console/console.js +++ b/src/console/console.js @@ -56,17 +56,34 @@ window.addEventListener('load', () => { input.addEventListener('keyup', handleKeyup); }); +const showCommand = (text) => { + let input = window.document.querySelector('#vimvixen-console-command-input'); + input.value = text; + input.focus(); + + let command = window.document.querySelector('#vimvixen-console-command'); + command.style.display = 'block'; + + let error = window.document.querySelector('#vimvixen-console-error'); + error.style.display = 'none'; +} + +const showError = (text) => { + let error = window.document.querySelector('#vimvixen-console-error'); + error.textContent = text; + error.style.display = 'block'; + + let command = window.document.querySelector('#vimvixen-console-command'); + command.style.display = 'none'; +} + messages.receive(window, (message) => { switch (message.type) { case 'vimvixen.console.show.command': - if (message.text) { - let input = window.document.querySelector('#vimvixen-console-command-input'); - input.value = message.text; - input.focus(); - } + showCommand(message.text); break; case 'vimvixen.console.show.error': - window.document.querySelector('#vimvixen-console-error').textContent = message.text; + showError(message.text); break; } }); |