diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2017-09-01 08:51:14 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2017-09-01 09:15:44 +0900 |
commit | 6e5286ef10b26d0a09f3882d6c3bfdbd92223d0f (patch) | |
tree | 40d46345e48d0567e1c65201ca9d55e428060172 /src/command-line | |
parent | f1b9c6ba9d33fe1927c4855d4981d88ad73d5818 (diff) |
Rename command-line to console
Diffstat (limited to 'src/command-line')
-rw-r--r-- | src/command-line/command-line-frame.js | 19 | ||||
-rw-r--r-- | src/command-line/command-line-frame.scss | 11 | ||||
-rw-r--r-- | src/command-line/command-line.html | 18 | ||||
-rw-r--r-- | src/command-line/command-line.js | 64 | ||||
-rw-r--r-- | src/command-line/command-line.scss | 52 |
5 files changed, 0 insertions, 164 deletions
diff --git a/src/command-line/command-line-frame.js b/src/command-line/command-line-frame.js deleted file mode 100644 index 3f1dda4..0000000 --- a/src/command-line/command-line-frame.js +++ /dev/null @@ -1,19 +0,0 @@ -import './command-line-frame.scss'; - -export default class CommandLineFrame { - constructor(win, initial = '') { - let url = browser.runtime.getURL('build/command-line.html') + - '#' + encodeURIComponent(initial); - - let element = window.document.createElement('iframe'); - element.src = url; - element.className = 'vimvixen-command-line-frame'; - win.document.body.append(element); - - this.element = element; - } - - remove() { - this.element.remove(); - } -} diff --git a/src/command-line/command-line-frame.scss b/src/command-line/command-line-frame.scss deleted file mode 100644 index 88772d9..0000000 --- a/src/command-line/command-line-frame.scss +++ /dev/null @@ -1,11 +0,0 @@ -.vimvixen-command-line-frame { - margin: 0; - padding: 0; - bottom: 0; - left: 0; - width: 100%; - height: 100%; - position: fixed; - z-index: 10000; - border: none; -} diff --git a/src/command-line/command-line.html b/src/command-line/command-line.html deleted file mode 100644 index bad0b66..0000000 --- a/src/command-line/command-line.html +++ /dev/null @@ -1,18 +0,0 @@ -<!doctype html> -<html> - <head> - <meta charset=utf-8 /> - <title>VimVixen command-line</title> - <script src='command-line.js'></script> - </head> - <body class='vimvixen-command-line'> - <div> - <p class='vimvixen-command-line-title'></p> - <div class='vimvixen-command-line-line'> - <i class='vimvixen-command-line-line-prompt'></i><input - id='vimvixen-command-line-line-input' - class='vimvixen-command-line-line-input'></input> - </div> - </div> - </body> -</html> diff --git a/src/command-line/command-line.js b/src/command-line/command-line.js deleted file mode 100644 index 34f3f35..0000000 --- a/src/command-line/command-line.js +++ /dev/null @@ -1,64 +0,0 @@ -import './command-line.scss'; - -const parent = window.parent; - -// TODO consider object-oriented -var prevValue = ""; - -const blurData = () => { - return JSON.stringify({ - type: 'vimvixen.commandline.blur' - }); -}; - -const keydownData = (input) => { - return JSON.stringify({ - type: 'vimvixen.commandline.enter', - value: input.value - }); -}; - -const keyupData = (input) => { - return JSON.stringify({ - type: 'vimvixen.commandline.change', - value: input.value - }); -}; - -const handleBlur = () => { - parent.postMessage(blurData(), '*'); -}; - -const handleKeydown = (e) => { - switch(e.keyCode) { - case KeyboardEvent.DOM_VK_ESCAPE: - parent.postMessage(blurData(), '*'); - break; - case KeyboardEvent.DOM_VK_RETURN: - parent.postMessage(keydownData(e.target), '*'); - break; - } -}; - -const handleKeyup = (e) => { - if (e.target.value === prevValue) { - return; - } - parent.postMessage(keyupData(e.target), '*'); - prevValue = e.target.value; -}; - -window.addEventListener('load', () => { - let hash = window.location.hash; - let initial = ''; - if (hash.length > 0) { - initial = decodeURIComponent(hash.substring(1)); - } - - let input = window.document.querySelector('#vimvixen-command-line-line-input'); - input.addEventListener('blur', handleBlur); - input.addEventListener('keydown', handleKeydown); - input.addEventListener('keyup', handleKeyup); - input.value = initial; - input.focus(); -}); diff --git a/src/command-line/command-line.scss b/src/command-line/command-line.scss deleted file mode 100644 index 68a0a03..0000000 --- a/src/command-line/command-line.scss +++ /dev/null @@ -1,52 +0,0 @@ -html, body, * { - margin: 0; - padding: 0; -} - -body { - position: absolute; - bottom: 0; - left: 0; - right: 0; -} - -.vimvixen-command-line { - border-top: 1px solid gray; - bottom: 0; - margin: 0; - padding: 0; - - @mixin input-style { - font-style: normal; - font-family: monospace; - font-size: 12px; - } - - - &-title { - background-color: lightgray; - font-weight: bold; - margin: 0; - padding: 0; - - @include input-style; - } - - &-line { - background-color: white; - display: flex; - - &-prompt:before { - content: ':'; - - @include input-style; - } - - &-input { - border: none; - flex-grow: 1; - - @include input-style; - } - } -} |