diff --git a/changedetectionio/static/js/global-settings.js b/changedetectionio/static/js/global-settings.js index 16ba33e1..f6930547 100644 --- a/changedetectionio/static/js/global-settings.js +++ b/changedetectionio/static/js/global-settings.js @@ -1,19 +1,4 @@ $(document).ready(function () { - function toggle() { - if ($('input[name="application-fetch_backend"]:checked').val() != 'html_requests') { - $('#requests-override-options').hide(); - $('#webdriver-override-options').show(); - } else { - $('#requests-override-options').show(); - $('#webdriver-override-options').hide(); - } - } - - $('input[name="application-fetch_backend"]').click(function (e) { - toggle(); - }); - toggle(); - $("#api-key").hover( function () { $("#api-key-copy").html('copy').fadeIn(); diff --git a/changedetectionio/static/js/vis.js b/changedetectionio/static/js/vis.js new file mode 100644 index 00000000..b3c036ff --- /dev/null +++ b/changedetectionio/static/js/vis.js @@ -0,0 +1,15 @@ +$(document).ready(function () { + + // Lazy Hide/Show elements mechanism + $('[data-visible-for]').hide(); + $(':radio').on('keyup keypress blur change click', function (e) { + $('[data-visible-for]').hide(); + var n = $(this).attr('name') + "=" + $(this).val(); + if (n === 'fetch_backend=system') { + n = "fetch_backend=" + default_system_fetch_backend; + } + $(`[data-visible-for~="${n}"]`).show(); + + }); + $(':radio:checked').change(); +}); \ No newline at end of file diff --git a/changedetectionio/static/js/watch-settings.js b/changedetectionio/static/js/watch-settings.js index 0b419959..25b3f2d2 100644 --- a/changedetectionio/static/js/watch-settings.js +++ b/changedetectionio/static/js/watch-settings.js @@ -1,39 +1,17 @@ $(document).ready(function () { - function toggle() { - if ($('input[name="fetch_backend"]:checked').val() == 'html_webdriver') { - if (playwright_enabled) { - // playwright supports headers, so hide everything else - // See #664 - $('#requests-override-options #request-method').hide(); - $('#requests-override-options #request-body').hide(); - // @todo connect this one up - $('#ignore-status-codes-option').hide(); - } else { - // selenium/webdriver doesnt support anything afaik, hide it all - $('#requests-override-options').hide(); - } - - $('#webdriver-override-options').show(); - - } else if ($('input[name="fetch_backend"]:checked').val() == 'system') { - $('#requests-override-options #request-method').hide(); - $('#requests-override-options #request-body').hide(); - $('#ignore-status-codes-option').hide(); - $('#requests-override-options').hide(); - $('#webdriver-override-options').hide(); - } else { - - $('#requests-override-options').show(); - $('#requests-override-options *:hidden').show(); - $('#webdriver-override-options').hide(); + // Lazy Hide/Show elements mechanism + $('[data-visible-for]').hide(); + $(':radio').on('keyup keypress blur change click', function (e){ + $('[data-visible-for]').hide(); + var n = $(this).attr('name') + "=" + $(this).val(); + if (n === 'fetch_backend=system') { + n = "fetch_backend=" + default_system_fetch_backend; } - } + $(`[data-visible-for~="${n}"]`).show(); - $('input[name="fetch_backend"]').click(function (e) { - toggle(); }); - toggle(); + $(':radio:checked').change(); $('#notification-setting-reset-to-default').click(function (e) { $('#notification_title').val(''); diff --git a/changedetectionio/templates/edit.html b/changedetectionio/templates/edit.html index e6882280..8a0d3172 100644 --- a/changedetectionio/templates/edit.html +++ b/changedetectionio/templates/edit.html @@ -3,6 +3,7 @@ {% from '_helpers.jinja' import render_field, render_checkbox_field, render_button %} {% from '_common_fields.jinja' import render_common_settings_form %} + @@ -124,10 +125,8 @@ {% endif %} -