diff --git a/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/Connect.page b/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/Connect.page index 9ec9adfca..ccba90033 100644 --- a/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/Connect.page +++ b/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/Connect.page @@ -468,13 +468,46 @@ const isCommaSeparatedURLs = input => .split(",") .every(value => /^(http|https):\/\/[^ "]+$/.test(value)); -$('body').on('change keyup', '.js-extraOrigins', function(data) { - console.debug('change keyup', data); +// toggle extra origins apply button +function extraOriginsValidateAndToggleDisabled() { validateExtraOrigins(); if (!isExtraOriginsValid) { return $('.js-extraOriginsApply').prop("disabled",true); - } + }i return $('.js-extraOriginsApply').removeAttr('disabled'); +} + +$('body').on('change keyup', '.js-extraOrigins', function(data) { + console.debug('change keyup', data); + extraOriginsValidateAndToggleDisabled(); +}); + +// Add the current URL to the Extra Origins setting on click then focus the input and automatically add the current window's origin +$('body').on('click', '.js-goToExtraOrigins', function(e) { + e.preventDefault(); + + $extraOriginsInput = $('.js-extraOrigins'); + + $('html, body').animate({ + scrollTop: $extraOriginsInput.offset().top + }, 150); + + // if the curent window origin is already in the input, run the validation and enable the apply button + if ($extraOriginsInput.val().includes(window.location.origin)) { + return extraOriginsValidateAndToggleDisabled(); + } + + $extraOriginsInput.focus(); + + if ($extraOriginsInput.val().length > 0) { + // don't overwrite the value of the input, only add to it + $extraOriginsInput.val($extraOriginsInput.val() + ', ' + window.location.origin); + } else { + // ensure the current window.location.origin is not already in the input before adding it + $extraOriginsInput.val(window.location.origin); + } + // run the validation on the field and enable the apply button + extraOriginsValidateAndToggleDisabled(); }); @@ -504,8 +537,9 @@ if (stripos($allowedOrigins.",", "/".$host.",") === false) {
_(Warning)_ . -
_(For best results, use one of these urls)_: +
_(For best results, add the current url to extra origins setting field below)_: _(Add the current URL to the Extra Origins setting)_
+

Allow Origins: