aboutsummaryrefslogtreecommitdiff
path: root/chrome/content/redirectList.js
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/content/redirectList.js')
-rw-r--r--chrome/content/redirectList.js62
1 files changed, 61 insertions, 1 deletions
diff --git a/chrome/content/redirectList.js b/chrome/content/redirectList.js
index 7a273cd..081359f 100644
--- a/chrome/content/redirectList.js
+++ b/chrome/content/redirectList.js
@@ -2,6 +2,9 @@ var RedirectList = {
id : "redirector@einaregilsson.com",
name : "Redirector",
+ lstRedirects: null,
+ btnDelete : null,
+ btnEdit : null,
addItemsToListBox : function(items) {
@@ -11,10 +14,13 @@ var RedirectList = {
for each (item in items) {
row = document.createElement('listitem');
- this.createCell(row, item.exampleUrl);
this.createCell(row, item.pattern);
+ this.createCell(row, item.exampleUrl);
this.createCell(row, item.redirectUrl);
this.createCell(row, item.onlyIfLinkExists);
+ this.createCell(row, item.patternType);
+
+ row.item = item;
list.appendChild(row);
}
@@ -32,10 +38,64 @@ var RedirectList = {
try {
RedirLib.initialize(this);
Redirector.init();
+ this.lstRedirects = $('lstRedirects');
+ this.btnDelete = $('btnDelete');
+ this.btnEdit = $('btnEdit');
this.addItemsToListBox(Redirector.list);
} catch(e) {
alert(e);
}
+ },
+
+ close : function() {
+ window.close();
+ },
+
+ editRedirect : function() {
+
+ var listItem = this.lstRedirects.selectedItem;
+
+ if (!listItem) {
+ return;
+ }
+
+ var item = listItem.item;
+
+ window.openDialog("chrome://redirector/content/redirect.xul",
+ "redirect",
+ "chrome,dialog,modal,centerscreen", item);
+
+ if (item.saved) {
+ var map = [item.pattern, item.exampleUrl, item.redirectUrl, item.onlyIfLinkExists, item.patternType];
+
+ for (var i in map) {
+ listItem.childNodes[i].setAttribute('value', map[i]);
+ listItem.childNodes[i].setAttribute('label', map[i]);
+ }
+
+ Redirector.save();
+ }
+
+ },
+
+ deleteRedirect : function() {
+ var index = this.lstRedirects.selectedIndex;
+
+ if (index == -1) {
+ return;
+ }
+
+ try {
+ this.lstRedirects.removeItemAt(index);
+ Redirector.deleteAt(index);
+ } catch(e) {alert(e);}
+ },
+
+ selectionChange : function() {
+ var index = this.lstRedirects.selectedIndex;
+
+ this.btnEdit.disabled = (index == -1);
+ this.btnDelete.disabled = (index == -1);
}
};