Skip to content

Commit

Permalink
Updating code
Browse files Browse the repository at this point in the history
  • Loading branch information
zhephree committed Dec 16, 2011
1 parent aedb04e commit 51d50cc
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 125 deletions.
18 changes: 12 additions & 6 deletions Foursquare/app/assistants/explore-assistant.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ ExploreAssistant.prototype.handleRadio = function(event){

ExploreAssistant.prototype.trendingSuccess = function(r) {
var j=r.responseJSON.response;
logthis("trending loaded");

var varray=j.venues;
varray.sort(function(a, b){return (a.location.distance - b.location.distance);});
Expand Down Expand Up @@ -258,18 +259,23 @@ ExploreAssistant.prototype.trendingSuccess = function(r) {

logthis("4");


if(tmp_venue.todos.count>0){
tmp_venue.dogear="block";
if(tmp_venue.todos){
if(tmp_venue.todos.count>0){
tmp_venue.dogear="block";
}else{
tmp_venue.dogear="none";
}
}else{
tmp_venue.dogear="none";
}

logthis("5");

if(tmp_venue.specials!=undefined){
if(tmp_venue.specials.length>0){
tmp_venue.specialimage='<img src="images/small-special.png" class="small-special">';
if(tmp_venue.specials){
if(tmp_venue.specials!=undefined){
if(tmp_venue.specials.length>0){
tmp_venue.specialimage='<img src="images/small-special.png" class="small-special">';
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion Foursquare/app/assistants/oauth-assistant.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ OauthAssistant.prototype.titleChanged = function(event) {
event.preventDefault();
var callbackUrl=event.url;
var responseVars=callbackUrl.split("#access_token=");
if(responseVars[0] == "http://zhephree.com/foursquare/callback" || responseVars[0] == "http://zhephree.com/foursquare/callback/"){
if(responseVars[0] == "http://zhephree.com/foursquare/callback" || responseVars[0] == "http://zhephree.com/foursquare/callback/" || responseVars[0] == "http://zhephree.com/foursquare/callback.php" || responseVars[0] == "http://zhephree.com/foursquare/callback.php/"){
logthis("token="+responseVars[1]);
this.cookieData=new Mojo.Model.Cookie("oauth");
this.cookieData.put({
Expand Down
240 changes: 123 additions & 117 deletions Foursquare/app/assistants/venuedetail-assistant.js
Original file line number Diff line number Diff line change
Expand Up @@ -780,118 +780,56 @@ logthis("done mayor");
var showbutton=false;
var specialWidth=0;
this.controller.get('special_content').innerHTML='';

if(j.venue.specials.length>0){ //specials here
var nearbyShown=false;
this.nearbys=[];
var lastHereSpecial=0;
specialWidth=j.venue.specials.length*300;
this.controller.get("special_content").style.width=(specialWidth)+"px";
if(j.venue.specials.length+j.venue.specialsNearby.length>1){
this.controller.get("triangle-right").show();
}
for(var b = 0; b < j.venue.specials.length;b++) {
var special_type=j.venue.specials[b].type;
var special_msg=j.venue.specials[b].message;
var special_description=j.venue.specials[b].description;
var special_unlocked=(j.venue.specials[b].unlocked)? j.venue.specials[b].unlocked: false;
var unlock_msg="";
switch(special_type) { //can be 'mayor','count','frequency','other' we're just gonna lump non-mayor specials into one category
case "mayor":
var spt="<img src=\"images/smallcrown.png\" width=\"22\" height=\"22\" /> Mayor Special";
break;
default:
var spt="<img src=\"images/starburst.png\" width=\"22\" height=\"22\" /> Foursquare Special";
break;
}
if(special_unlocked){
unlock_msg='<div class="special-unlocked">You\'ve unlocked this special!</div>';
}else{
unlock_msg='<div class="special-locked">You have not unlocked this special.</div>';
}


var special_venue="";

if(j.venue.specials[b].id!=lastHereSpecial){
this.controller.get('special_content').innerHTML = '<div class="special-wrapper"><div class="checkin-special-title" x-mojo-loc="">'+spt+'</div><div class=""><div class="">'+special_msg+'<div class="checkin-venue">'+special_venue+'</div><div class="checkin-venue">'+unlock_msg+'</div></div></div></div>'+this.controller.get('special_content').innerHTML;

lastHereSpecial=j.venue.specials[b].id;
}


//spt="Mayor Special";
//special_msg="There's a special text thing here. There's a special text thing here. There's a special text thing here. ";
//special_venue="@ Venue Name (123 Venue St.)";
}//end of for
//this.controller.get('special_content').innerHTML+='<br class="breaker">';
this.controller.get("nearby-special").addClassName("here-button");
showbutton=true;
this.controller.get("nearbySpecials").hide();
this.controller.get("nearby-special").show();
Mojo.Event.listen(this.controller.get("nearby-special"),Mojo.Event.tap,function(){
this.controller.get("special_overlay").toggle();
}.bind(this));
Mojo.Animation.animateStyle(this.controller.get("nearby-special"),"top","linear",{from: -53, to: 0, duration: 1});
nearbyShown=true;
if(!j.venue.specialsNearby){
j.venue.specialsNearby=[];
}

logthis("**************finished with specials here");
logthis(this.controller.get('special_content').innerHTML);

if(j.venue.specialsNearby.length>0){ //specials nearby
logthis("has enarby specials");
this.nearbys=[];
var lastNearbySpecial=0;
logthis("specials1");
this.controller.get("special_content").style.width=((j.venue.specialsNearby.length*300)+specialWidth)+"px";
logthis("specials2");
if(j.venue.specialsNearby.length+j.venue.specials.length>1){
this.controller.get("triangle-right").show();
}
logthis("specials3");
for(var b = 0; b < j.venue.specialsNearby.length;b++) {
logthis("specials4");
var special_type=j.venue.specialsNearby[b].type;
var special_msg=j.venue.specialsNearby[b].message;
var special_description=j.venue.specialsNearby[b].description;
var special_unlocked=(j.venue.specialsNearby[b].unlocked)? j.venue.specialsNearby[b].unlocked: false;
var unlock_msg="";
logthis("specials5");
switch(special_type) { //can be 'mayor','count','frequency','other' we're just gonna lump non-mayor specials into one category
case "mayor":
var spt="<img src=\"images/smallcrown.png\" width=\"22\" height=\"22\" /> Mayor Special";
break;
default:
var spt="<img src=\"images/starburst.png\" width=\"22\" height=\"22\" /> Foursquare Special";
break;
}
spt=spt+" Nearby";
logthis("specials6");
if(special_unlocked){
unlock_msg='<div class="special-unlocked">You\'ve unlocked this special!</div>';
}else{
unlock_msg='<div class="special-locked">You have not unlocked this special.</div>';
}

logthis("specials7");

var special_venue="@ "+j.venue.specialsNearby[b].venue.name;
if(j.venue.specialsNearby[b].id!=lastNearbySpecial){
this.controller.get('special_content').innerHTML += '<div class="special-wrapper" id="special'+j.venue.specialsNearby[b].id+'"><div class="checkin-special-title" x-mojo-loc="">'+spt+'</div><div class=""><div class="">'+special_msg+'<div class="checkin-venue">'+special_venue+'</div><div class="checkin-venue">'+unlock_msg+'</div></div></div></div>';//+this.controller.get('special_content').innerHTML;

lastNearbySpecial=j.venue.specialsNearby[b].id;
}

logthis("specials8");

//spt="Mayor Special";
//special_msg="There's a special text thing here. There's a special text thing here. There's a special text thing here. ";
//special_venue="@ Venue Name (123 Venue St.)";
}//end of for
logthis("specials9");
if(!nearbyShown){
this.controller.get("nearby-special").addClassName("nearby-button2");
if(j.venue.specials){
if(j.venue.specials.length>0){ //specials here
var nearbyShown=false;
this.nearbys=[];
var lastHereSpecial=0;
specialWidth=j.venue.specials.length*300;
this.controller.get("special_content").style.width=(specialWidth)+"px";
if(j.venue.specials.length+j.venue.specialsNearby.length>1){
this.controller.get("triangle-right").show();
}
for(var b = 0; b < j.venue.specials.length;b++) {
var special_type=j.venue.specials[b].type;
var special_msg=j.venue.specials[b].message;
var special_description=j.venue.specials[b].description;
var special_unlocked=(j.venue.specials[b].unlocked)? j.venue.specials[b].unlocked: false;
var unlock_msg="";
switch(special_type) { //can be 'mayor','count','frequency','other' we're just gonna lump non-mayor specials into one category
case "mayor":
var spt="<img src=\"images/smallcrown.png\" width=\"22\" height=\"22\" /> Mayor Special";
break;
default:
var spt="<img src=\"images/starburst.png\" width=\"22\" height=\"22\" /> Foursquare Special";
break;
}
if(special_unlocked){
unlock_msg='<div class="special-unlocked">You\'ve unlocked this special!</div>';
}else{
unlock_msg='<div class="special-locked">You have not unlocked this special.</div>';
}


var special_venue="";

if(j.venue.specials[b].id!=lastHereSpecial){
this.controller.get('special_content').innerHTML = '<div class="special-wrapper"><div class="checkin-special-title" x-mojo-loc="">'+spt+'</div><div class=""><div class="">'+special_msg+'<div class="checkin-venue">'+special_venue+'</div><div class="checkin-venue">'+unlock_msg+'</div></div></div></div>'+this.controller.get('special_content').innerHTML;

lastHereSpecial=j.venue.specials[b].id;
}


//spt="Mayor Special";
//special_msg="There's a special text thing here. There's a special text thing here. There's a special text thing here. ";
//special_venue="@ Venue Name (123 Venue St.)";
}//end of for
//this.controller.get('special_content').innerHTML+='<br class="breaker">';
this.controller.get("nearby-special").addClassName("here-button");
showbutton=true;
this.controller.get("nearbySpecials").hide();
this.controller.get("nearby-special").show();
Expand All @@ -901,14 +839,82 @@ logthis("done mayor");
Mojo.Animation.animateStyle(this.controller.get("nearby-special"),"top","linear",{from: -53, to: 0, duration: 1});
nearbyShown=true;
}
logthis("specials10");
for(var g=0;g<j.venue.specialsNearby.length;g++){
Mojo.Event.listen(this.controller.get('special'+j.venue.specialsNearby[g].id),Mojo.Event.tap,function(e,g){
this.controller.stageController.pushScene({name: "venuedetail", transition: Mojo.Transition.zoomFade},j.venue.specialsNearby[g].venue,_globals.username,_globals.password,_globals.uid,false,undefined,undefined,this,false,true);
}.bindAsEventListener(this,g));
}

}
logthis("**************finished with specials here");
logthis(this.controller.get('special_content').innerHTML);

if(j.venue.specialsNearby){
if(j.venue.specialsNearby.length>0){ //specials nearby
logthis("has enarby specials");
this.nearbys=[];
var lastNearbySpecial=0;
logthis("specials1");
this.controller.get("special_content").style.width=((j.venue.specialsNearby.length*300)+specialWidth)+"px";
logthis("specials2");
if(j.venue.specialsNearby.length+j.venue.specials.length>1){
this.controller.get("triangle-right").show();
}
logthis("specials3");
for(var b = 0; b < j.venue.specialsNearby.length;b++) {
logthis("specials4");
var special_type=j.venue.specialsNearby[b].type;
var special_msg=j.venue.specialsNearby[b].message;
var special_description=j.venue.specialsNearby[b].description;
var special_unlocked=(j.venue.specialsNearby[b].unlocked)? j.venue.specialsNearby[b].unlocked: false;
var unlock_msg="";
logthis("specials5");
switch(special_type) { //can be 'mayor','count','frequency','other' we're just gonna lump non-mayor specials into one category
case "mayor":
var spt="<img src=\"images/smallcrown.png\" width=\"22\" height=\"22\" /> Mayor Special";
break;
default:
var spt="<img src=\"images/starburst.png\" width=\"22\" height=\"22\" /> Foursquare Special";
break;
}
spt=spt+" Nearby";
logthis("specials6");
if(special_unlocked){
unlock_msg='<div class="special-unlocked">You\'ve unlocked this special!</div>';
}else{
unlock_msg='<div class="special-locked">You have not unlocked this special.</div>';
}

logthis("specials7");

var special_venue="@ "+j.venue.specialsNearby[b].venue.name;
if(j.venue.specialsNearby[b].id!=lastNearbySpecial){
this.controller.get('special_content').innerHTML += '<div class="special-wrapper" id="special'+j.venue.specialsNearby[b].id+'"><div class="checkin-special-title" x-mojo-loc="">'+spt+'</div><div class=""><div class="">'+special_msg+'<div class="checkin-venue">'+special_venue+'</div><div class="checkin-venue">'+unlock_msg+'</div></div></div></div>';//+this.controller.get('special_content').innerHTML;

lastNearbySpecial=j.venue.specialsNearby[b].id;
}

logthis("specials8");

//spt="Mayor Special";
//special_msg="There's a special text thing here. There's a special text thing here. There's a special text thing here. ";
//special_venue="@ Venue Name (123 Venue St.)";
}//end of for
logthis("specials9");
if(!nearbyShown){
this.controller.get("nearby-special").addClassName("nearby-button2");
showbutton=true;
this.controller.get("nearbySpecials").hide();
this.controller.get("nearby-special").show();
Mojo.Event.listen(this.controller.get("nearby-special"),Mojo.Event.tap,function(){
this.controller.get("special_overlay").toggle();
}.bind(this));
Mojo.Animation.animateStyle(this.controller.get("nearby-special"),"top","linear",{from: -53, to: 0, duration: 1});
nearbyShown=true;
}
logthis("specials10");
for(var g=0;g<j.venue.specialsNearby.length;g++){
Mojo.Event.listen(this.controller.get('special'+j.venue.specialsNearby[g].id),Mojo.Event.tap,function(e,g){
this.controller.stageController.pushScene({name: "venuedetail", transition: Mojo.Transition.zoomFade},j.venue.specialsNearby[g].venue,_globals.username,_globals.password,_globals.uid,false,undefined,undefined,this,false,true);
}.bindAsEventListener(this,g));
}


}
}
logthis("**************finished with specials nearby");
logthis(this.controller.get('special_content').innerHTML);
Expand Down
2 changes: 2 additions & 0 deletions Foursquare/app/lib/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ _globals.whatsnew={
"id":"whatsnew",
"icon":"",
"pages":[
"Here's what's new in foursquare webOS <b>v2.8.4</b>! Follow me on Twitter: <a href=\"http://mobile.twitter.com/zhephree\">@zhephree</a><ul><li>Sorry for the bugs lately. Something changed in foursquare's API that I didn't account for. I take the blame here. Enjoy this update. Hopefully the next update will be to bring NEW features and not fix existing ones<li>Fixed a bug preventing Venues with a special from loading</li><li>Fixed a bug that prevented list of Trending Places from displaying in Explore tab</li></ul>",
"Here's what's new in foursquare webOS <b>v2.8.3</b>! Follow me on Twitter: <a href=\"http://mobile.twitter.com/zhephree\">@zhephree</a><ul><li>Fixed a bug preventing Venues from loading</li><li>Adapted to Pre 3 resolution</li></ul>",
"Here's what's new in foursquare webOS <b>v2.8.2</b>! Follow me on Twitter: <a href=\"http://mobile.twitter.com/zhephree\">@zhephree</a><ul><li>Fixed a bug preventing Preferences from loading</li><li>Fixed a bug that prevented you from adding new venues</li></ul>",
"Here's what's new in foursquare webOS <b>v2.8.0</b>! Follow me on Twitter: <a href=\"http://mobile.twitter.com/zhephree\">@zhephree</a><ul><li>Fixed a bug that prevented user's mayorships from being seen</li><li>Now compatible with the TouchPad!</li></ul>",
"Here's what's new in foursquare webOS <b>v2.7.7</b>! Follow me on Twitter: <a href=\"http://mobile.twitter.com/zhephree\">@zhephree</a><ul><li>Added Spaz as a Twitter client option</li><li>Fixed a bug preventing venues from displaying; now sorted by your likely selection; not by distance or grouped (Foursquare API Change)</li><li>Fixed a bug where 'undefined' was displayed as the venue address</li></ul>",
Expand Down
2 changes: 1 addition & 1 deletion Foursquare/appinfo.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "com.foursquare.foursquare",
"version": "2.8.2",
"version": "2.8.4",
"vendor": "foursquare",
"noWindow" : "true",
"timingEnabled": "true",
Expand Down
1 change: 1 addition & 0 deletions Foursquare/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>4Square Check In</title>
<meta name="viewport" content="height=device-height" />
<script src="/usr/palm/frameworks/mojo/mojo.js" type="text/javascript" x-mojo-version="1" />
<script src="base64.js" type="text/javascript"/>
<script src="oauth.js" type="text/javascript"/>
Expand Down

0 comments on commit 51d50cc

Please sign in to comment.