This repository has been archived by the owner on Oct 14, 2022. It is now read-only.
/
index.html
216 lines (198 loc) · 7.04 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
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery Mobile: Theme Download</title>
<link rel="stylesheet" href="./css/themes/toysfortots.css" />
<link rel="stylesheet" href="./css/themes/jquery.mobile.icons.min.css" />
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile.structure-1.4.5.min.css" />
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="https://apis.google.com/js/client.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
<script type="text/javascript" src="https://rawgithub.com/nwcell/ics.js/master/ics.deps.min.js"></script>
<style>
.ui-autocomplete-loading {
background: white url("ui-anim_basic_16x16.gif") right center no-repeat;
}
.ui-header .ui-title {margin: 0 20%;}
ul.ui-autocomplete.ui-menu{
font-weight: bold;
}
.ui-autocomplete {
width: 200px;
background: white;
border-radius: 10px;
min-height: 2em;
list-style: none;
display: block;
}
#custom-border-radius .ui-btn-icon-notext.ui-corner-all {
-webkit-border-radius: .3125em;
border-radius: .3125em;
}
@media screen and (max-width: 321px){
.ui-btn{
font-size : 12px;
border-radius: 2px;
}
}
</style>
</head>
<body>
<div data-role="page" id="main" data-theme="a">
<div data-role="header" data-position="inline">
<h1>Indiana Toys for Tots</h1>
</div>
<div data-role="content" data-theme="a">
<script>
var api_url = "https://toysfortots.herokuapp.com/"
(function($) {
$.getJSON(api_url + 'read_all', function (data) {
var outArray = [];
$.each(data, function(index){
outArray.push(index);
});//end each
$( "#county" ).autocomplete({
source: outArray,
minLength: 3,
delay: 1000
});//end autocomplete
});//end getJSON
}) (jQuery );
function geoFindMe() {
var output = document.getElementById("out");
if (!navigator.geolocation){
return;
}
function success(position) {
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
$.getJSON('http://nominatim.openstreetmap.org/reverse?format=json&addressdetails=1&lat='+latitude+'&lon='+longitude,
function (data){
var county = data.address.county;
county = county.replace("County", "").trim();
$("#county").val(county);
});
};
function error() {
};
navigator.geolocation.getCurrentPosition(success, error);
}//end geoFindMe
</script>
<p>
<div class="ui-widget">
<label for="county">Enter a County</label>
<input id="county" class="ui-content" />
<div data-role="controlgroup" data-type="horizontal">
<a href="#" class="ui-btn ui-corner-all ui-btn-inline ui-icon-location ui-alt-icon ui-btn-icon-left" onclick="geoFindMe()">Current Location</a>
<a href="#two" class="ui-btn ui-corner-all ui-btn-inline ui-icon-search ui-alt-icon ui-btn-icon-left" onclick="countyFunction()">Search</a>
</div>
</div>
</p>
</div>
</div>
<!-- Start of second page: #two -->
<div data-role="page" id="two" data-theme="a">
<div data-role="header">
<h1>Indiana Toys for Tots</h1>
</div><!-- /header -->
<div data-role="content" data-theme="a">
<p class="emptythis">I have an id of "two" on my page container. I'm the second page container in this multi-page template.</p>
<p><a href="#main" data-direction="reverse" class="ui-btn ui-shadow ui-corner-all ui-btn-b">Back</a></p>
</div><!-- /content -->
<div data-role="footer">
<h4></h4>
</div><!-- /footer -->
</div><!-- /page two -->
<script>
var api_url = "https://toysfortots.herokuapp.com/"
var cal = ics();
var gCal={
'summary' : '',
'location' : '',
'description' : '',
'start' : {
'dateTime':'',
'timeZone' : 'America/New_York'
},
'end' : {
'dateTime' : '',
'timeZone' : 'America/New_York'
}
};
function countyFunction(){
var coordinator ="";
$.getJSON(api_url + 'read_all', function( data ){
var county = $('#county').val().trim();
var dataKey = data[county];
if(typeof dataKey === 'undefined'){
$('.emptythis').replaceWith("<p class='emptythis'>No results found <br /></p>");
return
}
coordinator = data[county].coordinator;
var outHTML="<p class='emptythis'>";
for(var i=0; i<coordinator.length;i++){
if(coordinator[i].name){
if(i==0){
outHTML+="Coordinator :\t"+coordinator[i].name+"<br />";
} else {
outHTML+="Coordinator "+(i+1)+":\t"+coordinator[i].name+"<br />"
}
};
if(coordinator[i].site){outHTML+="Website:<a href='"+coordinator[i].site+"'>"+coordinator[i].site+"</a><br />"};
if(coordinator[i].phone){outHTML+="Phone\t<a href='tel:"+coordinator[i].phone+"'>"+coordinator[i].phone+"</a><br />"};
if(coordinator[i].email){outHTML+="E-mail:\t<a href='mailto:"+coordinator[i].email+"'>"+coordinator[i].email+"</a><br /><br />"};
}
if(data[county].events!=undefined){
$.each(data[county].events, function(key, value){
cal.addEvent(value.subject, value.description, value.location, value.begin, value.end);
gCal.summary=value.subject;
gCal.description=value.description;
gCal.location=value.location;
value.begin = new Date(value.begin);
value.end = new Date(value.end);
gCal.start.dateTime=value.begin.toISOString();
gCal.end.dateTime=value.end.toISOString();
});
outHTML+="<a href=\"javascript:cal.download()\" class=\"ui-btn ui-corner-all ui-alt-icon ui-icon-calendar ui-btn-icon-left\">Download Events</a>" ;
outHTML+="<a href=\"#\" class=\"ui-btn ui-corner-all\" onClick=\"googleCalendarAdd()\"><i class=\"fa fa-calendar-plus-o\"></i>Add to Google Calendar</a>";
}
outHTML+="</p>";
$('.emptythis').replaceWith(outHTML);
});
}
function emptyThis(){
$(".emptythis").empty();
}
/**
gcal scope:https://www.googleapis.com/auth/calendar
URIs relative to https://www.googleapis.com/calendar/v3, unless otherwise noted
insert POST /calendars/calendarId/events Creates an event.
**/
function googleCalendarAdd(){
auth();
gapi.client.load('calendar', 'v3').then(function(){
var request = gapi.client.calendar.events.insert({
'calendarId': 'primary',
'resource': gCal
});
request.execute(function(resp){
var outHTML = "<p class='emptyThis'>";
outHTML+="Events successfully updated";
outHTML+="</p>";
$(".emptyThis").replaceWith(outHTML);
});
});//end function promise
}//end googleCalendarAdd
function auth() {
var config = {
'client_id': '537444421651-selo4r5u1skpvt9kmsbj2ocgev6nr6is.apps.googleusercontent.com',
'scope': 'https://www.googleapis.com/auth/calendar'
};
gapi.auth.authorize(config, function(){});
}
</script>
</body>
</html>