-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
397 lines (315 loc) · 13.1 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
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
<!doctype html>
<!-- Conditional comment for mobile ie7 blogs.msdn.com/b/iemobile/ -->
<!--[if IEMobile 7 ]>
<html class="no-js iem7" lang="en"> <![endif]-->
<!--[if (gt IEMobile 7)|!(IEMobile)]><!-->
<html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<title>Yeca - te canta la posta</title>
<meta name="description" content="">
<!-- Mobile viewport optimization h5bp.com/ad -->
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<!-- Home screen icon Mathias Bynens mathiasbynens.be/notes/touch-icons -->
<!-- For iPhone 4 with high-resolution Retina display: -->
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="img/h/apple-touch-icon.png">
<!-- For first-generation iPad: -->
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="img/m/apple-touch-icon.png">
<!-- For non-Retina iPhone, iPod Touch, and Android 2.1+ devices: -->
<link rel="apple-touch-icon-precomposed" href="img/l/apple-touch-icon-precomposed.png">
<!-- For nokia devices: -->
<link rel="shortcut icon" href="img/l/apple-touch-icon.png">
<!-- iOS web app, delete if not needed. https://github.com/h5bp/mobile-boilerplate/issues/94 -->
<!-- <meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black"> -->
<!-- <script>(function(){var a;if(navigator.platform==="iPad"){a=window.orientation!==90||window.orientation===-90?"img/startup-tablet-landscape.png":"img/startup-tablet-portrait.png"}else{a=window.devicePixelRatio===2?"img/startup-retina.png":"img/startup.png"}document.write('<link rel="apple-touch-startup-image" href="'+a+'"/>')})()</script> -->
<!-- The script prevents links from opening in mobile safari. https://gist.github.com/1042026 -->
<!-- <script>(function(a,b,c){if(c in b&&b[c]){var d,e=a.location,f=/^(a|html)$/i;a.addEventListener("click",function(a){d=a.target;while(!f.test(d.nodeName))d=d.parentNode;"href"in d&&(d.href.indexOf("http")||~d.href.indexOf(e.host))&&(a.preventDefault(),e.href=d.href)},!1)}})(document,window.navigator,"standalone")</script> -->
<!-- Mobile IE allows us to activate ClearType technology for smoothing fonts for easy reading -->
<meta http-equiv="cleartype" content="on">
<!-- more tags for your 'head' to consider h5bp.com/d/head-Tips -->
<!-- Main Stylesheet -->
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.css"/>
<link rel="stylesheet" href="js/libs/leaflet/leaflet.css"/>
<!-- All JavaScript at the bottom, except for Modernizr which enables HTML5 elements & feature detects -->
<script src="js/libs/modernizr-2.0.6.min.js"></script>
<!-- Grab Google CDN's jQuery, with a protocol relative URL; fall back to local if necessary -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/libs/jquery-1.7.1.min.js"><\/script>')</script>
<script src="js/libs/jquery.mobile-1.1.0.js"></script>
</head>
<body>
<!-- Templating html -->
<textarea id="path-result-item-template" style="display: none;">
<% _.each(paths,function (path) { %>
<li>
<a onclick="extend_data(<%=path.id%>)" href="#">
<img class="ui-li-icon" src="<%=path.favicon%>" width="25" height="25">
<%=path.title%> (<%=path.time%>)
</a>
</li>
<% }); %>
</textarea>
<textarea id="path-steps-detail" style="display: none;">
<% _.each(steps,function (steps) { %>
<li> <%=steps.text%></li>
<% }); %>
</textarea>
<!-- //Templating html -->
<div id="container">
<header>
<!-- <h1>Loading Yeca...</h1> -->
</header>
<!-- Start of first page: #one -->
<div data-role="page" id="one">
<div data-role="header" data-theme="d">
<h1>
<img class="header-image" src="marketing/logo.png">
</h1>
</div>
<!-- /header -->
<div data-role="content">
<form action="#">
<div>
<p>
<label for="from-input" class="ui-hidden-accessible">Desde</label>
<input type="text" name="from-string" id="from-input" placeholder="Desde donde estoy"
data-mini="true" disabled/>
</p>
<p>
<label for="to-input" class="ui-hidden-accessible">Hasta</label>
<input type="text" name="from-string" id="to-input" placeholder="Hasta" data-mini="true"
disabled/>
</p>
<p>
<a id="go-button"
href="#"
data-role="button"
data-icon="arrow-r"
data-iconpos="right"
data-mini="true">Ir!</a>
</p>
</div>
</form>
<div id="map-container-1">
<div id="map"></div>
</div>
</div>
<!-- /content -->
</div>
<!-- /page one -->
<!-- Start of second page: #two -->
<div data-role="page" id="two">
<div data-role="header" data-theme="d">
<a href="#"
id="go-search"
data-transition="slide"
data-role="button"
data-icon="arrow-l"
data-iconpos="left"
data-mini="true">Volver</a>
<h1>
<img class="header-image" src="marketing/logo.png">
</h1>
</div>
<!-- /header -->
<div class="" data-role="content">
<ul id="search-result-list" data-role="listview" data-theme="c">
<!-- Here must be the list of possible paths -->
</ul>
<br/>
<div id="map-container-2"></div>
</div>
<!-- /content -->
<div data-role="footer" data-theme="d">
<h4></h4>
</div>
</div>
<!-- /page two -->
<!-- Start of thirth page: #three -->
<div data-role="page" id="three">
<div data-role="header" data-theme="d">
<h1>
<img class="header-image" src="marketing/logo.png">
</h1>
<a href="#"
id="go-result"
data-transition="slide"
data-icon="arrow-l"
data-iconpos="left"
data-mini="true"
class="ui-btn-left"
data-role="button">Volver</a>
</div>
<!-- /header -->
<div data-role="content">
<h2>Detalle del recorrido:</h2>
<br/>
<div id="data">
<ol>
</ol>
</div>
<div id="map-container-3"></div>
</div>
<!-- /content -->
<div data-role="footer" data-theme="d">
<h4></h4>
</div>
</div>
<!-- /page two -->
</div>
<!--! end of #container -->
<!-- JavaScript at the bottom for fast page loading -->
<!-- USIG API -->
<script src="http://servicios.usig.buenosaires.gob.ar/usig-js/dev/usig.AutoCompleterFull.min.js"
type="text/javascript"></script>
<script src="http://servicios.usig.buenosaires.gob.ar/usig-js/dev/usig.Recorridos.min.js"
type="text/javascript"></script>
<!-- Underscore.js -->
<script src="js/underscore-1.3.3.js"></script>
<!-- Leaflet -->
<script src="js/libs/leaflet/leaflet.js"></script>
<script src="js/libs/proj4js-compressed.js"></script>
<script src="js/libs/proj4leaflet.js"></script>
<script src="js/leaflet-test.js"></script>
<!-- scripts concatenated and minified via ant build script-->
<script src="js/helper.js"></script>
<script src="js/script.js"></script>
<!-- end scripts-->
<script type="text/javascript">
var icons = {
"walk":"img/icons/transport/pedestriancrossing.png",
"car":"img/icons/transport/car.png",
"bus":"img/icons/transport/bus.png",
"train":"img/icons/transport/tramway.png",
"subway":"img/icons/transport/underground.png",
"cycle":"img/icons/transport/cycling.png",
"transporte_publico":"img/icons/transport/underground.png"
};
var detect_bus = /^\d/;
var detect_train = /^F\.C\./;
var paths;
function extend_data(id) {
var path = paths[id];
path.getDetalle(function (detalle) {
var detailSteps = $(detalle).map(function () {
return {
text:this.text
}
});
var stepsHtml = _.template($("#path-steps-detail").text(), {steps:detailSteps});
$("#data ol").append($(stepsHtml));
Yeca.showPlan(path.getPlan());
Yeca.changePage(3);
},
function () {
alert('Se produjo un error al intentar cargar los detalles del recorrido.');
});
}
function show_paths(found) {
paths = found;
$(paths).each(function (index, v) {
var tipo = v.getTipo();
v.desc = tipo == 'walk' ? 'Caminando' : tipo == 'car' ? 'En auto' : tipo == 'cycle' ? 'En bici' : v.toString();
v.tipo = tipo != 'transporte_publico' ? tipo : v.desc.match(detect_bus) ? 'bus' : v.desc.match(detect_train) ? 'train' : 'subway';
});
var posiblePaths = $(paths).map(function (index, p) {
return {
id:index,
title:p.desc,
favicon:icons[p.tipo],
time:p.time_string()
}
});
var directionsHtml = _.template($("#path-result-item-template").text(), {paths:posiblePaths});
$("#search-result-list").empty().append($(directionsHtml));
$("#search-result-list").listview('refresh');
}
function search_paths(from, to, success, error) {
var full_results = [];
var types = ['transporte', 'auto', 'pie'];
var process_next = function (results) {
full_results = full_results.concat(results);
var type = types.pop();
if (type) {
usig.Recorridos.opts.tipo = type;
usig.Recorridos.buscarRecorridos(from, to, process_next);
} else {
full_results.sort(function (a, b) {
return a.getTime() - b.getTime();
});
success(full_results);
}
};
process_next([]);
}
$(function () {
$("#go-button").bind("click tap", function () {
var toText = $("#to-input").val();
if (_.isEmpty(toText)) {
$("#to-input").addClass("invalid-input");
} else {
$("#to-input").removeClass("invalid-input");
Yeca.searchPaths(function (paths) {
Yeca.changePage(2);
show_paths(paths);
});
}
});
//Return to the result paths
$("#go-result").bind("click tap",function(){
Yeca.changePage(2);
});
//Go back to search page
$("#go-search").bind("click tap",function(){
Yeca.changePage(1);
});
Yeca.init();
$("#from-input").on("blur", function() {
var value = $(this).val();
if (value == null || value.length < 1)
Yeca.origin = null;
});
Yeca.initAutocompleter(
'from-input',
function (option) {
if (option instanceof usig.Direccion || option instanceof usig.inventario.Objeto) {
Yeca.origin = option;
}
},
function (pt) {
if (pt instanceof usig.Punto) {
if (Yeca.origin instanceof usig.Direccion) {
Yeca.origin.setCoordenadas(pt);
}
}
}
);
Yeca.initAutocompleter(
'to-input',
function (option) {
if (option instanceof usig.Direccion || option instanceof usig.inventario.Objeto) {
Yeca.destination = option;
}
},
function (pt) {
if (pt instanceof usig.Punto) {
if (Yeca.destination instanceof usig.Direccion) {
Yeca.destination.setCoordenadas(pt);
}
}
}
);
Yeca.resizeMap();
$(window).bind("resize orientationchange", Yeca.resizeMap);
//Finish load the page, and transition to the first page
Yeca.changePage(1);
});
</script>
<!-- Debugger - remove for production -->
<!-- <script src="https://getfirebug.com/firebug-lite.js"></script> -->
</body>
</html>