aboutsummaryrefslogtreecommitdiff
path: root/src/console
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2017-09-01 16:29:36 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2017-09-01 18:08:38 +0900
commit02ea10a357955752dda4c72c49de2340997c9818 (patch)
tree1cb621bd8ea538e128a7263012d3c8bc077e2e0d /src/console
parent2312ba6560fe8ca81a6ed100a726fe970cba1fd5 (diff)
show error text
Diffstat (limited to 'src/console')
-rw-r--r--src/console/console-frame.js2
-rw-r--r--src/console/console-frame.scss1
-rw-r--r--src/console/console.html2
-rw-r--r--src/console/console.js29
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;
}
});