diff options
author | Einar Egilsson | 2008-01-07 22:44:06 +0000 |
---|---|---|
committer | Einar Egilsson | 2008-01-07 22:44:06 +0000 |
commit | abc92ba06bb84d544a0d1deb065eb608cac8190e (patch) | |
tree | ba33b2f82fecca18aef7b0a9dadf2cb2af3b2d51 /chrome/content | |
parent | 0ee5f981f3e708246674d26f8a26fc9b6d8f5fc9 (diff) |
Redirector 1.5
git-svn-id: http://einaregilsson.googlecode.com/svn/mozilla/redirector/trunk@102 119bf307-c92d-0410-89bd-8f53e6181181
Diffstat (limited to 'chrome/content')
-rw-r--r-- | chrome/content/help.html | 76 | ||||
-rw-r--r-- | chrome/content/overlay.js | 77 | ||||
-rw-r--r-- | chrome/content/overlay.xul | 4 | ||||
-rw-r--r-- | chrome/content/redirectList.js | 8 | ||||
-rw-r--r-- | chrome/content/redirectList.xul | 4 | ||||
-rw-r--r-- | chrome/content/redirector.js | 8 | ||||
-rw-r--r-- | chrome/content/redirector.tws | bin | 0 -> 783 bytes |
7 files changed, 140 insertions, 37 deletions
diff --git a/chrome/content/help.html b/chrome/content/help.html index a9f5245..b4846aa 100644 --- a/chrome/content/help.html +++ b/chrome/content/help.html @@ -9,7 +9,7 @@ <body>
<h1>Redirector Help</h1>
<h3>Table of contents</h3>
- <ol>
+ <ul>
<li><a href="#whatisredirector">What is Redirector?</a></li>
<li><a href="#basicusage">Basic usage</a>
<ul>
@@ -24,8 +24,17 @@ <li><a href="#wildcards">Wildcards</a></li>
<li><a href="#regularexpressions">Regular expressions</a></li>
<li><a href="#xpathredirects">XPath redirects</a></li>
- <li><a href="#examples">Examples</a></li>
- </ol>
+ <li><a href="#examples">Examples</a>
+ <ol>
+ <li><a href="#ex1">Static redirect</a></li>
+ <li><a href="#ex2">Redirect using query string parameter and wildcards</a></li>
+ <li><a href="#ex3">Redirect using query string parameter and regular expressions</a></li>
+ <li><a href="#ex4">Redirect to a different folder using wildcards</a></li>
+ <li><a href="#ex5">Redirect http to https using wildcards</a></li>
+ </ol>
+
+ </li>
+ </ul>
<a name="whatisredirector"></a>
@@ -114,7 +123,64 @@ <a name="examples"></a>
<h4>Examples</h4>
-
- <p>To be continued in next version...</p>
+
+ <ol>
+ <li>
+ <strong><a name="ex1"></a>Static redirect</strong><br/>
+ Redirects from http://example.com/foo to http://example.com/bar
+ <p>
+ <strong>Include pattern:</strong> http://example.com/foo<br/>
+ <strong>Exclude pattern:</strong><br/>
+ <strong>Redirect to:</strong> http://example.com/bar<br/>
+ <strong>Pattern type:</strong> Wildcard<br />
+ </p>
+
+ </li>
+ <li>
+ <strong><a name="ex2"></a>Redirect using query string parameter and wildcards</strong><br/>
+ Redirects from http://example.com/index.php?id=12345&a=b to http://example.com/printerfriendly.php?id=12345&a=b
+ where 12345 could be any number.
+ <p>
+ <strong>Include pattern:</strong> http://example.com/index.php?id=*&a=b<br/>
+ <strong>Exclude pattern:</strong><br/>
+ <strong>Redirect to:</strong> http://example.com/printerfriendly.com?id=$1&a=b<br/>
+ <strong>Pattern type:</strong> Wildcard<br />
+ </p>
+ </li>
+ <li>
+ <strong><a name="ex3"></a>Redirect using query string parameter and regular expressions</strong><br/>
+ Redirects from http://example.com/index.php?id=12345&a=b to http://example.com/printerfriendly.php?id=12345&a=b
+ where 12345 could be any number.
+ <p>
+ <strong>Include pattern:</strong> http://example.com/index.php\?id=(\d+)&a=b<br/>
+ <strong>Exclude pattern:</strong><br/>
+ <strong>Redirect to:</strong> http://example.com/printerfriendly.com?id=$1&a=b<br/>
+ <strong>Pattern type:</strong> Regular Expression<br />
+ </p>
+ </li>
+ <li>
+ <strong><a name="ex4"></a>Redirect to a different folder using wildcards</strong><br/>
+ Redirects from http://example.com/category/fish/index.php to http://example.com/category/cats/index.php
+ where fish could be any word. The exclude pattern makes sure that there is only one
+ folder there, so for instance http://example.com/category/fish/cat/mouse/index.php would not match.
+ <p>
+ <strong>Include pattern:</strong> http://example.com/category/*/index.php<br/>
+ <strong>Exclude pattern:</strong> http://example.com/category/*/*/index.php<br/>
+ <strong>Redirect to:</strong> http://example.com/category/cats/index.php<br/>
+ <strong>Pattern type:</strong> Wildcard<br />
+ </p>
+ </li>
+ <li>
+ <strong><a name="ex5"></a>Redirect http to https using wildcards</strong><br/>
+ Redirects from http://mail.google.com/randomcharacters to https://mail.google.com/randomcharacters
+ where randomcharacters could be anything.
+ <p>
+ <strong>Include pattern:</strong> http://mail.google.com*<br/>
+ <strong>Exclude pattern:</strong><br/>
+ <strong>Redirect to:</strong> https://mail.google.com$1<br/>
+ <strong>Pattern type:</strong> Wildcard<br />
+ </p>
+ </li>
+ </ol>
</body>
</html>
\ No newline at end of file diff --git a/chrome/content/overlay.js b/chrome/content/overlay.js index dd6f527..f1d2241 100644 --- a/chrome/content/overlay.js +++ b/chrome/content/overlay.js @@ -16,7 +16,9 @@ var RedirectorOverlay = { RedirLib.debug("Initializing..."); $('contentAreaContextMenu') .addEventListener("popupshowing", function(e) { RedirectorOverlay.showContextMenu(e); }, false); - + + this.ffversion = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULAppInfo).version; + if (!RedirLib.getBoolPref('showContextMenu')) { $('redirector-context').hidden = true; } @@ -44,12 +46,15 @@ var RedirectorOverlay = { } } }, + + isVersion3 : function() { + return this.ffversion.toString().charAt(0) == '3'; + }, overrideOnStateChange : function() { var origOnStateChange = nsBrowserStatusHandler.prototype.onStateChange; nsBrowserStatusHandler.prototype.onStateChange = function(aWebProgress, aRequest, aStateFlags, aStatus) { - if(aStateFlags & Ci.nsIWebProgressListener.STATE_START && aStateFlags| Ci.nsIWebProgressListener.STATE_IS_NETWORK && aStateFlags| Ci.nsIWebProgressListener.STATE_IS_REQUEST @@ -96,32 +101,61 @@ var RedirectorOverlay = { }, overrideOpenNewWindowWith: function() { - + window.__openNewWindowWith = window.openNewWindowWith; - window.openNewWindowWith = function (href, sourceURL, postData, allowThirdPartyFixup) { - var redirectUrl = Redirector.getRedirectUrlForInstantRedirect(href); - if (redirectUrl.url) { - __openNewWindowWith(redirectUrl.url, href, postData, allowThirdPartyFixup); - } else { - __openNewWindowWith(href, sourceURL, postData, allowThirdPartyFixup); - } - }; + + if (this.isVersion3()) { + + window.openNewWindowWith = function (aUrl, aDocument, aPostData, aAllowThirdPartyFixup, aReferrer) { + var redirectUrl = Redirector.getRedirectUrlForInstantRedirect(aUrl); + if (redirectUrl.url) { + __openNewWindowWith(redirectUrl.url, aDocument, aPostData, aAllowThirdPartyFixup, aUrl); + } else { + __openNewWindowWith(aUrl, aDocument, aPostData, aAllowThirdPartyFixup, aReferrer); + } + }; + + } else { //version 2.* + + window.openNewWindowWith = function (href, sourceURL, postData, allowThirdPartyFixup) { + var redirectUrl = Redirector.getRedirectUrlForInstantRedirect(href); + if (redirectUrl.url) { + __openNewWindowWith(redirectUrl.url, href, postData, allowThirdPartyFixup); + } else { + __openNewWindowWith(href, sourceURL, postData, allowThirdPartyFixup); + } + }; + } }, overrideOpenNewTabWith: function() { window.__openNewTabWith = window.openNewTabWith; - window.openNewTabWith = function (href, sourceURL, postData, event, allowThirdPartyFixup) { - var redirectUrl = Redirector.getRedirectUrlForInstantRedirect(href); - if (redirectUrl.url) { - __openNewTabWith(redirectUrl.url, href, postData, event, allowThirdPartyFixup); - } else { - __openNewTabWith(href, sourceURL, postData, event, allowThirdPartyFixup); - } + if (this.isVersion3()) { + window.openNewTabWith = function (aUrl, aDocument, aPostData, aEvent, aAllowThirdPartyFixup, aReferrer) { + var redirectUrl = Redirector.getRedirectUrlForInstantRedirect(aUrl); + if (redirectUrl.url) { + __openNewTabWith(redirectUrl.url, aDocument, aPostData, aEvent, aAllowThirdPartyFixup, aUrl); + } else { + __openNewTabWith(aUrl, aDocument, aPostData, aEvent, aAllowThirdPartyFixup, aReferrer); + } + + }; - }; + } else { //version 2.* + window.openNewTabWith = function (href, sourceURL, postData, event, allowThirdPartyFixup) { + var redirectUrl = Redirector.getRedirectUrlForInstantRedirect(href); + if (redirectUrl.url) { + __openNewTabWith(redirectUrl.url, href, postData, event, allowThirdPartyFixup); + } else { + __openNewTabWith(href, sourceURL, postData, event, allowThirdPartyFixup); + } + + }; + + } }, @@ -182,12 +216,11 @@ var RedirectorOverlay = { statusBarClick : function(event) { var LEFT = 0, RIGHT = 2; - alert($('redirector-status-popup').style.right); if (event.button == LEFT) { RedirectorOverlay.toggleEnabled(); } else if (event.button == RIGHT) { - $('redirector-status-popup').left = $('redirector-status').left; - $('redirector-status-popup').showPopup(); + Redirector.openSettings(); + //$('redirector-status-popup').showPopup(); } }, diff --git a/chrome/content/overlay.xul b/chrome/content/overlay.xul index 3333be1..5bd827f 100644 --- a/chrome/content/overlay.xul +++ b/chrome/content/overlay.xul @@ -26,10 +26,12 @@ </popup> <statusbar id="status-bar"> <statusbarpanel id="redirector-status"> - <menupopup id="redirector-status-popup"> + <!-- Put back in later + <menupopup id="redirector-status-popup" position="at_pointer"> <menuitem label="&RedirectorManageRedirects.label;" accesskey="&RedirectorManageRedirects.accesskey;" oncommand="Redirector.openSettings();" /> <menuitem label="&RedirectorHelp.label;" accesskey="&RedirectorHelp.accesskey;" oncommand="Redirector.openHelp();" /> </menupopup> + --> <image id="redirector-statusbar-img" src="chrome://redirector/content/statusactive.PNG" tooltiptext="Redirector is enabled;" style="width:16px; height:16px;" diff --git a/chrome/content/redirectList.js b/chrome/content/redirectList.js index 30bb64e..5da5ed8 100644 --- a/chrome/content/redirectList.js +++ b/chrome/content/redirectList.js @@ -19,11 +19,9 @@ var RedirectList = { newItem.getElementsByAttribute('name', 'dscrRedirectTo')[0].setAttribute('value', item.redirectUrl); newItem.item = item; list.appendChild(newItem); + newItem.setAttribute("selected", false); } - if (list.children.length > 0) { - list.selectedIndex = 0; - } - list.clearSelection(); + }, onLoad : function() { @@ -32,12 +30,12 @@ var RedirectList = { Redirector.init(); this.lstRedirects = $('lstRedirects'); + this.lstRedirects.selType = 'single'; //For fx3 this.template = document.getElementsByTagName('richlistitem')[0]; this.lstRedirects.removeChild(this.template); this.btnDelete = $('btnDelete'); this.btnEdit = $('btnEdit'); this.addItemsToListBox(Redirector.list); - this.lstRedirects.selectedIndex = -1; } catch(e) { alert(e); } diff --git a/chrome/content/redirectList.xul b/chrome/content/redirectList.xul index ed0a130..e3638b0 100644 --- a/chrome/content/redirectList.xul +++ b/chrome/content/redirectList.xul @@ -16,8 +16,8 @@ <script type="application/x-javascript" src="redirectList.js"/>
<vbox>
- <richlistbox id="lstRedirects" style="margin-bottom:5px; border:solid 1px grey;" height="330px" ondblclick="RedirectList.editRedirect();" onselect="RedirectList.selectionChange();">
- <richlistitem style="border-bottom:dotted 1px grey;">
+ <richlistbox seltype="single" id="lstRedirects" style="margin-bottom:5px; border:solid 1px grey;" height="330px" ondblclick="RedirectList.editRedirect();" onselect="RedirectList.selectionChange();">
+ <richlistitem style="border-bottom:dotted 1px grey;" selected="false">
<grid>
<cols>
</cols>
diff --git a/chrome/content/redirector.js b/chrome/content/redirector.js index 622f170..62966d6 100644 --- a/chrome/content/redirector.js +++ b/chrome/content/redirector.js @@ -266,14 +266,18 @@ var Redirector = { }, openHelp : function() { + var windowName = "redirectorHelp"; var windowsMediator = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator); var win; var iter = windowsMediator.getEnumerator(null); while (iter.hasMoreElements()) { win = iter.getNext(); - alert(win.name); + if (win.name == windowName) { + win.focus(); + return; + } } - //window.openDialog("chrome://redirector/content/help.html", windowName, "chrome,dialog,resizable=yes,location=0,toolbar=0,status=0,width=800px,height=600px,centerscreen", this); + window.openDialog("chrome://redirector/content/help.html", windowName, "chrome,dialog,resizable=yes,location=0,toolbar=0,status=0,width=800px,height=600px,centerscreen", this); }, diff --git a/chrome/content/redirector.tws b/chrome/content/redirector.tws Binary files differnew file mode 100644 index 0000000..b69455f --- /dev/null +++ b/chrome/content/redirector.tws |