From 0ee5f981f3e708246674d26f8a26fc9b6d8f5fc9 Mon Sep 17 00:00:00 2001 From: Einar Egilsson Date: Tue, 1 Jan 2008 21:40:32 +0000 Subject: git-svn-id: http://einaregilsson.googlecode.com/svn/mozilla/redirector/trunk@101 119bf307-c92d-0410-89bd-8f53e6181181 --- chrome/content/redirect.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'chrome/content/redirect.js') 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])); } -- cgit v1.2.3-70-g09d2