MediaWiki:Gadget-FormCheck.js: Difference between revisions
From Tsadra Foundation Advanced Contemplative Scholarships
((by SublimeText.Mediawiker)) |
((by SublimeText.Mediawiker)) |
||
Line 45: | Line 45: | ||
console.log("Fields missing... Solitary hermitage"); | console.log("Fields missing... Solitary hermitage"); | ||
$('.MustField, .SolMustField').each( function(index, value) { | $('.MustField, .SolMustField').each( function(index, value) { | ||
if($(this) === '' ) | if( ($(this) === '') || ($(this).length === 0) ){ | ||
var name = $(this).attr("name"); | |||
console.log( index + ': ' + name ); | |||
} | |||
}); | }); | ||
$('input[name="status"]').val("Saved"); | $('input[name="status"]').val("Saved"); |
Revision as of 08:30, 26 June 2024
$('#TfacsSubmission').ready( function() {
$('.section-nav-toggles').click( function(event) {
setTimeout( function() {
var activeTable = $('.mw-collapsible:not(.mw-collapsed)')
var atOffset = $(activeTable).offset().top
var navBarHeight = $('#mw-navigation').outerHeight()
$([document.documentElement, document.body]).animate({
scrollTop: atOffset - ( navBarHeight * 2 ) - 7
}, 0);
}, "1");
$(this).next().next('.section-nav-toggles').toggle();
$(this).prev().prev('.section-nav-toggles').toggle();
var nextText = 'Next section <i class="fa-duotone fa-diagram-next pl-1"></i>'
var prevText = 'Previous section <i class="fa-duotone fa-diagram-previous pl-1"></i>'
if ( $(this).html() == nextText ) {
$(this).html(prevText);
} else {
$(this).html(nextText);
}
});
function checkForm() {
$('#TfacsSubmission input, #TfacsSubmission select, #TfacsSubmission textarea').prop('disabled', false);
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... Three-year retreat");
$('.MustField, .ThreeMustField').each( function(index, val) {
if( ($(this) === '') || ($(this).length === 0) ){
var name = $(this).attr("name");
console.log( index + ': ' + name );
}
});
$('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... Solitary hermitage");
$('.MustField, .SolMustField').each( function(index, value) {
if( ($(this) === '') || ($(this).length === 0) ){
var name = $(this).attr("name");
console.log( index + ': ' + name );
}
});
$('input[name="status"]').val("Saved");
}
} else {
console.log("Retreat type not set." + $('select[name="retreattype[]"]').val());
}
}
if( ($('input[name="status"]').val() === 'Saved') || $('input[name="status"]').val() === 'Complete' ) {
jQuery(document).ready( checkForm() );
$('#TfacsSubmission input, #TfacsSubmission select, #TfacsSubmission textarea').on( "keyup", checkForm() );
} else {
$('#TfacsSubmission input, #TfacsSubmission select, #TfacsSubmission textarea').not('#DummyField, #TfacsSubmitApplication').prop('disabled', true);
}
})