-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
375 lines (312 loc) · 17 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
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
<html>
<head>
<title>easyscanner</title>
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.0/css/bootstrap-combined.min.css"
rel="stylesheet">
<link rel="stylesheet" type="text/css" href="css/style.css">
<link href='http://fonts.googleapis.com/css?family=Oxygen' rel='stylesheet' type='text/css'>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="js/cities.js"></script>
<script type="text/javascript" src="js/handlebars.js"></script>
<script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.0/js/bootstrap.min.js"></script>
<script type="text/javascript">
$(function() {
$('.search-input').focus();
var searchInputDiv = document.getElementsByClassName('search-input')[0];
searchInputDiv.onfocus = function() {
$(this).html($(this).text());
window.setTimeout(function() {
var sel, range;
if (window.getSelection && document.createRange) {
range = document.createRange();
range.selectNodeContents(searchInputDiv);
sel = window.getSelection();
sel.removeAllRanges();
sel.addRange(range);
} else if (document.body.createTextRange) {
range = document.body.createTextRange();
range.moveToElementText(searchInputDiv);
range.select();
}
}, 1);
};
$('.search-input').blur(function() {
highlightInput();
})
$('.search-input').keydown(function(e) {
var value = $('.search-input').text();
if ((value.length < 2) && (e.keyCode == 8)) {
$('.clear-button').click();
return;
}
})
$('.search-input').keypress(function(e) {
var value = $('.search-input').html();
if (e.charCode == 13) {
$('.loading-area').show();
$.get('/api?q=' + value, function(response) {
$('.loading-area').hide();
var rOut = '';
var bOut = '';
var source = $("#result-template").html();
var template = Handlebars.compile(source);
source = $("#result-best-template").html();
var bestTemplate = Handlebars.compile(source);
var count = 0;
for (var r in response) {
var row = response[r];
var date = new Date(row[2]);
var dateParts = date.toString().split(' ');
var context = {
price: row[3],
date: dateParts[2] + ' ' + dateParts[1],
airline: row[4],
originCode: row[0].substring(0, 3).toUpperCase(),
destinationCode: row[1].substring(0, 3).toUpperCase(),
transit: Cities[Math.round(Math.random(70)) + 80].substring(0, 3).toUpperCase(),
randTime1: (Math.round(Math.random(13)) + 10) + ':00',
randTime2: (Math.round(Math.random(13)) + 10) + ':00',
randTime3: (Math.round(Math.random(13)) + 10) + ':00',
randTime4: (Math.round(Math.random(13)) + 10) + ':00'
}
if (count > 1)
rOut += template(context);
else
bOut += bestTemplate(context);
count++;
if (count > 15)
break;
}
$('.b-h2').html('Best Offers');
if ((response == -1)||(response.length == 0)) {
$('.b-h2').html('No Results :-(');
}
$('.r-h2').hide();
$('.see-more-h2').hide();
if (response.length > 2) {
$('.r-h2').show();
if (response.length > 15) {
$('.see-more-h2').show();
}
}
$('.r-result-group').html(rOut);
$('.b-result-group').html(bOut);
$('.results-area').fadeIn();
$('.clear-button').fadeIn();
$('#sample-under-input').fadeOut(function() {
$('#actions-under-input').fadeIn();
});
})
highlightInput();
$('.search-input').blur();
return false;
}
})
$('.clear-button').click(function() {
$('.search-input').html('');
$('.search-input').focus();
$('.results-area').fadeOut();
$('.clear-button').fadeOut();
$('#actions-under-input').fadeOut(function() {
$('#sample-under-input').fadeIn();
});
})
$('#more-samples-a').popover({ trigger: 'hover' });
$('#more-samples-a2').popover({ trigger: 'hover' });
})
function highlightInput() {
var value = $('.search-input').html();
for (var c in Cities) {
var city = Cities[c];
if (value.toLowerCase().indexOf(city.toLowerCase()) > -1) {
value = value.replace(new RegExp(city, 'gi'), '<b>' + city + '</b>');
}
}
var monthNames = ['January','February','March','April','May', 'June','July','August','September','October','November','December'];
for (var m in monthNames) {
var month = monthNames[m];
if (value.toLowerCase().indexOf(month.toLowerCase()) > -1) {
value = value.replace(new RegExp(month, 'gi'), '<span class="time-hightlight">' + month + '</span>');
} else if (value.toLowerCase().indexOf(month.substring(0, 3).toLowerCase()) > -1) {
value = value.replace(new RegExp(month.substring(0, 3), 'gi'), '<span class="time-hightlight">' + month + '</span>');
}
}
$('.search-input').html(value);
$('#plotResults').on('show', function () {
var value = $('.search-input').text();
$('#results-plot').remove();
$('#plotResults').find('.modal-body').append('<iframe id="results-plot" src="/chart?m=chart&q=' + encodeURI(value) + '" frameborder="0" style="width: 100%; height: 100%"></iframe>');
$('#detailed-chart-a').attr('href', '/scatterplot?m=chart-large&q=' + encodeURI(value))
})
$('#paginationModal').on('show', function () {
$('#pagination-modal-body').find('iframe').remove();
$('#pagination-modal-body').append('<iframe src="/pagination" frameborder="0" style="width: 100%; height: 400px; overflow-x: hidden;"></iframe>');
})
}
</script>
</head>
<body>
<script id="result-template" type="text/x-handlebars-template">
<div class="result">
<img src="img/airlines/{{ airline }}}.png">
<span class="date">{{ date }}</span>
<div class="details">
{{ randTime1 }} {{originCode}} - {{ randTime2 }} {{transit}} <br>
{{ randTime3 }} {{transit}} - {{ randTime4 }} {{destinationCode}}
</div>
<a href="#myModal" data-toggle="modal" role="button" class="price">£ {{ price }}</a>
</div>
</script>
<script id="result-best-template" type="text/x-handlebars-template">
<div class="result result-best">
<img src="img/airlines/{{ airline }}}.png">
<span class="date">{{ date }}</span>
<div class="details">
{{ randTime1 }} {{originCode}} - {{ randTime2 }} {{transit}} <br>
{{ randTime3 }} {{transit}} - {{ randTime4 }} {{destinationCode}}
</div>
<a href="#myModal" data-toggle="modal" role="button" class="price">£ {{ price }}</a>
</div>
</script>
<div class="content">
<a href="/" class="logo">
<img src="img/plane.png">
easyscanner
</a>
<div class="input-area">
<div class="search-input" contenteditable="true"></div>
<div class="clear-button">×</div>
<div class="under-input" id="sample-under-input">Sample: <b>From Athens to Edinburgh in February</b> (<a id="more-samples-a" href="#" data-toggle="popover" data-placement="right" data-content="to Athens; From Tokyo; From Edinburgh in April" data-original-title="Sample Queries">more samples</a>)</div>
<div class="under-input" id="actions-under-input">
<i class="icon-cog"></i> <a href="#advSearch" data-toggle="modal" role="button" >Advanced Search</a>
<i class="icon-align-right"></i> <a href="#plotResults" data-toggle="modal" role="button">Plot Results</a>
<i class="icon-question-sign"></i> <a id="more-samples-a2" href="#" data-toggle="popover" data-placement="right" data-content="to Athens; From Tokyo; From Edinburgh in April" data-original-title="Sample Queries">Sample Queries</a>
</div>
</div>
<div class="results-area">
<h2 class="b-h2">Best Offers</h2>
<div class="results-group b-result-group">
</div>
<h2 class="r-h2">Other Offers</h2>
<div class="results-group r-result-group">
</div>
<h2 class="see-more-h2"><a href="#paginationModal" data-toggle="modal" role="button">See All Results</a></h2>
</div>
<div class="loading-area">
<img src="img/loader.gif">
</div>
</div>
<!-- Modal -->
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Flight Details</h3>
</div>
<div class="modal-body">
<table class="table table-striped">
<thead>
<tr>
<th>Origin</th>
<th>Departure</th>
<th>Destination</th>
<th>Arrival</th>
</tr>
</thead>
<tbody>
<tr>
<td><b class="highlight"><i class="icon-plane"></i> Mumbai (MBI)</b></td>
<td>12:55</td>
<td><b class="highlight">Singapore (ATH)</b></td>
<td>22:20</td>
</tr>
<tr>
<td><b class="highlight"><i class="icon-plane"></i> Singapore (ATH)</b></td>
<td>05:30</td>
<td><b class="highlight">Melbourne (MBR)</b></td>
<td>22:20</td>
</tr>
</tbody>
</table>
<ul id="tabs" class="nav nav-tabs">
<li class="active"> <a href="#home" data-toggle="tab"><i class="icon-map-marker"></i> Map</a></li>
<li> <a href="#profile" data-toggle="tab"><i class="icon-qrcode"></i> QR Code</a></li>
<li> <a href="#booknow" data-toggle="tab"><i class="icon-ok"></i> Book for <b>£ 360.00</b></a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="home">
<div class="map-container">
<iframe width="425" height="180" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.com/maps?f=d&source=s_d&saddr=Mumbai,+Maharashtra,+India&daddr=Melbourne,+Victoria,+Australia&hl=en&geocode=FZATIwEdWAZYBCnB7URmMMbnOzFpjGSNj-2kXQ%3BFaUAv_0d0PajCCn3TbrStUbWajGQzYwhdVYEBA&aq=1&oq=melb&sll=-9.60044,109.235314&sspn=62.961618,79.013672&mra=ls&ie=UTF8&t=m&ll=-9.795678,109.335938&spn=79.529203,149.414063&z=2&output=embed"></iframe><br /><small><a href="https://maps.google.com/maps?f=d&source=embed&saddr=Mumbai,+Maharashtra,+India&daddr=Melbourne,+Victoria,+Australia&hl=en&geocode=FZATIwEdWAZYBCnB7URmMMbnOzFpjGSNj-2kXQ%3BFaUAv_0d0PajCCn3TbrStUbWajGQzYwhdVYEBA&aq=1&oq=melb&sll=-9.60044,109.235314&sspn=62.961618,79.013672&mra=ls&ie=UTF8&t=m&ll=-9.795678,109.335938&spn=79.529203,149.414063&z=2" style="color:#0000FF;text-align:left">View Larger Map</a></small>
</div>
</div>
<div class="tab-pane" id="profile">
<div class="qr">
<img src="img/qr.png" style="max-width: 180px">
</div>
</div>
<div class="tab-pane" id="booknow">
<div class="qr">
<button class="btn btn-info" data-dismiss="modal" aria-hidden="true">Book with eBookers <b>£ 360.00</b></button>
<br>
<br>
<button class="btn btn-info" data-dismiss="modal" aria-hidden="true">Book with eDreams <b>£ 389.00</b></button>
<br>
<br>
<button class="btn btn-info" data-dismiss="modal" aria-hidden="true">Book with lastminute.com <b>£ 453.00</b></button>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<img src="img/airlines/easyjet.png" class="pull-left">
<button class="btn" data-dismiss="modal" aria-hidden="true"><i class="icon-remove-circle"></i> Close</button>
</div>
</div>
<!-- Advanced Search -->
<div id="advSearch" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="advSearchLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="advSearchLabel">Advanced Search</h3>
</div>
<div class="modal-body" style="background: #34363E">
<img src="img/advsearch.png" alt="">
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true"><i class="icon-remove-circle"></i> Close</button>
<button class="btn btn-info" data-dismiss="modal" aria-hidden="true"><i class="icon-white icon-ok"></i> Search</button>
</div>
</div>
<!-- Results Plot -->
<div id="plotResults" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="plotResultsLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="plotResultsLabel">Results Plot</h3>
</div>
<div class="modal-body">
<iframe id="results-plot" src="/chart" frameborder="0" style="width: 100%; height: 100%"></iframe>
</div>
<div class="modal-footer">
<a id="detailed-chart-a" target="_blank" href="/scatterplot" class="btn btn-info pull-left" aria-hidden="true"><i class="icon-fullscreen icon-white"></i> Detailed View</a>
<button class="btn" data-dismiss="modal" aria-hidden="true"><i class="icon-remove-circle"></i> Close</button>
</div>
</div>
<!-- Paginated Results -->
<div id="paginationModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="ppaginationModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="paginationModalLabel">All Results</h3>
</div>
<div class="modal-body" id="pagination-modal-body">
<iframe frameborder="0" style="width: 100%; height: 400px; overflow-x: hidden;"></iframe>
</div>
<div class="modal-footer">
<a target="_blank" href="/pagination" class="btn btn-info pull-left" aria-hidden="true"><i class="icon-fullscreen icon-white"></i> Detailed View</a>
<a href="#" class="btn pull-left" aria-hidden="true"><i class=" icon-filter"></i> Filter Results</a>
<button class="btn" data-dismiss="modal" aria-hidden="true"><i class="icon-remove-circle"></i> Close</button>
</div>
</div>
</body>
</html>