Moved javascript to seperate file
Signed-off-by: Keith Irwin <mail@keithirwin.us>master
parent
0efcc2afa8
commit
bb2ac0ca37
23
index.html
23
index.html
|
@ -59,28 +59,11 @@
|
|||
|
||||
<footer>
|
||||
<div style="float:left"><a href="https://github.com/keith24/Compass/blob/master/README.md">About</a></div>
|
||||
<div style="float:right">Made by <a href="https://keithirwin.us/">Keith Irwin</a>.</div>
|
||||
<div style="float:right">by <a href="https://keithirwin.us/">Keith Irwin</a>.</div>
|
||||
</footer>
|
||||
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
|
||||
<script>
|
||||
window.addEventListener("deviceorientation", handleOrientation, true);
|
||||
function handleOrientation(event) {
|
||||
|
||||
// No orientation data
|
||||
if(!event.absolute) {
|
||||
$('#rose-error').show();
|
||||
|
||||
} else {
|
||||
var rot = 'rotate('+event.alpha.toString().substring(0,5)+'deg)';
|
||||
$('#rose').css({
|
||||
'-ms-transform': rot,
|
||||
'-webkit-transform': rot,
|
||||
'transform': rot
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<script src="script.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
window.addEventListener("deviceorientation", setRose, true);
|
||||
|
||||
function setRose(e) {
|
||||
|
||||
// No orientation data
|
||||
if(!e.absolute) {
|
||||
$('#rose-error').show();
|
||||
} else {
|
||||
|
||||
// Rotate rose
|
||||
var rot = 'rotate('+e.alpha.toString().substring(0,5)+'deg)';
|
||||
$('#rose').css({
|
||||
'-ms-transform': rot,
|
||||
'-webkit-transform': rot,
|
||||
'transform': rot
|
||||
});
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue