src: consistently use message.type

This commit is contained in:
Colin Caine 2017-10-04 23:58:30 +01:00
parent 72ae2f0559
commit 7b789350df
4 changed files with 8 additions and 8 deletions

View file

@ -1,6 +1,6 @@
/** CommandLine API for inclusion in background script
Receives messages from CommandLinePage
Receives messages from commandline_frame
*/
export namespace onLine {
@ -12,9 +12,9 @@ export namespace onLine {
return () => { listeners.delete(cb) }
}
// Receive events from CommandLinePage and pass to listeners
/** Receive events from commandline_frame and pass to listeners */
function handler(message: any) {
if (message.command === "commandline") {
if (message.type === "commandline") {
for (let listener of listeners) {
listener(message.exStr)
}

View file

@ -14,7 +14,7 @@ clInput.addEventListener("keydown", function (keyevent) {
function process() {
// TODO.
console.log(clInput.value)
browser.runtime.sendMessage({command: "commandline", exStr: clInput.value})
browser.runtime.sendMessage({type: "commandline", exStr: clInput.value})
clInput.value = ""
}

View file

@ -2,7 +2,7 @@
// Type for messages sent from keydown_content
interface KeydownShimMessage {
command: string
type: string
event: Event
}
@ -18,7 +18,7 @@ export const onKeydown = { addListener }
// Receive events from content and pass to listeners
function handler(message: KeydownShimMessage) {
if (message.command === "keydown") {
if (message.type === "keydown") {
for (let listener of listeners) {
listener(message.event)
}

View file

@ -27,12 +27,12 @@ function keyeventHandler(ke: KeyboardEvent) {
if (stopPropagation) {
ke.stopPropagation()
}
browser.runtime.sendMessage({command: "keydown", event: shallowKeyboardEvent(ke)})
browser.runtime.sendMessage({type: "keydown", event: shallowKeyboardEvent(ke)})
}
// Listen for suppression messages from bg script.
function backgroundListener(message) {
if (message.command === "keydown-suppress") {
if (message.type === "keydown-suppress") {
if ('preventDefault' in message.data) {
preventDefault = message.data.preventDefault
}