This repository has been archived by the owner on Nov 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to sign in and save settings. Add terms of service page.
- Loading branch information
1 parent
09f0c49
commit 28db2c8
Showing
19 changed files
with
1,704 additions
and
400 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,73 @@ | ||
function commitToWindow(windowInstance, type, payload) { | ||
windowInstance.dispatchEvent(new CustomEvent('processVuexMutation', {detail: {type, payload}})); | ||
windowInstance.dispatchEvent(new CustomEvent('processVuexMutation', { | ||
detail: { | ||
type, | ||
payload | ||
} | ||
})); | ||
} | ||
|
||
function actionToWindow(windowInstance, type, payload) { | ||
windowInstance.dispatchEvent(new CustomEvent('processVuexAction', {detail: {type, payload}})); | ||
windowInstance.dispatchEvent(new CustomEvent('processVuexAction', { | ||
detail: { | ||
type, | ||
payload | ||
} | ||
})); | ||
} | ||
|
||
export default { | ||
methods: { | ||
start(RemoteEventBus, {settings, transcriptInterim, transcriptFinal, transcriptTyped}, onClose) { | ||
let chromelessWindow = window.open('/receivers/chromeless', 'WebCaptionerChild', 'height=700,width=900,toolbar=0,location=0,menubar=0'); | ||
|
||
if (!chromelessWindow) { | ||
alert('Unable to open a new window.'); | ||
return; | ||
} | ||
|
||
RemoteEventBus.$on('sendMutationToReceivers', ({mutation, payload}) => { | ||
commitToWindow(chromelessWindow, mutation, payload); | ||
}); | ||
|
||
function restoreSettings() { | ||
actionToWindow(chromelessWindow, 'RESTORE_SETTINGS', { settings }); | ||
commitToWindow(chromelessWindow, 'captioner/SET_TRANSCRIPT_INTERIM', { transcriptInterim }); | ||
commitToWindow(chromelessWindow, 'captioner/SET_TRANSCRIPT_FINAL', { transcriptFinal }); | ||
commitToWindow(chromelessWindow, 'captioner/SET_TRANSCRIPT_TYPED', { transcriptTyped }); | ||
|
||
// Only do it once for this window | ||
window.removeEventListener('receiverIsReadyToReceiveMutations', restoreSettings); | ||
} | ||
window.addEventListener('receiverIsReadyToReceiveMutations', restoreSettings); | ||
|
||
// I wanted to check for the unload event here, but it also fires on reload | ||
// and the load event didn't fire reliably when refreshing. So for now this interval | ||
// seemed more reliable. | ||
let checkOpenInterval; | ||
|
||
checkOpenInterval = setInterval(function(){ | ||
if (!chromelessWindow || chromelessWindow.closed) { | ||
onClose(); | ||
clearInterval(checkOpenInterval); | ||
} | ||
},500); | ||
}, | ||
} | ||
} | ||
methods: { | ||
start(RemoteEventBus, { | ||
settings, | ||
transcriptInterim, | ||
transcriptFinal, | ||
transcriptTyped | ||
}, onClose) { | ||
let chromelessWindow = window.open('/receivers/chromeless', 'WebCaptionerChild', 'height=700,width=900,toolbar=0,location=0,menubar=0'); | ||
|
||
if (!chromelessWindow) { | ||
alert('Unable to open a new window.'); | ||
return; | ||
} | ||
|
||
RemoteEventBus.$on('sendMutationToReceivers', ({ | ||
mutation, | ||
payload | ||
}) => { | ||
commitToWindow(chromelessWindow, mutation, payload); | ||
}); | ||
|
||
function restoreSettings() { | ||
actionToWindow(chromelessWindow, 'RESTORE_SETTINGS_OBJECT', { | ||
settings | ||
}); | ||
commitToWindow(chromelessWindow, 'captioner/SET_TRANSCRIPT_INTERIM', { | ||
transcriptInterim | ||
}); | ||
commitToWindow(chromelessWindow, 'captioner/SET_TRANSCRIPT_FINAL', { | ||
transcriptFinal | ||
}); | ||
commitToWindow(chromelessWindow, 'captioner/SET_TRANSCRIPT_TYPED', { | ||
transcriptTyped | ||
}); | ||
|
||
// Only do it once for this window | ||
window.removeEventListener('receiverIsReadyToReceiveMutations', restoreSettings); | ||
} | ||
window.addEventListener('receiverIsReadyToReceiveMutations', restoreSettings); | ||
|
||
// I wanted to check for the unload event here, but it also fires on reload | ||
// and the load event didn't fire reliably when refreshing. So for now this interval | ||
// seemed more reliable. | ||
let checkOpenInterval; | ||
|
||
checkOpenInterval = setInterval(function () { | ||
if (!chromelessWindow || chromelessWindow.closed) { | ||
onClose(); | ||
clearInterval(checkOpenInterval); | ||
} | ||
}, 500); | ||
}, | ||
} | ||
} |
Oops, something went wrong.