Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
107
gaia/dev_apps/geoloc/index.html
Executable file
107
gaia/dev_apps/geoloc/index.html
Executable file
|
|
@ -0,0 +1,107 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1">
|
||||
<meta charset="utf-8" />
|
||||
<title>Geolocation Debug</title>
|
||||
<link rel="stylesheet" type="text/css" href="shared/style/buttons.css" />
|
||||
<link rel="stylesheet" type="text/css" href="shared/style/headers.css" />
|
||||
<link rel="stylesheet" type="text/css" href="shared/style/input_areas.css" />
|
||||
<link rel="stylesheet" type="text/css" href="shared/elements/gaia-theme/gaia-theme.css /">
|
||||
<link rel="stylesheet" type="text/css" href="style/geoloc.css" />
|
||||
<script type="application/javascript" src="js/geoloc.js"></script>
|
||||
|
||||
<!-- localization -->
|
||||
<meta name="defaultLanguage" content="en-US">
|
||||
<meta name="availableLanguages" content="en-US">
|
||||
<link rel="localization" href="locales/geoloc.{locale}.properties">
|
||||
<link rel="localization" href="/shared/locales/date/date.{locale}.properties">
|
||||
<script src="shared/js/l10n.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script defer src="shared/js/component_utils.js"></script>
|
||||
<script defer src="shared/elements/gaia_switch/script.js"></script>
|
||||
</head>
|
||||
<body role="application">
|
||||
<section role="region">
|
||||
<header>
|
||||
<h1 data-l10n-id="geolocation-tracker">Geolocation tracker</h1>
|
||||
</header>
|
||||
</section>
|
||||
|
||||
<section role="region">
|
||||
<div class="bb-docs">
|
||||
<button id="btnGet" data-l10n-id="geoloc-get">Get</button>
|
||||
<button id="btnStart" data-l10n-id="geoloc-start">Start</button>
|
||||
<button id="btnStop" data-l10n-id="geoloc-stop">Stop</button>
|
||||
<button id="btnClear" data-l10n-id="geoloc-clear">Clear</button>
|
||||
<button id="btnSave" data-l10n-id="geoloc-save">Save as a file</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section role="region">
|
||||
<header>
|
||||
<h1 data-l10n-id="geoloc-parameters" id="h1-parameters" data-hide="parameters" class="bb-docs">Parameters</h1>
|
||||
</header>
|
||||
<div class="bb-docs" id="parameters">
|
||||
<fieldset>
|
||||
<legend data-l10n-id="geoloc-timeout">Timeout</legend>
|
||||
<section>
|
||||
<input type="number" id="geoloc-timeout" value="0" />
|
||||
</section>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend data-l10n-id="geoloc-maxage">Max. age</legend>
|
||||
<section>
|
||||
<input type="number" id="geoloc-maxage" value="0" />
|
||||
</section>
|
||||
</fieldset>
|
||||
<span class="desc" data-l10n-id="geoloc-msecs">Timeout and Max. age are specified in miliseconds.</span>
|
||||
<ul>
|
||||
<li>
|
||||
<gaia-switch id="geoloc-highaccuracy" checked>
|
||||
<label data-l10n-id="geoloc-highaccuracy">High accuracy</label>
|
||||
</gaia-switch>
|
||||
</li>
|
||||
<li>
|
||||
<gaia-switch id="geoloc-debug" checked>
|
||||
<label data-l10n-id="geoloc-debug">Show debug traces</label>
|
||||
</gaia-switch>
|
||||
</li>
|
||||
<li>
|
||||
<gaia-switch id="geoloc-keep" checked>
|
||||
<label data-l10n-id="geoloc-keep">Keep locations</label>
|
||||
</gaia-switch>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section role="region">
|
||||
<header>
|
||||
<h1 data-l10n-id="geoloc-status" id="h1-status" data-hide="status">Status</h1>
|
||||
</header>
|
||||
<div class="bb-docs" id="status">
|
||||
<fieldset>
|
||||
<legend data-l10n-id="gps-fixes">Fixes</legend>
|
||||
<section>
|
||||
<input type="text" disabled="disabled" id="nbr-gps-fixes" placeholder="0" />
|
||||
</section>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend data-l10n-id="last-fix">Last</legend>
|
||||
<section>
|
||||
<input type="text" disabled="disabled" data-l10n-id="date-last-fix" id="date-last-fix" placeholder="None" />
|
||||
</section>
|
||||
</fieldset>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section role="region">
|
||||
<header>
|
||||
<h1 data-l10n-id="geoloc-debug-log" id="h1-debuglog" data-hide="debuglog">Debug log</h1>
|
||||
</header>
|
||||
<div class="bb-docs" id="debuglog">
|
||||
<span id="log"></span>
|
||||
</div>
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
||||
325
gaia/dev_apps/geoloc/js/geoloc.js
Executable file
325
gaia/dev_apps/geoloc/js/geoloc.js
Executable file
|
|
@ -0,0 +1,325 @@
|
|||
var running = false;
|
||||
var watchId = undefined;
|
||||
var sep = "<br />************<br />";
|
||||
|
||||
var _ = undefined;
|
||||
|
||||
var locations = undefined;
|
||||
|
||||
function successWatch(position) {
|
||||
var debug = document.getElementById('geoloc-debug').checked;
|
||||
var s = document.querySelector('#log');
|
||||
|
||||
if (!debug) {
|
||||
s.innerHTML = "";
|
||||
}
|
||||
|
||||
if (keep()) {
|
||||
locations.push(position);
|
||||
}
|
||||
|
||||
s.innerHTML = sep + s.innerHTML;
|
||||
for (var i in position.coords) {
|
||||
var e = position.coords[i];
|
||||
if (typeof e == 'number') {
|
||||
s.innerHTML = i + ":" + position.coords[i] + "<br />" + s.innerHTML;
|
||||
}
|
||||
}
|
||||
var link = '<a href="http://www.openstreetmap.org/?mlat=' + position.coords.latitude + '&mlon=' + position.coords.longitude + '&zoom=16">Show on map</a><br />';
|
||||
s.innerHTML = link + s.innerHTML;
|
||||
|
||||
var nbfixes = document.getElementById('nbr-gps-fixes');
|
||||
nbfixes.value = parseInt(nbfixes.value) + 1;
|
||||
|
||||
var datefix = document.getElementById('date-last-fix');
|
||||
var cdate = new Date();
|
||||
var localeFormat = cdate.toLocaleString(navigator.languages, {
|
||||
month: 'numeric',
|
||||
day: 'numeric',
|
||||
year: 'numeric'
|
||||
});
|
||||
datefix.value = localeFormat;
|
||||
}
|
||||
|
||||
function errorWatch(msg) {
|
||||
var s = document.querySelector('#log');
|
||||
if (typeof msg == "object") {
|
||||
if (msg.code == 1) {
|
||||
msg = "Permission denied";
|
||||
}
|
||||
if (msg.code == 2) {
|
||||
msg = "Position unavailable";
|
||||
}
|
||||
if (msg.code == 3) {
|
||||
msg = "Timed out";
|
||||
}
|
||||
}
|
||||
s.innerHTML = sep + msg + sep + s.innerHTML;
|
||||
}
|
||||
|
||||
function successGet(position) {
|
||||
successWatch(position);
|
||||
enable('btnGet');
|
||||
enable('btnStart');
|
||||
enable('btnClear');
|
||||
enable('btnSave');
|
||||
}
|
||||
|
||||
function errorGet(msg) {
|
||||
errorWatch(msg);
|
||||
enable('btnGet');
|
||||
enable('btnStart');
|
||||
enable('btnClear');
|
||||
}
|
||||
|
||||
function getOptions() {
|
||||
if (navigator.geolocation) {
|
||||
locations = new Array();
|
||||
document.getElementById('nbr-gps-fixes').value = "0";
|
||||
document.getElementById('date-last-fix').value = "";
|
||||
show('status');
|
||||
if (document.getElementById('geoloc-debug').checked) {
|
||||
show('debuglog');
|
||||
}
|
||||
running = true;
|
||||
return {
|
||||
enableHighAccuracy: document.getElementById('geoloc-highaccuracy').checked ? true : false,
|
||||
timeout: parseInt(document.getElementById('geoloc-timeout').value),
|
||||
maximumAge: parseInt(document.getElementById('geoloc-maxage').value)
|
||||
};
|
||||
}
|
||||
errorWatch('not supported');
|
||||
return null;
|
||||
}
|
||||
|
||||
function getGeoloc() {
|
||||
errorWatch("getting current position");
|
||||
options = getOptions();
|
||||
if (options) {
|
||||
navigator.geolocation.getCurrentPosition(successGet, errorGet, options);
|
||||
disable('btnGet');
|
||||
disable('btnStart');
|
||||
disable('btnStop');
|
||||
disable('btnClear');
|
||||
disable('btnSave');
|
||||
}
|
||||
}
|
||||
|
||||
function startGeoloc() {
|
||||
errorWatch("Starting watchPosition");
|
||||
options = getOptions();
|
||||
if (options) {
|
||||
watchId = navigator.geolocation.watchPosition(successWatch, errorWatch, options);
|
||||
enable('btnStop');
|
||||
enable('btnClear');
|
||||
disable('btnGet');
|
||||
disable('btnStart');
|
||||
disable('btnSave');
|
||||
}
|
||||
}
|
||||
|
||||
function stopGeoloc() {
|
||||
if (watchId != undefined) {
|
||||
errorWatch("Stopping watchPosition");
|
||||
navigator.geolocation.clearWatch(watchId);
|
||||
disable('btnStop');
|
||||
enable('btnGet');
|
||||
enable('btnClear');
|
||||
enable('btnStart');
|
||||
if (keep()) {
|
||||
enable('btnSave');
|
||||
}
|
||||
running = false;
|
||||
}
|
||||
}
|
||||
|
||||
function clearGeoloc() {
|
||||
var s = document.querySelector('#log');
|
||||
s.innerHTML = "";
|
||||
}
|
||||
|
||||
function locationsToGPX() {
|
||||
var xmldoc = document.implementation.createDocument("", "", null);
|
||||
var doc = xmldoc.createElementNS('http://www.topografix.com/GPX/1/1', 'gpx');
|
||||
doc.setAttribute('creator', 'FirefoxOS geotracker');
|
||||
doc.setAttribute('version', '1.1');
|
||||
xmldoc.appendChild(doc);
|
||||
|
||||
var time = xmldoc.createElement('time');
|
||||
|
||||
var dtf = Intl.DateTimeFormat(navigator.languages, {
|
||||
year: 'numeric',
|
||||
moth: 'numeric',
|
||||
day: 'numeric',
|
||||
hour: 'numeric',
|
||||
minute: 'numeric',
|
||||
second: 'numeric',
|
||||
timeZoneName: 'short'
|
||||
});
|
||||
var ts = xmldoc.createTextNode(dtf.format(new Date()));
|
||||
time.appendChild(ts);
|
||||
doc.appendChild(time);
|
||||
|
||||
var createSimpleNode = function(name, value) {
|
||||
var e = xmldoc.createElement(name);
|
||||
e.appendChild(xmldoc.createTextNode(value));
|
||||
return e;
|
||||
};
|
||||
|
||||
for (var ei in locations) {
|
||||
var e = locations[ei];
|
||||
var x = xmldoc.createElement('wpt');
|
||||
x.setAttribute('lat', e.coords.latitude);
|
||||
x.setAttribute('lon', e.coords.longitude);
|
||||
|
||||
var ele = createSimpleNode('ele', e.coords.altitude);
|
||||
x.appendChild(ele);
|
||||
|
||||
var time = createSimpleNode('time', dtf.format(new Date(e.timestamp)));
|
||||
x.appendChild(time);
|
||||
|
||||
var ext = xmldoc.createElement('extensions');
|
||||
x.appendChild(ext);
|
||||
var accuracy = createSimpleNode('accuracy', e.coords.accuracy);
|
||||
ext.appendChild(accuracy);
|
||||
|
||||
var altitudeAccuracy = createSimpleNode('altitudeAccuracy', e.coords.altitudeAccuracy);
|
||||
ext.appendChild(altitudeAccuracy);
|
||||
|
||||
if (!isNaN(e.coords.speed)) {
|
||||
var speed = createSimpleNode('speed', e.coords.speed);
|
||||
ext.appendChild(speed);
|
||||
}
|
||||
|
||||
if (!isNaN(e.coords.heading)) {
|
||||
var heading = createSimpleNode('heading', e.coords.heading);
|
||||
ext.appendChild(heading);
|
||||
}
|
||||
|
||||
doc.appendChild(x);
|
||||
}
|
||||
|
||||
return xmldoc;
|
||||
}
|
||||
|
||||
function locationsToFile(format) {
|
||||
var xmldoc = undefined;
|
||||
if (format == "gpx") {
|
||||
xmldoc = locationsToGPX();
|
||||
}
|
||||
|
||||
var oSerializer = new XMLSerializer();
|
||||
return '<?xml version="1.0" ?>'
|
||||
+ oSerializer.serializeToString(xmldoc);
|
||||
}
|
||||
|
||||
function saveGeoloc() {
|
||||
var date = (new Date()).toLocaleFormat("%Y%m%d%H%M%S");
|
||||
var file = locationsToFile("gpx");
|
||||
var blob = new Blob([file], {type: 'application/gpx+xml'});
|
||||
var fname = "geoloc/geoloc-" + date + ".gpx";
|
||||
var storage = navigator.getDeviceStorage('sdcard');
|
||||
if (!storage) {
|
||||
console.log("No storage available!");
|
||||
console.log(file);
|
||||
return;
|
||||
}
|
||||
var save = storage.addNamed(blob, fname);
|
||||
save.onsuccess = function() {
|
||||
alert("Successfully saved " + fname);
|
||||
};
|
||||
save.onerror = function() {
|
||||
alert("Error while saving to " + fname + ": " + this.error.name);
|
||||
};
|
||||
}
|
||||
|
||||
function enable(id) {
|
||||
var e = document.getElementById(id);
|
||||
if (e) {
|
||||
e.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
function disable(id) {
|
||||
var e = document.getElementById(id);
|
||||
if (e) {
|
||||
e.disabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
function show(id) {
|
||||
var e = document.getElementById(id);
|
||||
if (e) {
|
||||
e.style.display = "block";
|
||||
}
|
||||
}
|
||||
|
||||
function hide(id) {
|
||||
var e = document.getElementById(id);
|
||||
if (e) {
|
||||
e.style.display = "none";
|
||||
}
|
||||
}
|
||||
|
||||
function keep() {
|
||||
var e = document.getElementById('geoloc-keep');
|
||||
if (e) {
|
||||
return e.checked;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
window.addEventListener('DOMContentLoaded', function() {
|
||||
_ = navigator.mozL10n.get;
|
||||
disable('btnStop');
|
||||
disable('btnClear');
|
||||
disable('btnSave');
|
||||
hide('parameters');
|
||||
hide('status');
|
||||
hide('debuglog');
|
||||
var keep = document.getElementById('geoloc-keep');
|
||||
keep.addEventListener('change', function(ev) {
|
||||
if (running) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ev.target.checked) {
|
||||
enable('btnSave');
|
||||
} else {
|
||||
disable('btnSave');
|
||||
}
|
||||
});
|
||||
|
||||
document.getElementById('geoloc-debug').addEventListener('change', function(ev) {
|
||||
if (ev.target.checked) {
|
||||
show('debuglog');
|
||||
} else {
|
||||
hide('debuglog');
|
||||
}
|
||||
});
|
||||
|
||||
var showHideDiv = function(ev, tgt) {
|
||||
var clicktarget = document.getElementById(tgt);
|
||||
clicktarget.addEventListener(ev, function(ev) {
|
||||
var target = ev.target.dataset['hide'];
|
||||
var el = document.getElementById(target);
|
||||
if (el) {
|
||||
if (el.style.display == "" || el.style.display == "block") {
|
||||
hide(target);
|
||||
} else {
|
||||
show(target);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
showHideDiv('click', 'h1-parameters');
|
||||
showHideDiv('click', 'h1-status');
|
||||
showHideDiv('click', 'h1-debuglog');
|
||||
|
||||
document.getElementById('btnGet').addEventListener('click', getGeoloc);
|
||||
document.getElementById('btnStart').addEventListener('click', startGeoloc);
|
||||
document.getElementById('btnStop').addEventListener('click', stopGeoloc);
|
||||
document.getElementById('btnClear').addEventListener('click', clearGeoloc);
|
||||
document.getElementById('btnSave').addEventListener('click', saveGeoloc);
|
||||
});
|
||||
20
gaia/dev_apps/geoloc/locales/geoloc.en-US.properties
Executable file
20
gaia/dev_apps/geoloc/locales/geoloc.en-US.properties
Executable file
|
|
@ -0,0 +1,20 @@
|
|||
geolocation-tracker = Geolocation tracker
|
||||
|
||||
geoloc-get = Get current
|
||||
geoloc-start = Start
|
||||
geoloc-stop = Stop
|
||||
geoloc-clear = Clear
|
||||
geoloc-debug = Show debug traces
|
||||
geoloc-keep = Keep locations
|
||||
geoloc-save = Save as a file
|
||||
geoloc-parameters = Parameters
|
||||
geoloc-status = Status
|
||||
geoloc-debug-log = Debug log
|
||||
geoloc-timeout = Timeout
|
||||
geoloc-maxage = Max. age
|
||||
geoloc-highaccuracy = High accuracy
|
||||
geoloc-msecs = Timeout and max. age are specified in milliseconds.
|
||||
|
||||
gps-fixes = Fixes
|
||||
last-fix = Last
|
||||
date-last-fix.placeholder = None
|
||||
41
gaia/dev_apps/geoloc/manifest.webapp
Executable file
41
gaia/dev_apps/geoloc/manifest.webapp
Executable file
|
|
@ -0,0 +1,41 @@
|
|||
{
|
||||
"name": "Geoloc",
|
||||
"description": "Geolocation Tracker",
|
||||
"type": "certified",
|
||||
"launch_path": "/index.html",
|
||||
"developer": {
|
||||
"name": "lissyx",
|
||||
"url": "https://github.com/lissyx/gaia-geoloc"
|
||||
},
|
||||
"permissions": {
|
||||
"geolocation":{},
|
||||
"device-storage:sdcard":{ "access": "readonly" }
|
||||
},
|
||||
"locales": {
|
||||
"ar": {
|
||||
"name": "Geoloc",
|
||||
"description": "Geolocation Tracker"
|
||||
},
|
||||
"en-US": {
|
||||
"name": "Geoloc",
|
||||
"description": "Geolocation Tracker"
|
||||
},
|
||||
"fr": {
|
||||
"name": "Geoloc",
|
||||
"description": "Enregistrement de géolocalisation"
|
||||
},
|
||||
"zh-TW": {
|
||||
"name": "Geoloc",
|
||||
"description": "Geolocation Tracker"
|
||||
}
|
||||
},
|
||||
"icons": {
|
||||
"84": "/style/icons/default_84.png",
|
||||
"126": "/style/icons/default_126.png",
|
||||
"142": "/style/icons/default_142.png",
|
||||
"189": "/style/icons/default_189.png",
|
||||
"284": "/style/icons/default_284.png"
|
||||
},
|
||||
"default_locale": "en-US",
|
||||
"orientation": "portrait-primary"
|
||||
}
|
||||
27
gaia/dev_apps/geoloc/style/geoloc.css
Executable file
27
gaia/dev_apps/geoloc/style/geoloc.css
Executable file
|
|
@ -0,0 +1,27 @@
|
|||
html, body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
body {
|
||||
background: none;
|
||||
}
|
||||
|
||||
li {
|
||||
list-style: none;
|
||||
margin-left: -2em;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
li span {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
fieldset legend {
|
||||
text-transform: none;
|
||||
}
|
||||
|
||||
span.desc {
|
||||
padding: 1em;
|
||||
}
|
||||
BIN
gaia/dev_apps/geoloc/style/icons/default_126.png
Executable file
BIN
gaia/dev_apps/geoloc/style/icons/default_126.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
BIN
gaia/dev_apps/geoloc/style/icons/default_142.png
Executable file
BIN
gaia/dev_apps/geoloc/style/icons/default_142.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 2.5 KiB |
BIN
gaia/dev_apps/geoloc/style/icons/default_189.png
Executable file
BIN
gaia/dev_apps/geoloc/style/icons/default_189.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 3.7 KiB |
BIN
gaia/dev_apps/geoloc/style/icons/default_284.png
Executable file
BIN
gaia/dev_apps/geoloc/style/icons/default_284.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 5.9 KiB |
BIN
gaia/dev_apps/geoloc/style/icons/default_84.png
Executable file
BIN
gaia/dev_apps/geoloc/style/icons/default_84.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
Loading…
Reference in a new issue