From df9facb3f63dceec56762eae6ec7896eee3e80d8 Mon Sep 17 00:00:00 2001 From: Xaver Maierhofer Date: Sun, 12 Feb 2017 01:39:13 +0100 Subject: [PATCH] [TASK] Remove local storage test --- lib/forcegraph.js | 30 ++++++++++++------------------ lib/utils/helper.js | 11 ----------- 2 files changed, 12 insertions(+), 29 deletions(-) diff --git a/lib/forcegraph.js b/lib/forcegraph.js index c6d554c..eba9f19 100644 --- a/lib/forcegraph.js +++ b/lib/forcegraph.js @@ -38,10 +38,6 @@ define(['d3', 'helper'], function (d3, helper) { } function savePositions() { - if (!helper.localStorageTest()) { - return; - } - var save = intNodes.map(function (d) { return { id: d.o.id, x: d.x, y: d.y }; }); @@ -721,22 +717,20 @@ define(['d3', 'helper'], function (d3, helper) { return !d.o.node; }); - if (helper.localStorageTest()) { - var save = JSON.parse(localStorage.getItem('graph/nodeposition')); + var save = JSON.parse(localStorage.getItem('graph/nodeposition')); - if (save) { - var nodePositions = {}; - save.forEach(function (d) { - nodePositions[d.id] = d; - }); + if (save) { + var nodePositions = {}; + save.forEach(function (d) { + nodePositions[d.id] = d; + }); - intNodes.forEach(function (d) { - if (nodePositions[d.o.id] && (d.x === undefined || d.y === undefined)) { - d.x = nodePositions[d.o.id].x; - d.y = nodePositions[d.o.id].y; - } - }); - } + intNodes.forEach(function (d) { + if (nodePositions[d.o.id] && (d.x === undefined || d.y === undefined)) { + d.x = nodePositions[d.o.id].x; + d.y = nodePositions[d.o.id].y; + } + }); } var diameter = graphDiameter(intNodes); diff --git a/lib/utils/helper.js b/lib/utils/helper.js index ddcbc04..7693907 100644 --- a/lib/utils/helper.js +++ b/lib/utils/helper.js @@ -66,17 +66,6 @@ define({ return this.dictGet(dict[k], key); }, - localStorageTest: function localStorageTest() { - var test = 'test'; - try { - localStorage.setItem(test, test); - localStorage.removeItem(test); - return true; - } catch (e) { - return false; - } - }, - listReplace: function listReplace(s, subst) { for (var key in subst) { var re = new RegExp(key, 'g');