Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
initial commit
  • Loading branch information
triceam committed Oct 2, 2012
1 parent 6f0cd9b commit 5241daf
Show file tree
Hide file tree
Showing 550 changed files with 64,182 additions and 1 deletion.
9 changes: 9 additions & 0 deletions License.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
THIS SOFTWARE IS PROVIDED BY ANDREW M. TRICE 'AS IS' AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANDREW M. TRICE OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45 changes: 44 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,47 @@
Walkable-App
============

Walkable-App is an open source application that shows location based points of interest, based on your current location. Walkable is built as a multi-platform mobile application using PhoneGap.
Walkable Restaurants provides you with an easy way to find a bite to eat or refreshing drink anywhere in the US. Either select a type of cuisine, or enter a search phrase, and the Walkable Restaurants app will find destinations that are nearby.
Only destinations near your current location will be returned in your search result. If we are able to calculate travel times based upon walking and train schedules, then we will only return destinations within a 20-minute walk. If we are not able to calculate walk time, only destinations within 2.5 miles of your current location will be displayed.

Walking time calculations are only available for CA, FL, & NY. All other locations will display distance in miles. Additional states may be available in the future for walking/train transit times.
Data Services

All walking/travel time distance calculations are obtained through <a href="http://www.traveltimeapp.com/" target="_blank">Travel Time, by Igeolise</a>. This service calcualtes travel time between geographic locations based upon walking, driving, and mass transit systems.
<hr/>
All point-of-interest (POI) information is obtained through services provided by <a href="http://www.factual.com/" target="_blank">factual.com</a>. This application uses the <a href="http://www.factual.com/data-apis/places/restaurants" target="_blank">U.S. Restaurants</a> data set, which provides information for over 800,000 restaurants across the United States, including location, price ratings, cuisine, and more.


<h3>Attribution</h3>

The following creative commons assets were used in this application:
<ul style="margin: 8px; padding: 0px;">

<li><a href="http://commons.wikimedia.org/wiki/File:Roasted_coffee_beans.jpg" target="_blank">Roasted Coffee Beans - Wikimeda</a></li>
<li><a href="http://commons.wikimedia.org/wiki/File:Rotiniwithtomatosauce.jpg" target="_blank">Rotini With Tomato Sauce - Wikimeda</a></li>
<li><a href="http://commons.wikimedia.org/wiki/File:Kopfsalat_Setzlinge.JPG" target="_blank">Lettuce, from Wikimeda</a></li>
<li><a href="http://thenounproject.com/noun/magnifying-glass/#icon-No95" target="_blank">Magnifying Glass - The Noun Project</a></li>
<li><a href="http://thenounproject.com/noun/walking/#icon-No250" target="_blank">Walking - The Noun Project</a></li>
<li><a href="http://thenounproject.com/noun/star/#icon-No2889" target="_blank">Star - The Noun Project</a></li>
</ul>
<h3>Open Source</h3>

The Walkable Restaurants application source code is freely available and open source on GitHub. Application source code is intended to be used as a learning tool for building PhoneGap applications using backbone.js.
Additional open source libraries used in this app include:

<ul style="margin: 8px; padding: 0px;">

<li><a href="http://phonegap.com" target="_blank">PhoneGap</a></li>
<li><a href="http://twitter.github.com/bootstrap/" target="_blank">Twitter Bootstrap (UI)</a></li>
<li><a href="leaflet.cloudmade.com" target="_blank">Leaflet (Maps)</a></li>
<li><a href="http://backbonejs.org/" target="_blank">Backbone.js</a></li>
<li><a href="triceam.github.com/app-UI/" target="_blank">App-UI</a></li>
<li><a href="underscorejs.org" target="_blank">Underscore.js</a></li>
<li><a href="jquery.com" target="_blank">jQuery</a></li>
<li><a href="cubiq.org/iscroll" target="_blank">iScroll</a></li>

</ul>


The server-side portion of this application simply aggregates data from Factual and Travel Time, and is developed with <a href="nodejs.org" target="_blank">node.js</a>, using the <a href="http://expressjs.com/" target="_blank">expressjs</a> framework.
42 changes: 42 additions & 0 deletions client/www/app/TemplateManager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

var templates = {
loaded: 0,
requested: 0
};

var ___templatesLoadedCallback = undefined;

function loadTemplates(callback) {
___templatesLoadedCallback = callback;

//load Mousetache HTML templates
for (var key in templates) {
(function() {
var _key = key.toString();
if ( _key != "loaded" && _key != "requested" ){
templates.requested ++;

var templateLoaded = function( template ){
onTemplateLoaded( template, _key );
}

$.get( templates[ _key ], templateLoaded, "html" );
}
})();
}
}




function onTemplateLoaded(template, key) {

//alert( key + ": " + template);
templates[ key ] = template;
templates.loaded ++;

if ( templates.loaded == templates.requested ) {
___templatesLoadedCallback();
}
}

52 changes: 52 additions & 0 deletions client/www/app/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@

document.addEventListener("deviceready", onDeviceReady, false);

function onDeviceReady() {

console.log( "READY" );

window.GeoWatcher.watch();

loadTemplates( appTemplatesLoaded );
}

function appTemplatesLoaded() {
console.log( "VIEW TEMPLATES LOADED" );

$("body").empty();



var homeView = new HomeView();


//Setup the ViewNavigator
window.viewNavigator = new ViewNavigator( 'body' );
window.viewNavigator.pushView( homeView );

}

document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);

