aboutsummaryrefslogtreecommitdiff
path: root/chrome/content/redirectList.js
diff options
context:
space:
mode:
authorEinar Egilsson2007-06-02 00:24:35 +0000
committerEinar Egilsson2007-06-02 00:24:35 +0000
commitb0c6f7a2bff3d57f1c8d05a561dbd0bbca0228ca (patch)
treeb9d11f284141f8aacd80e917bcd05877c3aee6e1 /chrome/content/redirectList.js
parentf77a93fe56b90c89d3a881d9af84d43e451efe8d (diff)
Redirector: All main functionality except Regex working.
git-svn-id: http://einaregilsson.googlecode.com/svn/mozilla/redirector/trunk@57 119bf307-c92d-0410-89bd-8f53e6181181
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);
}
};