Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 4 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Showing with 66 additions and 26 deletions.
  1. +17 −0 assets/www/css/style.css
  2. +49 −26 assets/www/js/main.js
View
17 assets/www/css/style.css
@@ -203,3 +203,20 @@
height: 26px !important;
margin-top: 2px;
}
+
+/* Page Loading Message */
+
+div.ui-loader {
+ background-image: -webkit-gradient(linear, left top, left bottom, from( #BEB6A3 /*{g-bar-background-start}*/), to( #8D8778 /*{g-bar-background-end}*/)); /* Saf4+, Chrome */
+ background-image: -webkit-linear-gradient(top, #BEB6A3 /*{g-bar-background-start}*/, #8D8778 /*{g-bar-background-end}*/); /* Chrome 10+, Saf5.1+ */
+ background-image: -moz-linear-gradient(top, #BEB6A3 /*{g-bar-background-start}*/, #8D8778 /*{g-bar-background-end}*/); /* FF3.6 */
+ background-image: -ms-linear-gradient(top, #BEB6A3 /*{g-bar-background-start}*/, #8D8778 /*{g-bar-background-end}*/); /* IE10 */
+ background-image: -o-linear-gradient(top, #BEB6A3 /*{g-bar-background-start}*/, #8D8778 /*{g-bar-background-end}*/); /* Opera 11.10+ */
+ background-image: linear-gradient(top, #BEB6A3 /*{g-bar-background-start}*/, #8D8778 /*{g-bar-background-end}*/);
+ border: 1px solid #FFF;
+ box-shadow: 0 0 2px #333;
+ -moz-box-shadow: 0 0 2px #333;
+ -webkit-box-shadow: 0 0 2px #333;
+ color: #FFF;
+ text-shadow: 0 1px 0 #333;
+}
View
75 assets/www/js/main.js
@@ -24,6 +24,7 @@ window.WUR = {
places: [],
markers: [],
server: "http://mpd-hotness.nfshost.com",
+ loading: false, // Whether or not a page is being loaded
map: null,
$map: null,
mappedPlaces: null // The number of places currently displayed on the map
@@ -67,7 +68,7 @@ WUR.submitRating = function() {
$.mobile.changePage($('#home'));
})
.fail(function() {
- alert('Error: Failed to submit rating');
+ alert('An error occurred while submitting your rating. Try again later.');
});
}
@@ -90,7 +91,7 @@ WUR.getRatings = function() {
}
})
.fail(function() {
- console.log('Error: Failed to retrieve destination ratings');
+ alert('An error occurred while retrieving destination ratings. Try again later.');
});
}
@@ -109,7 +110,7 @@ WUR.getPlaces = function(radius) {
})
.fail(function(results, status) {
if (status != google.maps.places.PlacesServiceStatus.ZERO_RESULTS) {
- console.log('Error: Failed to search Google Places');
+ alert('An error occurred while retrieving destination information. Try again later.');
}
});
}
@@ -125,11 +126,15 @@ WUR.refreshDetails = function(place) {
data: {
place_id: place.id
}
- }).done(function(detailResult) {
+ })
+ .done(function(detailResult) {
place.rating = detailResult.rating;
place.rating_count = detailResult.rating_count;
WUR.loadDetailPage(place);
- })
+ })
+ .fail(function() {
+ alert("An error occurred while retrieving your destination's details. Try again later.");
+ })
}
/**
@@ -150,44 +155,56 @@ WUR.updateGeolocation = function() {
WUR.currentLatLng = new google.maps.LatLng(lat, lon);
})
.fail(function() {
- console.log('Error: Failed to detect geolocation');
+ alert('An error occurred while trying to determine your location. Check your GPS settings and try again.');
});
}
+WUR.loadFailHandler = function() {
+ WUR.loading = false;
+ $.mobile.hidePageLoadingMsg();
+}
+
/**
* Refreshes the places menu on the rating page
* based on the user's current geolocation
*/
WUR.refreshPlacesMenu = function() {
+ WUR.loading = true;
var $placesMenu = $('#places-menu').selectmenu('disable');
WUR.updateGeolocation()
.done(function() {
WUR.getPlaces(WUR.nearbyRadius)
.done(function(places, status) {
+ WUR.loading = false;
if (status === google.maps.places.PlacesServiceStatus.OK) {
$placesMenu
.jqotesub(WUR.templates.menuOption, places)
.selectmenu('refresh')
.selectmenu('enable');
+ $.mobile.hidePageLoadingMsg();
}
else {
+ $.mobile.hidePageLoadingMsg();
alert("Hey, you're not in a bar! You should get out more often!");
}
- });
- });
+ })
+ .fail(WUR.loadFailHandler);
+ })
+ .fail(WUR.loadFailHandler);
}
/**
* Refreshes the list of hotspots on the hotspots page
*/
WUR.refreshHotspotList = function(refreshMapPage) {
+ WUR.loading = true;
WUR.updateGeolocation()
.done(function() {
// Query Google Places and WhereUR database simultaneously
$.when( WUR.getPlaces(WUR.searchRadius), WUR.getRatings() )
.done(function(placesResult, ratingsResult) {
-
+ WUR.loading = false;
var places = placesResult[0],
ratings = ratingsResult[0];
@@ -219,11 +236,15 @@ WUR.refreshHotspotList = function(refreshMapPage) {
WUR.places = places;
WUR.renderSortedHotspots('distance');
+ $.mobile.hidePageLoadingMsg();
+
if (refreshMapPage === true) {
WUR.loadMapPage(places);
}
- });
- });
+ })
+ .fail(WUR.loadFailHandler);
+ })
+ .fail(WUR.loadFailHandler);
}
/**
@@ -360,16 +381,6 @@ WUR.loadDetailPage = function(place) {
});
}
-WUR.clearRatings = function() {
- $.ajax({
- dataType: 'jsonp',
- url: WUR.server + "/clear_ratings.php"
- })
- .done(function() {
- WUR.refreshHotspotList();
- });
-}
-
/**
* Resizes the map on the map page to fill the viewport
*/
@@ -390,6 +401,7 @@ $(document)
// Disable jQuery Mobile page transitions
.bind('mobileinit', function(){
$.mobile.defaultPageTransition = 'none';
+ $.mobile.defaultDialogTransition = 'none';
})
.ready(function() {
@@ -406,6 +418,11 @@ $(document)
$('#rating')
.bind('pagebeforeshow', function() {
// Refresh the rating page every time it is shown
+ $(this).one('pageshow', function() {
+ if (WUR.loading) {
+ $.mobile.showPageLoadingMsg();
+ }
+ });
WUR.refreshPlacesMenu();
})
.bind('pageinit', function() {
@@ -430,20 +447,21 @@ $(document)
});
$('#refresh-list-button').click(function() {
+ $.mobile.showPageLoadingMsg();
WUR.refreshHotspotList();
});
- $('#clear-ratings-button').click(function() {
- WUR.clearRatings();
- });
-
$('#refresh-list-with-option-button').click(function() {
var radius = $('#radius').val();
WUR.searchRadius = (radius * 1609.344);
- WUR.refreshHotspotList();
});
$('#hotspots').bind('pagebeforeshow', function() {
+ $(this).one('pageshow', function() {
+ if (WUR.loading) {
+ $.mobile.showPageLoadingMsg();
+ }
+ });
WUR.refreshHotspotList();
});
@@ -464,12 +482,17 @@ $(document)
return;
}
else if (WUR.mappedPlaces.length === 1) {
+ $.mobile.showPageLoadingMsg();
WUR.updateGeolocation()
.done(function() {
WUR.loadMapPage(WUR.mappedPlaces);
+ })
+ .always(function() {
+ $.mobile.hidePageLoadingMsg();
});
}
else {
+ $.mobile.showPageLoadingMsg();
WUR.refreshHotspotList(true);
}
});

No commit comments for this range

Something went wrong with that request. Please try again.