Permalink
Browse files

Added splash screen for autologin; fixed venue search; neabry veneus …

…autoload
  • Loading branch information...
1 parent 55a3665 commit 836ccd0f238c9250e033944c049b5918ebf022b5 @zhephree zhephree committed Nov 12, 2009
@@ -10,11 +10,17 @@ function MainAssistant(expressLogin,credentials) {
this.username=this.credentials.username;
this.password=this.credentials.password;
}
+
}
MainAssistant.prototype.setup = function() {
/* this function is for setup tasks that have to happen when the scene is first created */
if (this.expressLogin) {
+ $("loginfields").style.visibility="hidden";
+ $("main").removeClassName("palm-hasheader");
+ $("message").style.marginTop="70px";
+ $("main").style.background="url(SPLASH_boy_transparent.png) no-repeat left top";
+
this.login(this.username,this.password);
}
@@ -54,7 +60,7 @@ MainAssistant.prototype.login = function(uname, pass){
var url = "http://api.foursquare.com/v1/user.json";
auth = make_base_auth(uname, pass);
- $('message').innerHTML += '<br/>sending login request';
+ $('message').innerHTML = '<br/>Logging <b>'+uname+'</b> in to Foursquare...';
var request = new Ajax.Request(url, {
method: 'get',
@@ -69,7 +75,7 @@ var userData;
MainAssistant.prototype.loginRequestSuccess = function(response) {
userData = response.responseJSON.user;
- $('message').innerHTML += '<br/>' + response.responseJSON.user.checkin.display;
+ $('message').innerHTML = '<br/>' + response.responseJSON.user.checkin.display;
this.cookieData=new Mojo.Model.Cookie("credentials");
Mojo.Log.error('############################created cookie object.');
@@ -78,7 +84,7 @@ MainAssistant.prototype.loginRequestSuccess = function(response) {
password: this.password
});
Mojo.Log.error('###########saved cookie?');
- this.controller.stageController.swapScene('nearby-venues', auth, userData);
+ setTimeout(this.controller.stageController.swapScene('nearby-venues',auth,userData),3000);
}
MainAssistant.prototype.loginRequestFailed = function(response) {
@@ -9,12 +9,11 @@ function NearbyVenuesAssistant(a, ud) {
}
NearbyVenuesAssistant.prototype.setup = function() {
-
+ Mojo.Log.error("#####setting up nearby");
//Create the attributes for the textfield
this.textFieldAtt = {
hintText: 'Leave Blank to Search All Nearby',
textFieldName: 'name',
- modelProperty: 'originalValue',
multiline: false,
disabledProperty: 'disabled',
focus: true,
@@ -28,13 +27,13 @@ NearbyVenuesAssistant.prototype.setup = function() {
requiresEnterKey: false
};
//Create the model for the text field
- this.model = {
- originalValue : ''
+ this.textModel = {
+ value : ''
};
this.resultsModel = {items: [], listTitle: $L('Results')};
//Setup the textfield widget and observer
- this.controller.setupWidget('sendField', this.textFieldAtt, this.model);
+ this.controller.setupWidget('sendField', this.textFieldAtt, this.textModel);
// Set up the attributes & model for the List widget:
this.controller.setupWidget('results-venue-list',
@@ -67,8 +66,8 @@ NearbyVenuesAssistant.prototype.setup = function() {
items: [{ icon: "", command: "", label: " "},
{ icon: "", command: "", label: " "},
{ label: "Venues", width: 100 },
- { icon: '', command: '', label: " "},
- { icon: '', command: '', label: " "}]
+ { iconPath: 'map.png', command: 'venue-map', label: " "},
+ { iconPath: 'search.png', command: 'venue-search', label: " "}]
}]
});
@@ -90,9 +89,31 @@ NearbyVenuesAssistant.prototype.setup = function() {
toggleCmd: "do-Previous"
}]
});
+
+
+ this.controller.setupWidget("drawerId",
+ this.drawerAttributes = {
+ modelProperty: 'open',
+ unstyled: false
+ },
+ this.drawerModel = {
+ open: false
+ });
+
+
+ Mojo.Log.error("#########setup nearby");
+
}
+
+
+
+
+
+
+
+
NearbyVenuesAssistant.prototype.onGetNearbyVenues = function(event) {
@@ -130,12 +151,15 @@ NearbyVenuesAssistant.prototype.failedLocation = function(event) {
NearbyVenuesAssistant.prototype.getVenues = function(latitude, longitude) {
$('message').innerHTML += '<br/>Searching Venues...';
+ Mojo.Log.error("--------lat="+latitude+", long="+longitude);
- var query = this.model.originalValue;
+ var query = this.textModel.value;
+ $('message').innerHTML += "("+query+")";
+ //var query='';
var url = 'http://api.foursquare.com/v1/venues.json';
var request = new Ajax.Request(url, {
method: 'get',
- evalJSON: 'true',
+ evalJSON: 'force',
requestHeaders: {}, //Not doing a search with auth due to malformed JSON results from it
parameters: {geolat:latitude, geolong:longitude, r:.5, l:50, q:query},
onSuccess: this.nearbyVenueRequestSuccess.bind(this),
@@ -148,8 +172,10 @@ NearbyVenuesAssistant.prototype.nearbyVenueRequestSuccess = function(response) {
mybutton.mojo.deactivate();
//$('message').innerHTML = response.responseText;
+ Mojo.Log.error("----------------got venues");
$('message').innerHTML = '';
+
if (response.responseJSON == undefined) {
$('message').innerHTML = 'No Results Found';
}
@@ -158,7 +184,7 @@ NearbyVenuesAssistant.prototype.nearbyVenueRequestSuccess = function(response) {
//Got Results... JSON responses vary based on result set, so I'm doing my best to catch all circumstances
var venueList = [];
- if (response.responseJSON.venues.group != undefined) { //If there is only 1 result it falls into this structure
+ /*if (response.responseJSON.venues.group != undefined) { //If there is only 1 result it falls into this structure
$('message').innerHTML = response.responseJSON.venues.group;
venueList = [response.responseJSON.venues.group.venue];
} else { //Otherwise multiple results are stuffed into an array of arrays, so I go
@@ -170,10 +196,45 @@ NearbyVenuesAssistant.prototype.nearbyVenueRequestSuccess = function(response) {
}
}
+ }*/
+
+ if(response.responseJSON.venues[0] != undefined) {
+ $('message').innerHTML='venues[0] is not undefined';
+ if(response.responseJSON.venues[0].length > 0) {
+ for (var i = 0; i < response.responseJSON.venues[0].length; i++) {
+ venueList[i] = response.responseJSON.venues[0][i];
+ venueList[i].grouping = "Nearby Favorites";
+ }
+ }else{
+ venueList[0]=response.responseJSON.venues[0].venue;
+ venueList[0].grouping="Nearby Favorites";
+ }
+ }else if(response.responseJSON.venues.group != undefined){
+ $('message').innerHTML='group is not undefined';
+ Mojo.Log.error(response.responseText);
+ if(response.responseJSON.venues.group.length>1) {
+ for (var i = 0; i < response.responseJSON.venues.group.length; i++) {
+ venueList[i] = response.responseJSON.venues.group[i];
+ venueList[i].grouping = "Nearby";
+ }
+ }else{
+ venueList[0] = response.responseJSON.venues.group.venue;
+ venueList[0].grouping="Nearby";
+ }
}
+ if(response.responseJSON.venues.group == undefined) {
+ for (var i = venueList.length; i < response.responseJSON.venues[1].length; i++) {
+ venueList[i] = response.responseJSON.venues[1][i];
+ venueList[i].grouping = "Nearby";
+ }
+ }
+
+
+
+
//now set the result list to the list's model
- this.resultsModel.items = $A(venueList);
+ this.resultsModel.items =venueList;// $A(venueList);
this.controller.modelChanged(this.resultsModel);
}
}
@@ -238,11 +299,24 @@ NearbyVenuesAssistant.prototype.checkInFailed = function(response) {
$('message').innerHTML = 'Check In Failed: ' + repsonse.responseText;
}
+
+
+
+
+
+
+
+
+
+
NearbyVenuesAssistant.prototype.handleCommand = function(event) {
if (event.type === Mojo.Event.command) {
switch (event.command) {
- case "command":
- break;
+ case "venue-search":
+ Mojo.Log.error("===========venue search clicked");
+ $("drawerId").mojo.toggleState();
+ this.controller.modelChanged(this.drawerModel)
+ break;
}
}
}
@@ -251,6 +325,8 @@ NearbyVenuesAssistant.prototype.handleCommand = function(event) {
NearbyVenuesAssistant.prototype.activate = function(event) {
/* put in event handlers here that should only be in effect when this scene is active. For
example, key handlers that are observing the document */
+ this.onGetNearbyVenues();
+
}
@@ -1,3 +1,4 @@
-<div class='result row' x-mojo-tap-highlight='momentary'>
- <div class='search-title' style='padding-left:20px;'>#{name}</div>
+<div class='result row' x-mojo-tap-highlight='momentary' style="padding:0">
+ <div class="truncating-text capitalize">#{name}</div>
+ <div class='truncating-text palm-info-text capitalize' style='padding:0;padding-left:10px;padding-bottom: 7px;'>#{address}</div>
</div>
@@ -1,4 +1,5 @@
<div id="main" class="palm-hasheader">
+ <div id="loginfields">
<div id='header' class="palm-header">Foursquare</div>
<div class="palm-group">
<div class="palm-group-title" x-mojo-loc=''>Login</div>
@@ -18,5 +19,6 @@
</div>
</div>
<div x-mojo-element="Button" id="goLogin"></div>
+ </div>
<div id='message' style='padding:20px;'></div>
</div>
@@ -4,6 +4,7 @@
</div>
</div>-->
<div id="main" class="palm-hasheader centered">
+<div x-mojo-element="Drawer" id="drawerId" class="drawerClass" name="drawerName">
<div class="palm-group">
<div class="palm-group-title" x-mojo-loc=''>Search Venues</div>
<div class="palm-list">
@@ -18,6 +19,27 @@
</div>
<div id="go_button" x-mojo-element="Button"></div>
+
+
+
+</div>
+
+<!--
+<div class="palm-group">
+ <div class="palm-group-title" x-mojo-loc=''>Search Venues</div>
+ <div class="palm-list">
+ <div class="palm-row single">
+ <div class="palm-row-wrapper textfield-group" x-mojo-focus-highlight="true">
+ <div class="title">
+ <div id="sendField" x-mojo-element="TextField" ></div>
+ </div>
+ </div>
+ </div>
+ </div>
+</div>
+<div id="go_button" x-mojo-element="Button"></div>
+-->
+
<div id='message' style='padding: 0 20px;'></div>
<div class="palm-group" id='resultListBox' style='display:none;'>
@@ -8,3 +8,9 @@
margin:10px;
border:1px solid #999999;
}
+
+body {background-color: #fff !important;}
+
+#message {
+ width: 100%;
+}
View
0 README 100644 → 100755
No changes.

0 comments on commit 836ccd0

Please sign in to comment.