window.addEvent('domready', function() { /*****************************************************************/ /*****************************************************************/ /*****************************************************************/ var url = 'index.php?id=142'; // refresh every 55 seconds var timer = 55; // periodical and dummy variables for later use var periodical, dummy; var wnlog = $('wnlog_res'); /* ajax istance */ var ajax = new Ajax(url, { update: wnlog, method: 'get', onComplete: function() { // when complete, we remove the spinner wnlog.removeClass('ajax-loading'); /* Tips 1 */ var TipsWN = new Tips($$('.TipsWN'), { initialize:function(){ this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 500, wait: false}).set(0); }, onShow: function(toolTip) { this.fx.start(1); }, onHide: function(toolTip) { this.fx.start(0); }, className: 'wntt' }); }, onCancel: function() { // when we stop timed ajax while it's requesting // we forse to cancel the request, so here we // just remove the spinner wnlog.removeClass('ajax-loading'); } }); /* our refresh function: it sets a dummy to prevent caching of php and add the loader class */ var refresh = (function() { // dummy to prevent caching of php dummy = $time() + $random(0, 100); // requests of our php plus dummy as query ajax.request(dummy); }); // load events $clear(periodical); // the periodical starts here, the * 1000 is because milliseconds required periodical = refresh.periodical(timer * 1000, this); // this is the first only request, later on will be only the periodical and refresh // that do the request. If we don't do this way, we have to wait for XXX seconds before // the first request. ajax.request($time()); /*****************************************************************/ /*****************************************************************/ /*****************************************************************/ });