From b0c6f7a2bff3d57f1c8d05a561dbd0bbca0228ca Mon Sep 17 00:00:00 2001 From: Einar Egilsson Date: Sat, 2 Jun 2007 00:24:35 +0000 Subject: Redirector: All main functionality except Regex working. git-svn-id: http://einaregilsson.googlecode.com/svn/mozilla/redirector/trunk@57 119bf307-c92d-0410-89bd-8f53e6181181 --- chrome/content/redirect.js | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) (limited to 'chrome/content/redirect.js') diff --git a/chrome/content/redirect.js b/chrome/content/redirect.js index cfd2a2e..5be85f7 100644 --- a/chrome/content/redirect.js +++ b/chrome/content/redirect.js @@ -3,29 +3,40 @@ var Redirect = { onLoad : function() { - var params = window.arguments[0]; - $('txtExampleUrl').value = params.inn.url; - $('txtPattern').value = params.inn.url; - $('txtRedirectUrl').value = params.inn.redirect || ''; - + var item = window.arguments[0]; + item.saved = false; + $('txtExampleUrl').value = item.exampleUrl; + $('txtPattern').value = item.pattern; + $('txtRedirectUrl').value = item.redirectUrl || ''; + $('chkOnlyIfLinkExists').checked = item.onlyIfLinkExists || false; + + if (item.patternType == kRedirectorRegex) { + $('rdoRegex').setAttribute('selected', true); + $('rdoWildcard').setAttribute('selected', false); + } }, onAccept : function() { - var params = window.arguments[0]; - - params.out.pattern = $('txtPattern').value; - params.out.patternType = kRedirectorWildcard; - params.out.exampleUrl =$('txtExampleUrl').value; - params.out.redirectUrl = $('txtRedirectUrl').value; - params.out.onlyIfLinkExists = $('chkOnlyIfLinkExists').checked; + var item = window.arguments[0]; + + item.pattern = $('txtPattern').value; + if ($('rdoRegex').selected) { + item.patternType = kRedirectorRegex; + } else { + item.patternType = kRedirectorWildcard; + } + item.exampleUrl =$('txtExampleUrl').value; + item.redirectUrl = $('txtRedirectUrl').value; + item.onlyIfLinkExists = $('chkOnlyIfLinkExists').checked; + item.saved = true; return true; }, testPattern : function() { - try { + var match; + alert(Redirector.wildcardMatch($('txtPattern').value, $('txtExampleUrl').value)); - } catch(e) {alert(e);} } }; \ No newline at end of file -- cgit v1.2.3-70-g09d2