[TASK] Remove local storage test
This commit is contained in:
parent
cd60af97c8
commit
df9facb3f6
@ -38,10 +38,6 @@ define(['d3', 'helper'], function (d3, helper) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function savePositions() {
|
function savePositions() {
|
||||||
if (!helper.localStorageTest()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var save = intNodes.map(function (d) {
|
var save = intNodes.map(function (d) {
|
||||||
return { id: d.o.id, x: d.x, y: d.y };
|
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;
|
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) {
|
if (save) {
|
||||||
var nodePositions = {};
|
var nodePositions = {};
|
||||||
save.forEach(function (d) {
|
save.forEach(function (d) {
|
||||||
nodePositions[d.id] = d;
|
nodePositions[d.id] = d;
|
||||||
});
|
});
|
||||||
|
|
||||||
intNodes.forEach(function (d) {
|
intNodes.forEach(function (d) {
|
||||||
if (nodePositions[d.o.id] && (d.x === undefined || d.y === undefined)) {
|
if (nodePositions[d.o.id] && (d.x === undefined || d.y === undefined)) {
|
||||||
d.x = nodePositions[d.o.id].x;
|
d.x = nodePositions[d.o.id].x;
|
||||||
d.y = nodePositions[d.o.id].y;
|
d.y = nodePositions[d.o.id].y;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var diameter = graphDiameter(intNodes);
|
var diameter = graphDiameter(intNodes);
|
||||||
|
@ -66,17 +66,6 @@ define({
|
|||||||
return this.dictGet(dict[k], key);
|
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) {
|
listReplace: function listReplace(s, subst) {
|
||||||
for (var key in subst) {
|
for (var key in subst) {
|
||||||
var re = new RegExp(key, 'g');
|
var re = new RegExp(key, 'g');
|
||||||
|
Loading…
Reference in New Issue
Block a user