Skip to content

Commit

Permalink
Added local storage
Browse files Browse the repository at this point in the history
  • Loading branch information
LupusUmbrae committed Apr 11, 2016
1 parent 8ca5dc2 commit b2f0893
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions static/javascript/kdm.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
run.$inject = ['$rootScope', '$parse'];

function jsonify(scope) {
console.log(scope.tabs);
return JSON.stringify(scope.tabs);
}

Expand Down Expand Up @@ -49,8 +48,13 @@

$rootScope.tabs = [];

addNewSettlement($rootScope);
addNewChar($rootScope);
var local = localStorage.getItem('kdm');
if(local ==null ) {
addNewSettlement($rootScope);
addNewChar($rootScope);
} else {
load($rootScope, local);
}

$rootScope.timeline = {};
$rootScope.timeline.options = [];
Expand Down Expand Up @@ -130,6 +134,13 @@
}
});
});

$rootScope.$watch('tabs', function(newVal, oldVal) {
if (newVal !== undefined && oldVal !== undefined && newVal !== oldVal)
{
localStorage.setItem('kdm', jsonify($rootScope));
}
}, true);
}

function addNewChar(scope) {
Expand Down Expand Up @@ -224,7 +235,7 @@

function createEmptySettlement(id) {
var kdm = loadFromFile("static/json/settlement.json");
kdm.id = id;
kdm.id = id;
return kdm;
}

Expand Down

0 comments on commit b2f0893

Please sign in to comment.