diff options
Diffstat (limited to 'chrome/content/redirect.js')
-rw-r--r-- | chrome/content/redirect.js | 22 |
1 files changed, 20 insertions, 2 deletions
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 |