-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththisapp.js
68 lines (62 loc) · 2.59 KB
/
thisapp.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
function DOMloaded() {
document.addEventListener("deviceready", phonegapLoaded, false);
// Wait for device API libraries to load
//
document.addEventListener("deviceready", onDeviceReady, false);
}
function phonegapLoaded() {
var element = document.getElementById('deviceInfo');
var name = device.name;
var cordova = device.cordova;
var platform = device.platform;
var uuid = device.uuid;
var vers = device.version;
var model = device.model;
var networkstate = navigator.network.connection.type;
var states = {};
states[Connection.UNKNOWN] = 'Unknown connection';
states[Connection.ETHERNET] = 'Ethernet connection';
states[Connection.WIFI] = 'WIFI connection';
states[Connection.CELL_2G] = '2G connection';
states[Connection.CELL_3G] = '3G connection';
states[Connection.CELL_4G] = '4G connection';
states[Connection.NONE] = 'No connection';
$(function() {
$("body").append("<h1>Device information</h1>");
});
element.innerHTML = 'Device Name: ' + name + '<br />' + 'Device Platform: '
+ platform + '<br />' + 'Device UUID: ' + uuid + '<br />'
+ 'Device Version: ' + vers + '<br />' + 'Device Model: ' + model
+ '<br />' + 'Device Network: ' + states[networkstate] + '<br />'
+ 'Device PhoneGap Version: ' + cordova + '<br />';
}
// device APIs are available
//
/*
* function onDeviceReady() { var options = { maximumAge : 600000, timeout :
* 10000, enableHighAccuracy : true }; watchID =
* navigator.geolocation.watchPosition(geolocationSuccess, geolocationError,
* options); $(function() { $("body").append(geolocationSuccess(position));
*
* }); }
*/
/*
* function geolocation() { // test if the geolocation is available var
* geolocationoptions = { enableHighAccuracy : true }; watchID =
* navigator.geolocation.getCurrentPosition(geolocationSuccess,
* geolocationError, geolocationoptions);
*/
/*
* function geolocationSuccess(position) { var element =
* document.getElementById('geolocation'); $(function() { $("body").append("<h1>Device
* information</h1>");}); element.innerHTML = 'Latitude: ' +
* position.coords.latitude + '<br />' + 'Longitude: ' +
* position.coords.longitude + '<br />' + 'Altitude: ' +
* position.coords.altitude + '<br />' + 'Accuracy: ' +
* position.coords.accuracy + '<br />' + 'Altitude Accuracy: ' +
* position.coords.altitudeAccuracy + '<br />' + 'Heading: ' +
* position.coords.heading + '<br />' + 'Speed: ' + position.coords.speed + '<br />' +
* 'Timestamp: ' + position.timestamp + '<br />' + '<hr />' +
* element.innerHTML; } function geolocationError(error) { alert('code: ' +
* error.code + '\n' + 'message: ' + error.message + '\n'); }}
*/