-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
executable file
·288 lines (280 loc) · 11.4 KB
/
index.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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
<!DOCTYPE html>
<html>
<head>
<!--Import Google Icon Font-->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!--Import materialize.css-->
<link type="text/css" rel="stylesheet" href="css/materialize.min.css" media="screen,projection" />
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="https://cdn.pubnub.com/sdk/javascript/pubnub.4.20.1.js"></script>
<script type="text/javascript" src="https://cdn.rawgit.com/chingyawhao/materialize-clockpicker/master/dist/js/materialize.clockpicker.js"></script>
<!--Let browser know website is optimized for mobile-->
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<body>
<div class="navbar-fixed">
<nav>
<div class="nav-wrapper indigo accent-2">
<a href="#" class="brand-logo">INSURANCE</a>
<i class="material-icons right black-text" style="padding-right:15px" onclick="logout()">power_settings_new</i>
</div>
</nav>
</div>
<div class="row">
<div class="col s12">
<ul class="tabs">
<li class="tab col s3">
<a class="active" href="#test1">Passenger</a>
</li>
<li class="tab col s3">
<a href="#test2">Profile</a>
</li>
</ul>
</div>
<div id="test1" class="col s12">
<div class="row" id="passengerList">
</div>
</div>
<div id="test2" class="col s12">
<div class="row">
<div id="test1" class="col s12">
<div class="row">
</br>
<Center>
<i class="material-icons" style="font-size: 150px;color:darkblue">account_circle</i>
<h5 id="company_name"></h5>
<h5 id="company_balance">Wallet Balance - </h5>
</Center>
</div>
</div>
</div>
<a class=" col s6 push-s3 btn-large green modal-trigger" href="#addParticipant">SET AIRLINE TIME</a>
<div id="addParticipant" class="modal">
<div class="modal-content">
<h4>Did the Airline arrive ?</h4>
</div>
<div class="modal-footer">
<a href="#!" class="modal-action modal-close waves-effect waves-green btn-flat" onclick="AirlineDestinationTimeSet()">Yes</a>
</div>
</div>
</div>
</div>
<div id="Loader" class="modal" >
<div class="modal-content">
<h5>Please wait....</h5>
</div>
</div>
<div id="addCard" class="modal">
<div class="modal-content row">
<div class="input-field col s12">
<input id="cardId" type="text" class="validate">
<label for="cardId">Enter Card Number</label>
</div>
<a href="#!" class=" col s4 push-s4 modal-action modal-close waves-effect waves-green btn green" onclick="cardLinking()">
<i class="large material-icons left ">add</i> Add</a>
</div>
</div>
<!--JavaScript at end of body for optimized loading-->
<script type="text/javascript" src="js/materialize.min.js"></script>
<script>
$(document).ready(function () {
$('.tabs').tabs();
$('.modal-trigger').click(function () { });
$('.modal').modal();
addUsers(0);
});
function AirlineDestinationTimeSet() {
$.ajax('http://localhost:3000/api/Customer',
{
type: 'GET',
async: false,
success: function (data) {
for (i = 0; i < data.length; i++) {
obj = data[i];
var d = new Date();
var h = addZero(d.getHours());
var m = addZero(d.getMinutes());
timeStamp = h + ":" + m;
data[i].airlineDestinationTime = timeStamp;
$.ajax('http://localhost:3000/api/Customer/' + data[i].userId,
{
type: 'put',
async: false,
data: obj,
dataType: 'application/json',
success: function (data) {
},
error: function (errormsg) {
}
});
}
Materialize.toast('Airline Destination Time Set!', 3000);
},
error: function () {
}
});
}
function addZero(i) {
if (i < 10) {
i = "0" + i;
}
return i;
}
function addUsers(callairline) {
$('#Loader').modal('open');
callairline = callairline;
//Adding passengers
$.ajax('http://localhost:3000/api/Customer',
{
dataType: 'json', // type of response data
timeout: 500, // timeout milliseconds
type: 'GET',
async: false,
success: function (data, status, xhr) { // success callback function
for (i = 0; i < data.length; i++) {
$.ajax('http://localhost:3000/api/Account/' + data[i].customerAccount.split('#')[1],
{
async: false,
dataType: 'json', // type of response data
timeout: 500, // timeout milliseconds
type: 'GET',
success: function (data1, status, xhr) { // success callback function
// for (i1 = 0; i1 < data.length; i1++) {
$('#passengerList').append('<div class="col s12"><div class="z-depth-3 card light-blue darken-4"><div class="card-content white-text"><span class="card-title">' + data[i].firstName + ' ' + data[i].lastName + '</span></div><div class="card-action"><a href="#">Balance - ' + data1.balance + '</a><a class=" ">Id - ' + data[i].userId + '</a><a href="#add" onclick="addTags(\'' + data[i].userId + '\')" id="' + data[i].userId + '" class="right modal-action modal-close cyan-text">+ Add</a></div></div></div>');
if (data[i].baggageId != "--")
document.getElementById(data[i].userId).outerHTML = "<div class=\"right red-text\">Tag Id:<b> " + data[i].baggageId + "</b></div>";
return true;
// }
},
error: function (jqXhr, textStatus, errorMessage) { // error callback
$('p').append('Error1: ' + errorMessage);
i = i - 1;
}
});
}
},
error: function (jqXhr, textStatus, errorMessage) { // error callback
$('p').append('Error2: ' + errorMessage);
}
});
if (callairline == 0) {
addAirline();
}
else{
$('#Loader').modal('close');
}
return true;
};
function cardLinking() {
$.ajax('http://localhost:3000/api/Customer',
{
type: 'GET',
async: false,
success: function (data) {
for (i = 0; i < data.length; i++) {
if (data[i].userId == sessionStorage.getItem('cardUserId')) {
obj = data[i];
obj.baggageId = $('#cardId').val().toString();
$.ajax('http://localhost:3000/api/Customer/' + sessionStorage.getItem('cardUserId'),
{
type: 'put',
async: false,
data: obj,
dataType: 'application/json',
success: function (data) {
},
error: function (errormsg) {
if(errormsg.status == 200){
$('#passengerList').empty();
addUsers(1);
Materialize.toast('Card Linked successfull !', 3000);
}
}
});
}
}
}
});
$('#cardId').val("")
}
function addTags(id) {
sessionStorage.setItem("cardUserId", id);
$('#addCard').modal('open');
pubnub = new PubNub({
// get your keys on pubnub
publishKey: '',
subscribeKey: ''
}) // your subscribe key
pubnub.subscribe({
channels: ['IOT-RFID'],
});
pubnub.addListener({
message: function (m) {
// handle message
var actualChannel = m.actualChannel;
var channelName = m.channel; // The channel for which the message belongs
var msg = m.message; // The Payload
var publisher = m.publisher;
var subscribedChannel = m.subscribedChannel;
var channelGroup = m.subscription; // The channel group or wildcard subscription match (if exists)
var pubTT = m.timetoken; // Publish timetoken
$('#cardId').focus();
$('#cardId').val(msg);
console.log("------ Baggage arrived ! -------")
},
presence: function (p) {
// handle presence
var action = p.action; // Can be join, leave, state-change or timeout
var channelName = p.channel; // The channel for which the message belongs
var channelGroup = p.subscription; // The channel group or wildcard subscription match (if exists)
var presenceEventTime = p.timestamp; // Presence event timetoken
var status = p.status; // 200
var message = p.message; // OK
var service = p.service; // service
var uuids = p.uuids; // UUIDs of users who are connected with the channel with their state
var occupancy = p.occupancy; // No. of users connected with the channel
},
status: function (s) {
// handle status
var category = s.category; // PNConnectedCategory
var operation = s.operation; // PNSubscribeOperation
var affectedChannels = s.affectedChannels; // The channels affected in the operation, of type array.
var subscribedChannels = s.subscribedChannels; // All the current subscribed channels, of type array.
var affectedChannelGroups = s.affectedChannelGroups; // The channel groups affected in the operation, of type array.
var lastTimetoken = s.lastTimetoken; // The last timetoken used in the subscribe request, of type long.
var currentTimetoken = s.currentTimetoken; // The current timetoken fetched in the subscribe response, which is going to be used in the next request, of type long.
}
});
}
function addAirline() {
//Adding Airline
$.ajax('http://localhost:3000/api/Airlines',
{
dataType: 'json', // type of response data
timeout: 500, // timeout milliseconds
type: 'GET',
async: false,
success: function (data, status, xhr) {
$('#company_name').append(data[0].airlineName);
$.ajax('http://localhost:3000/api/Account/' + data[0].airlineAccount.split("#")[1],
{
dataType: 'json', // type of response data
timeout: 500, // timeout milliseconds
type: 'GET',
async: false,
success: function (data, status, xhr) {
$('#company_balance').append(data.balance);
}
});
}
});
$('#Loader').modal('close');
return true;
}
function logout() {
sessionStorage.clear();
window.location = "login.html"
}
</script>
</body>
</html>