</table>
<div id="envFlashAvail" style="display:none">
Flashlight:
-<button id="envFlashOn" class="envButton">On</button>
-<button id="envFlashOff" class="envButton">Off</button>
+<button id="envFlashOn" class="envButton">On</button><button
+ id="envFlashOff" class="envButton" disabled="true">Off</button>
</div>
<div id="envFlashUnavail">
<!-- No camera with flash available -->
}
}, 5000);
try {
- for (var cameraId of window.navigator.mozCameras.getListOfCameras()) {
- window.navigator.mozCameras.getCamera({camera: cameraId}, function(aCamera) {
+ var cameras = navigator.mozCameras.getListOfCameras();
+ for (i = 0; i < cameras.length; i++) {
+ var promise = navigator.mozCameras.getCamera(cameras[i], {},
+ function(aCamera) {
if (aCamera.capabilities.flashModes.indexOf('torch') !== -1) {
- this.flashCamera = aCamera;
+ gModEnv.foundFlashCamera(aCamera);
}
- });
- }
- if (this.flashCamera) {
- document.getElementById("envFlashOn").onclick = gModEnv.switchFlashlight(true);
- document.getElementById("envFlashOff").onclick = gModEnv.switchFlashlight(false);
- document.getElementById("envFlashUnavail").style.display = "none";
- document.getElementById("envFlashAvail").style.display = "block";
+ },
+ function(aError) { console.log("camera error: " + aError); }
+ );
}
} catch (e) {
// camera api not supported
document.getElementById("envFlashAvail").style.display = "none";
}
},
+ foundFlashCamera(aCamera) {
+ this.flashCamera = aCamera;
+ document.getElementById("envFlashOn").onclick = function() { console.log("on"); gModEnv.switchFlashlight(true); };
+ document.getElementById("envFlashOff").onclick = function() { console.log("off"); gModEnv.switchFlashlight(false); };
+ document.getElementById("envFlashUnavail").style.display = "none";
+ document.getElementById("envFlashAvail").style.display = "block";
+ },
deactivate: function() {
gSounds.scan.pause();
window.removeEventListener("devicelight", this.lightEvent, true);
switchFlashlight: function(aEnabled) {
if (this.flashCamera) {
this.flashCamera.flashMode = aEnabled ? 'torch' : 'off';
+ document.getElementById("envFlashOn").disabled == aEnabled;
+ document.getElementById("envFlashOff").disabled == !aEnabled;
}
}
}
padding-top: 1em;
}
+button {
+ font: inherit;
+ border: none;
+ color: #000000;
+ background-color: #C09070;
+ border-radius: 3000px;
+ margin: 0 .25em;
+}
+
+button.disabled {
+ background-color: #402858;
+}
+
.posVal, .gravVal {
text-align: right;
}
height: 100%;
}
+#envFlashAvail {
+ padding: 1em 3px 0;
+}
+
+#envFlashOn {
+ margin-right: 0;
+ border-top-right-radius: 0;
+ border-bottom-right-radius: 0;
+}
+
+#envFlashOff {
+ margin-left: 0;
+ border-top-left-radius: 0;
+ border-bottom-left-radius: 0;
+}
+
@media screen and (min-width: 500px) {
body {
font-size: 24px;