mirror of
https://github.com/unraid/api.git
synced 2026-02-18 14:08:29 -06:00
refactor: Connect extra origins add current host button
This commit is contained in:
@@ -464,22 +464,15 @@ $('body').on('change keyup', '.js-extraOrigins', function(data) {
|
||||
});
|
||||
|
||||
// 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) {
|
||||
$('body').on('click', '.js-setCurrentHostExtraOrigins', 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);
|
||||
@@ -503,10 +496,14 @@ $('body').on('click', '.js-goToExtraOrigins', function(e) {
|
||||
<div markdown="1" class="<?=$shade?>"><!-- begin allowedOrigins warning -->
|
||||
<dl>
|
||||
<div style="margin-bottom: 2rem;">
|
||||
<span class="orange-text"><i class='fa fa-warning fa-fw'></i> <strong>_(Warning)_</strong></span> <?= sprintf(_('Your current url **%s** is not in the list of allowed origins for this server'), $serverState->host) ?>.
|
||||
<br/>_(For best results, add the current url to extra origins setting field below)_: <a class="js-goToExtraOrigins" href="#extraOriginsSettings">_(Add the current URL to the Extra Origins setting)_</a>
|
||||
<span class="orange-text">
|
||||
<i class='fa fa-warning fa-fw'></i> <strong>_(Warning)_</strong></span>
|
||||
<?= sprintf(_('Your current url **%s** is not in the list of allowed origins for this server'), $serverState->host) ?>.
|
||||
<br/>
|
||||
_(For best results, add the current url to the **Unraid API extra origins** field below then apply the change)_.
|
||||
<br>
|
||||
<dd>
|
||||
<p>Allow Origins:</p>
|
||||
<p>_(Known Origins)_:</p>
|
||||
<ul>
|
||||
<? foreach($serverState->combinedKnownOrigins as $origin): ?>
|
||||
<li><a href="<?= $origin ?>"><?= $origin ?></a></li>
|
||||
@@ -718,7 +715,9 @@ _(Account status)_:
|
||||
:unraidnet_extraorigins_help:
|
||||
|
||||
|
||||
: <button class="js-extraOriginsApply" type="button" onclick="applyExtraOrigins(this)" disabled="disabled">_(Apply)_</button>
|
||||
: <div>
|
||||
<? if ($serverState->combinedKnownOrigins): ?> <button class="js-setCurrentHostExtraOrigins" href="#extraOriginsSettings">_(Add Current Origin)_</button><? endif ?> <button class="js-extraOriginsApply" type="button" onclick="applyExtraOrigins(this)" disabled="disabled">_(Apply)_</button>
|
||||
</div>
|
||||
<!-- // end extra origins -->
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user