show error text

This commit is contained in:
Shin'ya Ueoka 2017-09-01 16:29:36 +09:00
parent 2312ba6560
commit 02ea10a357
4 changed files with 26 additions and 8 deletions

View file

@ -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;
}
});