Ability to remove saves
This commit is contained in:
parent
d5ceb0afec
commit
539151e3ac
@ -393,6 +393,9 @@ Views.prototype.showMainMenu = function () {
|
|||||||
this.addMainMenuItem("Загрузить…", function() {
|
this.addMainMenuItem("Загрузить…", function() {
|
||||||
views.showLoadStateMenu();
|
views.showLoadStateMenu();
|
||||||
});
|
});
|
||||||
|
this.addMainMenuItem("Удалить…", function() {
|
||||||
|
views.showRemoveStateMenu();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
this.addMainMenuItem("Закрыть", function() {
|
this.addMainMenuItem("Закрыть", function() {
|
||||||
$('#menu').hide();
|
$('#menu').hide();
|
||||||
@ -608,4 +611,30 @@ Views.prototype.createLoadStateClickFunction = function (index, save) {
|
|||||||
views.parser.setPosition(save.position);
|
views.parser.setPosition(save.position);
|
||||||
$('#menu').hide();
|
$('#menu').hide();
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
Views.prototype.showRemoveStateMenu = function () {
|
||||||
|
var saves = JSON.parse(localStorage.saves || null) || {};
|
||||||
|
var items = saves[rpyscript] || [];
|
||||||
|
|
||||||
|
$('#menuTitle').text('Удалить');
|
||||||
|
$('#menuChoose').empty();
|
||||||
|
this.addMainMenuItem("Закрыть", function() {
|
||||||
|
$('#menu').hide();
|
||||||
|
});
|
||||||
|
for(var i = items.length - 1; i >= 0; i--) {
|
||||||
|
var li = $('<li>', {text: items[i].time});
|
||||||
|
li.click(this.createRemoveStateClickFunction(i));
|
||||||
|
li.appendTo($('#menuChoose'));
|
||||||
|
}
|
||||||
|
$('#menu').show();
|
||||||
|
};
|
||||||
|
Views.prototype.createRemoveStateClickFunction = function (index) {
|
||||||
|
var views = this;
|
||||||
|
return function () {
|
||||||
|
var saves = JSON.parse(localStorage.saves || null) || {};
|
||||||
|
saves[rpyscript].splice(index, 1);
|
||||||
|
localStorage.saves = JSON.stringify(saves);
|
||||||
|
views.showRemoveStateMenu();
|
||||||
|
};
|
||||||
};
|
};
|
Loading…
Reference in New Issue
Block a user