ping updates trigger 'nav-update' custom event from <nav>

This commit is contained in:
Fabio Comuni 2011-06-16 12:04:27 +02:00
parent 63390aa800
commit ffee5dd69e

View file

@ -29,10 +29,33 @@
var langSelect = false; var langSelect = false;
var commentBusy = false; var commentBusy = false;
$(document).ready(function() { $(function() {
$.ajaxSetup({cache: false}); $.ajaxSetup({cache: false});
msie = $.browser.msie ; msie = $.browser.msie ;
/* nav update event */
$('nav').bind('nav-update', function(e,data){;
var net = $(data).find('net').text();
if(net == 0) { net = ''; $('#net-update').hide() } else { $('#net-update').show() }
$('#net-update').html(net);
var home = $(data).find('home').text();
if(home == 0) { home = ''; $('#home-update').hide() } else { $('#home-update').show() }
$('#home-update').html(home);
var mail = $(data).find('mail').text();
if(mail == 0) { mail = ''; $('#mail-update').hide() } else { $('#mail-update').show() }
$('#mail-update').html(mail);
var intro = $(data).find('intro').text();
var register = $(data).find('register').text();
if(intro == 0) { intro = ''; }
if(register != 0 && intro != '') { intro = intro+'/'+register; }
if(register != 0 && intro == '') { intro = '0/'+register; }
if (intro == '') { $('#notify-update').hide() } else { $('#notify-update').show() }
$('#notify-update').html(intro);
});
NavUpdate(); NavUpdate();
// Allow folks to stop the ajax page updates with the pause/break key // Allow folks to stop the ajax page updates with the pause/break key
$(document).keypress(function(event) { $(document).keypress(function(event) {
@ -90,23 +113,8 @@
if(! stopped) { if(! stopped) {
$.get("ping",function(data) { $.get("ping",function(data) {
$(data).find('result').each(function() { $(data).find('result').each(function() {
var net = $(this).find('net').text(); // send nav-update event
if(net == 0) { net = ''; $('#net-update').hide() } else { $('#net-update').show() } $('nav').trigger('nav-update', this);
$('#net-update').html(net);
var home = $(this).find('home').text();
if(home == 0) { home = ''; $('#home-update').hide() } else { $('#home-update').show() }
$('#home-update').html(home);
var mail = $(this).find('mail').text();
if(mail == 0) { mail = ''; $('#mail-update').hide() } else { $('#mail-update').show() }
$('#mail-update').html(mail);
var intro = $(this).find('intro').text();
var register = $(this).find('register').text();
if(intro == 0) { intro = ''; }
if(register != 0 && intro != '') { intro = intro+'/'+register; }
if(register != 0 && intro == '') { intro = '0/'+register; }
if (intro == '') { $('#notify-update').hide() } else { $('#notify-update').show() }
$('#notify-update').html(intro);
}); });
}) ; }) ;
} }