From b0c6f7a2bff3d57f1c8d05a561dbd0bbca0228ca Mon Sep 17 00:00:00 2001 From: Einar Egilsson Date: Sat, 2 Jun 2007 00:24:35 +0000 Subject: Redirector: All main functionality except Regex working. git-svn-id: http://einaregilsson.googlecode.com/svn/mozilla/redirector/trunk@57 119bf307-c92d-0410-89bd-8f53e6181181 --- chrome/content/redirectList.js | 62 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) (limited to 'chrome/content/redirectList.js') 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); } }; -- cgit v1.2.3-70-g09d2