diff --git a/public_html/js/Views.js b/public_html/js/Views.js index 03a599f..1437799 100644 --- a/public_html/js/Views.js +++ b/public_html/js/Views.js @@ -393,6 +393,9 @@ Views.prototype.showMainMenu = function () { this.addMainMenuItem("Загрузить…", function() { views.showLoadStateMenu(); }); + this.addMainMenuItem("Удалить…", function() { + views.showRemoveStateMenu(); + }); } this.addMainMenuItem("Закрыть", function() { $('#menu').hide(); @@ -608,4 +611,30 @@ Views.prototype.createLoadStateClickFunction = function (index, save) { views.parser.setPosition(save.position); $('#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 = $('
  • ', {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(); + }; }; \ No newline at end of file