Skip to content

Commit

Permalink
Merge pull request #42 from VALIDproject/feature_updateDataOnChange
Browse files Browse the repository at this point in the history
do not load parsed data from localstorage (workaround for #41)
  • Loading branch information
alex-rind authored Aug 6, 2018
2 parents 3c71066 + 8ea8272 commit 9af9c0b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
42 changes: 21 additions & 21 deletions app/data.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
/**
* This module is responsible for initializing the data.
* 1) if a local storage is available it is used.
* This module is responsible for initializing the data.
* 1) if a local storage is available it is used.
* 2) also the combined objects from a previous session is restored.
*/
*/

exports.init = function(rawData)
{
hasLocalStorage = typeof(Storage) !== "undefined";
if(hasLocalStorage) {
data = JSON.parse(localStorage.getItem("data"));
if(data == null) {
data = require('dataparse').parse(rawData);
localStorage.setItem("data",JSON.stringify(data));
}
}
else {
// if(hasLocalStorage) {
// data = JSON.parse(localStorage.getItem("data"));
// if(data == null) {
// data = require('dataparse').parse(rawData);
// localStorage.setItem("data",JSON.stringify(data));
// }
// }
// else {
data = require('dataparse').parse(rawData);
}
// }
nodes = data[0];
links = data[1];
ndxLinks = crossfilter(links);
Expand All @@ -27,13 +27,13 @@ exports.init = function(rawData)
targetRestId = nodes.length;
nodes.push({name:"Sonstige Medien",gov:0});

if(hasLocalStorage) {
combinedObj = JSON.parse(localStorage.getItem("combinedObj"));
if(combinedObj == null) {
combinedObj = new Array();
}
}
else{
// if(hasLocalStorage) {
// combinedObj = JSON.parse(localStorage.getItem("combinedObj"));
// if(combinedObj == null) {
// combinedObj = new Array();
// }
// }
// else{
combinedObj = new Array();
}
};
// }
};
8 changes: 4 additions & 4 deletions app/globalFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ deleteData = function(dimension)
type: "remove"
});

if(hasLocalStorage)
localStorage.setItem("combinedObj",JSON.stringify(combinedObj));
// if(hasLocalStorage)
// localStorage.setItem("combinedObj",JSON.stringify(combinedObj));

updateAll();
}
Expand Down Expand Up @@ -258,8 +258,8 @@ combineData = function(dimension)
type: "combine"
});

if(hasLocalStorage)
localStorage.setItem("combinedObj",JSON.stringify(combinedObj));
// if(hasLocalStorage)
// localStorage.setItem("combinedObj",JSON.stringify(combinedObj));

updateAll();
}
Expand Down

0 comments on commit 9af9c0b

Please sign in to comment.