User:Quarenon/dropdown.js

/** * dropdown.js * * Individually customize IP block, file delete, and page delete dropdowns. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */

$(function {	function modifyDropdown(id, dropdown) {		$select = $('select#' + id);

$select.empty; $select.html(' Other reason '); for (var optgroup in dropdown) { var options = dropdown[optgroup];

$optgroup = $(' ').attr('label', optgroup); for (var i in options) { $optgroup.append($(' ').val(options[i]).text(options[i])); }

$select.append($optgroup); }	}

if (wgAction == 'delete') { if (wgNamespaceNumber == 6) { (typeof(customFileDeleteDropdown) == 'object') && modifyDropdown('wpDeleteReasonList', customFileDeleteDropdown); } else { (typeof(customPageDeleteDropdown) == 'object') && modifyDropdown('wpDeleteReasonList', customPageDeleteDropdown); }	} else if (wgPageName == 'Special:Block') { (typeof(customBlockDropdown) == 'object') && modifyDropdown('wpBlockReasonList', customBlockDropdown); } });