Skip to content

Commit

Permalink
- attempts to detect internet connection and avoid making main timeli…
Browse files Browse the repository at this point in the history
…ne request if none exists

- screwing around with Audio playback and basically not getting anywhere
- added simple showBanner() helper to scene.js
- changed displayErrorInfo() in scene.js to just return text, because changes in how alert popups animate in now seem to screw it up
- removed a couple unneeded .html templates
- changed UI for detail actions to use a palm-group
- changed user detail timeline to use a disclosure element
- changed start scene to use palm group for main buttons
  • Loading branch information
funkatron committed Jul 6, 2009
1 parent 9bb7265 commit 82f1288
Show file tree
Hide file tree
Showing 11 changed files with 250 additions and 210 deletions.
40 changes: 33 additions & 7 deletions app/assistants/my-timeline-assistant.js
Expand Up @@ -375,9 +375,36 @@ MyTimelineAssistant.prototype.getEntryElementByStatusId = function(id) {


MyTimelineAssistant.prototype.getData = function() {

var thisA = this;

sch.markAllAsRead('#my-timeline div.timeline-entry');
this.showInlineSpinner('activity-spinner-my-timeline', 'Looking for new tweets…');

function getCombinedTimeline(statusobj) {

dump(statusobj);

if ( statusobj.isInternetConnectionAvailable === true) {
thisA._getData.call(thisA);
} else {
thisA.showBanner('Not connected to Internet');
}

}

if ( Mojo.Host.current === Mojo.Host.browser ) {
this._getData();
}
/*
only get data if we're connected
*/
this.checkInternetStatus( getCombinedTimeline );
};

MyTimelineAssistant.prototype._getData = function() {

this.showInlineSpinner('activity-spinner-my-timeline', 'Looking for new tweets…');

/*
friends_count is the only one that gets used currently
*/
Expand Down Expand Up @@ -564,13 +591,12 @@ MyTimelineAssistant.prototype.renderTweets = function(tweets, render_callback, f

var new_count = jQuery('#my-timeline div.timeline-entry.new:visible').length;

// alert("new_count:"+new_count);
// alert("fullscreen"+this.isFullScreen);

if (!from_cache && new_count > 0) {
this.playAudioCue('newmsg');
}

if (!from_cache && new_count > 0 && !this.isFullScreen) {
// if (!from_cache && new_count > 0) {
this.newMsgBanner(new_count);
this.playAudioCue('newmsg');
} else if (this.isFullScreen) {
dump("I am not showing a banner! in "+this.controller.sceneElement.id);
}
Expand All @@ -586,7 +612,7 @@ MyTimelineAssistant.prototype.renderTweets = function(tweets, render_callback, f
this.hideInlineSpinner('activity-spinner-my-timeline');
this.saveTimelineCache();
} else {
// this.clearInlineSpinner('activity-spinner-my-timeline');
this.hideInlineSpinner('activity-spinner-my-timeline');
jQuery().trigger('load_from_mytimeline_cache_done');
}

Expand Down
1 change: 1 addition & 0 deletions app/assistants/start-assistant.js
Expand Up @@ -60,6 +60,7 @@ StartAssistant.prototype.setup = function() {

this.initAppMenu();


Mojo.Event.listen($('start-login-button'), Mojo.Event.tap, this.showLogin.bind(this));
Mojo.Event.listen($('start-search-button'), Mojo.Event.tap, this.showSearch.bind(this));
}
Expand Down
3 changes: 2 additions & 1 deletion app/assistants/user-detail-assistant.js
Expand Up @@ -148,8 +148,9 @@ UserDetailAssistant.prototype.activate = function(event) {

var thisA = this; // for closures

jQuery('#user-detail-actions #view-user-posts', this.scroller).live(Mojo.Event.tap, function(e) {
jQuery('#user-timeline-trigger', this.scroller).live(Mojo.Event.tap, function(e) {
dump(jQuery(this).attr('id'));
jQuery(this).find('.arrow_button').toggleClass('palm-arrow-closed').toggleClass('palm-arrow-expanded')
jQuery('#user-timeline').slideToggle('500');
});
jQuery('#user-detail-actions #search-user', this.scroller).live(Mojo.Event.tap, function(e) {
Expand Down
144 changes: 80 additions & 64 deletions app/helpers/scene.js
Expand Up @@ -533,6 +533,23 @@ scene_helpers.addCommonSceneMethods = function(assistant) {
}



assistant.showBanner = function(text, category) {

var category = category || 'misc';

var launchArgs = {
'fromstage':this.getStageName()
};
var bannerArgs = {
'messageText':text,
'soundClass':'alerts'
};

var appController = Mojo.Controller.getAppController();
appController.showBanner(bannerArgs, launchArgs, category);
}



assistant.newMsgBanner = function(count) {
Expand Down Expand Up @@ -608,19 +625,21 @@ scene_helpers.addCommonSceneMethods = function(assistant) {

var makeCue = function(clip) {
var cue = new Audio();
if (cue.palm) {
cue.mojo.audioClass = "media";
}
cue.src = clip;
cue.autoplay = false;

return cue;
};

this.audioCues = {
'newmsg': makeCue('sounds/New.mp3'),
'send': makeCue('sounds/CSnd.mp3'),
'receive': makeCue('sounds/CRcv.mp3'),
'startup': makeCue('sounds/On.mp3'),
'shutdown':makeCue('sounds/Off.mp3'),
'wilhelm': makeCue('sounds/wilhelm.mp3')
'newmsg': makeCue(Mojo.appPath + 'sounds/New.mp3'),
'send': makeCue(Mojo.appPath + 'sounds/CSnd.mp3'),
'receive': makeCue(Mojo.appPath + 'sounds/CRcv.mp3'),
'startup': makeCue(Mojo.appPath + 'sounds/On.mp3'),
'shutdown':makeCue(Mojo.appPath + 'sounds/Off.mp3'),
'wilhelm': makeCue(Mojo.appPath + 'sounds/wilhelm.mp3')
};


Expand All @@ -629,36 +648,44 @@ scene_helpers.addCommonSceneMethods = function(assistant) {


assistant.playAudioCue = function(clip) {


dump('trying to play '+clip);

if (!this.audioCues) {
this._initSound();
};

switch(clip) {
case 'newmsg':
this.audioCues.newmsg.play();
break;

case 'send':
this.audioCues.send.play();
break;

case 'receive':
this.audioCues.receive.play();
break;

case 'startup':
this.audioCues.startup.play();
break;

case 'shutdown':
this.audioCues.shutdown.play();
break;
try {
this.audioCues[clip].play();
} catch (err) {
this.showDialogBox('error', err);
}

case 'wilhelm':
this.audioCues.wilhelm.play();
break;
};
// switch(clip) {
// case 'newmsg':
// this.audioCues.newmsg.play();
// break;
//
// case 'send':
// this.audioCues.send.play();
// break;
//
// case 'receive':
// this.audioCues.receive.play();
// break;
//
// case 'startup':
// this.audioCues.startup.play();
// break;
//
// case 'shutdown':
// this.audioCues.shutdown.play();
// break;
//
// case 'wilhelm':
// this.audioCues.wilhelm.play();
// break;
// };
};


Expand Down Expand Up @@ -752,6 +779,20 @@ scene_helpers.addCommonSceneMethods = function(assistant) {
};



assistant.checkInternetStatus = function(on_success, on_failure) {
this.controller.serviceRequest('palm://com.palm.connectionmanager', {
method: 'getstatus',
parameters: {},
onSuccess: on_success,
onFailure: on_failure
});
};





assistant.displayErrorInfo = function(msg, errors, template) {

var error_info;
Expand All @@ -767,7 +808,7 @@ scene_helpers.addCommonSceneMethods = function(assistant) {
dump(errors);

if (!template) {
template = 'error_info';
template = 'error_info_text';
}


Expand All @@ -781,43 +822,18 @@ scene_helpers.addCommonSceneMethods = function(assistant) {
}
}

/*
We want to be able to pass html into the error dialogs, but escaping is on,
so we do a little dynamic workaround
*/
var dialog_widget = Mojo.Controller.errorDialog(msg+' {{error_html}}');
dialog_widget.innerHTML = dialog_widget.innerHTML.replace('{{error_html}}', error_html);
// /*
// We want to be able to pass html into the error dialogs, but escaping is on,
// so we do a little dynamic workaround
// */
// var dialog_widget = Mojo.Controller.errorDialog(msg+' {{error_html}}');
// dialog_widget.innerHTML = dialog_widget.innerHTML.replace('{{error_html}}', error_html);

}


assistant.clearTimelineCache = function(callback) {
var thisA = this;

// Mojo.Log.info('Timeline Caching disabled for now');

/*
by setting "replace" to true, we wipe the cache depot completely
*/

this.cacheDepot = makeCacheDepot(true);

// var users = sc.app.prefs.get('users');
//
// for (var i=0; i<users.length; i++) {
// var id = users[i].id;
// cacheDepot.simpleAdd(id, {},
// function() {
// // thisA.showAlert('Cache cleared');
// dump('Cache '+username+' cleared');
// },
// function() {
// // Mojo.Controller.errorDialog('Cache clearing FAILED');
// dump('Cache '+username+' clear failed');
// }
// );
// }

}


Expand Down
1 change: 1 addition & 0 deletions app/helpers/spaz.js
Expand Up @@ -36,6 +36,7 @@ var findAndSwapScene = function(targetScene, returnValue) {
};



/**
* converts various items in a timeline entry's text into clickables
* @param {string} str
Expand Down
29 changes: 0 additions & 29 deletions app/views/message-detail/message-detail.html

This file was deleted.

24 changes: 16 additions & 8 deletions app/views/start/start-scene.html
Expand Up @@ -2,16 +2,24 @@
<div id="start-scene" class="palm-dark" style="display:none">

<div id="start-section" style="text-align:center">
<div>
<div><img src="images/spaz-icon-alpha_256.png" width="256" height="245" alt="Spaz Icon Alpha 256"></div>
<div>Welcome to Spaz <spaz id="app-version"></spaz></div>
</div>
<div><img src="images/spaz-icon-alpha_256.png" width="256" height="245" alt="Spaz Icon Alpha 256"></div>

<button class="palm-button" id="start-login-button">Log-in to your account</button>
<button class="palm-button" id="start-search-button">Search &amp; explore Twitter</button>
<div class="palm-group palm-group-spaz">
<div class="palm-group-title" x-mojo-loc=''>Welcome to Spaz <spaz id="app-version"></spaz></div>
<div class="palm-list">
<div class="palm-row single">
<button class="palm-button" id="start-login-button">Log-in to your account</button>
</div>
<div class="palm-row single">
<button class="palm-button" id="start-search-button">Search &amp; explore Twitter</button>
</div>
</div>
</div>

<div id="start-smallprint">&copy; 2009 <a href="http://funkatron.com" class="clickable">Funkatron Productions</a><br/>
Powered by <a href="http://github.com/funkatron/spazcore" class="clickable">SpazCore</a></div>
<div id="start-smallprint">
&copy; 2009 <a href="http://funkatron.com" class="clickable">Funkatron Productions</a><br/>
Powered by <a href="http://github.com/funkatron/spazcore" class="clickable">SpazCore</a>
</div>

</div> <!-- start-section end -->

Expand Down

0 comments on commit 82f1288

Please sign in to comment.