<div id="sideBottom">
<ul id="navlist">
-<li id="navPos" onclick="switchModule('Pos');">Position</li>
-<li id="navGrav" onclick="switchModule('Grav');">Gravity</li>
-<li id="navOther" onclick="switchModule('Other');">Other</li>
+<li id="navPos">Position</li>
+<li id="navGrav">Gravity</li>
+<li id="navDev">Device</li>
+<li id="navOther">Other</li>
</ul>
</div>
<ul id="sideRemark">
-<li onclick="toggleFullscreen();">Full Screen</li>
+<li id="fullScreenButton">Full Screen</li>
</ul>
</div>
</div>
</section>
+<section id="sectDev">
+<table>
+<tr><td>Battery Level:</td><td id="devBattLevel" class="deviceVal">...</td></tr>
+<tr><td>Battery Status:</td><td id="devBattStatus" class="deviceVal">...</td></tr>
+<!-- to come : storage data -->
+</table>
+</section>
+
<section id="sectOther">
<p>This tricorder model doesn't have other sensors yet, please contact
the <a href="http://www.kairo.at/apps" target="_blank">Starfleet science
gSounds.keyaction = new Audio("sound/key-action.opus");
gSounds.keypress = new Audio("sound/key-press.opus");
+ document.getElementById("fullScreenButton").addEventListener("click",
+ function(aEvent) { toggleFullscreen(); }, false);
+
+ var navItems = document.getElementById("navlist").children;
+ for (var i = 0; i <= navItems.length - 1; i++) {
+ navItems[i].addEventListener("click",
+ function(aEvent) {
+ switchModule(aEvent.target.id.replace("nav", ""));
+ }, false);
+ }
+
gSounds.launch.play();
window.addEventListener("beforeunload", function( event ) {
gSounds.shutdown.play();
}
}
-function switchModule(modname) {
+function switchModule(aModname) {
gSounds.keyaction.play();
var sections = document.getElementsByTagName('section');
for (var i = 0; i <= sections.length - 1; i++) {
navs[i].classList.remove("active");
}
- var navItem = document.getElementById("nav" + modname);
+ var navItem = document.getElementById("nav" + aModname);
navItem.classList.add("active");
- document.getElementById("sect" + modname).classList.add("active");
+ document.getElementById("sect" + aModname).classList.add("active");
document.getElementById("mainHeader").textContent =
- (modname == "Other") ? "Web Tricorder" : navItem.textContent;
+ (aModname == "Other") ? "Web Tricorder" : navItem.textContent;
- window["gMod" + modname].activate();
+ window["gMod" + aModname].activate();
}
var gModPos = {
},
}
+
+var gModDev = {
+ activate: function() {
+ gSounds.scan.play();
+ this.batteryTimer =
+ setInterval(function () { gModDev.updateBattery(); }, 100);
+ },
+ deactivate: function() {
+ clearTimeout(this.batteryTimer);
+ gSounds.scan.pause();
+ },
+ updateBattery: function() {
+ document.getElementById("devBattLevel").textContent = (navigator.battery.level * 100).toFixed(1) + "%";
+ document.getElementById("devBattStatus").textContent =
+ navigator.battery.charging ? "charging, " + navigator.battery.chargingTime + "s remaining"
+ : navigator.battery.dischargingTime + "s usage remaining";
+ },
+ batteryTimer: null,
+}
+
+var gModNull = {
+ activate: function() {
+ //gSounds.scan.play();
+ },
+ deactivate: function() {
+ gSounds.scan.pause();
+ },
+}
+
var gModOther = {
activate: function() {
//gSounds.scan.play();