Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
accel-test/js/main.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
41 lines (34 sloc)
1.09 KB
This file contains 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
// if (window.DeviceMotionEvent) { | |
// window.addEventListener('devicemotion', deviceMotionHandler, false); | |
// } else { | |
// document.getElementById("warning").innerHTML = "Not supported." | |
// } | |
// function deviceMotionHandler(eventData) { | |
// // Grab the acceleration from the results | |
// var acceleration = eventData.acceleration; | |
// var trimmedaccel = acceleration.x.toPrecision(2) | |
// switch (trimmedaccel >= 0) { | |
// case true: | |
// $("body").addClass('up'); | |
// $("body").removeClass('down'); | |
// break; | |
// case false: | |
// $("body").addClass('down'); | |
// $("body").removeClass('up'); | |
// break; | |
// } | |
// } | |
var x = document.getElementById("warning"); | |
function getLocation() { | |
if (navigator.geolocation) { | |
navigator.geolocation.getCurrentPosition(showPosition); | |
} else { | |
x.innerHTML = "Geolocation is not supported by this browser."; | |
} | |
} | |
function showPosition(position) { | |
x.innerHTML = "Latitude: " + position.coords.latitude + | |
"<br>Longitude: " + position.coords.longitude + | |
"<br>Altitude: " + position.coords.altitude; | |
} | |
getLocation(); |