show error text

jh-changes
Shin'ya Ueoka 7 years ago
parent 2312ba6560
commit 02ea10a357
  1. 2
      src/console/console-frame.js
  2. 1
      src/console/console-frame.scss
  3. 2
      src/console/console.html
  4. 29
      src/console/console.js

@ -2,7 +2,7 @@ import './console-frame.scss';
import * as messages from '../shared/messages'; import * as messages from '../shared/messages';
export default class ConsoleFrame { export default class ConsoleFrame {
constructor(win, initial = '') { constructor(win) {
let element = window.document.createElement('iframe'); let element = window.document.createElement('iframe');
element.src = browser.runtime.getURL('build/console.html'); element.src = browser.runtime.getURL('build/console.html');
element.className = 'vimvixen-console-frame'; element.className = 'vimvixen-console-frame';

@ -8,4 +8,5 @@
position: fixed; position: fixed;
z-index: 10000; z-index: 10000;
border: none; border: none;
pointer-events:none;
} }

@ -8,7 +8,7 @@
<body class='vimvixen-console'> <body class='vimvixen-console'>
<p id='vimvixen-console-error' <p id='vimvixen-console-error'
class='vimvixen-console-error'></p> class='vimvixen-console-error'></p>
<div> <div id='vimvixen-console-command'>
<p class='vimvixen-console-title'></p> <p class='vimvixen-console-title'></p>
<div class='vimvixen-console-command'> <div class='vimvixen-console-command'>
<i class='vimvixen-console-command-prompt'></i><input <i class='vimvixen-console-command-prompt'></i><input

@ -56,17 +56,34 @@ window.addEventListener('load', () => {
input.addEventListener('keyup', handleKeyup); 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) => { messages.receive(window, (message) => {
switch (message.type) { switch (message.type) {
case 'vimvixen.console.show.command': case 'vimvixen.console.show.command':
if (message.text) { showCommand(message.text);
let input = window.document.querySelector('#vimvixen-console-command-input');
input.value = message.text;
input.focus();
}
break; break;
case 'vimvixen.console.show.error': case 'vimvixen.console.show.error':
window.document.querySelector('#vimvixen-console-error').textContent = message.text; showError(message.text);
break; break;
} }
}); });