diff options
-rw-r--r-- | chrome/content/redirect.js | 1 | ||||
-rw-r--r-- | chrome/content/redirect.xul | 2 | ||||
-rw-r--r-- | chrome/content/redirectList.js | 39 | ||||
-rw-r--r-- | chrome/content/redirectList.xul | 1 | ||||
-rw-r--r-- | chrome/locale/en-US/redirectList.dtd | 1 | ||||
-rw-r--r-- | install.rdf | 4 |
6 files changed, 35 insertions, 13 deletions
diff --git a/chrome/content/redirect.js b/chrome/content/redirect.js index f4609e3..08af778 100644 --- a/chrome/content/redirect.js +++ b/chrome/content/redirect.js @@ -10,6 +10,7 @@ var Redirect = { $('txtRedirectUrl').value = item.redirectUrl || ''; $('chkOnlyIfLinkExists').checked = item.onlyIfLinkExists || false; + $('txtPattern').focus(); this.strings = document.getElementById("redirector-strings"); if (item.patternType == kRedirectorRegex) { diff --git a/chrome/content/redirect.xul b/chrome/content/redirect.xul index 479729a..68d23c4 100644 --- a/chrome/content/redirect.xul +++ b/chrome/content/redirect.xul @@ -21,7 +21,7 @@ <rows>
<row>
<text value="&txtExampleUrl.label;" style="margin-top:6px;"/>
- <textbox id="txtExampleUrl" disabled="true" style="width:400px;"/>
+ <textbox id="txtExampleUrl" style="width:400px;"/>
</row>
<row>
<text value="&txtPattern.label;" style="margin-top:6px;"/>
diff --git a/chrome/content/redirectList.js b/chrome/content/redirectList.js index 081359f..159bc8a 100644 --- a/chrome/content/redirectList.js +++ b/chrome/content/redirectList.js @@ -12,16 +12,7 @@ var RedirectList = { var item, row, value; for each (item in items) { - row = document.createElement('listitem'); - - 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; - + row = this.createRow(item); list.appendChild(row); } }, @@ -33,6 +24,18 @@ var RedirectList = { row.appendChild(cell); }, + createRow : function(item) { + var row = document.createElement('listitem'); + + 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; + return row; + }, onLoad : function() { try { @@ -51,6 +54,22 @@ var RedirectList = { window.close(); }, + addRedirect : function() { + + var item = { pattern : '', exampleUrl : '', redirectUrl : '', onlyIfLinkExists : false, patternType : 'W'}; + + window.openDialog("chrome://redirector/content/redirect.xul", + "redirect", + "chrome,dialog,modal,centerscreen", item); + + if (item.saved) { + var row = this.createRow(item); + $('lstRedirects').appendChild(row); + Redirector.addRedirect(item); + } + + }, + editRedirect : function() { var listItem = this.lstRedirects.selectedItem; diff --git a/chrome/content/redirectList.xul b/chrome/content/redirectList.xul index 264baa2..975497b 100644 --- a/chrome/content/redirectList.xul +++ b/chrome/content/redirectList.xul @@ -37,6 +37,7 @@ </listbox>
<hbox style="align:right;">
+ <button id="btnAdd" onclick="RedirectList.addRedirect();" label="&btnAdd.label;" disabled="false" />
<button id="btnEdit" onclick="RedirectList.editRedirect();" label="&btnEdit.label;" disabled="true" />
<button id="btnDelete" onclick="RedirectList.deleteRedirect();" label="&btnDelete.label;" disabled="true" />
<button id="btnClose" onclick="RedirectList.close();" label="&btnClose.label;"/>
diff --git a/chrome/locale/en-US/redirectList.dtd b/chrome/locale/en-US/redirectList.dtd index 9af7605..21434c5 100644 --- a/chrome/locale/en-US/redirectList.dtd +++ b/chrome/locale/en-US/redirectList.dtd @@ -5,6 +5,7 @@ <!ENTITY colRedirectTo.label "Redirect to"> <!ENTITY colOnlyIfLinkExits.label "Only if link exists"> <!ENTITY colPatternType.label "Pattern type"> +<!ENTITY btnAdd.label "Add..."> <!ENTITY btnEdit.label "Edit..."> <!ENTITY btnDelete.label "Delete"> <!ENTITY btnClose.label "Close"> diff --git a/install.rdf b/install.rdf index 3b3fd7e..9eb365f 100644 --- a/install.rdf +++ b/install.rdf @@ -5,10 +5,10 @@ <Description about="urn:mozilla:install-manifest"> <em:id>redirector@einaregilsson.com</em:id> <em:name>Redirector</em:name> - <em:version>0.9.1</em:version> + <em:version>0.9.2</em:version> <em:creator>Einar Egilsson</em:creator> <em:description>Automatically redirects to user-defined urls on certain pages</em:description> - <em:homepageURL>https://addons.mozilla.org/en-US/firefox/addon/5064</em:homepageURL> + <em:homepageURL>http://tech.einaregilsson.com/projects/redirector/</em:homepageURL> <em:optionsURL>chrome://redirector/content/redirectList.xul</em:optionsURL> <em:iconURL>chrome://redirector/content/redirector.png</em:iconURL> <em:targetApplication> |