parent
d51b674467
commit
d5007a747c
4 changed files with 51 additions and 23 deletions
@ -1,19 +1,43 @@ |
|||||||
import './console-frame.scss'; |
import './console-frame.scss'; |
||||||
|
import * as messages from '../shared/messages'; |
||||||
|
|
||||||
export default class ConsoleFrame { |
export default class ConsoleFrame { |
||||||
constructor(win, initial = '') { |
constructor(win, initial = '') { |
||||||
let url = browser.runtime.getURL('build/console.html') + |
|
||||||
'#' + encodeURIComponent(initial); |
|
||||||
|
|
||||||
let element = window.document.createElement('iframe'); |
let element = window.document.createElement('iframe'); |
||||||
element.src = url; |
element.src = browser.runtime.getURL('build/console.html'); |
||||||
element.className = 'vimvixen-console-frame'; |
element.className = 'vimvixen-console-frame'; |
||||||
win.document.body.append(element); |
win.document.body.append(element); |
||||||
|
|
||||||
this.element = element; |
this.element = element; |
||||||
|
|
||||||
|
this.hide(); |
||||||
|
} |
||||||
|
|
||||||
|
showCommand(text) { |
||||||
|
this.showFrame(); |
||||||
|
|
||||||
|
let message = { |
||||||
|
type: 'vimvixen.console.show.command', |
||||||
|
text: text |
||||||
|
}; |
||||||
|
messages.send(this.element.contentWindow, message); |
||||||
|
} |
||||||
|
|
||||||
|
showError(text) { |
||||||
|
this.showFrame(); |
||||||
|
|
||||||
|
let message = { |
||||||
|
type: 'vimvixen.console.show.error', |
||||||
|
text: text |
||||||
|
}; |
||||||
|
messages.send(this.element.contentWindow, message); |
||||||
|
} |
||||||
|
|
||||||
|
showFrame() { |
||||||
|
this.element.style.display = 'block'; |
||||||
} |
} |
||||||
|
|
||||||
remove() { |
hide() { |
||||||
this.element.remove(); |
this.element.style.display = 'none'; |
||||||
} |
} |
||||||
} |
} |
||||||
|
Reference in new issue