From a62300554bc3c4f0e5df918fef40c57fef521974 Mon Sep 17 00:00:00 2001 From: Einar Egilsson Date: Sat, 2 Jun 2007 23:53:51 +0000 Subject: git-svn-id: http://einaregilsson.googlecode.com/svn/mozilla/redirector/trunk@58 119bf307-c92d-0410-89bd-8f53e6181181 --- chrome/content/redirect.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'chrome/content/redirect.js') diff --git a/chrome/content/redirect.js b/chrome/content/redirect.js index 5be85f7..f4609e3 100644 --- a/chrome/content/redirect.js +++ b/chrome/content/redirect.js @@ -10,6 +10,8 @@ var Redirect = { $('txtRedirectUrl').value = item.redirectUrl || ''; $('chkOnlyIfLinkExists').checked = item.onlyIfLinkExists || false; + this.strings = document.getElementById("redirector-strings"); + if (item.patternType == kRedirectorRegex) { $('rdoRegex').setAttribute('selected', true); $('rdoWildcard').setAttribute('selected', false); @@ -34,9 +36,25 @@ var Redirect = { }, testPattern : function() { - var match; + var redirectUrl, pattern, example, extName; + + redirectUrl = $('txtRedirectUrl').value; + pattern = $('txtPattern').value; + example = $('txtExampleUrl').value; + + extName = this.strings.getString('extensionName'); - alert(Redirector.wildcardMatch($('txtPattern').value, $('txtExampleUrl').value)); + if ($('rdoRegex').selected) { + redirectUrl = Redirector.regexMatch(pattern, example, redirectUrl); + } else { + redirectUrl = Redirector.wildcardMatch(pattern, example, redirectUrl); + } + + if (redirectUrl || (redirectUrl === '' && $('txtRedirectUrl').value === '')) { + RedirLib.msgBox(extName, this.strings.getFormattedString('testPatternSuccess', [pattern, example, redirectUrl])); + } else { + RedirLib.msgBox(extName, this.strings.getFormattedString('testPatternFailure', [pattern, example])); + } } }; \ No newline at end of file -- cgit v1.2.3-70-g09d2