summaryrefslogtreecommitdiffstats
path: root/watch-library/simulator
diff options
context:
space:
mode:
authorJoey Castillo <joeycastillo@utexas.edu>2022-02-09 13:40:29 -0500
committerJoey Castillo <joeycastillo@utexas.edu>2022-02-09 13:40:29 -0500
commit108b9991d293eecbd02fa87ea6dea1c239959dc4 (patch)
tree1916070e548c4261d5f3dd9302488474f3db0134 /watch-library/simulator
parent79b037b4fb0a3f401406875c281afe2cf0864830 (diff)
downloadSensor-Watch-108b9991d293eecbd02fa87ea6dea1c239959dc4.tar.gz
Sensor-Watch-108b9991d293eecbd02fa87ea6dea1c239959dc4.tar.bz2
Sensor-Watch-108b9991d293eecbd02fa87ea6dea1c239959dc4.zip
simulator: add geolocation support
Diffstat (limited to 'watch-library/simulator')
-rw-r--r--watch-library/simulator/shell.html29
1 files changed, 29 insertions, 0 deletions
diff --git a/watch-library/simulator/shell.html b/watch-library/simulator/shell.html
index 1a4de984..2f560aba 100644
--- a/watch-library/simulator/shell.html
+++ b/watch-library/simulator/shell.html
@@ -321,6 +321,8 @@
<p style="text-align: center;"><a href="https://github.com/alexisphilip/Casio-F-91W">Original F-91W SVG</a> is &copy; 2020 Alexis Philip, and is used here under the terms of the MIT license.</p>
</div>
+<button onclick="getLocation()">Set location register (will prompt for access)</button>
+<br>
<textarea id="output" rows="8" style="width: 100%"></textarea>
<script type='text/javascript'>
@@ -361,6 +363,33 @@
if (text) Module.printErr('[post-exception status] ' + text);
};
};
+ lat = 0;
+ lon = 0;
+ function updateLocation(location) {
+ lat = Math.round(location.coords.latitude * 100);
+ lon = Math.round(location.coords.longitude * 100);
+ }
+ function showError(error) {
+ switch(error.code) {
+ case error.PERMISSION_DENIED:
+ alert("Permission denied");
+ break;
+ case error.POSITION_UNAVAILABLE:
+ alert("Location unavailable");
+ break;
+ case error.TIMEOUT:
+ alert("Request timed out");
+ break;
+ case error.UNKNOWN_ERROR:
+ alert("Unknown error");
+ break;
+ }
+ }
+ function getLocation() {
+ if (navigator.geolocation) {
+ navigator.geolocation.getCurrentPosition(updateLocation, showError);
+ }
+ }
</script>
{{{ SCRIPT }}}
</body>