-
Notifications
You must be signed in to change notification settings - Fork 0
/
SpyEye.html
259 lines (237 loc) · 12.3 KB
/
SpyEye.html
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
<!DOCTYPE html>
<html>
<head>
<title></title>
<!-- Include meta tag to ensure proper rendering and touch zooming -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Include jQuery Mobile stylesheets -->
<link href="css/themes/Color.css" rel="stylesheet" />
<link href="css/themes/jquery.mobile.icons.min.css" rel="stylesheet" />
<link rel="stylesheet" href="css/jquery.mobile-1.4.5.min.css">
<!-- Include the jQuery library -->
<script src="js/jquery-1.11.3.min.js"></script>
<!-- Include the jQuery Mobile library -->
<script src="js/jquery.mobile-1.4.5.min.js"></script>
<!--<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCvTt4mGpTjYcyLaiMFM0jyJQ9fKgwwO80&libraries=places"></script>-->
<script src="http://maps.googleapis.com/maps/api/js?sensor=false&libraries=places"></script>
<script src="js/jquery.geocomplete.js"></script>
<script src="js/logger.js"></script>
<style>
#map-page, #map {
width: 100%;
height: 100%;
padding: 0;
}
::-webkit-input-placeholder { /* WebKit, Blink, Edge */
color: #e0dada;
}
</style>
</head>
<body>
<div data-role="page" id="map-page" data-url="map-page" data-theme="c">
<div data-role="header">
<h1>Welcome to ISecure App</h1>
<div data-role="navbar">
<ul>
<li><a href="iReacedAdmin.html" rel="external" data-transition="slidefade" data-icon="search">IReached</a></li>
<li><a href="SpyEye.html" rel="external" data-transition="slidefade" data-icon="eye">SpyEye</a></li>
<li><a href="AntiTheft.html" rel="external" data-transition="slidefade" data-icon="user">AntiTheft</a></li>
<li><a href="index.html" rel="external" data-transition="slidefade" data-icon="power">Signout</a></li>
</ul>
</div>
</div>
<div data-role="main" class="ui-content details">
<form>
<input type="search" name="search-5" id="geocomplete" value="" placeholder="Search Location...">
<fieldset class="ui-grid-b">
<!--<div class="ui-block-a"><button class="ui-btn ui-mini ui-corner-all" id="btnStart">Start</button></div>-->
<div class="ui-block-a"><label>Lat/Long</label></div>
<div class="ui-block-b"><input id="realLat" name="lat" type="text" value="" disabled="disabled" placeholder="Latitude"></div>
<div class="ui-block-c"><input id="realLng" name="lng" type="text" value="" disabled="disabled" placeholder="Longitude"></div>
</fieldset>
<fieldset class="ui-grid-b">
<div class="ui-block-a"><label>More Information</label></div>
<div class="ui-block-b"><input id="address" name="formatted_address" type="text" value="" disabled="disabled" placeholder="Location"></div>
<div class="ui-block-c"><input type="number" id="txtEmerNum" placeholder="Emergency Number"></div>
</fieldset>
<fieldset class="ui-grid-b">
<div class="ui-block-a"></div>
<div class="ui-block-b"></div>
<div class="ui-block-c"><button id="btnSave" class="ui-btn ui-corner-all">Save</button></div>
</fieldset>
<!--<div class="details" style="display:none;">
<input id="realLat" name="lat" type="text" value="">
<input id="realLng" name="lng" type="text" value="">
<input id="address" name="formatted_address" type="text" value="">
</div>-->
</form>
<button id="center" style="display:none;">.geocomplete("map").setCenter()</button>
<div id="map" class="map_canvas" style="width:100%;height:430px;">
</div>
</div>
<div data-role="footer">
<h1>@Copyright 2019</h1>
</div>
</div>
<script>
/*
* Google Maps documentation: http://code.google.com/apis/maps/documentation/javascript/basics.html
* Geolocation documentation: http://dev.w3.org/geo/api/spec-source.html
*/
$(document).ready(function () {
var createStatement = "CREATE TABLE IF NOT EXISTS app_SpyEye (id INTEGER PRIMARY KEY AUTOINCREMENT, latitude TEXT, longitude TEXT, Location TEXT, EmergencyNumber TEXT, isReached TEXT)";
var insertStatement = "INSERT INTO app_SpyEye (latitude, longitude, Location, EmergencyNumber, isReached) VALUES (?, ?, ?, ?, ?)";
var updateStatement = "UPDATE app_SpyEye SET latitude = ?, longitude = ?, Location = ?, EmergencyNumber = ? where id = 1";
var selectStatement = "Select * from app_SpyEye";
var dropStatement = "DROP TABLE app_SpyEye";
var db = openDatabase("SecureDb", "1.0", "App I Secure", 200000); // Open SQLite Database
var dataset;
var DataType;
function dropTable() // Function Call when Drop Button Click.. Talbe will be dropped from database.
{
db.transaction(function (tx) { tx.executeSql(dropStatement, [], null, onError); });
}
//dropTable();
function initDatabase() // Function Call When Page is ready.
{
try {
if (!window.openDatabase) // Check browser is supported SQLite or not.
{
ShowMessage('Databases are not supported in this mobile.');
}
else {
// alert('db Initialized.')
createTable(); // If supported then call Function for create table in SQLite
}
}
catch (e) {
if (e == 2) {
// Version number mismatch.
ShowMessage("Invalid database version.");
} else {
ShowMessage("Unknown error " + e + ".");
}
return;
}
}
initDatabase(); // call to initialize database
function ShowRecord() {
db.transaction(function (tx) {
tx.executeSql(selectStatement, [], function (tx, result) {
dataset = result.rows;
if (dataset.length == 0) {
return false;
}
else {
return true;
//alert('already exist');
}
});
});
}
//ShowRecord();
var defaultLatLng = new google.maps.LatLng(34.0983425, -118.3267434);
if (navigator.geolocation) {
function success(pos) {
// Location found, show map with these coordinates
defaultLatLng = new google.maps.LatLng(pos.coords.latitude, pos.coords.longitude);
$('#realLat').val(parseFloat(pos.coords.latitude).toFixed(5));
$('#realLng').val(parseFloat(pos.coords.longitude).toFixed(5));
//var latlng = { lat: parseFloat(pos.coords.latitude), lng: parseFloat(pos.coords.longitude) };
var request = new XMLHttpRequest();
var method = 'GET';
var url = 'http://maps.googleapis.com/maps/api/geocode/json?latlng=' + pos.coords.latitude + ',' + pos.coords.longitude + '&sensor=true';
var async = true;
request.open(method, url, async);
request.onreadystatechange = function () {
if (request.readyState == 4 && request.status == 200) {
var data = JSON.parse(request.responseText);
var address = data.results[0];
$('#address').val(address.formatted_address);
}
};
request.send();
//$('#address').val(pos.coords.formatted_address);
$("#center").trigger("click");
}
function fail(error) {
//drawMap(defaultLatLng); // Failed to find location, show default map
$("#center").trigger("click");
}
// Find the users current position. Cache the location for 5 minutes, timeout after 6 seconds
navigator.geolocation.getCurrentPosition(success, fail, { maximumAge: 500000, enableHighAccuracy: true, timeout: 6000 });
} else {
drawMap(defaultLatLng); // No geolocation support, show default map
}
$("#geocomplete").geocomplete({
map: ".map_canvas",
details: ".details"
});
$("#center").click(function () {
var map = $("#geocomplete").geocomplete("map"),
center = defaultLatLng;
map.setCenter(center);
map.setZoom(16);
$("#geocomplete").geocomplete({
map: ".map_canvas",
details: ".details"
});
});
//// Save Button coding
$('#btnSave').click(function () {
if ($('#address').val() != "" && $('#txtEmerNum').val() != "") {
db.transaction(function (tx) {
tx.executeSql(selectStatement, [], function (tx, result) {
dataset = result.rows;
//if (dataset.length == 0) {
if ($('#txtEmerNum').val() != "" && $('#txtEmerNum').val().length == 11) {
db.transaction(function (tx) {
tx.executeSql(insertStatement, [$('#realLat').val(), $('#realLng').val(), $('#address').val(), $('#txtEmerNum').val(), '0'], onSuccess, onError);
});
}
else {
ShowMessage("Enter valid number.");
}
//}
//else {
// db.transaction(function (tx) {
// tx.executeSql(updateStatement, [$('#realLat').val(), $('#realLng').val(), $('#address').val(), $('#txtEmerNum').val()], onSuccess, onError);
// });
//}
});
});
}
else {
ShowMessage('Please enter all fields.');
}
return false;
});
function onError(tx, error) // Function for Hendeling Error...
{
ShowMessage("dbError: " + error.message);
}
function onSuccess(tx, error) // Function for Hendeling Success...
{
$('#realLat').val(""); $('#realLng').val(""); $('#address').val(""); $('#txtEmerNum').val("");
$('#geocomplete').val("");
ShowMessage('Location updated successfully.');
}
function createTable() // Function for Create Table in SQLite.
{
db.transaction(function (tx) { tx.executeSql(createStatement, [], null, onError); });
}
///// Message function
function ShowMessage(message) {
$.mobile.loading('show',
{
theme: "a", text: (message),
textonly: true, textVisible: true
});
setTimeout(function () {
$.mobile.loading('hide');
}, 2000);
}
});
</script>
</body>
</html>