mirror of
https://github.com/vale981/tridactyl
synced 2025-03-04 17:11:40 -05:00
src: consistently use message.type
This commit is contained in:
parent
72ae2f0559
commit
7b789350df
4 changed files with 8 additions and 8 deletions
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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 = ""
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue