From e5f69904485c924d8eef44dd64ee7a07d9fc4789 Mon Sep 17 00:00:00 2001 From: Einar Egilsson Date: Tue, 30 Aug 2011 14:09:25 +0200 Subject: Delete redirects --- chrome/code/redirector.js | 4 ++-- chrome/js/settings.js | 14 ++++++++++---- chrome/settings.html | 4 ++-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/chrome/code/redirector.js b/chrome/code/redirector.js index 8a5cbed..9c7d769 100644 --- a/chrome/code/redirector.js +++ b/chrome/code/redirector.js @@ -40,8 +40,8 @@ Redirector = { } }, - deleteRedirectAt : function(index) { - this._list.splice(index, 1); + deleteRedirect : function(redirect) { + this._list.splice(this._list.indexOf(redirect), 1); this.save(); }, diff --git a/chrome/js/settings.js b/chrome/js/settings.js index c5675f6..29cdf29 100644 --- a/chrome/js/settings.js +++ b/chrome/js/settings.js @@ -75,7 +75,7 @@ $(document).ready(function() { var template = $('#redirect-list').html().replace(/^\s*|\s$/g, ''); function databind() { - $('#redirect-list').html(''); + $('#redirect-list').empty(); for (var i = 0; i < Redirector.redirectCount; i++) { var redirect = Redirector.getRedirectAt(i); var node = $(template); @@ -87,10 +87,16 @@ $(document).ready(function() { node.data('redirect', redirect); } - $('#redirect-list li a').click(function() { - alert(this.parentNode.parentNode.redirect); - }); } + + $('#redirect-list li div a.delete').live('click', function(ev) { + var redirect = $(this.parentNode.parentNode).data('redirect'); + if (PromptService.confirm(null, tr("deleteConfirmationTitle"), tr("deleteConfirmationText"))) { + Redirector.deleteRedirect(redirect); + $(this.parentNode.parentNode).remove(); + } + ev.preventDefault(); + }); databind(); diff --git a/chrome/settings.html b/chrome/settings.html index 117a200..ec98b10 100644 --- a/chrome/settings.html +++ b/chrome/settings.html @@ -61,8 +61,8 @@