Revision 9eefb3a2

b/ui/static/synnefo.js
38 38
var networks = [], networks_changes_since = 0;
39 39

  
40 40

  
41
//FIXME: authentication
42
//if cookie with value X-Auth-Token exists, set the value on the headers.
43
    $.ajaxSetup({
44
        'beforeSend': function(xhr) {
45
            //if ($.cookie("X-Auth-Token") != null) {
46
              xhr.setRequestHeader("X-Auth-Token", $.cookie("X-Auth-Token"));
47
            //} else {
48
            //    $.cookie("X-Auth-Token", "46e427d657b20defe352804f0eb6f8a2"); // set X-Auth-Token cookie
49
            //}
41
var error_timeout = 20000;
42
$.ajaxSetup({
43
    'beforeSend': function(xhr) {
44
          xhr.setRequestHeader("X-Auth-Token", $.cookie("X-Auth-Token"));
45
    },
46

  
47
    // catch uncaught error requests
48
    // stop interaction and show only for the 5xx errors
49
    // refresh the page after 20secs
50
    error: function(jqXHR, textStatus, errorThrown) {
51
        // stop interaction for important (aka 500) error codes only
52
        if (jqXHR.status >= 500 && jqXHR.status < 600)
53
        {
54
            try {
55
                ajax_error(jqXHR.status, undefined, 'Unknown', jqXHR.responseText);
56
            } catch(err) {
57
                ajax_error(0, undefined, 'Unknown', jqXHR.responseText);
58
            }
50 59
        }
51
    });
60

  
61
        // refresh after 10 seconds
62
        window.setTimeout("window.location.reload()", window.error_timeout);
63
    }
64
});
52 65

  
53 66

  
54 67
// jquery show/hide events
......
375 388
        var found = false;
376 389
        var index = 0;
377 390
        $.each(servers, function(i, s) {
378
            console.log(index);
379 391
            if (s.id == id) { found = true, index = i };
380 392
        });
381 393
        if (found)
......
2087 2099
    box.addClass('success');
2088 2100
    box.removeClass('error');
2089 2101

  
2090
    var sel = function(s){console.log(box); return $(s, box)};
2102
    var sel = function(s){return $(s, box)};
2091 2103

  
2092 2104
    sel("h3 span.header-box").text(config.title);
2093 2105
    sel("div.machine-now-building").html(config.content);

Also available in: Unified diff