in modules/js/htdocs/ui.js [509:546]
ui.appcache.get = function(uri, mode) {
debug('ui.appcache.get', uri, mode);
// Get resource from local storage first
var h = uri.indexOf('#');
var u = h == -1? uri : uri.substring(0, h);
if(mode != 'remote') {
var item = lstorage.getItem('ui.r.' + u);
if(item != null && item != '')
return item;
if(mode == 'local')
return undefined;
}
// Get resource from network
var http = new XMLHttpRequest();
http.open("GET", mode == 'remote'? (u + '?t=' + new Date().getTime() + '&r=' + Math.random()) : u, false);
http.setRequestHeader('Accept', '*/*');
http.setRequestHeader('X-Cache-Control', 'no-cache');
http.send(null);
if(http.status == 200) {
var ct = http.getResponseHeader("Content-Type");
if(http.responseText == '' || ct == null || ct == '') {
error('http error', u, 'No-Content');
return undefined;
}
lstorage.setItem('ui.r.' + u, http.responseText);
return http.responseText;
}
error('http error', u, http.status, http.statusText);
// Redirect to login page
if(http.status == 403 && window.top.location.href.pathname != '/logout/dologout/') {
if(window.onloginredirect)
window.onloginredirect(new Error('403 ' + http.statusText));
}
return undefined;
};