This file contains hidden or 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
.accelerated { | |
-webkit-transform: translate3d(0,0,0); | |
-moz-transform: translate3d(0,0,0); | |
-ms-transform: translate3d(0,0,0); | |
-o-transform: translate3d(0,0,0); | |
transform: translate3d(0,0,0); | |
} |
This file contains hidden or 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
var webcamStream = null, | |
video = document.getElementById('player'); | |
// try go get them all | |
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia; | |
document.getElementById('play').addEventListener('click', function(e) { | |
navigator.getUserMedia({ | |
video: true | |
}, |
This file contains hidden or 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
<button id="play">Capture webcam</button> | |
<button id="stop">Freeze image</button> | |
<video id="player"></video> | |
This file contains hidden or 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
// Check the browser capabilities | |
if ('getBattery' in navigator) { | |
navigator.getBattery().then(initBatteryListeners); | |
} else { | |
document.getElementById('content').innerHTML = 'Your browser doesn\'t support the Battery API. Try Chrome or Firefox.'; | |
} | |
// Callback when getting the battery | |
function initBatteryListeners(battery) { | |
updateInterface(battery); |
This file contains hidden or 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
window.addEventListener('devicelight', function(e) { | |
var html = document.querySelector('html'); | |
if (e.value < 100) { | |
html.classList.remove('light'); | |
html.classList.add('dark'); | |
} else { | |
html.classList.remove('dark'); | |
html.classList.add('light'); | |
} |
This file contains hidden or 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
document.addEventListener('visibilitychange', function(e) { | |
document.title = "vascocosta.net | " + document.visibilityState; | |
if (document.visibilityState === "visible") { | |
startXHR(); | |
} else { | |
stopXHR(); | |
} | |
}); |