MediaWiki:SelectContent.js

/* SelectContent */ /* Description: Display content from the Select menu. @uthor: KhangND */

var containers = $('.sel-container'); var fields = $('.fields');

for (indx = 0; indx < containers.length; indx++) { var cur = indx + 1; var selector = '#select' + cur; var max = $(fields[indx]).children.length / 2; //fields count $(fields[indx]).attr('id', 'select' + cur);

// create $select = $(' ', {       id: 'selector' + cur,        onchange: 'change(' + cur + ')',        appendTo: $(containers[indx])    });

for (i = 1; i <= max; i++) { // create correponding to fields $(' ', {           value: i,            text: $(selector + ' #name' + i).text,            appendTo: $select        }); // hide field names on desktop $(selector + ' #name' + i).css('display', 'none'); // show field 1 upon loaded if (i !== 1) $(selector + ' #field' + i).css('display', 'none'); } }

//Onchange handler function change(indx) { var selector = '#select' + indx; var option = $('#selector' + indx).val; for (i = 1; i <= max; i++) { if (i != option) $(selector + ' #field' + i).css('display', 'none'); else $(selector + ' #field' + i).css('display', ''); } }