diff options
author | Einar Egilsson | 2008-01-01 21:40:32 +0000 |
---|---|---|
committer | Einar Egilsson | 2008-01-01 21:40:32 +0000 |
commit | 0ee5f981f3e708246674d26f8a26fc9b6d8f5fc9 (patch) | |
tree | cec3968640052197f028f4701f94ac7689f3e06a /chrome/content/redirect.js | |
parent | d30ede45e7ff0624ca4a1bcc565c344a6df23ee2 (diff) |
git-svn-id: http://einaregilsson.googlecode.com/svn/mozilla/redirector/trunk@101 119bf307-c92d-0410-89bd-8f53e6181181
Diffstat (limited to 'chrome/content/redirect.js')
-rw-r--r-- | chrome/content/redirect.js | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/chrome/content/redirect.js b/chrome/content/redirect.js index 08af778..be6cb96 100644 --- a/chrome/content/redirect.js +++ b/chrome/content/redirect.js @@ -8,9 +8,10 @@ var Redirect = { $('txtExampleUrl').value = item.exampleUrl; $('txtPattern').value = item.pattern; $('txtRedirectUrl').value = item.redirectUrl || ''; + $('txtExcludePattern').value = item.excludePattern || ''; $('chkOnlyIfLinkExists').checked = item.onlyIfLinkExists || false; - $('txtPattern').focus(); + $('txtPattern').focus(); this.strings = document.getElementById("redirector-strings"); if (item.patternType == kRedirectorRegex) { @@ -30,6 +31,7 @@ var Redirect = { } item.exampleUrl =$('txtExampleUrl').value; item.redirectUrl = $('txtRedirectUrl').value; + item.excludePattern = $('txtExcludePattern').value; item.onlyIfLinkExists = $('chkOnlyIfLinkExists').checked; item.saved = true; @@ -37,22 +39,32 @@ var Redirect = { }, testPattern : function() { - var redirectUrl, pattern, example, extName; + var redirectUrl, pattern, excludePattern, example, extName, isExcluded; redirectUrl = $('txtRedirectUrl').value; pattern = $('txtPattern').value; + excludePattern = $('txtExcludePattern').value; example = $('txtExampleUrl').value; extName = this.strings.getString('extensionName'); if ($('rdoRegex').selected) { redirectUrl = Redirector.regexMatch(pattern, example, redirectUrl); + if (excludePattern) { + isExcluded = Redirector.regexMatch(excludePattern, example, 'exclude'); + } } else { redirectUrl = Redirector.wildcardMatch(pattern, example, redirectUrl); + if (excludePattern) { + isExcluded = Redirector.wildcardMatch(excludePattern, example, 'exclude'); + } } - if (redirectUrl || (redirectUrl === '' && $('txtRedirectUrl').value === '')) { + var isRedirectMatch = redirectUrl || (redirectUrl === '' && $('txtRedirectUrl').value === ''); + if (isRedirectMatch && !isExcluded) { RedirLib.msgBox(extName, this.strings.getFormattedString('testPatternSuccess', [pattern, example, redirectUrl])); + } else if (isExcluded) { + RedirLib.msgBox(extName, this.strings.getFormattedString('testPatternExclude', [example, excludePattern])); } else { RedirLib.msgBox(extName, this.strings.getFormattedString('testPatternFailure', [pattern, example])); } |