This commit is contained in:
moorgar11 2014-03-11 09:24:07 +01:00
parent a683144414
commit 7c33835b8a
3 changed files with 26 additions and 4 deletions

10
index.html Normal file
View file

@ -0,0 +1,10 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<script src="lock.js"></script>
<script src="main.js"></script>
</head>
<body>
<canvas id="canvas" width="200px" height="200px" style="background-color: #fff;"></canvas>
</body>
</html>

View file

@ -1,5 +1,5 @@
var context;
var main = function () {
var lockinit = function () {
var canvas = document.getElementById("canvas");
context = canvas.getContext('2d');
drawLock();
@ -47,6 +47,4 @@ var drawDial = function(rot) {
context.fill();
}
context.restore();
}
window.onload = main;
}

14
main.js Normal file
View file

@ -0,0 +1,14 @@
var onSucess = function(heading) {
var element = document.getElementById('heading');
element.innerHTML = 'Heading: ' + heading;
};
var onErrors = function() {
alert('onError!');
};
var startup = function(){
var watchID = navigator.compass.watchHeading(onSuccess, onErrors);
lockinit();
}
window.onload = startup;