Skip to content
Newer
Older
100644 345 lines (286 sloc) 10.3 KB
bda2a3b index.jsp is new landing page, logout functionality added
Jake Levine authored
1 <%@ page contentType="text/html;charset=UTF-8" language="java" %>
2
d161527 @aquillano updated index.jsp
aquillano authored
3 <%@ page import="meetupnow.NewsItem" %>
bda2a3b index.jsp is new landing page, logout functionality added
Jake Levine authored
4 <%@ page import="javax.jdo.PersistenceManager" %>
5 <%@ page import="javax.jdo.Query" %>
6 <%@ page import="java.util.List" %>
d161527 @aquillano updated index.jsp
aquillano authored
7 <%@ page import="java.util.Date" %>
b904930 added map functionallity to index.jsp
Michael Shapiro authored
8
9af4d91 map on index queries all topics in database
Michael Shapiro authored
9
d161527 @aquillano updated index.jsp
aquillano authored
10 <!DOCTYPE html>
c66706c @aquillano add index.jsp
aquillano authored
11 <html>
12 <head>
d161527 @aquillano updated index.jsp
aquillano authored
13 <title>MeetupNOW</title>
c66706c @aquillano add index.jsp
aquillano authored
14 <link rel="stylesheet" href="css/reset.css" type="text/css" />
1c588db @aquillano styling EventPage
aquillano authored
15 <link rel="stylesheet" href="css/meetupnow.css" type="text/css" />
b904930 added map functionallity to index.jsp
Michael Shapiro authored
16 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
c66706c @aquillano add index.jsp
aquillano authored
17 <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
4fa6f95 seperated javascript from index into new file index.js
Michael Shapiro authored
18 <script type="text/javascript" src="/js/index.js"></script>
c66706c @aquillano add index.jsp
aquillano authored
19 <script type="text/javascript">
d161527 @aquillano updated index.jsp
aquillano authored
20 function initialize() {
21 var myLatlng = new google.maps.LatLng(-34.397, 150.644);
22 var myOptions = {
23 zoom: 8,
24 center: myLatlng,
25 mapTypeId: google.maps.MapTypeId.ROADMAP
26 }
27 var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
28 }
29 </script>
30 <script type="text/javascript">
31
32
33
34 $(function() {
35
36 var out = $('#activity');
37
38 var alerts = new Array();
39 var counter = 0;
40 var frameNum = 3;
41 var frames = new Array();
42
43 <%!
44 public static String timeBetween(Date d1, Date d2){
45 long now = d1.getTime();
46 long then = d2.getTime();
47
48 long seconds = (now - then)/1000;
49 long minutes = seconds/60;
50 long hours = minutes/60;
51 long days = hours/24;
52
53 if (seconds < 60) {
54 if (seconds == 1) {return seconds+" second ago";}
55 else {return seconds+" seconds ago";}
56 }
57 if (minutes < 60) {
58 if (minutes == 1) {return minutes+" minute ago";}
59 else {return minutes+" minutes ago";}
60 }
61 if (hours < 24) {
62 if (hours == 1) {return hours+" hour ago";}
63 else {return hours+" hours ago";}
64 }
65 if (days == 1) {return days+" day ago";}
66 else {return days+" days ago";}
67
68 }
69 %>
70
71 <%
72 PersistenceManager pmr = PMF.get().getPersistenceManager();
73 List<NewsItem> newsFeed = new ArrayList<NewsItem>();
74 Query newsQuery = pmr.newQuery(NewsItem.class);
75 newsQuery.declareParameters("long startdate");
76 newsQuery.setFilter("timeCreated > startdate");
77 newsQuery.setOrdering("timeCreated descending");
78
79 try {
80 newsFeed = (List<NewsItem>) newsQuery.execute(0);
81 for (int i = 0; i < newsFeed.size(); i++) {
82 NewsItem n = newsFeed.get(i);
83 Date now = new Date();
84 Date then = new Date(n.getTimeCreated());
85
86 %>
87
88 alerts[<%=i%>] = new item("<%=n.getType()%>","<%=n.getName()%>","<%=n.getMessage()%>","<%=n.getEvConName()%>","<%=n.getContainerName()%>","<%=timeBetween(now,then)%>","<%=n.getLink()%>");
89
90 <%
91 }
92 } finally {
93 newsQuery.closeAll();
94 }
95 %>
96 var i;
97 for (i = 0; i < frameNum; i=i+1) {
98 frames[i] = contain(alerts[i]);
99 }
100
101 var interval = window.setInterval(loop, 0);
102
103 function loop() {
104 var i;
105 out.empty();
106 var index;
107 for (i = frameNum - 1; i >= 0 ; i=i-1) {
108 index = alerts.length - 1 - counter - i;
109 if (index < 0) {index = index + alerts.length}
110 out.append(contain(alerts[index]));
111 }
112 counter = counter + 1;
113 if (counter >= alerts.length) {
114 counter = 0;
115 }
116
117 var randomnumber = Math.floor(Math.random()*15000)
118 if (randomnumber < 5000) {randomnumber = 5000};
119 window.clearInterval(interval);
120 interval = window.setInterval(loop, randomnumber);
121 }
122
123 });
124
125 function contain(alert) {
126 return "<div class=\"activityFeedItem\"><span>"+ formatAlert(alert) +"</span></div>";
127 }
128
129 function formatAlert(alert) {
130 var evName;
131 var contain;
132 if (alert.type == "comment") {
133 if (alert.eventName == "null") { evName = "on an event"; }
134 else {evName = "on event " + alert.eventName;}
135 return "<i>"+alert.name+"</i> commented <a href=\""+alert.link+"\"><b>"+evName+"</b></a>: <b>"+ alert.message+"</b> <i> ~ "+alert.time+"</i>";
136 }
137 if (alert.type == "event_create") {
138 if (alert.container == "null") {contain = "";}
139 else { contain = "in topic "+alert.container;}
140 return "<i>"+alert.name+"</i> created a new event "+contain+": <a href=\""+alert.link+"\"><b>"+alert.eventName+"</b></a>: "+alert.message+" <i> ~ "+alert.time+"</i>";
141 }
142 if (alert.type == "event_rsvp") {
143 if (alert.eventName == "null") {evName = "an event";}
144 else {evName = alert.eventName;}
145 if (alert.container == "null") {contain = "";}
146 else {contain = " in topic "+alert.container;}
147 return "<i>"+alert.name+"</i> is hitting up <a href=\""+alert.link+"\"><b>"+evName+"</b></a>"+contain+" <i> ~ "+alert.time +"</i>";
148 }
149
150 }
151
152
153 function item(ty,n,m,e,c,ti,l) {
154 this.type = ty;
155 this.name = n;
156 this.message = m;
157 this.eventName = e;
158 this.container = c;
159 this.time = ti;
160 this.link = l;
161 }
162
163 </script>
164
165
166
167 <script type="text/javascript">
b904930 added map functionallity to index.jsp
Michael Shapiro authored
168
4fa6f95 seperated javascript from index into new file index.js
Michael Shapiro authored
169
170 function loadEvents(){
0cb5a98 fix minor bugs
Michael Shapiro authored
171 <%@ include file="jsp/cookie.jsp" %>
4490cb9 changed header files in order to properly precompile
Jake Levine authored
172 <%@ include file="jsp/declares.jsp" %>
9af4d91 map on index queries all topics in database
Michael Shapiro authored
173
174 <%@ page import="meetupnow.Topic" %>
b904930 added map functionallity to index.jsp
Michael Shapiro authored
175 <%
176
9b16224 sync database with meetup in index
Michael Shapiro authored
177
178 API_URL = "http://api.meetup.com/ew/containers?order=name&offset=0&format=json&link=http%3A%2F%2Fjake-meetup-test.appspot.com&page=200&sig_id=12219924&sig=18c1783ca4472bbaa62c745ee138082b";
179 APIrequest = new Request(Request.Verb.GET, API_URL);
180 APIresponse = APIrequest.send();
181 JSONObject json;
182 JSONArray top_list;
183
184
0cb5a98 fix minor bugs
Michael Shapiro authored
185
9af4d91 map on index queries all topics in database
Michael Shapiro authored
186 String TopicList = "container_id=654,713,";
187 Query TopicQuery = pm.newQuery(Topic.class);
188 TopicQuery.setFilter("id != 0");
189 TopicQuery.declareParameters("String reqTokenParam"); //Setup Query
190
9b16224 sync database with meetup in index
Michael Shapiro authored
191 List<Topic> Topics = new ArrayList<Topic>();
9af4d91 map on index queries all topics in database
Michael Shapiro authored
192 try {
9b16224 sync database with meetup in index
Michael Shapiro authored
193 Topics = (List<Topic>) pm.detachCopyAll((List<Topic>) TopicQuery.execute(key));
9af4d91 map on index queries all topics in database
Michael Shapiro authored
194 for (int i = 0; i < Topics.size(); i++){
195 TopicList = TopicList + Integer.toString(Topics.get(i).getId()) + ",";
196 }
197 if (TopicList.charAt(TopicList.length() - 1) == ',')
198 TopicList = TopicList.substring(0, TopicList.length() - 1);
199 } finally {
92d7c95 modified index.jsp to recognize whether a user is logged in and if so
Michael Shapiro authored
200
9af4d91 map on index queries all topics in database
Michael Shapiro authored
201 }
202
9b16224 sync database with meetup in index
Michael Shapiro authored
203 Topic NewTopic;
204
205 try{
206 json = new JSONObject(APIresponse.getBody());
207 top_list = json.getJSONArray("results");
208 boolean found = false;
209
210 for (int j = 0; j < top_list.length(); j++){
211 found = false;
212 for (int i = 0; i < Topics.size(); i++){
213 if( top_list.getJSONObject(j).getString("id").equals(Topics.get(i).getId()) ){
214 found = true;
215 }
216 }
217 if (!found){
218 System.out.println(top_list.getJSONObject(j).getString("name"));
219 NewTopic = new Topic(top_list.getJSONObject(j).getString("description"), top_list.getJSONObject(j).getJSONObject("founder").getString("member_id"), top_list.getJSONObject(j).getString("name"), Integer.parseInt(top_list.getJSONObject(j).getString("id")));
220 try {
221 pm.makePersistent(NewTopic);
222 }
223
224 finally {
225
226 }
227 }
228 }
229
230 }
231 catch (JSONException j){
232
233 }
234
1fea70c fixed index.jsp to work when user is not logged in
Jake Levine authored
235 if (!key.equals("empty")) {
236 try {
f9ddbec declare user in cookie.jsp
Michael Shapiro authored
237 users = (List<MeetupUser>) query.execute(key);
1fea70c fixed index.jsp to work when user is not logged in
Jake Levine authored
238 if (users.iterator().hasNext()) {
239 Token accessToken = new Token(users.get(0).getAccToken(),users.get(0).getAccTokenSecret());
9af4d91 map on index queries all topics in database
Michael Shapiro authored
240 API_URL = "http://api.meetup.com/ew/events/?status=upcoming&" + TopicList + "&lat=" + users.get(0).getLat() + "&lon=" + users.get(0).getLon() + "&radius=" + distance;
9b16224 sync database with meetup in index
Michael Shapiro authored
241
19f68b7 minor changes to index.jsp
Michael Shapiro authored
242 APIrequest = new Request(Request.Verb.GET, API_URL);
1fea70c fixed index.jsp to work when user is not logged in
Jake Levine authored
243 scribe.signRequest(APIrequest,accessToken);
19f68b7 minor changes to index.jsp
Michael Shapiro authored
244 APIresponse = APIrequest.send();
9b16224 sync database with meetup in index
Michael Shapiro authored
245 %>data = <%=APIresponse.getBody().toString()%><%
b904930 added map functionallity to index.jsp
Michael Shapiro authored
246 }
247 }
1fea70c fixed index.jsp to work when user is not logged in
Jake Levine authored
248 finally {
19f68b7 minor changes to index.jsp
Michael Shapiro authored
249
1fea70c fixed index.jsp to work when user is not logged in
Jake Levine authored
250 }
92d7c95 modified index.jsp to recognize whether a user is logged in and if so
Michael Shapiro authored
251 }
252 else {
b904930 added map functionallity to index.jsp
Michael Shapiro authored
253
1061fe0 minor changes
Michael Shapiro authored
254 API_URL = "http://api.meetup.com/ew/events?status=upcoming&radius=25.0&order=time&offset=0&format=json&page=200&container_id=654&sig_id=12219924&sig=73487b47859ee335994dac5770ba0d18";
19f68b7 minor changes to index.jsp
Michael Shapiro authored
255 APIrequest = new Request(Request.Verb.GET, API_URL);
256 APIresponse = APIrequest.send();
257 %>var data = <%=APIresponse.getBody().toString()%><%
92d7c95 modified index.jsp to recognize whether a user is logged in and if so
Michael Shapiro authored
258
259 }
b904930 added map functionallity to index.jsp
Michael Shapiro authored
260 %>
4fa6f95 seperated javascript from index into new file index.js
Michael Shapiro authored
261 use_everywhere(data);
262 }
92d7c95 modified index.jsp to recognize whether a user is logged in and if so
Michael Shapiro authored
263
c66706c @aquillano add index.jsp
aquillano authored
264 </script>
265 </head>
d161527 @aquillano updated index.jsp
aquillano authored
266 <body onload="loadEvents()">
291f974 minor bug fix
Michael Shapiro authored
267
4a67df7 added jsp header file
Michael Shapiro authored
268 <%@ include file="jsp/header.jsp" %>
d161527 @aquillano updated index.jsp
aquillano authored
269 <div id="wrapper">
270 <div id="wrapperContent">
271 <div id="contentRight">
272 <div class="map_context">
273 <span class="map_title title">Happening NOW near you...</span>
274 <div id="map_canvasContainer">
275 <div id="map_canvas">
276
277 </div><!-- end #map_canvas -->
278 </div><!-- end #map_canvasContainer -->
279 </div><!-- end .map_context -->
280 <div id="searchContext">
281 <div id="search">
282 <form action="search" method="post" accept-charset="utf-8">
283 <div class="element">
284 <div class="label">
285 <label for="query">Search for: </label>
286 </div> <!-- end .label -->
287 <div class="input">
288 <input type="text" name="query" value="" id="query" size="20" maxlength="100">
289 </div> <!-- end .input -->
290 </div> <!-- end .element -->
291 <div class="element">
292 <div class="label">
293 <label for="location">City or Postal Code</label>
294 </div> <!-- end .label -->
295 <div class="input">
296 <input type="text" name="location" value="" id="location" size="15" maxlength="100">
297 </div> <!-- end .input -->
298 </div> <!-- end .element -->
c66706c @aquillano add index.jsp
aquillano authored
299
d161527 @aquillano updated index.jsp
aquillano authored
300 <div class="submit">
301 <input type="submit" value="Search" class="submitBtn">
302 </div> <!-- end .submit -->
303 </form>
304 </div> <!-- end #search -->
305 </div> <!-- end #searchContext -->
306 <div id="mn_geoListContext">
307 <div id="mn_geoListHeader">
308 <span class="listTitle">Results near [location]</span>
309 </div><!-- mn_geoListHeader -->
310 <div id="mn_geoListBody">
46fc271 isfsdf
Michael Shapiro authored
311
d161527 @aquillano updated index.jsp
aquillano authored
312 </div> <!-- end #mn_geoListBody -->
313 <div id="mn_geoListFooter">
314 <div id="searchResultsNav">
315 <span class="showAll"></span>
316 <span class="paginationNav"></span>
317 </div> <!-- end searchResultsNav -->
318 </div><!-- mn_geoListFooter -->
319 </div><!-- mn_geoListContext -->
320 </div> <!-- end #contentRight -->
321 <div id="contentLeft">
1c588db @aquillano styling EventPage
aquillano authored
322 <div id="contentLeftContext">
d161527 @aquillano updated index.jsp
aquillano authored
323 <span class="title">Get Started.</span>
324 <div id="action">
325 <a href="#"><span class="btn_main">Register</span></a>
e650c15 @aquillano minor update
aquillano authored
326 <a href="CreateEvent.jsp"><span class="btn_main">Create Event</span></a>
9af4d91 map on index queries all topics in database
Michael Shapiro authored
327 <a href="search.jsp"><span class="btn_main">Search Topics</span></a>
d161527 @aquillano updated index.jsp
aquillano authored
328 </div> <!-- end #action -->
329 <div id="actionDesc">
330 <span class="heading">MeetupNow is a platform built to Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. </span>
331 <span class="heading">Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris.</span>
332 </div> <!-- end #actionDesc -->
333 </div> <!-- end #actionContext -->
334 <div id="activityFeedContext">
335 <div id="activityFeed">
336 <span class="title">Activity Feed.</span>
337 <div id = "activity"> </div>
338 </div>
339 </div> <!-- end #activityFeed -->
340 </div> <!-- end #contentLeft -->
341 </div> <!-- end #wrapperContent -->
342 </div> <!-- end #wrapper -->
1c588db @aquillano styling EventPage
aquillano authored
343
9af4d91 map on index queries all topics in database
Michael Shapiro authored
344 <%@ include file="jsp/footer.jsp" %>
Something went wrong with that request. Please try again.