Display instruction text only if recording is enabled

This commit is contained in:
David Rowe 2017-04-06 09:22:01 +12:00
parent b29bfd4bb4
commit 813a5684e3
2 changed files with 11 additions and 3 deletions

View file

@ -10,7 +10,8 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
var elEnableRecording, var isUsingToolbar = false,
elEnableRecording,
elInstructions, elInstructions,
EVENT_BRIDGE_TYPE = "record", EVENT_BRIDGE_TYPE = "record",
BODY_LOADED_ACTION = "bodyLoaded", BODY_LOADED_ACTION = "bodyLoaded",
@ -19,13 +20,19 @@ var elEnableRecording,
TABLET_INSTRUCTIONS = "Close the tablet to start recording", TABLET_INSTRUCTIONS = "Close the tablet to start recording",
WINDOW_INSTRUCTIONS = "Close the window to start recording"; WINDOW_INSTRUCTIONS = "Close the window to start recording";
function updateInstructions() {
elInstructions.innerHTML = elEnableRecording.checked ? (isUsingToolbar ? WINDOW_INSTRUCTIONS : TABLET_INSTRUCTIONS) : "";
}
function onScriptEventReceived(data) { function onScriptEventReceived(data) {
var message = JSON.parse(data); var message = JSON.parse(data);
if (message.type === EVENT_BRIDGE_TYPE) { if (message.type === EVENT_BRIDGE_TYPE) {
if (message.action === ENABLE_RECORDING_ACTION) { if (message.action === ENABLE_RECORDING_ACTION) {
elEnableRecording.checked = message.value; elEnableRecording.checked = message.value;
updateInstructions();
} else if (message.action === USING_TOOLBAR_ACTION) { } else if (message.action === USING_TOOLBAR_ACTION) {
elInstructions.innerHTML = message.value ? WINDOW_INSTRUCTIONS : TABLET_INSTRUCTIONS; isUsingToolbar = message.value;
updateInstructions();
} }
} }
} }
@ -36,6 +43,7 @@ function onBodyLoaded() {
elEnableRecording = document.getElementById("enable-recording"); elEnableRecording = document.getElementById("enable-recording");
elEnableRecording.onchange = function () { elEnableRecording.onchange = function () {
updateInstructions();
EventBridge.emitWebEvent(JSON.stringify({ EventBridge.emitWebEvent(JSON.stringify({
type: EVENT_BRIDGE_TYPE, type: EVENT_BRIDGE_TYPE,
action: ENABLE_RECORDING_ACTION, action: ENABLE_RECORDING_ACTION,

View file

@ -24,7 +24,7 @@
<label for="enable-recording">Enable recording</label> <label for="enable-recording">Enable recording</label>
</div> </div>
<div class="instructions"> <div class="instructions">
<p id="instructions">Close the tablet to start recording.</p> <p id="instructions"></p>
</div> </div>
<script> <script>
onBodyLoaded(); onBodyLoaded();