content/hifi-content/seefo/production/puck-attach/puck-attach.html
2022-02-14 02:04:11 +01:00

67 lines
2.5 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<link rel="stylesheet" href="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" />
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
<script>
$(document).ready(function () {
// hook up a handler for events that come from hifi.
EventBridge.scriptEventReceived.connect(function (msg) {
// add available tracked object to selector
var selector = $("#puckno");
var data = JSON.parse(msg);
var availableTrackedObjects = data.pucks;
var selectedPuck = data.selectedPuck;
if (Array.isArray(availableTrackedObjects)) {
for (var i = 0; i < availableTrackedObjects.length; i++) {
selector.append('<option value="' + availableTrackedObjects[i] + '">TrackedObject' + availableTrackedObjects[i] + '</option>');
var selected = (selectedPuck === availableTrackedObjects[i]);
if (selected) {
selector.val(availableTrackedObjects[i]);
}
}
}
selector.trigger("change");
});
$("#create").click(function () {
var obj = {cmd: "create"};
obj.puckno = $("#puckno").val();
EventBridge.emitWebEvent(JSON.stringify(obj));
});
$("#finalize").click(function () {
var obj = {cmd: "finalize"};
obj.puckno = $("#puckno").val();
EventBridge.emitWebEvent(JSON.stringify(obj));
});
$("#destroy").click(function () {
var obj = {cmd: "destroy"};
obj.puckno = $("#puckno").val();
EventBridge.emitWebEvent(JSON.stringify(obj));
});
// let the interface script know we are ready to receive data
EventBridge.emitWebEvent(JSON.stringify({cmd: "ready"}));
});
</script>
<head>
<meta charset="utf-8" />
<body>
<div style="margin:10px">
<div class="ui-field-contain">
<label for="puckno">Tracked Puck</label>
<select name="puckno" id="puckno" data-native-menu="false">
<option value="-1">NONE</option>
</select>
</div>
<button id="create" class="ui-btn ui-corner-all">Create Puck</button>
<button id="finalize" class="ui-btn ui-corner-all">Finalize Puck</button>
<button id="destroy" class="ui-btn ui-corner-all">Destroy Puck</button>
</div>
</body>
</head>
</html>