/*
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
document.addEventListener("backbutton", onBackKey, false);
}
function onBackKey( event ) {
if ( window.viewNavigator.history.length > 1 ){
event.preventDefault();
window.viewNavigator.popView();
return false;
}
navigator.app.exitApp();
}
*/
41 changes: 41 additions & 0 deletions client/www/app/model/SearchManager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

window.SearchManager = {

//apiUrl:"http://localhost:3000/api?",
apiUrl:"http://walkable.aws.af.cm/restaurants-api?",

search:function (searchString, successCallback, errorCallback) {
//console.log(searchString);
//https://maps.google.com/maps?q=San+Francisco,+CA&hl=en&ll=37.772089,-122.400945&spn=0.006852,0.013937&sll=37.6,-95.665&sspn=55.236004,114.169922&oq=san+fr&hnear=San+Francisco,+California&t=m&z=17
var searchURL = this.apiUrl + "q=" + encodeURIComponent(searchString) + "&ll=" + window.GeoWatcher.position.latitude + "," + window.GeoWatcher.position.longitude + "&d=" + new Date().getTime();
//var searchURL = this.apiUrl + "q=" + encodeURIComponent(searchString) + "&ll=37.772089,-122.400945&d=" + new Date().getTime();
//console.log(searchURL);

$.ajax({
url:searchURL,
success:function(result){
if ( successCallback ) {
successCallback( result );
}
},
error:function(error){
if ( errorCallback ){
errorCallback( error );
}
}
});

},

findPointById:function (id, collection) {
for (var x=0; x<collection.length; x++) {
var poi = collection[x];
if (poi.factual_id == id){
return poi;
}
}
return null;
}
}

//https://maps.google.com/maps?q=new+york+city&ll=40.714354,-74.005977&spn=0.008262,0.006362&hnear=New+York&gl=us&t=m&z=17
77 changes: 77 additions & 0 deletions client/www/app/util/GeoWatcher.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
window.GeoWatcher = {

position:null,
timestamp:null,

watch:function(){
var self = this;

this.onSuccess = function(event){
self.success(event);
}
this.onError = function(event){
self.error(event);
}

//console.log("watch");
this.watchID = navigator.geolocation.watchPosition(this.onSuccess, this.onError, { timeout: 30000 });
},

unwatch:function() {
//console.log("unwatch");
navigator.geolocation.clearWatch(this.watchID);
},

success:function(position) {
//console.log("success");
this.timestamp = new Date();
this.position = {
latitude: position.coords.latitude,
longitude: position.coords.longitude,
altitude: position.coords.altitude,
accuracy: position.coords.accuracy,
altitudeAccuracy: position.coords.altitudeAccuracy,
heading: position.coords.heading,
speed: position.coords.speed,
timestamp: position.timestamp
}

//console.log( this.position );
},

error:function(err) {
//console.log("error");
$(document).trigger("geoWatcherError");
},

isValidLocation: function() {
return this.position != undefined &&
!isNaN(this.position.latitude)&&
!isNaN(this.position.longitude);

}
}

/*
// onSuccess Callback
// This method accepts a `Position` object, which contains
// the current GPS coordinates
//
function onSuccess(position) {
var element = document.getElementById('geolocation');
element.innerHTML = 'Latitude: ' + position.coords.latitude + '<br />' +
'Longitude: ' + position.coords.longitude + '<br />' +
'<hr />' + element.innerHTML;
}
// onError Callback receives a PositionError object
//
function onError(error) {
alert('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
}
// Options: throw an error if no update is received every 30 seconds.
//
var watchID = navigator.geolocation.watchPosition(onSuccess, onError, { timeout: 30000 });
*/
8 changes: 8 additions & 0 deletions client/www/app/util/HTMLUtil.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
window.HTMLUtil = {
encode: function (value){
return $('<div/>').text(value).html();
},
decode: function(value){
return $('<div/>').html(value).text();
}
}
55 changes: 55 additions & 0 deletions client/www/app/util/NativeUtil.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
NativeUtil = {
getDirections: function( latitude, longitude ){

var url = 'http://maps.google.com/maps?daddr=' + latitude + ',' + longitude;
this.openExternalURL( url );
},

webSearch: function( string ){
this.openExternalURL( "http://www.google.com/#hl=en&output=search&sclient=psy-ab&q=" + string + "&oq=" + string + "&fp=1" );
},

openExternalURL: function ( url ) {
this.confirmLeaveApp( function( button ) {
if (button==2 || button == undefined) {
var android = navigator.userAgent.search( "Android" ) >= 0;

if (android) {
navigator.app.loadUrl( url );
}
else {
window.open( url, '_blank' );
}
}
});
},

confirmLeaveApp: function( callback ) {
if ( navigator.notification && navigator.notification.confirm ){
navigator.notification.confirm(
"You will leave the Walkable Restaurants App. Would you like to continue?",
callback,
'Confirm',
'No,Yes'
);
}
else {
callback();
}
},

touchSupported: function() {
return "ontouchstart" in window;
},

isTablet: function() {

var win = $(window);
var w = win.width();
var h = win.height();
var _w = Math.min( w,h );
var _h = Math.max( w,h );

return (_w > 640 && _h > 960 );
}
}
22 changes: 22 additions & 0 deletions client/www/app/util/POIUtil.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

window.POIUtil = {
getCalculatedColor: function(poi) {

var percent;
if ( poi.travel_time_seconds > 0 ) {
percent = poi.travel_time_seconds / 1200;
}
else {
percent = poi["$distance"] / 3200;
}

if ( percent >= 0.75) {
return "e87562";
}
else if (percent >= 0.4) {
return "e8da62";
}
else return "52bf27";

}
}
Loading

0 comments on commit 5241daf

Please sign in to comment.