MediaWiki:Gadget-togglePatrollerRequests.js

/** * A toggle script for hiding "patrol-requests". * This is basically just a function for hiding/redisplaying a heading with its underlying conversation. * * Created by User:Jack McKalling */ $(document).ready(function {	/**	 * Create a handler for toggling the display of "empty" headings along with their content	 * TODO: differentiate the toggling by status rather than just "all"	 * @param booShow boolean whether to display or hide the "empty" headings	 */	function toggleEmptyHeadings(booShow) {		$("h2").nextAll("h3").each(function { var headingContent = $(this).nextUntil("h3"); if (headingContent.length > 0 // if heading has content at all           &&  headingContent.is(function { return $(this).is(".patrol-request-hide"); }) // and contains finished requests            && !headingContent.is(function { return $(this).is(".patrol-request"); })) { // but no unfinished ones if (booShow) $(this).show; else $(this).hide; }   	});	}	/**	 * Create a handler for displaying hideable patrol requests	 */    $(".patrol-request-toggle-show").on("click", function { $(".patrol-request-hide").next("dl").show; $(".patrol-request-hide").show; toggleEmptyHeadings(true); });   /**     * Create a handler for hiding hideable patrol requests     */    $(".patrol-request-toggle-hide").on("click", function { $(".patrol-request-hide").next("dl").hide; $(".patrol-request-hide").hide; toggleEmptyHeadings(false); }); });