/**
 *  Backup
 *  ======
 *
 *  Using local stored information to provide a backup for reconnection.
 */

if ( LOCAL['player'] ) {

  var range = parseFloat( JSON.parse(LOCAL.player).time ) +
              config.reconnectConfig.backupDuration - Date.now();

  if ( range >= 0 ) extend( BACKUP, JSON.parse(LOCAL.player) );
}

delete LOCAL['player'];


/**
 *  Overwrites the data in the localStorage
 *
 *  TODO: instead of always serializing the whole instance, just update the increment
 */

function updateBackup() {

  LOCAL['player'] = JSON.stringify(PLAYER);
}


/**
 *  Uses the former data as initial values
 *
 *  TODO: check if account information (name) should also be stored
 *
 *  @param  {[type]} data [description]
 */

function restoreBackup ( player ) {

  if ( !config.reconnectConfig.restoreEnabled ) return;

  if ( BACKUP.id   ) player.id   = BACKUP.id;
  if ( BACKUP.time ) player.time = BACKUP.time;

  if ( !BACKUP.data ) return;

  var data = player.data,
      last = BACKUP.data, keys = getKeys(last);

  for ( var i = 0, l = keys.length; i < l; i++ ) data[ keys[i] ] = last[ keys[i] ];
}

@@ -168,23 +168,26 @@
 se(LOCAL
-.
+%5B'
 player
+'%5D
 ).time )
@@ -312,15 +312,18 @@
 OCAL
-.
+%5B'
 player
+'%5D
 ) );
@@ -490,24 +490,24 @@
 rement%0A */%0A%0A
-
 function upd
@@ -521,16 +521,73 @@
 up() %7B%0A%0A
+  if ( !config.reconnectConfig.restoreEnabled ) return;%0A%0A
   LOCAL%5B

check for restoreBackup flag