From 365d01d637136913dcec1d7b0dff5b1089a7c96a Mon Sep 17 00:00:00 2001
From: Vincent Nivoliers <vincent.nivoliers@univ-lyon1.fr>
Date: Fri, 23 Sep 2016 17:33:36 +0200
Subject: [PATCH] fixed localStorage key prefix with innerHTML

---
 js/explorer.js         |  3 +--
 js/notes.js            |  2 +-
 js/pgm_construction.js | 38 ++------------------------------------
 3 files changed, 4 insertions(+), 39 deletions(-)

diff --git a/js/explorer.js b/js/explorer.js
index 44ced0c..5367288 100644
--- a/js/explorer.js
+++ b/js/explorer.js
@@ -134,12 +134,11 @@ function openXML(filename, handler) {
 }
 
 /* exploration */
-
 var planet = {} ;
 var center_map = null ;
 
 var storage_prefix = 'Explosurf:' 
-    + document.getElementById('planet-name').innerHTML.toLowerCase() 
+    + document.getElementById('planet-name').innerHTML.toLowerCase().replace(/\s+/mg, '')
     + ':explorer'
   ;
 
diff --git a/js/notes.js b/js/notes.js
index 15f1996..81ff8fb 100644
--- a/js/notes.js
+++ b/js/notes.js
@@ -11,7 +11,7 @@
 
 /* local storage prefix */
 var storage_prefix = 'Explosurf:' 
-    + document.getElementById('planet-name').innerHTML.toLowerCase() 
+    + document.getElementById('planet-name').innerHTML.toLowerCase().replace(/\s+/mg, '')
     + ':notes'
   ;
 
diff --git a/js/pgm_construction.js b/js/pgm_construction.js
index ea87ab3..6e91c93 100644
--- a/js/pgm_construction.js
+++ b/js/pgm_construction.js
@@ -60,7 +60,7 @@ var has_absolute_fixed_bug = (function() {
 
 /*prefix for local storage*/
 var storage_prefix = 'Explosurf:' 
-    + document.getElementById('planet-name').innerHTML.toLowerCase()
+    + document.getElementById('planet-name').innerHTML.toLowerCase().replace(/\s+/mg, '')
     + ':pgm'
   ;
 
@@ -203,47 +203,13 @@ document.getElementById('pgm-load-local').addEventListener(
   }
 ) ;
 
-/* pack the full Explosurf data in a blob */
-var file_blob = null ;
-
-function generate_blob() {
-  local_save() ;
-  var data = new Blob(
-    [JSON.stringify(localStorage)],
-    {type : 'application/json'}
-  ) ;
-  if(file_blob !== null) {
-    window.URL.revokeObjectURL(file_blob) ;
-  }
-  file_blob = window.URL.createObjectURL(data) ;
-  return file_blob ;
-}
-
-/* propose the blob for download : save all data */
+/* save all data using filesaver.js */
 function blob_download() {
   var blob = new Blob(
     [JSON.stringify(localStorage)],
     {type : 'application/json'}
   ) ;
   saveAs(blob, 'explosurf.json') ;
-  /*
-  var link = document.createElement('a') ;
-  link.setAttribute('download', 'explosurf.json') ;
-  link.href = generate_blob() ;
-  document.body.appendChild(link) ;
-
-  setTimeout(function () {
-    var event ;
-    if(typeof MouseEvent !== 'function') {
-      event = document.createEvent("MouseEvent");
-      event.initMouseEvent("click",true,false,window,0,0,0,0,0,false,false,false,false,0,null);
-    } else {
-      event = new MouseEvent('click');
-    }
-    link.dispatchEvent(event);
-    document.body.removeChild(link);
-  }, 66);
-  */
 }
 
 /* load the saved data */
-- 
GitLab