PeriodicalUpdater expansion
Reported by crasy | August 17th, 2008 @ 02:37 PM
Hi
its my first ticket soo please excuse formerrors and my english, it is terrible.
i want to reset only! the timer from the PeriodicalUpdater whithout do a new request. over stop and start does a new request will be effected.
i think it is a good function to reset the timer for anyone, too.
my solution (quick and dirty):
var PU = new Ajax.PeriodicalUpdater('foo', 'bar.php', {
method: 'get', frequency: 10, decay: 1
});
clearTimeout(PU.timer);
PU.timer = PU.onTimerEvent.bind(PU).delay(PU.decay * PU.frequency);
but i think this is fast implementated in the prototype source for a clean and fast solution.
e.G. (untested):
Ajax.PeriodicalUpdater = Class.create(Ajax.Base, {
initialize: function($super, container, url, options) {
$super(options);
this.onComplete = this.options.onComplete;
this.frequency = (this.options.frequency || 2);
this.decay = (this.options.decay || 1);
this.updater = { };
this.container = container;
this.url = url;
this.start();
},
start: function() {
this.options.onComplete = this.updateComplete.bind(this);
this.onTimerEvent();
},
stop: function() {
this.updater.options.onComplete = undefined;
clearTimeout(this.timer);
(this.onComplete || Prototype.emptyFunction).apply(this, arguments);
},
resset: function() {
clearTimeout(this.timer);
this.timer = this.onTimerEvent.bind(this).delay(this.decay * this.frequency);
},
updateComplete: function(response) {
if (this.options.decay) {
this.decay = (response.responseText == this.lastText ?
this.decay * this.options.decay : 1);
this.lastText = response.responseText;
}
this.timer = this.onTimerEvent.bind(this).delay(this.decay * this.frequency);
},
onTimerEvent: function() {
this.updater = new Ajax.Updater(this.container, this.url, this.options);
}
});
greetz crasy aka. Kay Linzmeier
PS: thanks for your work, its a realy realy realy good framework.
Comments and changes to this ticket
-
Tobie Langel August 21st, 2008 @ 12:44 AM
- → Tag changed from ajax.updater to ajax ajax.updater needs_patch needs_tests
- → State changed from new to enhancement
-
-
John-David Dalton August 25th, 2008 @ 04:47 PM
- → State changed from invalid to duplicate
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
The Prototype JavaScript library.
