-
Notifications
You must be signed in to change notification settings - Fork 0
/
index2.html
1034 lines (926 loc) · 33.3 KB
/
index2.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
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<!--
Customize this policy to fit your own app's needs. For more guidance, see:
https://github.com/apache/cordova-plugin-whitelist/blob/master/README.md#content-security-policy
Some notes:
* gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication
* https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly
* Disables use of inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
* Enable inline JS: add 'unsafe-inline' to default-src
-->
<!-- Removing 'unsafe-eval'. If needed, I will figure out a way around it -->
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: http://158.69.165.236/VentasOnline/json/data/admin/all/products https://maps.googleapis.com https://fonts.googleapis.com 'unsafe-eval' 'unsafe-inline' ws://*; style-src 'self' 'unsafe-inline'; media-src *; img-src * data:">
<!--
<meta http-equiv="Content-Security-Policy" content="default-src *; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; media-src *; img-src 'self' data:">
<!-- Required meta tags-->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<meta name="msapplication-tap-highlight" content="no">
<link rel="stylesheet" href="lib/font-awesome-4.5.0/css/font-awesome.min.css" />
<title>Sistemas Moviles</title>
</head>
<style>
#map_holder {
height: 500px;
background-color: #00caf2;
}
</style>
<script type="text/javascript" async defer
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyD3T-qPHkznTnM2rZtoZeHJlxcVRprJusc">
</script>
<style>
#map {
height: 100%;
}
html, body {
height: 100%;
margin: 0;
padding: 0;
}
</style>
<body class="theme-green" onload="showTable()">
<!-- Status bar overlay for full screen mode (PhoneGap) -->
<div class="statusbar-overlay"></div>
<!-- Panels overlay-->
<div class="panel-overlay"></div>
<!-- Left panel with cover effect-->
<div class="panel panel-left panel-cover">
<!--<div class="content-block">-->
<div class="content-block-title">Menu</div>
<div class="list-block">
<ul>
<li>
<a href="#" class="search-link item-content list-panel-all close-panel item-link">
<div class="item-inner">
<div class="item-title">Buscar</div>
</div>
</a>
</li>
<li>
<a href="#" class="favorites-link item-content list-panel-all close-panel item-link">
<div class="item-inner">
<div class="item-title">Favoritos </div>
</div>
</a>
</li>
<li>
<a href="Mapa.html" class="mapa-link item-content list-panel-all close-panel item-link">
<div class="item-inner">
<div class="item-title">Mapa</div>
</div>
</a>
</li>
<li>
<a href="#" class="login-link item-content list-panel-all close-panel item-link">
<div class="item-inner">
<div class="item-title">Login</div>
</div>
</a>
</li>
</ul>
</div>
</div>
<!-- Views -->
<div class="views" >
<!-- Your main view, should have "view-main" class -->
<div class="view view-main">
<!-- Top Navbar-->
<div class="navbar">
<div class="navbar-inner" data-page="index">
<div class="left">
<!--
Left link contains only icon - additional "icon-only" class
Additional "open-panel" class tells app to open panel when we click on this link
-->
<a href="#" class="link icon-only open-panel"><i class="fa fa-bars"></i></a>
</div>
<!-- We need cool sliding animation on title element, so we have additional "sliding" class -->
<div class="center sliding">App Ventas</div>
</div>
</div>
<!-- Pages container, because we use fixed-through navbar and toolbar, it has additional appropriate classes-->
<div class="pages navbar-through toolbar-through">
<!-- Page, "data-page" contains page name -->
<div data-page="index" class="page">
<!-- Scrollable page content -->
<div class="page-content">
<form action="#" method="GET" id="search">
<div class="content-block-title"></div>
<div class="list-block">
<ul>
<li>
<div class="item-content">
<div class="item-inner">
<div class="item-input">
<input type="text" name="term" id="query"
placeholder="Escribe el Producto a Buscar"
autocorrect="off" autocapitalize="off">
</div>
</div>
</div>
</li>
<li class="item-divider">::: Conéctate Ecosistema de Marketing Móvil :::</li>
<li>
<label class="label-radio item-content">
<input type="radio" name="filter" value="track">
<div class="item-media">
<i class="icon icon-form-radio"></i>
</div>
<div class="item-inner">
<div class="item-title"> Nombre </div>
</div>
</label>
</li>
<li>
<label class="label-radio item-content">
<input type="radio" name="filter" value="artist">
<div class="item-media">
<i class="icon icon-form-radio"></i>
</div>
<div class="item-inner">
<div class="item-title">Precio</div>
</div>
</label>
</li>
<li>
<label class="label-radio item-content">
<input type="radio" name="filter" value="album">
<div class="item-media">
<i class="icon icon-form-radio"></i>
</div>
<div class="item-inner">
<div class="item-title">Existencia</div>
</div>
</label>
</li>
<li>
<label class="label-radio item-content">
<!-- Checked by default -->
<input type="radio" name="filter" value="all" checked>
<div class="item-media">
<i class="icon icon-form-radio"></i>
</div>
<div class="item-inner">
<div class="item-title">Todas las anteriores</div>
</div>
</label>
</li>
</ul>
</div>
<input type="hidden" name="limit" value="25" />
<div class="content-block">
<input type="submit" class="button button-big button-fill search-submit" value="Buscar Productos" />
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<script type="text/template7" id="results">
<!-- Dynamic navbar for iOS theme -->
{{#if @global.ios}}
<div class="navbar">
<div class="navbar-inner">
<div class="left sliding">
<a href="#" class="back link">
<i class="icon icon-back"></i>
<span>Buscar</span>
</a>
</div>
<div class="center sliding">Resultados</div>
</div>
</div>
{{/if}}
<div class="page" data-page="results">
<!-- Fixed navbar for Material theme -->
{{#if @global.material}}
<div class="navbar">
<div class="navbar-inner">
<div class="left">
<a href="#" class="back link"><i class="icon icon-back"></i></a>
</div>
<div class="center">Resultados</div>
</div>
</div>
{{/if}}
<div class="page-content">
<div class="content-block-title">{{tracks.count}} Regresar</div>
<div class="list-block media-list">
<ul>
{{#each tracks.items}}
<li>
<a href="#" class="item-link item-content"
data-item="{{@index}}"
data-context="{{stringify this}}"
data-template="details"
>
<div class="item-media">
<img width="80" src="http://158.69.165.236/VentasOnline/resources/images/{{this.code}}.jpg" />
</div>
<div class="item-inner">
<div class="item-title-row">
<div class="item-title">{{this.name}}</div>
<div class="item-after">{{this.unitPrice}}</div>
</div>
<div class="item-subtitle">{{this.description}}</div>
<div class="item-text">{{this.brand}}</div>
</div>
</a>
</li>
{{/each}}
</ul>
</div>
</div>
</div>
</script>
<script type="text/template7" id="details">
<!-- Dynamic navbar for iOS theme -->
{{#if @global.ios}}
<div class="navbar">
<div class="navbar-inner">
<div class="left sliding">
<a href="#" class="back link">
<i class="icon icon-back"></i>
<span>Results</span>
</a>
</div>
<div class="center sliding">Detalle del Producto</div>
<div class="right">
<a href="#" class="link star">
<i class="fa fa-star-o"></i>
</a>
</div>
</div>
</div>
{{/if}}
<div class="page" data-page="details">
<!-- Fixed navbar for Material theme -->
{{#if @global.material}}
<div class="navbar">
<div class="navbar-inner">
<div class="left">
<a href="#" class="back link"><i class="icon icon-back"></i></a>
</div>
<div class="center">Detalle del Producto</div>
<div class="right">
<a href="#" class="link star">
<i class="fa fa-star-o"></i>
</a>
</div>
</div>
</div>
{{/if}}
<div class="page-content">
<div class="card">
<div class="card-header no-border no-padding">
<img width="80" src="http://158.69.165.236/VentasOnline/resources/images/{{this.code}}.jpg" width="100%" />
</div>
<div class="card-content">
<div class="card-content-inner">
<div class="track-name">{{this.name}}</div>
<div class="artists-name">Lo mejor {{this.description}}</div>
<div class="album-title">{{this.name}}</div>
</div>
</div>
</div>
</div>
</div>
</script>
<script type="text/template7" id="favorites">
<!-- Dynamic navbar for iOS theme -->
{{#if @global.ios}}
<div class="navbar">
<div class="navbar-inner">
<div class="left">
<a href="#" class="link icon-only open-panel"><i class="fa fa-bars"></i></a>
</div>
<div class="center sliding">Favorites</div>
</div>
</div>
{{/if}}
<div class="page" data-page="favorites">
<!-- Fixed navbar for Material theme -->
{{#if @global.material}}
<div class="navbar">
<div class="navbar-inner">
<div class="left">
<a href="#" class="link icon-only open-panel"><i class="fa fa-bars"></i></a>
</div>
<div class="center sliding">Favoritos</div>
</div>
</div>
{{/if}}
<div class="page-content">
{{#if tracks}}
<div class="content-block-title">Productos</div>
<div class="list-block media-list">
<ul>
{{#each tracks}}
<li>
<a href="#" class="item-link item-content"
data-item="{{@index}}"
data-context="{{stringify this}}"
data-template="details"
>
<div class="item-media">
<img width="80" src="http://localhost:8082/VentasOnline/resources/images/{{this.code}}.jpg" width="100%" />
</div>
<div class="item-inner">
<div class="item-title-row">
<div class="item-title">{{this.name}}</div>
<div class="item-after">{{this.name}}</div>
</div>
<div class="item-subtitle">{{this.name}}</div>
<div class="item-text">{{this.name}}</div>
</div>
</a>
</li>
{{/each}}
</ul>
</div>
{{else}}
<div class="content-block">
<p>Si tienes un producto de Compra frecuente.</p>
</div>
{{/if}}
</div>
</div>
</script>
<script type="text/template7" id="login">
<!-- Dynamic navbar for iOS theme -->
{{#if @global.ios}}
<div class="navbar">
<div class="navbar-inner">
<div class="left">
<a href="#" class="link icon-only open-panel"><i class="fa fa-bars"></i></a>
</div>
<div class="center sliding">login</div>
</div>
</div>
{{/if}}
<div class="page" data-page="login">
<!-- Fixed navbar for Material theme -->
{{#if @global.material}}
<div class="navbar">
<div class="navbar-inner">
<div class="left">
<a href="#" class="link icon-only open-panel"><i class="fa fa-bars"></i></a>
</div>
<div class="center sliding">Login</div>
</div>
</div>
{{/if}}
<div class="page-content">
{{#if tracks1}}
<div class="content-block-title">Productos</div>
<div class="list-block media-list">
<ul>
{{#each tracks1}}
<li>
<a href="#" class="item-link item-content"
data-item="{{@index}}"
data-context="{{stringify this}}"
data-template="details"
>
<div class="item-media">
<img width="80" src="http://localhost:8082/VentasOnline/resources/images/{{this.code}}.jpg" width="100%" />
</div>
<div class="item-inner">
<div class="item-title-row">
<div class="item-title">{{this.name}}</div>
<div class="item-after">{{this.name}}</div>
</div>
<div class="item-subtitle">{{this.name}}</div>
<div class="item-text">{{this.name}}</div>
</div>
</a>
</li>
{{/each}}
</ul>
</div>
{{else}}
<div class="content-block-title">Inicio</div>
<form action="#" method="post" enctype="application/x-www-form-urlencoded" class="list-block inset" id="form-login" accept-charset="UTF-8">
<ul>
<li>
<div class="item-content">
<div class="item-media"><i class="icon icon-form-name"></i></div>
<div class="item-inner">
<div class="item-title label">Usuario</div>
<div class="item-input">
<input type="text" name="vf_username" id="vf_username">
</div>
</div>
</div>
</li>
<li>
<div class="item-content">
<div class="item-media"><i class="icon icon-form-password"></i></div>
<div class="item-inner">
<div class="item-title label">Contraseña</div>
<div class="item-input">
<input type="password" name="vf_password" id="vf_password">
</div>
</div>
</div>
</li>
<li>
<div class="item-content">
<div class="item-media"><i class="icon icon-form-toggle"></i></div>
<div class="item-inner">
<div class="item-title label">Recordarme</div>
<div class="item-input">
<label class="label-switch">
<input type="checkbox" name="vf_remember" id="vf_remember">
<div class="checkbox"></div>
</label>
</div>
</div>
</div>
</li>
</ul>
<div class="content-block"> <input type="submit" value="Entrar" class="button button-big button-fill" id="btn-submit" > </div>
</form>
{{/if}}
</div>
</div>
</script>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="lib/MSOpenTech/winstore-jscompat.js"></script>
<script type="text/javascript" src="lib/framework7/js/framework7.min.js"></script>
<script type="text/javascript" src="js/init-styles.js"></script>
<script type="text/javascript">
document.addEventListener("DOMContentLoaded", function(event) {
$$('#views').show();
init();
});
</script>
</script>
<script type="text/javascript">
function showTable() {
document.getElementById('views').style.display = "block";
localStorage.setItem('show', 'true');
alert();
}
</script>
<script type="text/javascript">
var isMaterial = Framework7.prototype.device.ios === false;
var isIos = Framework7.prototype.device.ios === true;
// Add the above as global variables for templates
Template7.global = {
material: isMaterial,
ios: isIos,
};
var mainView;
// A template helper to turn ms durations to mm:ss
// We need to be able to pad to 2 digits
function pad2(number) {
if (number <= 99) { number = ('0' + number).slice(-2); }
return number;
}
// Now the actual helper to turn ms to [hh:]mm:ss
function durationFromMsHelper(ms) {
if (typeof ms != 'number') {
return '';
}
var x = ms / 1000;
var seconds = pad2(Math.floor(x % 60));
x /= 60;
var minutes = pad2(Math.floor(x % 60));
x /= 60;
var hours = Math.floor(x % 24);
hours = hours ? pad2(hours) + ':' : '';
return hours + minutes + ':' + seconds;
}
// A stringify helper
// Need to replace any double quotes in the data with the HTML char
// as it is being placed in the HTML attribute data-context
function stringifyHelper(context) {
var str = JSON.stringify(context);
return str.replace(/"/g, '"');
}
// Finally, register the helpers with Template7
Template7.registerHelper('durationFromMs', durationFromMsHelper);
Template7.registerHelper('stringify', stringifyHelper);
// If we need to use custom DOM library, let's save it to $$ variable:
var $$ = Dom7;
if (!isIos) {
// Change class
$$('.view.navbar-through').removeClass('navbar-through').addClass('navbar-fixed');
// And move Navbar into Page
$$('.view .navbar').prependTo('.view .page');
}
// Initialize app
var myApp = new Framework7({
material: isIos? false : true,
template7Pages: true,
precompileTemplates: true,
swipePanel: 'left',
swipePanelActiveArea: '30',
swipeBackPage: true,
animateNavBackIcon: true,
pushState: !!Framework7.prototype.device.os,
template7Data: {
index: {
firstname: 'William ',
lastname: 'Root',
age: 27,
position: 'Developer',
company: 'TechShell',
}
},
});
function init() {
// Add view
//alert('guillermo.. este es el init .....');
var urlLocalImg = 'http://localhost:8082/VentasOnline/img';
mainView = myApp.addView('.view-main', {
// Because we want to use dynamic navbar, we need to enable it for this view:
dynamicNavbar: true,
domCache: true,
});
// Handle Cordova Device Ready Event
$$(document).on('deviceready', function deviceIsReady() {
//alert('deviceready');
//console.log('Device is ready!');
});
$$(document).on('click', '.panel .search-link', function searchLink() {
// Only change route if not already on the index
// It would be nice to have a better way of knowing this...
alert('Busca link');
var indexPage = $$('.page[data-page=index]');
if (indexPage.hasClass('cached')) {
mainView.router.load({
pageName: 'index',
animatePages: false,
reload: true,
});
}
});
$$(document).on('click', '.panel .favorites-link', function searchLink() {
// @TODO fetch the favorites (if any) from localStorage
//alert('favoritos.....');
var favorites = JSON.parse(localStorage.getItem('favorites'));
mainView.router.load({
template: myApp.templates.favorites,
animatePages: false,
context: {
tracks: favorites,
},
reload: true,
});
});
$$(document).on('click', '.panel .login-link', function searchLink() {
// @TODO fetch the favorites (if any) from localStorage
alert('login esta es una prueba');
/*var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://maps.googleapis.com/maps/api/js?key=AIzaSyCALqy7VMo7lkAGgnMly-qi7mNdRyyHWuM&callback=initMap';
//document.body.appendChild(script);
*/
var favorites = JSON.parse(localStorage.getItem('favorites'));
//initMap();
mainView.router.load({
template: myApp.templates.login,
animatePages: false,
context: {
tracks: favorites,
},
reload: true,
});
//mainView.router.load({url:'home.html', ignoreCache: true, reload: false});
//mainView.router.loadPage('home.html');
});
$$(document).on('click', '.panel .mapa-link', function searchLink() {
// @TODO fetch the favorites (if any) from localStorage
/*var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://maps.googleapis.com/maps/api/js?key=AIzaSyCALqy7VMo7lkAGgnMly-qi7mNdRyyHWuM&callback=initMap';
//document.body.appendChild(script);
*/
var favorites = JSON.parse(localStorage.getItem('favorites'));
//initMap();
mainView.router.load({
template: myApp.templates.mapa,
animatePages: false,
context: {
tracks: favorites,
},
reload: true,
});
//mainView.router.load({url:'home.html', ignoreCache: true, reload: false});
//mainView.router.loadPage('home.html');
});
$$(document).on('submit', '#search', searchSubmit);
}
/**
* Search
* - functionality for the main search page
*/
function searchSubmit(e) {
//alert('guillermo');
var formData = myApp.formToJSON('#search');
e.preventDefault();
if (!formData.term) {
//por ahora no le paro....No filtro nada
//myApp.alert('Please enter a search term', 'Search Error');
//return;
}
if (formData.filter === 'all') {
formData.term = formData.term.trim();
} else {
formData.term = formData.filter + ':' + formData.term.trim();
}
delete formData.filter;
formData.media = 'music';
$$('input').blur();
url1 = 'http://158.69.165.236/VentasOnline/json/data/admin/all/products';
//url1 ='file:///C:/subidas/wsEstatico.html';
//alert(url1);
myApp.showPreloader('Searching');
$$.ajax({
//movil
//crossDomain: true,
//movil contentType: 'application/json;charset=UTF-8',
dataType: 'json',
//movil headers: {},
// data: formData,
processData: true,
url: url1,
//useDefaultXhrHeader: false,
crossDomain: true,
success: function searchSuccess(resp) {
var results = { count: 0 };
alert(resp);
results.count = 1; //resp.resultCount === 25 ? "25 (max)" : resp.resultCount;
results.items = resp;
myApp.hidePreloader();
mainView.router.load({
template: myApp.templates.results,
context: {
tracks: results,
},
});
},
error: function searchError(xhr, err) {
alert('An error has occurred', 'Search Error');
myApp.hidePreloader();
myApp.alert('An error has occurred', 'Search Error');
alert(JSON.stringify(err));
console.error("Error on ajax call: " + err);
console.log(JSON.stringify(xhr));
}
});
}
/**
* Details page
* - controls the playback controls and preview media object
*/
var mediaPreview = null;
var mediaTimer = null;
function playbackControlsClickHandler(e) {
alert('este es el click.....lo borro');
var buttonTarget = $$(e.target);
if (buttonTarget.hasClass('play')) {
monitorMediaPreviewCurrentPosition(mediaPreview);
mediaPreview.play();
setPlaybackControlsStatus('pending');
return;
}
monitorMediaPreviewCurrentPosition();
mediaPreview.stop();
setPlaybackControlsStatus('stopped');
return;
};
function setPlaybackControlsStatus(status) {
alert('estes es el status uno ');
status ='stopped';
alert(status);
alert('estes es el status 2');
var allButtons = $$('.playback-controls a');
var playButton = $$('.playback-controls .play-button');
var pendingButton = $$('.playback-controls .pending-button');
var stopButton = $$('.playback-controls .stop-button');
switch (status) {
case 'stopped':
allButtons.removeClass('displayed');
playButton.addClass('displayed');
break;
case 'pending':
allButtons.removeClass('displayed');
pendingButton.addClass('displayed');
break;
case 'playing':
allButtons.removeClass('displayed');
stopButton.addClass('displayed');
break;
default:
allButtons.removeClass('displayed');
playButton.addClass('displayed');
}
}
function monitorMediaPreviewCurrentPosition(media) {
alert('este es el status de monitor.....' );
var percent = 0;
var progressbar = $$('.playback-controls .duration .progressbar');
// If no media object is provided, stop monitoring
if (!media) {
alert("Error getting position media timer ");
clearInterval(mediaTimer);
return;
}
mediaTimer = setInterval(function () {
media.getCurrentPosition(
function (position) {
if (position > -1) {
percent = (position / media.getDuration()) * 100;
myApp.setProgressbar(progressbar, percent);
}
},
function (e) {
alert("Error getting position");
console.error("Error getting position", e);
});
}, 100);
}
function mediaPreviewSuccessCallback() {
alert('Media preview callback');
var progressbar = $$('.playback-controls .duration .progressbar');
setPlaybackControlsStatus('stopped');
myApp.setProgressbar(progressbar, 0, 100);
}
function mediaPreviewErrorCallback(error) {
alert('Media Error');
setPlaybackControlsStatus('stopped');
console.error(error);
}
function mediaPreviewStatusCallback(status) {
//guillermo alert('Media 1 status');
status = 4;
// var progressbar = $$('.playback-controls .duration .progressbar');
switch (status) {
case 2: // playing
setPlaybackControlsStatus('playing');
myApp.setProgressbar(progressbar, 0, 0);
break;
case 4: // stopped
setPlaybackControlsStatus('stopped');
break;
default:
// Default fall back not needed
}
}
function addOrRemoveFavorite(e) {
alert('favorities.....');
if (this.isFavorite) {
// remove the favorite from the arrays
this.favoriteIds.splice(this.favoriteIds.indexOf(this.id), 1);
var favorites = this.favorites.filter(function(fave) {
return fave.id !== this.id;
}, this);
this.favorites = favorites;
this.isFavorite = false;
// update the UI
$$('.link.star').html('<i class="fa fa-star-o"></i>');
} else {
// add the favorite to the arrays
if (this.favorites === null) this.favorites = [];
this.favorites.push(this.track);
this.favoriteIds.push(this.id);
this.isFavorite = true;
// update the UI
$$('.link.star').html('<i class="fa fa-star"></i>');
}
if (this.favorites.length === 0) {
// clear it out so the template knows it's empty when it returns
// as {{#if favorites}} sees an empty array as truthy
this.favorites = null;
}
// save it back to localStorage
localStorage.setItem('favorites', JSON.stringify(this.favorites));
localStorage.setItem('favoriteIds', JSON.stringify(this.favoriteIds));
// if we got here from the favorites page, we need to reload its context
// so it will update as soon as we go "back"
if (this.fromPage === 'favorites') {
// Reload the previous page
mainView.router.load({
template: myApp.templates.favorites,
context: {
tracks: this.favorites,
},
reload: true,
reloadPrevious: true,
});
}
}
myApp.onPageInit('details', function(page) {
var previewUrl = page.context.previewUrl;
//return ; // que pirato soy.....
if (typeof Media !== 'undefined') {
alert('Media sin definir ......');
// Create media object on page load so as to let it start buffering right
// away...
/*guillermo ....mediaPreview = new Media(previewUrl, mediaPreviewSuccessCallback,
mediaPreviewErrorCallback, mediaPreviewStatusCallback);
*/
} else {
// Create a dummy media object for when viewing in a browser, etc
// this really is optional, using `phonegap serve` polyfills the
// Media plugin
//alert('Media definido..........'); ojo solo para que funcione hay que
// quitar esta funcion se deja solo para play.....
function noMedia() {
myApp.alert('Media playback not supported', 'Media Error');
alert('Media playback not supported');
setTimeout(function() {
setPlaybackControlsStatus('stopped');
mediaPreviewStatusCallback(4); // stopped
console.error('No media plugin available');
}, 0);
}
mediaPreview = {
play: noMedia,
stop: function() {},
release: function() {},
getCurrentPosition: function() {},
};
}
// fetch the favorites
var favorites = JSON.parse(localStorage.getItem('favorites')) || [];
var favoriteIds = JSON.parse(localStorage.getItem('favoriteIds')) || [];
var isFavorite = false;
if (favoriteIds.indexOf(page.context.id) !== -1) {
$$('.link.star').html('<i class="fa fa-star"></i>');
isFavorite = true;
}
// set up a context object to pass to the handler
var pageContext = {
track: page.context,
id: page.context.id,
isFavorite: isFavorite,
favorites: favorites,
favoriteIds: favoriteIds,
fromPage: page.fromPage.name,
};
// bind the playback and favorite controls
$$('.playback-controls a').on('click', playbackControlsClickHandler);
$$('.link.star').on('click', addOrRemoveFavorite.bind(pageContext));
});
myApp.onPageBeforeRemove('details', function(page) {
return ; //que pirata soy.....jejejeje
alert('Media 1 onpageBefore');
// stop playing before leaving the page
monitorMediaPreviewCurrentPosition();
mediaPreview.stop();
mediaPreview.release();
// keep from leaking memory by removing the listeners we don't need
$$('.playback-controls a').off('click', playbackControlsClickHandler);
$$('.link.star').off('click', addOrRemoveFavorite);
});
myApp.onPageInit('index', function (page) {
alert('Inicio index');
});
myApp.onPageInit('mapa', function (page) {
//console.log('About page initialized');
//console.log(page);
// alert('Inicio de Mapa....');
if (navigator.geolocation){
//myApp.alert("Location obtained");
navigator.geolocation.getCurrentPosition(onSuccess, onError, {enableHighAccuracy: true, timeout: 10000});
} else {
//myApp.alert("Location not obtained");
}
});
var map;
function onSuccess(position) {
myApp.alert("Estoy Aqui.....");
var longitude = position.coords.longitude;
//myApp.alert(longitude);
var latitude = position.coords.latitude;
//myApp.alert(latitude);
var latLong = new google.maps.LatLng(latitude, longitude);
var mapOptions = {