-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f08dc8e
Showing
11 changed files
with
264 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ExpiresByType text/cache-manifest "access plus 0 seconds" | ||
AddType application/x-web-app-manifest+json .webapp |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# FxStumbler | ||
|
||
Firefox OS Stumbler for Mozilla [http://location.services.mozilla.com](). | ||
|
||
This application uses API only available to certified apps. So you can only install it on a developer phone. You need to [enable remote debugging](https://developer.mozilla.org/en-US/docs/Mozilla/Firefox_OS/Debugging/Developer_settings#Remote_debugging) on your phone. | ||
|
||
To push the application to the phone, I [push it from the Firefox OS Simulator](https://developer.mozilla.org/en-US/docs/Tools/Firefox_OS_Simulator#Push_to_device). | ||
|
||
|
||
To create the package, use | ||
|
||
rm stumbler.zip && zip -r stumbler.zip index.html js locales manifest.webapp style | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"/> | ||
<meta http-equiv="pragma" content="no-cache"/> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>FxStumbler</title> | ||
<script type="text/javascript" src="js/stumbler.js"></script> | ||
</head> | ||
<body class=""> | ||
<h1>Push location Infos</h1> | ||
<p> | ||
<!-- | ||
<button id="install">Install</button> | ||
--> | ||
<button id="mobile">Push infos</button> | ||
</p> | ||
<p> | ||
<pre id="result"> | ||
</pre> | ||
</p> | ||
</body> | ||
</html> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
//jshint browser: true | ||
var result; | ||
function log(message) { | ||
"use strict"; | ||
if (typeof message === 'object') { | ||
message = JSON.stringify(message, null, ' '); | ||
} | ||
result.textContent += '[' + new Date().toISOString() + ']' + message + "\n"; | ||
} | ||
function getMobileInfos() { | ||
//jshint maxstatements: 30 | ||
"use strict"; | ||
var options = { | ||
enableHighAccuracy: true, | ||
timeout: 60000, // 1 minute | ||
maximumAge: 0 | ||
}, | ||
items = [], | ||
item = {}; | ||
result.textContent = ''; | ||
|
||
// Cell {{ | ||
function getCellInfos() { | ||
var conn, data, voice, cell = {}; | ||
log("[cell] Getting cell infos"); | ||
try { | ||
conn = window.navigator.mozMobileConnection; | ||
data = conn.data; | ||
voice = conn.voice; | ||
cell.radio = voice.type; | ||
cell.mcc = voice.network.mcc; | ||
cell.mnc = voice.network.mnc; | ||
cell.lac = voice.cell.gsmLocationAreaCode; | ||
cell.cid = voice.cell.gsmCellId; | ||
cell.signal = voice.signalStrength; | ||
cell.asu = undefined; | ||
cell.ta = undefined; | ||
cell.psc = undefined; | ||
log("[cell] Done"); | ||
} catch (e) { | ||
log("[cell] Error : " + e); | ||
} | ||
return cell; | ||
} | ||
// }} | ||
// Wifi {{ | ||
function getWifiInfos(cb) { | ||
var wifi, | ||
request, | ||
networks = []; | ||
|
||
log("[wifi] Getting Wifi infos"); | ||
try { | ||
wifi = navigator.mozWifiManager; | ||
request = wifi.getNetworks(); | ||
request.onsuccess = function () { | ||
log("[wifi] found " + this.result.length + " networks"); | ||
this.result.forEach(function (network) { | ||
var net; | ||
if (!/_nomap/.test(network.ssid)) { | ||
net = { | ||
key: network.bssid, | ||
channel: undefined, | ||
frequency: undefined, | ||
signal: network.signalStrength | ||
}; | ||
networks.push(net); | ||
} | ||
}); | ||
log("[wifi] Done"); | ||
cb(networks); | ||
}; | ||
request.onerror = function (err) { | ||
log('[wifi] Something goes wrong: ' + err); | ||
cb(networks); | ||
}; | ||
} catch (e) { | ||
log('[wifi] Something goes wrong: ' + e); | ||
cb(networks); | ||
} | ||
} | ||
function onWifiInfos(networks) { | ||
item.wifi = networks; | ||
item.cell = [ getCellInfos() ]; | ||
items.push(item); | ||
send(items); | ||
} | ||
// }} | ||
// send {{ | ||
function send() { | ||
var xhr, res, options; | ||
options = { | ||
mozAnon: true, | ||
mozSystem: true | ||
}; | ||
log("Sending…"); | ||
log(items); | ||
try { | ||
xhr = new XMLHttpRequest(options); | ||
xhr.open("POST", "https://location.services.mozilla.com/v1/submit", false); | ||
xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8"); | ||
xhr.send(JSON.stringify({items: items})); | ||
if (xhr.status === 204) { | ||
log("OK"); | ||
} else { | ||
log("K0"); | ||
try { | ||
log("Error sending datas: "); | ||
res = JSON.parse(xhr.responseText).errors; | ||
res.forEach(function (error) { log(error); }); | ||
} catch (e) { | ||
log('Unable to parse response: ' + e); | ||
} | ||
} | ||
} catch (e) { | ||
log('Error sending datas: ' + e); | ||
} | ||
} | ||
// }} | ||
// Geoloc {{ | ||
function onGeolocSuccess(pos) { | ||
log("[geoloc] Done"); | ||
item.lat = pos.coords.latitude; | ||
item.lon = pos.coords.longitude; | ||
item.accuracy = pos.coords.accuracy; | ||
|
||
getWifiInfos(onWifiInfos); | ||
} | ||
function onGeolocError(err) { | ||
log('[geoloc] Error: ' + err.code + ' : ' + err.message); | ||
log('Aborting.'); | ||
getWifiInfos(onWifiInfos); | ||
} | ||
// }} | ||
|
||
navigator.geolocation.getCurrentPosition(onGeolocSuccess, onGeolocError, options); | ||
|
||
|
||
return false; | ||
} | ||
/* | ||
function install() { | ||
"use strict"; | ||
var manifestUrl = 'http://clochix.net/public/stumbler/package.manifest', | ||
req = navigator.mozApps.installPackage(manifestUrl); | ||
req.onsuccess = function () { | ||
alert(this.result.origin); | ||
}; | ||
req.onerror = function () { | ||
alert(this.error.name); | ||
}; | ||
return false; | ||
} | ||
*/ | ||
window.addEventListener("load", function () { | ||
"use strict"; | ||
result = document.getElementById("result"); | ||
//document.getElementById('install').addEventListener('click', install); | ||
document.getElementById('mobile').addEventListener('click', getMobileInfos); | ||
}); | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"name": "FxStumbler", | ||
"description": "Client for Mozilla Location Service", | ||
"type": "certified", | ||
"version": "0.1", | ||
"launch_path": "/index.html", | ||
"developer": { | ||
"name": "Clochix", | ||
"url": "https://github.com/clochix/fxstumbler" | ||
}, | ||
"permissions": { | ||
"geolocation": { | ||
"description": "Geo Location" | ||
}, | ||
"mobileconnection":{ | ||
"description": "Access to GSM datas" | ||
}, | ||
"systemXHR":{ | ||
"description": "Send datas" | ||
}, | ||
"wifi-manage":{ | ||
"description": "Access to wifi data" | ||
} | ||
}, | ||
"default_locale": "en-US", | ||
"icons": { | ||
"30": "/style/icons/icon-30.png", | ||
"60": "/style/icons/icon-60.png", | ||
"128": "/style/icons/icon-128.png" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"name": "FxStumbler", | ||
"package_path" : "http://clochix.net/public/stumbler/stumbler.zip", | ||
"description": "Client for Mozilla Location Service", | ||
"type": "certified", | ||
"version": "0.1", | ||
"launch_path": "/index.html", | ||
"developer": { | ||
"name": "Clochix", | ||
"url": "https://github.com/clochix/fxstumbler" | ||
}, | ||
"permissions": { | ||
"geolocation": { | ||
"description": "Geo Location" | ||
}, | ||
"mobileconnection":{ | ||
"description": "Access to GSM datas" | ||
}, | ||
"systemXHR":{ | ||
"description": "Send datas" | ||
}, | ||
"wifi-manage":{ | ||
"description": "Access to wifi data" | ||
} | ||
}, | ||
"default_locale": "en-US", | ||
"icons": { | ||
"30": "/style/icons/icon-30.png", | ||
"60": "/style/icons/icon-60.png", | ||
"128": "/style/icons/icon-128.png" | ||
} | ||
} |
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Source: http://www.iconarchive.com/show/mobile-icons-by-webiconset/maps-icon.html | ||
Licence: Freeware |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.