*/
var Horde_Twitter = Class.create({
inReplyTo: '',
- page: 1,
oldestId: null,
newestId: null,
* opts.content The main content area, where the tweets are placed.
* opts.endpoint The url endpoint for horde/servcies/twitter.php
* opts.inreplyto
+ * opts.refreshrate How often to refresh the stream
* opts.strings.inreplyto
* opts.strings.defaultText
* opts.strings.justnow
*/
initialize: function(opts) {
- this.opts = opts;
+ this.opts = Object.extend({
+ refreshrate: 300
+ }, opts);
+
$(this.opts.input).observe('focus', function() {this.clearInput()}.bind(this));
$(this.opts.input).observe('blur', function() {
if (!$(this.opts.input).value.length) {
new Ajax.Request(this.opts.endpoint, {
method: 'post',
parameters: params,
- onComplete: this._getOlderEntriesCallback.bind(this),
+ onSuccess: this._getOlderEntriesCallback.bind(this),
onFailure: function() {
$(this.opts.spinner).toggle();
}
new Ajax.Request(this.opts.endpoint, {
method: 'post',
parameters: params,
- onComplete: this._getNewEntriesCallback.bind(this),
+ onSuccess: this._getNewEntriesCallback.bind(this),
onFailure: function() {
$(this.opts.spinner).toggle();
}
if (!this.oldestId) {
this.oldestId = response.responseJSON.o;
}
+
+ new PeriodicalExecuter(function(pe) { this.getNewEntries(); pe.stop(); }.bind(this), this.opts.refreshrate );
},
/**
class Horde_Block_Horde_twitter_timeline extends Horde_Block
{
/**
- * Whether this block has changing content. We dissallow autoupdating for
- * sites not using OAuth since the per-hour limits are then based on IP
- * address.
+ * Whether this block has changing content. Set this to false since we
+ * handle the updates via AJAX on our own.
*
*/
- var $updateable = true;
+ var $updateable = false;
/**
*
'height' => array(
'name' => _("Height of map (width automatically adjusts to block)"),
'type' => 'int',
- 'default' => 250)
+ 'default' => 250),
+ 'refresh_rate' => array(
+ 'name' => _("Number of seconds to wait to refresh"),
+ 'type' => 'int',
+ 'default' => 300)
);
}
$inReplyToText = _("In reply to:");
$contentNode = 'twitter_body' . $instance;
$justNowText = _("Just now...");
+ $refresh = empty($this->_params['refresh_rate']) ? 300 : $this->_params['refresh_rate'];
/* Add the client javascript / initialize it */
Horde::addScriptFile('twitterclient.js');
content: 'twitter_body{$instance}',
endpoint: '{$endpoint}',
inreplyto: '{$inReplyToNode}',
+ refreshrate: {$refresh},
strings: { inreplyto: '{$inReplyToText}', defaultText: '{$defaultText}', justnow: '{$justNowText}' }
});
EOT;