Subversion Repositories DevTools

Rev

Rev 7162 | Blame | Compare with Previous | Last modification | View Log | RSS feed

//  Vix specific Javascript for jquery use
//  Dynamic header support. Dynamically updates the page header to indicate
//      State of the build daemons
//      User has been logged out
//      Other information ....
//

//  Function to update the dynamic header content
//  Reduce server load. Only update the page if its visible
function updateHeader()
{
    //console.log ("Dynamic header update:", document.visibilityState, document.hidden);
    if (document.visibilityState !== 'hidden') {
        el = $('#hdrError');
        $.get('_json_daemon.asp', {opr : 'dynaHead'},function(data){

            // Display Build Daemon Error message
            if(data.indefPause > 0){
                var hlpImg = "<img src='images/i_help.gif' width='12' height='12' hspace='2' align='absmiddle' border='0' >"
                el.html('<a href=admin_build_service.asp style="text-decoration:none"><span class="mmError blink" title="Click for details">Warning: All Build Daemons are Stopped'+hlpImg+'</span></a>');
            }else{
                el.empty();
            }

            // Insert server date-time
            $('#hdrDateTime').text(data.now);

            //  Indicate if the user is now logged out
            var ul =  $('#usrName');
            if ( ul.length ){
                if ( !data.loggedIn ) {
                    ul[0].style.textDecoration = 'line-through'; 
                } else {
                    ul[0].style.textDecoration='none';
                }
            }
            
        },'json');
    }
}

//  
//  Init the dynamic header content
$(document).ready(function () {
    //console.log ("Dynamic header loaded");
    //
    //  Setup a function to be called every 30 seconds
    var indefTimer = null;
    updateHeader();
    indefTimer = setInterval( updateHeader,30000 );

    // Function to blink Text. Use sparingly

    function blink_text() {
        $('.blink').fadeOut(500);
        $('.blink').fadeIn(500);
    }
    setInterval(blink_text, 1000);

});

//  Listen for visibility changes and force an update when the page is shown
$(document).on('visibilitychange', function() {
    if(document.visibilityState !== 'hidden') {
        updateHeader();
        //console.log ("Page is visible");
    }
});