From 4eb50377c387743df2bf0c93fbd35d63a9661aea Mon Sep 17 00:00:00 2001 From: shortcutme Date: Thu, 18 Jun 2020 17:23:15 +0200 Subject: [PATCH] Warning about deleting private key for owned sites --- plugins/Sidebar/media/Sidebar.coffee | 33 ++++++++++-------- plugins/Sidebar/media/all.js | 50 +++++++++++++++++----------- 2 files changed, 50 insertions(+), 33 deletions(-) diff --git a/plugins/Sidebar/media/Sidebar.coffee b/plugins/Sidebar/media/Sidebar.coffee index 47c6e7f8..2f398522 100644 --- a/plugins/Sidebar/media/Sidebar.coffee +++ b/plugins/Sidebar/media/Sidebar.coffee @@ -346,6 +346,25 @@ class Sidebar extends Class if res == "ok" @wrapper.notifications.add "sign", "done", "#{inner_path} Signed and published!", 5000 + handleSiteDeleteClick: -> + if @wrapper.site_info.privatekey + question = "Are you sure?
This site has a saved private key" + options = ["Forget private key and delete site"] + else + question = "Are you sure?" + options = ["Delete this site", "Blacklist"] + @wrapper.displayConfirm question, options, (confirmed) => + if confirmed == 1 + @tag.find("#button-delete").addClass("loading") + @wrapper.ws.cmd "siteDelete", @wrapper.site_info.address, -> + document.location = $(".fixbutton-bg").attr("href") + else if confirmed == 2 + @wrapper.displayPrompt "Blacklist this site", "text", "Delete and Blacklist", "Reason", (reason) => + @tag.find("#button-delete").addClass("loading") + @wrapper.ws.cmd "siteblockAdd", [@wrapper.site_info.address, reason] + @wrapper.ws.cmd "siteDelete", @wrapper.site_info.address, -> + document.location = $(".fixbutton-bg").attr("href") + onOpened: -> @log "Opened" @scrollable() @@ -417,19 +436,7 @@ class Sidebar extends Class # Delete site @tag.find("#button-delete").off("click touchend").on "click touchend", => - @wrapper.displayConfirm "Are you sure?", ["Delete this site", "Blacklist"], (confirmed) => - if confirmed == 1 - @tag.find("#button-delete").addClass("loading") - @wrapper.ws.cmd "siteDelete", @wrapper.site_info.address, -> - document.location = $(".fixbutton-bg").attr("href") - else if confirmed == 2 - @wrapper.displayPrompt "Blacklist this site", "text", "Delete and Blacklist", "Reason", (reason) => - @tag.find("#button-delete").addClass("loading") - @wrapper.ws.cmd "siteblockAdd", [@wrapper.site_info.address, reason] - @wrapper.ws.cmd "siteDelete", @wrapper.site_info.address, -> - document.location = $(".fixbutton-bg").attr("href") - - + @handleSiteDeleteClick() return false # Owned checkbox diff --git a/plugins/Sidebar/media/all.js b/plugins/Sidebar/media/all.js index f83a5c5c..ff7e3cc3 100644 --- a/plugins/Sidebar/media/all.js +++ b/plugins/Sidebar/media/all.js @@ -55,7 +55,6 @@ }).call(this); - /* ---- Console.coffee ---- */ @@ -354,7 +353,6 @@ }).call(this); - /* ---- Menu.coffee ---- */ @@ -437,7 +435,6 @@ }).call(this); - /* ---- RateLimit.coffee ---- */ @@ -466,7 +463,6 @@ }).call(this); - /* ---- Scrollable.js ---- */ @@ -983,6 +979,35 @@ window.initScrollable = function () { })(this)); }; + Sidebar.prototype.handleSiteDeleteClick = function() { + var options, question; + if (this.wrapper.site_info.privatekey) { + question = "Are you sure?
This site has a saved private key"; + options = ["Forget private key and delete site"]; + } else { + question = "Are you sure?"; + options = ["Delete this site", "Blacklist"]; + } + return this.wrapper.displayConfirm(question, options, (function(_this) { + return function(confirmed) { + if (confirmed === 1) { + _this.tag.find("#button-delete").addClass("loading"); + return _this.wrapper.ws.cmd("siteDelete", _this.wrapper.site_info.address, function() { + return document.location = $(".fixbutton-bg").attr("href"); + }); + } else if (confirmed === 2) { + return _this.wrapper.displayPrompt("Blacklist this site", "text", "Delete and Blacklist", "Reason", function(reason) { + _this.tag.find("#button-delete").addClass("loading"); + _this.wrapper.ws.cmd("siteblockAdd", [_this.wrapper.site_info.address, reason]); + return _this.wrapper.ws.cmd("siteDelete", _this.wrapper.site_info.address, function() { + return document.location = $(".fixbutton-bg").attr("href"); + }); + }); + } + }; + })(this)); + }; + Sidebar.prototype.onOpened = function() { var menu; this.log("Opened"); @@ -1073,22 +1098,7 @@ window.initScrollable = function () { })(this)); this.tag.find("#button-delete").off("click touchend").on("click touchend", (function(_this) { return function() { - _this.wrapper.displayConfirm("Are you sure?", ["Delete this site", "Blacklist"], function(confirmed) { - if (confirmed === 1) { - _this.tag.find("#button-delete").addClass("loading"); - return _this.wrapper.ws.cmd("siteDelete", _this.wrapper.site_info.address, function() { - return document.location = $(".fixbutton-bg").attr("href"); - }); - } else if (confirmed === 2) { - return _this.wrapper.displayPrompt("Blacklist this site", "text", "Delete and Blacklist", "Reason", function(reason) { - _this.tag.find("#button-delete").addClass("loading"); - _this.wrapper.ws.cmd("siteblockAdd", [_this.wrapper.site_info.address, reason]); - return _this.wrapper.ws.cmd("siteDelete", _this.wrapper.site_info.address, function() { - return document.location = $(".fixbutton-bg").attr("href"); - }); - }); - } - }); + _this.handleSiteDeleteClick(); return false; }; })(this));