summaryrefslogtreecommitdiffstats
path: root/funcweb/funcweb/static/javascript/async_tools.js
blob: 98169fa40dbdaaf5f9169b108e1f6149281d33d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
function poll_async_changes(result){
    
    /**
     * Simple method that calls another to check the async results
     */

    //runs on the index page and polls the server side if there is new
    //change in the async db
    //alert(repr(result));
    if (result['changed']==true){
        //alert('Check it ');
        var the_change_msg = "We have some async changes : ";
        the_change_msg = the_change_msg + repr(result['changes'])+" check the <a href='/funcweb/display_async_results'>RESULTS</a> page!";
        getElement('globalerror').innerHTML = the_change_msg;
        window.setTimeout('check_async_change()',50000);
     }
    else
        window.setTimeout('check_async_change()',50000);
}

function check_async_change(){
    /**
     * Method that sends the xmlhttp request to check the changes
     */
    d = loadJSONDoc("/funcweb/check_async?"+queryString(
                {
                'check_change':true
                }
                ));
    d.addCallback(poll_async_changes);
    d.addErrback(poll_error);

}

function poll_error(error){
    var error_msg = "Async Error : probably you have shut down your server or your session has expired try to REFRESH and check your connection !";
    var error_div = getElement("globalerror");
    if (error_div != null){
        error_div.innerHTML = error_msg;
    }
}