Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
/** * DebateTree is a MediaWiki implementation of the dialectic algorithm * * By Sophivorus * * Documentation at https://commons.wikimedia.org/wiki/Help:DebateTree * * DebateTree is available under the GNU General Public License (http://www.gnu.org/licenses/gpl.html) */varDebateTree={/** * Get all the arguments in the page */getArguments:function(){return$('.debatetree').closest('li').add($('.debatetree').closest('li').find('li'));},/** * Get the objections to the given argument */getObjections:function(argument){return$(argument).children('ul').children('li');},/** * Return true if the given argument is sustained */isSustained:function(index,argument){returnDebateTree.getObjections(argument).filter(DebateTree.isSustained).length?false:true;},/** * Add the status to the arguments */addStatus:function(index,argument){varstatus=DebateTree.isSustained(index,argument)?'sustained':'refuted',div=$('<div>').addClass('debatetree-argument debatetree-'+status);$(argument).contents().filter(function(){returnthis.tagName!=='UL';}).wrapAll(div);},/** * Prepend the arrows to the arguments */addArrow:function(index,argument){if(DebateTree.getObjections(argument).length){vararrow=$('<span>').text('►').addClass('debatetree-arrow').click(DebateTree.toggleObjections).click();$(argument).css('list-style','none').children('.debatetree-argument').prepend(arrow);}},/** * Toggle the objections of the clicked argument */toggleObjections:function(event){vararrow=$(this),argument=arrow.closest('li');objections=DebateTree.getObjections(argument);objections.toggle();if(objections.is(':visible')){arrow.text('▼');}else{arrow.text('►');}},/** * Initialization script */init:function(){DebateTree.getArguments().each(DebateTree.addStatus);//args.each( DebateTree.addArrow );//$( '.debatetree-arrow', args ).click();}};$(DebateTree.init);