Subversion Repositories DevTools

Rev

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

Rev Author Line No. Line
7063 dpurdie 1
//  Vix specific Javascript for jquery use
2
//  Dynamic header support. Dynamically updates the page header to indicate
3
//      State of the build daemons
4
//      User has been logged out
5
//      Other information ....
6
//
7
 
8
//  Function to update the dynamic header content
7212 dpurdie 9
//  Reduce server load. Only update the page if its visible
7063 dpurdie 10
function updateHeader()
11
{
7212 dpurdie 12
    //console.log ("Dynamic header update:", document.visibilityState, document.hidden);
13
    if (document.visibilityState !== 'hidden') {
14
        el = $('#hdrError');
15
        $.get('_json_daemon.asp', {opr : 'dynaHead'},function(data){
7063 dpurdie 16
 
7212 dpurdie 17
            // Display Build Daemon Error message
18
            if(data.indefPause > 0){
19
                var hlpImg = "<img src='images/i_help.gif' width='12' height='12' hspace='2' align='absmiddle' border='0' >"
20
                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>');
21
            }else{
22
                el.empty();
23
            }
7063 dpurdie 24
 
7212 dpurdie 25
            // Insert server date-time
26
            $('#hdrDateTime').text(data.now);
7064 dpurdie 27
 
7212 dpurdie 28
            //  Indicate if the user is now logged out
29
            var ul =  $('#usrName');
30
            if ( ul.length ){
31
                if ( !data.loggedIn ) {
32
                    ul[0].style.textDecoration = 'line-through'; 
33
                } else {
34
                    ul[0].style.textDecoration='none';
35
                }
7064 dpurdie 36
            }
7212 dpurdie 37
 
38
        },'json');
39
    }
7063 dpurdie 40
}
41
 
42
//  
43
//  Init the dynamic header content
44
$(document).ready(function () {
45
    //console.log ("Dynamic header loaded");
46
    //
47
    //  Setup a function to be called every 30 seconds
48
    var indefTimer = null;
49
    updateHeader();
50
    indefTimer = setInterval( updateHeader,30000 );
7065 dpurdie 51
 
52
    // Function to blink Text. Use sparingly
53
 
54
    function blink_text() {
55
        $('.blink').fadeOut(500);
56
        $('.blink').fadeIn(500);
57
    }
58
    setInterval(blink_text, 1000);
59
 
7063 dpurdie 60
});
61
 
7212 dpurdie 62
//  Listen for visibility changes and force an update when the page is shown
63
$(document).on('visibilitychange', function() {
64
    if(document.visibilityState !== 'hidden') {
65
        updateHeader();
66
        //console.log ("Page is visible");
67
    }
68
});
69