<?php
// Copyright 1999-2022. Plesk International GmbH. All rights reserved.
?>
<script type="text/javascript">
//<![CDATA[

Jsw.onReady(function() {
    //
    // Attach disabling of dependent options to web scripting
    //
    document.querySelectorAll('#webScripting  .single-row').forEach(function (scriptingRow) {
        // Find elements relations information, controlling element is a first non-hidden input or select in a row
        var dependentInputs = Array.prototype.slice.call(scriptingRow.querySelectorAll('input:not([type="hidden"]),select'));
        var controllingInput = dependentInputs.shift();

        // Value of controlling input that disables dependent inputs
        var disablingValue = controllingInput.matches('select')
            ? 'none'
            : null;

        var switcher = function() {
            if (disablingValue === $F(controllingInput)) {
                dependentInputs.forEach(function (input) {
                    input.disabled = true;
                });
            } else {
                dependentInputs.forEach(function (input) {
                    input.disabled = false;
                });
            }
        };

        // Attach handler to controlling input
        controllingInput.addEventListener('click', switcher);

        // Set up initial state
        switcher();
    });
});
//]]>
</script>
