MediaWiki:DiscussionReprimands/code.js

importArticle({   type: "style",    article: "MediaWiki:DiscussionReprimands.css" }); if(!window.hasOwnProperty('dev')) { window.dev = {}; } if(!window.dev.hasOwnProperty('discussions')) { window.dev.discussions = {}; } if(!window.dev.discussions.hasOwnProperty('reprimands')) { window.dev.discussions.reprimands = {}; } if(!window.dev.discussions.reprimands.hasOwnProperty('page')) { window.dev.discussions.reprimands.page = wgFormattedNamespaces[4] + ':Reprimands'; } if(wgPageName === window.dev.discussions.reprimands.page) { $.getJSON(mw.util.wikiScript('api'),{   	action: 'query',    	prop: 'revisions',    	rvprop: 'content',    	titles: 'MediaWiki:Custom-DiscussionReprimands.json',    	format: 'json',    	indexpageids: true,    	q: Math.random    },function(res) {    	displayReprimands(JSON.parse(res.query.pages[res.query.pageids[0]].revisions[0]['*']));    }); function displayReprimands(reprimands) { mw.util.$content.empty.append(       	$(' ',{class: 'wikitable'}).append( $(' ').append(       			$(' ').append( $(' ',{text: 'Username'}), $(' ',{text: 'Reprimands'}), $(' ',{text: 'Date'}), $(' ',{text: 'Reason'}), $(' ',{text: 'Actions'}) )       		),        		$(' ',{class: 'reprimand-list'}) )       );    	reprimands.forEach(function(reprimand, idx) {    	    var count = reprimand.reprimands.length;    	    var sum = reprimand.reprimands.reduce(function(a,b) { return a + b.level; },0);   	    var tr = $(' ').append( $(' ',{rowspan: count}).append(	               $('',{ href: mw.util.getUrl(reprimand.name), text: reprimand.name })                   ),                $(' ',{rowspan: count, text: sum}), $(' '),               $(' '),                $(' ',{rowspan: count}) ).appendTo($('.reprimand-list'));           if(count >= 1) {                tr.find(':nth-child(3)').text(reprimand.reprimands[0].date);                tr.find(':nth-child(4)').text(reprimand.reprimands[0].reason);                reprimand.reprimands.shift;            }             if(count > 1) {                reprimand.reprimands.forEach(function(entry, ids) { $(' ').append(                       $(' ',{text: entry.date}),                        $(' ',{text: entry.reason})                    ).appendTo($('.reprimand-list')); });           }        });        $('.faq .answer').hide; $('.faq .question').click(function {           $(this).next.toggle;        }); } }