From de5fdf8e6a1ef28b0a1acb5ef76eabf7dff0adf5 Mon Sep 17 00:00:00 2001 From: Einar Egilsson Date: Fri, 6 Jan 2012 16:25:18 +0100 Subject: Basic CRUD working --- chrome/js/redirector-ui.js | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'chrome/js/redirector-ui.js') diff --git a/chrome/js/redirector-ui.js b/chrome/js/redirector-ui.js index 643f3f6..79e7fea 100644 --- a/chrome/js/redirector-ui.js +++ b/chrome/js/redirector-ui.js @@ -11,6 +11,7 @@ jQuery.fn.center = function () { } $(document).ready(function() { + $('link').attr('href',$('link').attr('href')+new Date()); var prefs = new RedirectorPrefs(); var strings = StringBundleService.createBundle('chrome://redirector/locale/redirector.properties', LocaleService.getApplicationLocale()); function tr(name) { @@ -121,9 +122,33 @@ $(document).ready(function() { bindRedirect(redirect); $('#redirect-form').center().css('top', '-=40px').show(); } + + function saveRedirect() { + var isNew = !window.editRedirect; + var redirect = isNew ? new Redirect() : window.editRedirect; + redirect.description = $('#description').val(); + redirect.exampleUrl = $('#example-url').val(); + redirect.includePattern = $('#include-pattern').val(); + redirect.excludePattern = $('#exclude-pattern').val(); + redirect.redirectUrl = $('#redirect-to').val(); + redirect.disabled = !$('#redirect-enabled').attr('checked'); + redirect.unescapeMatches = $('#unescape-matches').attr('checked'); + if ($('#regex-pattern').attr('checked')) { + redirect.patternType = Redirect.REGEX; + } else { + redirect.patternType = Redirect.WILDCARD; + } + if (isNew) { + Redirector.addRedirect(redirect); + } + Redirector.save(); + $('#redirect-form').hide(); + databind(); + } $('#redirect-list li div a.edit').live('click', function(ev) { var redirect = $(this.parentNode.parentNode).data('redirect'); + window.editRedirect = redirect; showRedirect(redirect); ev.preventDefault(); }); @@ -131,10 +156,11 @@ $(document).ready(function() { databind(); $('#import').click(importRedirects); $('#export').click(exportRedirects); - $('#new-redirect').click(function() { showRedirect({patternType:Redirect.REGEX});}); + $('#new-redirect').click(function() { window.editRedirect = null; showRedirect({patternType:Redirect.REGEX});}); $('#configure').click(configure); $('#cancel').click(function() { $('#redirect-form').hide();}); $('#configure').click(configure); + $('#save').click(saveRedirect); function configure() { $('#config').show(); -- cgit v1.2.3-70-g09d2