MediaWiki:Gadget-FormCheck.js: Difference between revisions

From Tsadra Foundation Advanced Contemplative Scholarships
((by SublimeText.Mediawiker))
((by SublimeText.Mediawiker))
Line 1: Line 1:
function checkForm() {
$('#TfacsSubmission').ready( function() {
    if( $('select[name="retreattype[]"]').val() === 'Three-year retreat') {
    function checkForm() {
        if( $('.MustField, .ThreeMustField').filter(function() { return this.value === ''; }).length === 0 ) {
        if( $('select[name="retreattype[]"]').val() === 'Three-year retreat') {
             console.log("All filled, setting status to 'Complete'.");
            if( $('.MustField, .ThreeMustField').filter(function() { return this.value === ''; }).length === 0 ) {
             $('input[name="status"]').val("Complete");
                console.log("All filled, setting status to 'Complete'.");
                $('input[name="status"]').val("Complete");
             } else {
                console.log("Fields missing..." + $('select[name="retreattype[]"]').val());
                $('input[name="status"]').val("Saved");
            }
        } else if( $('select[name="retreattype[]"]').val() === 'Solitary hermitage') {
            if( $('.MustField, .SolMustField').filter(function() { return this.value === ''; }).length === 0 ) {
                console.log("All filled, setting status to 'Complete'.");
                $('input[name="status"]').val("Complete");
             } else {
                console.log("Fields missing..." + $('select[name="retreattype[]"]').val());
                $('input[name="status"]').val("Saved");
            }
         } else {
         } else {
             console.log("Fields missing..." + $('select[name="retreattype[]"]').val());
             console.log("Retreat type not set." + $('select[name="retreattype[]"]').val());
            $('input[name="status"]').val("Saved");
        }
    } else if( $('select[name="retreattype[]"]').val() === 'Solitary hermitage') {
        if( $('.MustField, .SolMustField').filter(function() { return this.value === ''; }).length === 0 ) {
            console.log("All filled, setting status to 'Complete'.");
            $('input[name="status"]').val("Complete");
        } else {
            console.log("Fields missing..." + $('select[name="retreattype[]"]').val());
            $('input[name="status"]').val("Saved");
         }
         }
    }
    if( $('input[name="status"]').val() === 'Complete') {
        $('#TfacsSubmission input, #TfacsSubmission select, #TfacsSubmission textarea').not('#TfacsSubmitApplication').prop('disabled', true);
        $('.mw-collapsed').removeClass('mw-collapsed');
        $('.section-nav-toggles').hide();
    } else if( $('input[name="status"]').val() === 'Submitted') {
        $('#TfacsSubmission input, #TfacsSubmission select, #TfacsSubmission textarea').prop('disabled', true);
        $('.mw-collapsed').removeClass('mw-collapsed');
        $('.section-nav-toggles, #TfacsSubmitApplication').hide();
     } else {
     } else {
         console.log("Retreat type not set." + $('select[name="retreattype[]"]').val());
         jQuery(document).ready( checkForm() );
        $('#TfacsSubmission input, #TfacsSubmission select, #TfacsSubmission textarea').on( "keyup", checkForm() );
     }
     }
}
})
if( $('input[name="status"]').val() === 'Complete') {
    $('#TfacsSubmission input, #TfacsSubmission select, #TfacsSubmission textarea').not('#TfacsSubmitApplication').prop('disabled', true);
    $('.mw-collapsed').removeClass('mw-collapsed');
    $('.section-nav-toggles').hide();
} else if( $('input[name="status"]').val() === 'Submitted') {
    $('#TfacsSubmission input, #TfacsSubmission select, #TfacsSubmission textarea').prop('disabled', true);
    $('.mw-collapsed').removeClass('mw-collapsed');
    $('.section-nav-toggles, #TfacsSubmitApplication').hide();
} else {
    jQuery(document).ready( checkForm() );
    $('#TfacsSubmission input, #TfacsSubmission select, #TfacsSubmission textarea').on( "keyup", checkForm() );
}

Revision as of 08:47, 21 May 2024

$('#TfacsSubmission').ready( function() {
    function checkForm() {
        if( $('select[name="retreattype[]"]').val() === 'Three-year retreat') {
            if( $('.MustField, .ThreeMustField').filter(function() { return this.value === ''; }).length === 0 ) {
                console.log("All filled, setting status to 'Complete'.");
                $('input[name="status"]').val("Complete");
            } else {
                console.log("Fields missing..." + $('select[name="retreattype[]"]').val());
                $('input[name="status"]').val("Saved");
            }
        } else if( $('select[name="retreattype[]"]').val() === 'Solitary hermitage') {
            if( $('.MustField, .SolMustField').filter(function() { return this.value === ''; }).length === 0 ) {
                console.log("All filled, setting status to 'Complete'.");
                $('input[name="status"]').val("Complete");
            } else {
                console.log("Fields missing..." + $('select[name="retreattype[]"]').val());
                $('input[name="status"]').val("Saved");
            }
        } else {
            console.log("Retreat type not set." + $('select[name="retreattype[]"]').val());
        }
    }
    if( $('input[name="status"]').val() === 'Complete') {
        $('#TfacsSubmission input, #TfacsSubmission select, #TfacsSubmission textarea').not('#TfacsSubmitApplication').prop('disabled', true);
        $('.mw-collapsed').removeClass('mw-collapsed');
        $('.section-nav-toggles').hide();
    } else if( $('input[name="status"]').val() === 'Submitted') {
        $('#TfacsSubmission input, #TfacsSubmission select, #TfacsSubmission textarea').prop('disabled', true);
        $('.mw-collapsed').removeClass('mw-collapsed');
        $('.section-nav-toggles, #TfacsSubmitApplication').hide();
    } else {
        jQuery(document).ready( checkForm() );
        $('#TfacsSubmission input, #TfacsSubmission select, #TfacsSubmission textarea').on( "keyup", checkForm() );
    }
})