make local storage more robust (deal with gaps)

This commit is contained in:
Ralf Becker 2014-01-21 15:09:06 +00:00
parent 192bde119b
commit 58e13743fc
2 changed files with 13 additions and 8 deletions

View File

@ -139,13 +139,18 @@ egw.extend('debug', egw.MODULE_GLOBAL, function(_app, _wnd) {
if (window.localStorage && typeof window.localStorage[LASTLOG] != 'undefined')
{
var lastlog = parseInt(window.localStorage[LASTLOG]);
for(var i=lastlog; i < MAX_LOGS && typeof window.localStorage[LOG_PREFIX+i] != 'undefined'; ++i)
for(var i=lastlog; i < lastlog+MAX_LOGS; ++i)
{
logs.push(JSON.parse(window.localStorage[LOG_PREFIX+i]));
}
for (var i=0; i < lastlog; ++i)
{
logs.push(JSON.parse(window.localStorage[LOG_PREFIX+i]));
var log = window.localStorage[LOG_PREFIX+(i%MAX_LOGS)];
if (typeof log != 'undefined')
{
try {
logs.push(JSON.parse(log));
}
catch(e) {
// ignore not existing log entries
}
}
}
}
return logs;

View File

@ -228,8 +228,8 @@ function egw_getAppName()
function egw_refresh(_msg, _app, _id, _type, _targetapp, _replace, _with, _msg_type)
{
// Log for debugging purposes
egw.debug("log", "egw_refresh(%s, %s, %s, %o, %s, %s)",_msg,_app,_id,_type,_target_app,_replace,_with,_msg_type);
egw.debug("log", "egw_refresh(%s, %s, %s, %o, %s, %s)", _msg, _app, _id, _type, _targetapp, _replace, _with, _msg_type);
//alert("egw_refresh(\'"+_msg+"\',\'"+_app+"\',\'"+_id+"\',\'"+_type+"\')");
var win = typeof _targetapp != 'undefined' ? egw_appWindow(_targetapp) : window;