mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-27 00:18:56 +02:00
have locals torage woring
This commit is contained in:
parent
0735eb3d64
commit
465b25368e
7 changed files with 113 additions and 39 deletions
|
@ -4587,8 +4587,10 @@ var Sandbox = Backbone.View.extend({
|
|||
// handle the case where that level is not found...
|
||||
if (!levelJSON) {
|
||||
command.addWarning(
|
||||
'A level for that id "' + desiredID + '" was not found!!'
|
||||
'A level for that id "' + desiredID + '" was not found!! Opening up level selection view...'
|
||||
);
|
||||
Main.getEventBaton().trigger('commandSubmitted', 'levels');
|
||||
|
||||
command.set('status', 'error');
|
||||
deferred.resolve();
|
||||
return;
|
||||
|
@ -12456,9 +12458,7 @@ var Command = Backbone.Model.extend({
|
|||
var CommandEntry = Backbone.Model.extend({
|
||||
defaults: {
|
||||
text: ''
|
||||
},
|
||||
// stub out if no plugin available
|
||||
localStorage: (Backbone.LocalStorage) ? new Backbone.LocalStorage('CommandEntries') : null
|
||||
}
|
||||
});
|
||||
|
||||
exports.CommandEntry = CommandEntry;
|
||||
|
@ -15415,8 +15415,15 @@ var Main = require('../app');
|
|||
function LevelArbiter() {
|
||||
this.levelMap = {};
|
||||
this.init();
|
||||
// TODO -- local storage sync
|
||||
this.solvedMap = {};
|
||||
|
||||
var solvedMap = {};
|
||||
try {
|
||||
solvedMap = JSON.parse(localStorage.getItem('solvedMap'));
|
||||
} catch (e) {
|
||||
console.warn('local storage failed', e);
|
||||
throw e;
|
||||
}
|
||||
this.solvedMap = solvedMap;
|
||||
|
||||
Main.getEvents().on('levelSolved', this.levelSolved, this);
|
||||
}
|
||||
|
@ -15442,10 +15449,6 @@ LevelArbiter.prototype.init = function() {
|
|||
}, this);
|
||||
};
|
||||
|
||||
LevelArbiter.prototype.getSolvedMap = function() {
|
||||
return this.solvedMap;
|
||||
};
|
||||
|
||||
LevelArbiter.prototype.isLevelSolved = function(id) {
|
||||
if (!this.levelMap[id]) {
|
||||
throw new Error('that level doesnt exist!');
|
||||
|
@ -15455,6 +15458,15 @@ LevelArbiter.prototype.isLevelSolved = function(id) {
|
|||
|
||||
LevelArbiter.prototype.levelSolved = function(id) {
|
||||
this.solvedMap[id] = true;
|
||||
this.syncToStorage();
|
||||
};
|
||||
|
||||
LevelArbiter.prototype.syncToStorage = function() {
|
||||
try {
|
||||
localStorage.setItem('solvedMap', JSON.stringify(this.solvedMap));
|
||||
} catch (e) {
|
||||
console.warn('local storage fialed on set', e);
|
||||
}
|
||||
};
|
||||
|
||||
LevelArbiter.prototype.validateLevel = function(level) {
|
||||
|
@ -15616,6 +15628,14 @@ var LevelDropdownView = ContainedBase.extend({
|
|||
300,
|
||||
true
|
||||
));
|
||||
this.navEvents.on('negative', this.negative, this);
|
||||
this.keyboardListener = new KeyboardListener({
|
||||
events: this.navEvents,
|
||||
aliasMap: {
|
||||
esc: 'negative'
|
||||
},
|
||||
wait: true
|
||||
});
|
||||
|
||||
this.sequences = Main.getLevelArbiter().getSequences();
|
||||
this.container = new ModalTerminal({
|
||||
|
@ -15629,8 +15649,13 @@ var LevelDropdownView = ContainedBase.extend({
|
|||
}
|
||||
},
|
||||
|
||||
negative: function() {
|
||||
this.hide();
|
||||
},
|
||||
|
||||
show: function(deferred) {
|
||||
this.showDeferred = deferred;
|
||||
this.keyboardListener.listen();
|
||||
LevelDropdownView.__super__.show.apply(this);
|
||||
},
|
||||
|
||||
|
@ -15639,6 +15664,7 @@ var LevelDropdownView = ContainedBase.extend({
|
|||
this.showDeferred.resolve();
|
||||
}
|
||||
this.showDeferred = undefined;
|
||||
this.keyboardListener.mute();
|
||||
|
||||
LevelDropdownView.__super__.hide.apply(this);
|
||||
},
|
||||
|
@ -15942,7 +15968,6 @@ var CommandPromptView = Backbone.View.extend({
|
|||
this.commands.each(function(c) {
|
||||
Backbone.sync('delete', c, function() { });
|
||||
}, this);
|
||||
localStorage.setItem('CommandEntries', '');
|
||||
},
|
||||
|
||||
setTextField: function(value) {
|
||||
|
@ -18624,8 +18649,15 @@ var Main = require('../app');
|
|||
function LevelArbiter() {
|
||||
this.levelMap = {};
|
||||
this.init();
|
||||
// TODO -- local storage sync
|
||||
this.solvedMap = {};
|
||||
|
||||
var solvedMap = {};
|
||||
try {
|
||||
solvedMap = JSON.parse(localStorage.getItem('solvedMap'));
|
||||
} catch (e) {
|
||||
console.warn('local storage failed', e);
|
||||
throw e;
|
||||
}
|
||||
this.solvedMap = solvedMap;
|
||||
|
||||
Main.getEvents().on('levelSolved', this.levelSolved, this);
|
||||
}
|
||||
|
@ -18651,10 +18683,6 @@ LevelArbiter.prototype.init = function() {
|
|||
}, this);
|
||||
};
|
||||
|
||||
LevelArbiter.prototype.getSolvedMap = function() {
|
||||
return this.solvedMap;
|
||||
};
|
||||
|
||||
LevelArbiter.prototype.isLevelSolved = function(id) {
|
||||
if (!this.levelMap[id]) {
|
||||
throw new Error('that level doesnt exist!');
|
||||
|
@ -18664,6 +18692,15 @@ LevelArbiter.prototype.isLevelSolved = function(id) {
|
|||
|
||||
LevelArbiter.prototype.levelSolved = function(id) {
|
||||
this.solvedMap[id] = true;
|
||||
this.syncToStorage();
|
||||
};
|
||||
|
||||
LevelArbiter.prototype.syncToStorage = function() {
|
||||
try {
|
||||
localStorage.setItem('solvedMap', JSON.stringify(this.solvedMap));
|
||||
} catch (e) {
|
||||
console.warn('local storage fialed on set', e);
|
||||
}
|
||||
};
|
||||
|
||||
LevelArbiter.prototype.validateLevel = function(level) {
|
||||
|
@ -19405,8 +19442,10 @@ var Sandbox = Backbone.View.extend({
|
|||
// handle the case where that level is not found...
|
||||
if (!levelJSON) {
|
||||
command.addWarning(
|
||||
'A level for that id "' + desiredID + '" was not found!!'
|
||||
'A level for that id "' + desiredID + '" was not found!! Opening up level selection view...'
|
||||
);
|
||||
Main.getEventBaton().trigger('commandSubmitted', 'levels');
|
||||
|
||||
command.set('status', 'error');
|
||||
deferred.resolve();
|
||||
return;
|
||||
|
@ -19874,9 +19913,7 @@ var Command = Backbone.Model.extend({
|
|||
var CommandEntry = Backbone.Model.extend({
|
||||
defaults: {
|
||||
text: ''
|
||||
},
|
||||
// stub out if no plugin available
|
||||
localStorage: (Backbone.LocalStorage) ? new Backbone.LocalStorage('CommandEntries') : null
|
||||
}
|
||||
});
|
||||
|
||||
exports.CommandEntry = CommandEntry;
|
||||
|
@ -20491,7 +20528,6 @@ var CommandPromptView = Backbone.View.extend({
|
|||
this.commands.each(function(c) {
|
||||
Backbone.sync('delete', c, function() { });
|
||||
}, this);
|
||||
localStorage.setItem('CommandEntries', '');
|
||||
},
|
||||
|
||||
setTextField: function(value) {
|
||||
|
@ -21480,6 +21516,14 @@ var LevelDropdownView = ContainedBase.extend({
|
|||
300,
|
||||
true
|
||||
));
|
||||
this.navEvents.on('negative', this.negative, this);
|
||||
this.keyboardListener = new KeyboardListener({
|
||||
events: this.navEvents,
|
||||
aliasMap: {
|
||||
esc: 'negative'
|
||||
},
|
||||
wait: true
|
||||
});
|
||||
|
||||
this.sequences = Main.getLevelArbiter().getSequences();
|
||||
this.container = new ModalTerminal({
|
||||
|
@ -21493,8 +21537,13 @@ var LevelDropdownView = ContainedBase.extend({
|
|||
}
|
||||
},
|
||||
|
||||
negative: function() {
|
||||
this.hide();
|
||||
},
|
||||
|
||||
show: function(deferred) {
|
||||
this.showDeferred = deferred;
|
||||
this.keyboardListener.listen();
|
||||
LevelDropdownView.__super__.show.apply(this);
|
||||
},
|
||||
|
||||
|
@ -21503,6 +21552,7 @@ var LevelDropdownView = ContainedBase.extend({
|
|||
this.showDeferred.resolve();
|
||||
}
|
||||
this.showDeferred = undefined;
|
||||
this.keyboardListener.mute();
|
||||
|
||||
LevelDropdownView.__super__.hide.apply(this);
|
||||
},
|
||||
|
|
|
@ -11,8 +11,15 @@ var Main = require('../app');
|
|||
function LevelArbiter() {
|
||||
this.levelMap = {};
|
||||
this.init();
|
||||
// TODO -- local storage sync
|
||||
this.solvedMap = {};
|
||||
|
||||
var solvedMap = {};
|
||||
try {
|
||||
solvedMap = JSON.parse(localStorage.getItem('solvedMap'));
|
||||
} catch (e) {
|
||||
console.warn('local storage failed', e);
|
||||
throw e;
|
||||
}
|
||||
this.solvedMap = solvedMap;
|
||||
|
||||
Main.getEvents().on('levelSolved', this.levelSolved, this);
|
||||
}
|
||||
|
@ -38,10 +45,6 @@ LevelArbiter.prototype.init = function() {
|
|||
}, this);
|
||||
};
|
||||
|
||||
LevelArbiter.prototype.getSolvedMap = function() {
|
||||
return this.solvedMap;
|
||||
};
|
||||
|
||||
LevelArbiter.prototype.isLevelSolved = function(id) {
|
||||
if (!this.levelMap[id]) {
|
||||
throw new Error('that level doesnt exist!');
|
||||
|
@ -51,6 +54,15 @@ LevelArbiter.prototype.isLevelSolved = function(id) {
|
|||
|
||||
LevelArbiter.prototype.levelSolved = function(id) {
|
||||
this.solvedMap[id] = true;
|
||||
this.syncToStorage();
|
||||
};
|
||||
|
||||
LevelArbiter.prototype.syncToStorage = function() {
|
||||
try {
|
||||
localStorage.setItem('solvedMap', JSON.stringify(this.solvedMap));
|
||||
} catch (e) {
|
||||
console.warn('local storage fialed on set', e);
|
||||
}
|
||||
};
|
||||
|
||||
LevelArbiter.prototype.validateLevel = function(level) {
|
||||
|
|
|
@ -119,8 +119,10 @@ var Sandbox = Backbone.View.extend({
|
|||
// handle the case where that level is not found...
|
||||
if (!levelJSON) {
|
||||
command.addWarning(
|
||||
'A level for that id "' + desiredID + '" was not found!!'
|
||||
'A level for that id "' + desiredID + '" was not found!! Opening up level selection view...'
|
||||
);
|
||||
Main.getEventBaton().trigger('commandSubmitted', 'levels');
|
||||
|
||||
command.set('status', 'error');
|
||||
deferred.resolve();
|
||||
return;
|
||||
|
|
|
@ -163,9 +163,7 @@ var Command = Backbone.Model.extend({
|
|||
var CommandEntry = Backbone.Model.extend({
|
||||
defaults: {
|
||||
text: ''
|
||||
},
|
||||
// stub out if no plugin available
|
||||
localStorage: (Backbone.LocalStorage) ? new Backbone.LocalStorage('CommandEntries') : null
|
||||
}
|
||||
});
|
||||
|
||||
exports.CommandEntry = CommandEntry;
|
||||
|
|
|
@ -165,7 +165,6 @@ var CommandPromptView = Backbone.View.extend({
|
|||
this.commands.each(function(c) {
|
||||
Backbone.sync('delete', c, function() { });
|
||||
}, this);
|
||||
localStorage.setItem('CommandEntries', '');
|
||||
},
|
||||
|
||||
setTextField: function(value) {
|
||||
|
|
|
@ -28,6 +28,14 @@ var LevelDropdownView = ContainedBase.extend({
|
|||
300,
|
||||
true
|
||||
));
|
||||
this.navEvents.on('negative', this.negative, this);
|
||||
this.keyboardListener = new KeyboardListener({
|
||||
events: this.navEvents,
|
||||
aliasMap: {
|
||||
esc: 'negative'
|
||||
},
|
||||
wait: true
|
||||
});
|
||||
|
||||
this.sequences = Main.getLevelArbiter().getSequences();
|
||||
this.container = new ModalTerminal({
|
||||
|
@ -41,8 +49,13 @@ var LevelDropdownView = ContainedBase.extend({
|
|||
}
|
||||
},
|
||||
|
||||
negative: function() {
|
||||
this.hide();
|
||||
},
|
||||
|
||||
show: function(deferred) {
|
||||
this.showDeferred = deferred;
|
||||
this.keyboardListener.listen();
|
||||
LevelDropdownView.__super__.show.apply(this);
|
||||
},
|
||||
|
||||
|
@ -51,6 +64,7 @@ var LevelDropdownView = ContainedBase.extend({
|
|||
this.showDeferred.resolve();
|
||||
}
|
||||
this.showDeferred = undefined;
|
||||
this.keyboardListener.mute();
|
||||
|
||||
LevelDropdownView.__super__.hide.apply(this);
|
||||
},
|
||||
|
|
11
todo.txt
11
todo.txt
|
@ -1,20 +1,15 @@
|
|||
Big Things
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
[ ] local storage for solved map
|
||||
[ ] hookup for when solving happens
|
||||
[ ] level builder? :OOO
|
||||
* basically just an extension of level (or sandbox), that has commands like
|
||||
```save tree beginning``` or ```save tree goal``` and then a final
|
||||
dialog typing area thingy
|
||||
|
||||
|
||||
Medium things:
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Cases to handle / things to edit
|
||||
=======================
|
||||
[ ] what if they just type "levels" ?
|
||||
[ ] show level dropdown
|
||||
|
||||
Small things to implement:
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
@ -29,12 +24,16 @@ Big Bugs to fix:
|
|||
/*************************************
|
||||
** Publish Things **
|
||||
************************************/
|
||||
- cross browser support... firefox only.
|
||||
- cross browser support... firefox only LULZ. should be just css right?
|
||||
- fix terminal input field in general
|
||||
- maybe have keyboard navigation for level selection?
|
||||
|
||||
Done things:
|
||||
(I only started this on Dec 17th 2012 to get a better sense of what was done)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
[x] local storage for solved map
|
||||
[x] what if they just type "levels" ?
|
||||
[x] hookup for when solving happens
|
||||
[x] levels dropdown selection?
|
||||
[x] git demonstration view -- shouldnt be too bad. LOL WHAT A FUCKING JOKE like 4 hours
|
||||
[x] gotoSandbox command
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue