aboutsummaryrefslogtreecommitdiff
path: root/chrome
diff options
context:
space:
mode:
authorEinar Egilsson2011-08-30 14:09:25 +0200
committerEinar Egilsson2011-08-30 14:09:25 +0200
commite5f69904485c924d8eef44dd64ee7a07d9fc4789 (patch)
treed30ddb70b6232c67803124346aa37b6fd12ad071 /chrome
parentf0843d03e265c47258c92499248f45bff4ece6f4 (diff)
Delete redirects
Diffstat (limited to 'chrome')
-rw-r--r--chrome/code/redirector.js4
-rw-r--r--chrome/js/settings.js14
-rw-r--r--chrome/settings.html4
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 @@
<div>Redirect: <span class="pattern">pattern</span> to <span class="redirectTo"></span></div>
<div>Example: <span class="exampleUrl"></span> becomes <span class="redirectResult"></span></div>
<div>
- <a href="#edit">Edit</a>
- <a href="#delete">Delete</a>
+ <a class="edit" href="#edit">Edit</a>
+ <a class="delete" href="#delete">Delete</a>
</div>
</li>
</ul>