Moved javascript to seperate file

Signed-off-by: Keith Irwin <mail@keithirwin.us>
master
Keith Irwin 2016-12-13 17:54:56 -05:00
parent 0efcc2afa8
commit bb2ac0ca37
2 changed files with 22 additions and 20 deletions

View File

@ -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>

19
script.js Normal file
View File

@ -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
});
}
}