forked from SuffolkLITLab/resources
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
807 lines (673 loc) · 28.2 KB
/
index.html
File metadata and controls
807 lines (673 loc) · 28.2 KB
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
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
<meta name="apple-mobile-web-app-capable" content="no" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<title>Resource Finder (Beta)</title>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-108858221-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-108858221-1');
</script>
<meta property="og:image" content="images/icon_300.png"/>
<link rel="apple-touch-icon" href="images/icon_300.png"/>
<link rel="stylesheet" href="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" />
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script>
var app_id = ""
var region_name = ""
var lat = ""
var lon = ""
var zoomin = ""
function zoomfactor(zoomin,lat,lon,latorlon) {
// See https://www.johndcook.com/blog/2009/04/27/converting-miles-to-degrees-longitude-or-latitude/
var earth_radius = 3960.0
var degrees_to_radians = Math.PI/180.0
var radians_to_degrees = 180.0/Math.PI
var miles = 1
if (latorlon == "lat") {
if (zoomin==15) {
miles = 4
} else if (zoomin==14) {
miles = 8
} else if (zoomin==13) {
miles = 20
} else if (zoomin==12) {
miles = 50
} else if (zoomin==11) {
miles = 100
}
return (miles/earth_radius)*radians_to_degrees
} else {
if (zoomin==14) {
miles = 1
} else if (zoomin==13) {
miles = 20
} else if (zoomin==12) {
miles = 50
} else if (zoomin==11) {
miles = 100
}
var r = earth_radius*Math.cos(lat*degrees_to_radians)
return (miles/r)*radians_to_degrees
}
}
var undisc = 0;
$(document).on("mobileinit", function () {
$.mobile.hashListeningEnabled = false;
$.mobile.pushStateEnabled = false;
$.mobile.changePage.defaults.changeHash = false;
});
$(document).on('pagecontainershow', function(e, ui) {
if (readCookie("town") && ($.mobile.pageContainer.pagecontainer("getActivePage")[0].id == "filter")) {
console.log("change dropdown et al")
$("#town").val(readCookie("town")).attr('selected', true);
$("#town").selectmenu("refresh", true);
$("#age").val(readCookie("age"));
load_cats();
if (readCookie("list_map") == "list") {
$('input:radio[name="radio-choice-h-2"]')[0].checked = true;
$('#radio-choice-h-2a').attr('checked',true).checkboxradio('refresh');
$('#radio-choice-h-2b').attr('checked',false).checkboxradio('refresh');
} else if (readCookie("list_map") == "map") {
$('input:radio[name="radio-choice-h-2"]')[1].checked = true;
$('#radio-choice-h-2a').attr('checked',false).checkboxradio('refresh');
$('#radio-choice-h-2b').attr('checked',true).checkboxradio('refresh');
}
}
});
var dcat;
var keys = [];
function load_cat_names() {
console.log("catnames: "+ app_id + '/' + region_name)
axios.get(
'https://api.airtable.com/v0/' + app_id + '/' + region_name + '/?limit=1',
{
headers: { Authorization: "Bearer "+app_key }
}
).then(function(response){
dcat = response.data.records[0].fields;
for(var k in dcat) if (["Name", "Minimum Age", "Maximum Age", "Gender", "Address", "Description", "Application Requirements/Restrictions (if any)", "Website", "Phone", "Email", "Valid As Of", "Latitude", "Longitude"].indexOf(k) == -1) { keys.push([k.replace(/\W+/g,""),k]) };
cat_names = keys;
load_first();
}).catch(function(error){
console.log(error)
})
return true;
//return [["Outreach","Community Outreach"],["Counseling","Counseling"],["Training","Job Opportunities/Training"],["Health","Health Services"],["Academic","Academic Support"],["Case","Case Management"],["Mentor","Mentoring"],["Shelter","Shelter"],["LGBTQ","LGBTQ"],["Housing","Housing"]];
}
function load_filter () {
if (work == 0) {
$.mobile.changePage($('#filter'), { transition: 'slide'});
} else {
if ($.mobile.loading().is(':hidden')) {
$.mobile.loading("show");
}
setTimeout(function () {
load_filter()
}, 100);
}
}
function page_load() {
setTimeout(function(){
if (readCookie("region")) {
console.log(readCookie("region"),"there is a region cookie")
app_id = readCookie("region");
region_name = readCookie("region_name");
cat_names = load_cat_names();
load_regions(0)
//load_first();
load_filter();
} else {
console.log("there is NOT a region cookie")
// call function to get list of regions
load_regions();
}
}, 1000);
}
function region_to_filter(region_val,rname){
createCookie('region',region_val,365*100);
createCookie('region_name',rname,365*100)
app_id = region_val;
region_name = rname;
cat_names = load_cat_names();
console.log(region_val)
//load_first();
//$("#title").html('state'“>”'region');
}
function remove_cookies() {
createCookie('region',"",-1);
createCookie('region_name',"",-1);
createCookie("age","",-1);
createCookie("town","",-1);
createCookie("list_map","",-1);
createCookie("cats","",-1);
$('#town').html("<option value=\"0\" class=\"town_entry\">Choose a Location</option>\n<option v-for=\"item in items\" v-bind:value=\"item['fields']['Latitude, Longitude, Zoom']\" class=\"town_entry\">{{ item['fields']['Name'] }}</option>");
cat_names = [];
keys = [];
}
</script>
<script src="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
<script>
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
function saveCookies() {
age = $("#age").val();
town = $("#town").val();
list_map = $('input[name="radio-choice-h-2"]:checked', '#filter').val()
createCookie("age",age,365*100);
createCookie("town",town,365*100);
createCookie("list_map",list_map,365*100);
}
function load_cats() {
for (var i = 0; i < readCookie("cats").split(",").length; i++) {
console.log(readCookie("cats").split(",")[i]);
//Do something
$('#'+readCookie("cats").split(",")[i]).prop('checked', true).checkboxradio('refresh');
}
}
function save_cats() {
createCookie("cats",checked_cats(),365*100)
}
</script>
<style>
.content {
text-align:left;
max-width:700px;
margin:0 auto 0 auto;
padding:0 15px 25px 15px
}
</style>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
/* Popup container - can be anything you want */
.popup {
position: relative;
display: inline-block;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
/* The actual popup */
.popup .popuptext {
visibility: hidden;
width: 160px;
background-color: #555;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 8px 0;
position: absolute;
z-index: 1;
bottom: 125%;
left: 50%;
margin-left: -80px;
}
/* Popup arrow */
.popup .popuptext::after {
content: "";
position: absolute;
top: 100%;
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: #555 transparent transparent transparent;
}
/* Toggle this class - hide and show the popup */
.popup .show {
visibility: visible;
-webkit-animation: fadeIn 1s;
animation: fadeIn 1s;
}
/* Add animation (fade in the popup) */
@-webkit-keyframes fadeIn {
from {opacity: 0;}
to {opacity: 1;}
}
@keyframes fadeIn {
from {opacity: 0;}
to {opacity:1 ;}
}
.logos {
width:100%;
text-align:center;
padding-top: 15px;
}
</style>
</head>
<body onLoad="page_load();">
<div data-role="page" id="loading">
<div data-role="header" data-position="fixed">
<h1>Loading...</h1>
</div>
<div data-role="content" class="content">
<div class="logos">
<p><img src="images/LIT_logo.png" width="150px"/ border="0" ></p>
<p><img src="images/NU.png" width="200px"/ border="0" ></p>
<p><img src="images/ABA.png" width="200px"/ border="0" ></p>
</div>
</div>
</div>
<div data-role="page" id="region">
<div data-role="header" data-position="fixed">
<a href="#about" class="ui-btn ui-icon-info ui-btn-icon-notext ui-corner-all ui-btn-right" data-transition="slide"></a>
<h1>Resource Finder (Beta)</h1>
</div>
<div data-role="content" id="regions" class="content">
<p>Choose the region for desired program.</p>
</div>
</div>
<div data-role="page" id="filter">
<div data-role="header" data-position="fixed">
<h1 id="title"></h>
<a href="#about" class="ui-btn ui-icon-info ui-btn-icon-notext ui-corner-all ui-btn-right" data-transition="slide"></a>
<a href="#region" onClick="remove_cookies();" class="ui-btn ui-icon-gear ui-btn-icon-notext ui-corner-all ui-btn-left ui-icon-gear" data-transition="slide" data-direction="reverse"></a>
</div>
<div data-role="content" class="content">
<div class="ui-field-contain">Use the following selections to find social, community based programs & services.
<select id="town" name="select-native-1" id="select-native-1" style="width:100%" onChange="">
<option value="0" class="town_entry">Choose a Location</option>
<option v-for="item in items" v-bind:value="item['fields']['Latitude, Longitude, Zoom']" class="town_entry">{{ item['fields']['Name'] }}</option>
</select>
</div>
<p> Enter age of the person seeking services. Leave age blank to view all services.</p>
<div id="age_container"><input name="age" id="age" data-type="number" placeholder="Input Age" onChange="list_page();"></div>
<fieldset id="categories" data-role="controlgroup">
<p style="margin-top:15px;">Check the type(s) of service(s) you are looking for:</p>
</fieldset>
<fieldset data-role="controlgroup" data-type="horizontal">
<input type="radio" name="radio-choice-h-2" id="radio-choice-h-2a" value="list" checked="checked">
<label for="radio-choice-h-2a">List View</label>
<input type="radio" name="radio-choice-h-2" id="radio-choice-h-2b" value="map">
<label for="radio-choice-h-2b">Map View</label>
</fieldset>
<a href="javascript:results_page();" onClick="get_lat_log();list_page();saveCookies();save_cats();i=0;" data-role="button">Find Resources</a>
</div>
</div>
<div data-role="page" id="about">
<div data-role="header" data-position="fixed">
<h1>About</h1>
<a href="#" data-rel="back" data-transition="slide" data-direction="reverse" class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-arrow-l ui-btn-icon-notext"></a>
</div>
<div data-role="content" class="content">
<p> This app was created through the collaborative efforts of Northeastern University Law Lab, Nicole Siino, and Will Bean.</p>
<p> Nicole Siino is American Bar Association NextGen 2018/2019 Fellow and a recent graduate of Suffolk University Law School. During her time in law school, she was a Student Attorney in the Juvenile Defender Clinic. Nicole was also the Legal Innovation & Technology Fellow in her clinic in addition to representing juveniles in their delinquency matters. As a law student, Nicole created a website app that contains a comprehensive list of youth programs & resources in and around the Boston area which allows users to filter through to find the perfect program. It was through this fellowship that Nicole discovered she wanted to be part of the legal tech field. </p>
<p> This web app contains a comprehensive list of criminal justice programs & services to help to provide access to justice. The use of the app allows people to find and successfully participate in these programs which can have long-lasting impacts on their sentences - and their futures. The app enables its users to quickly search and find resources while in court, on the go, or sitting in an office.</p>
<p> You can check out the <a href="https://www.suffolklitlab.org">Suffolk Lit Lab's</a> website to see other LIT projects!</p>
<p> This website application runs of the data from this <a href="https://airtable.com/invite/l?inviteId=invT48E7v0Q3l0yzT&inviteToken=ad4c4e1de78fb9ba616c55f6e294e8998001b321f827c700f835bc22a2e7dea2">Airtable</a>. If you find any errors, please <a href="mailto:litlab@suffolk\.edu">Email</a> the Suffolk LIT Lab.</p>
<p style="text-align:center"><a href="https://suffolklitlab.org/" target="_blank"><img src="images/LIT_logo.png" width="200px"/ border="0"></a></p>
</div>
</div>
<div data-role="page" id="details">
<div data-role="header" data-position="fixed">
<h1>Details</h1>
<a href="#" data-rel="back" data-transition="slide" data-direction="reverse" class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-arrow-l ui-btn-icon-notext"></a>
</div>
<div data-role="content" class="content">
<div id="detail" v-for="" v-if="">
</div>
</div>
</div>
<div data-role="page" id="results">
<div data-role="header" data-position="fixed">
<h1>Results</h1>
<a href="#filter" data-transition="slide" data-direction="reverse" class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-home ui-btn-icon-notext"></a>
<div data-role="navbar">
<ul>
<li><a href="#results">List</a></li>
<li><a href="javascript:void('');" style="color:#ccc" onClick="size_map();$.mobile.changePage($('#map-page'), { transition: 'none'});">Map</a></li>
</ul>
</div>
</div>
<div data-role="content" class="content">
<h1 id="town_name"></h1>
<form id="searchfilter"class="ui-filterable">
<input id="filterBasic-input" data-type="search">
</form>
<ul id="org_list" data-role="listview" data-inset="true" data-filter="true" data-input="#filterBasic-input">
</ul>
</div>
<ul id="org_geo_list" style="display:none;"></ul>
</div>
<div data-role="page" id="map-page" style="background:#798e9e;">
<div data-role="header" data-position="fixed">
<h1>Results</h1>
<a href="#filter" data-transition="slide" data-direction="reverse" class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-home ui-btn-icon-notext"></a>
<div data-role="navbar">
<ul>
<li><a href="#results" data-transition="none" style="color:#ccc">List</a></li>
<li><a href="#map-page">Map</a></li>
</ul>
</div>
</div>
<div>
<div id="map" style="width:100%;height:100px;"></div>
</div>
</div>
<!-- Include Dependency Scripts -->
<!--<script type="text/javascript" src="https://unpkg.com/vue"></script>-->
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.16.2/axios.min.js"></script>
<script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBCDs-cJfxydB2mKizGvtEt5tGMhcxMjmk"></script>
<script type="text/javascript">
var meta_app_id = "app91Hf1BF6Zx11lT";
var app_key = "keyMCwJmZpyayqYhY";
var data;
var x = [];
function load_region_list() {
axios.get(
'https://api.airtable.com/v0/'+meta_app_id+'/Meta Data/?sort[0][field]=State',
{
headers: { Authorization: "Bearer "+app_key }
}
).then(function(response){
data = response.data.records;
data.forEach(function (arrayItem) {
if ((arrayItem.fields.State) && (x.indexOf(arrayItem.fields.State)==-1)) {
x.push(arrayItem.fields.State)
//console.log(x);
}
});
}).catch(function(error){
console.log(error)
})
return x;
}
var y = [];
var cat_names = [];
var region_names = load_region_list();
var categories = "";
//var ages = "";
var work = 0;
$("#region").on("pageshow" , function() {
region_names.forEach((cat, index) => {
$('#list_'+cat.replace(/ /g,"\\ ")).listview('refresh');
});
});
function load_regions(go) {
console.log("LOAD REGIONS")
console.log(region_names)
region_names.forEach((cat, index) => {
$("#regions").html( $("#regions").html() + "<div data-role=\"collapsible\" id=\"reg_"+cat+"\" data-inset=\"false\"><h3>"+cat+"</h3><ul id=\"list_"+cat+"\" data-role=\"listview\"><li v-for=\"item in items\"><a href=\"javascript:void('');\" v-bind:id=\"item['fields']['API Documentation (Base)']\" onClick=\"region_to_filter(this.id,$('#'+this.id).html());\">{{ item['fields']['Region'] }}</a></li></ul></div>");
});
region_names.forEach((cat, index) => {
load_api_data('#reg_'+cat.replace(/ /g,"\\ "),-1,cat);
});
if (go!=0) {
$.mobile.changePage($('#region'), { transition: 'fade', });
}
}
function load_first() {
console.log("LOAD FIRST")
$('#town-button').empty()
$("#categories").html("<p style=\"margin-top:15px;\">Check the type(s) of service(s) you are looking for:</p>")
$("#age_container").html("<input name=\"age\" id=\"age\" data-type=\"number\" placeholder=\"Input Age\" onChange=\"list_page();\">")
cat_names.forEach((cat, index) => {
$("#categories").html( $("#categories").html() + "<input type=\"checkbox\" name=\"checkbox-v-"+cat[0]+"\" id=\"checkbox-v-"+cat[0]+"\" onChange=\"list_page();\" class=\"boxcheck\">");
$("#categories").html( $("#categories").html() + "<label for=\"checkbox-v-"+cat[0]+"\">"+cat[1]+"</label>");
});
$( '#categories' ).enhanceWithin();
load_api_data('#filter',0);
$.mobile.changePage($('#filter'), { transition: 'slide', });
}
function checked_cats() {
var selected = [];
$('.boxcheck:checkbox:checked').each(function() {
selected.push($(this).attr('id'));
});
return selected;
}
function cutoff(longname){
output = longname.replace(/^checkbox-v-/g,'');
return output
}
function indexis(variablename) {
for(var i = 0; i < cat_names.length; i++) {
if(cat_names[i][0] == variablename) {
return cat_names[i][1];
}
}
}
function cats_filter() {
filter_string = ",OR("
for (var i = 0; i < checked_cats().length; i++) {
console.log(checked_cats()[i]);
filter_string= filter_string+"{"+ indexis(cutoff(checked_cats()[i])) +"}=1"
if (i<checked_cats().length-1) {
filter_string= filter_string+","
}
}
filter_string = filter_string+")"
return filter_string
}
function load_api_data(target,mode=3,id='') {
work = 1;
console.log("LOAD API DATA:",target,mode,id)
//https://api.airtable.com/v0/appHUknSmoIogemD5/Boston/?filterByFormula=AND(20<={Maximum Age},20>={Minimum Age},OR((FIND("Community Outreach",{Category})),(FIND("Counseling",{Category}))))
if (mode == -1) {
apicall = "https://api.airtable.com/v0/"+meta_app_id+"/Meta Data/?filterByFormula=(State=\""+id+"\")";
} else if (mode == 0) {
apicall = "https://api.airtable.com/v0/"+app_id+"/Locations/?sort[0][field]=Name&sort[0][direction]=asc";
} else if (mode == 1) {
//apicall = "https://api.airtable.com/v0/"+app_id+"/" + region_name + "/?limit=1";
} else if (mode == 2) {
apicall = "https://api.airtable.com/v0/"+app_id+"/" + region_name + "/?filterByFormula=AND("+(lat-zoomfactor(zoomin,lat,lon,"lat"))+"<={Latitude},"+(lat+zoomfactor(zoomin,lat,lon,"lat"))+">={Latitude},"+(lon-zoomfactor(zoomin,lat,lon,"lon"))+"<={Longitude},"+(lon+zoomfactor(zoomin,lat,lon,"lon"))+">={Longitude}"+cats_filter()+")&sort[0][field]=Name&sort[0][direction]=asc";
//console.log(lat,lon,apicall)
} else if (mode == 3) {
apicall = "https://api.airtable.com/v0/"+app_id+"/" + region_name + "/?filterByFormula=(RECORD_ID()=\""+id+"\")";
}
console.log(apicall)
var app = new Vue({
el: String(target),
data: {
items: []
},
mounted: function(){
this.loadItems();
},
methods: {
loadItems: function(){
// Init variables
var self = this
this.items = []
axios.get(
apicall,
{
headers: { Authorization: "Bearer "+ app_key }
}
).then(function(response){
self.items = response.data.records;
work = 0;
//console.log(response)
console.log(self.items)
}).catch(function(error){
console.log(error)
})
}
}
});
}
function results_page() {
$('#searchfilter').empty()
$('#searchfilter').html("<input id=\"filterBasic-input\" data-type=\"search\">")
if ($('#town').find(":selected").val() == 0) {
alert('You must choose a location.');
} else if ( isNaN(Number($('#age').val())) ) {
alert('You must enter a numeric age (in years) or leave blank.')
} else if ($('.boxcheck:checkbox:checked').length > 0) {
next_page_1()
} else {
alert('You must choose at least one type of service.')
}
}
function next_page_1() {
if (work == 0) {
if ($('input[name=radio-choice-h-2]:checked', '#filter').val() == "map") {
size_map();
$.mobile.changePage($('#map-page'), { transition: 'slide'});
} else {
$.mobile.changePage($('#results'), { transition: 'slide'});
}
} else {
if ($.mobile.loading().is(':hidden')) {
$.mobile.loading("show");
}
setTimeout(function () {
next_page_1()
}, 100);
}
}
function get_lat_log() {
geo_data = $('#town').find(":selected").val().split(',').map(Number);
console.log("LAT LON "+geo_data)
lat = geo_data[0];
lon = geo_data[1];
zoomin = geo_data[2];
}
function list_page() {
if ($('#town').find(":selected").val() != 0 && !isNaN(Number($('#age').val())) ) {
$("#org_list").html("");
$("#org_geo_list").html("<li id=\"ge0_points\" v-for=\"item in items\">{{ item['id'] }},{{ item['fields']['Name'] }},{{ item['fields']['Latitude'] }},{{ item['fields']['Longitude'] }}</li>");
categories = "";
cat_names.forEach((cat, index) => {
if ($('#checkbox-v-'+cat[0]).is(":checked")){
$("#org_list").html( $("#org_list").html() + "<li data-role=\"list-divider\">"+cat[1]+"</li>")
$("#org_list").html( $("#org_list").html() + "<li v-for=\"item in items\" v-if=\"item['fields']['"+cat[1]+"'] == '1'\"><a href=\"javascript:void('')\" v-bind:id=\"item['id']\" onClick=\"details_page(this.id);\">{{ item['fields']['Name'] }}<p>Ages: {{ item['fields']['Minimum Age'] }}-{{ item['fields']['Maximum Age']}}</p></a></li>")
if (categories != "") {
categories = categories+",";
}
categories = categories+"FIND(\""+cat[1]+"\",{Category})";
}
});
//if ($('#age').val()=="") {
// ages = "";
//} else {
// ages = Number($('#age').val())+"<={Maximum Age},"+Number($('#age').val())+">={Minimum Age},";
//}
$('#town_name').html($('#town').find(":selected").text());
load_api_data('#results',2);
//geo_data = $('#town').find(":selected").val().split(',').map(Number);
//console.log(geo_data)
//lat = geo_data[0];
//lon = geo_data[1];
//zoomin = geo_data[2];
} else {
return false;
}
}
function details_page(id) {
$("#detail").attr("v-for", "item in items");
//$("#detail").attr("v-if", "item['id'] == '"+id+"'");
$("#detail").html("");
$("#detail").html($("#detail").html() + "<h3>{{ item['fields']['Name'] }}</h3>")
$("#detail").html($("#detail").html() + "<h4>{{ item['fields']['Category'] }}</h4>");
$("#detail").html($("#detail").html() + "<p><b>Ages:</b> {{ item['fields']['Minimum Age'] }}-{{ item['fields']['Maximum Age'] }} <b>Gender(s):</b> {{ item['fields']['Gender'] }}</p>");
$("#detail").html($("#detail").html() + "<p><b>Phone:</b> <a v-bind:href=\"'tel:'+item['fields']['Phone']\" target=\"_blank\">{{ item['fields']['Phone'] }}</p>");
$("#detail").html($("#detail").html() + "<p><b>Email:</b> <a v-bind:href=\"'mailto:'+item['fields']['Email']\" target=\"_blank\">{{ item['fields']['Email'] }}</a></p>");
$("#detail").html($("#detail").html() + "<p><b>Website:</b> <a v-bind:href=\"item['fields']['Website']\" target=\"_blank\">{{ item['fields']['Website'] }}</a></p>");
$("#detail").html($("#detail").html() + "<p><b>Address:</b> <a v-bind:href=\"'https://www.google.com/maps/place/'+item['fields']['Address']\" target=\"_blank\">{{ item['fields']['Address'] }}</a></p>");
$("#detail").html($("#detail").html() + "<p><b>Application Requirements/Restrictions (if any):</b> {{ item['fields']['Application Requirements/Restrictions (if any)'] }}</p>");
$("#detail").html($("#detail").html() + "<p><b>Description:</b> {{ item['fields']['Description'] }}</p>");
$("#detail").html($("#detail").html() + "<p><b>Valid As Of:</b> {{ item['fields']['Valid As Of'] }}</p>");
load_api_data('#details',3,id);
//$.mobile.changePage($('#details'), { transition: 'slide'})
next_page_2();
//$('#details').listview('refresh');
//$( '#details' ).enhanceWithin();
//$.mobile.changePage($('#details'), { transition: 'slide'});
//return true;
}
function next_page_2() {
if (work == 0) {
$.mobile.changePage($('#details'), { transition: 'slide'})
} else {
if ($.mobile.loading().is(':hidden')) {
$.mobile.loading("show");
}
setTimeout(function () {
next_page_2()
}, 100);
}
}
//list_page();
/*
https://developers.google.com/maps/documentation/javascript/adding-a-google-map
*/
var markers = [];
function initMap(lat,lon,zoomin) {
var uluru = {lat: lat, lng: lon};
var map = new google.maps.Map(document.getElementById('map'), {
zoom: zoomin,
center: uluru
});
i = 0;
$('#org_geo_list li').each(function(){
//alert($(this).text());
pin_data = $(this).text().split(',');
marker = new google.maps.Marker({
position: {lat: Number(pin_data[2]), lng: Number(pin_data[3])},
map: map
});
var infowindow = new google.maps.InfoWindow({
content: "<div style=\"width:225px;text-align:center;\"><h2>"+pin_data[1]+"</h2><div style=\"width:100%;text-align:center;padding-bottom:10px;\"><a href=\"javascript:details_page(\'"+pin_data[0]+"\')\">view details</a></span></div>"
});
//creates an infowindow 'key' in the marker.
marker.infowindow = infowindow;
//finally call the explicit infowindow object
marker.addListener('click', function() {
hideAllInfoWindows(map);
return this.infowindow.open(map, this);
});
markers.push(marker);
++i;
});
google.maps.event.addListener(map, 'click', function() {
if (infowindow) {
infowindow.close();
}
});
}
function hideAllInfoWindows(map) {
markers.forEach(function(marker) {
marker.infowindow.close(map, marker);
});
}
function size_map() {
initMap(lat,lon,zoomin);
var map_pad = 81;
if (undisc==1) {
map_pad = 200;
}
$('#map').height( window.innerHeight - map_pad + 'px');
}
$("div[data-role=page]").bind("pagebeforeshow", function (e, data) {
$.mobile.silentScroll(0);
$.mobile.changePage.defaults.transition = 'slide'; // reset default here
})
</script>
</body>
</html>