Thread:Mathmagician/@comment-93604-20120509230753/@comment-4674838-20120511044733

Pecoes, I modified your version a bit. Now has 2 buttons -- 1 for hiding a single comment and 1 for hiding all comments by that user. There is no list of users now, all comments have show/hide buttons. Will probably add functionality to show/hide message wall posts later as well.

Issue: script doesn't run on page 2, 3, etc. Would be nice if there was a way to make it re-load when you go to previous pages of comments.

$(function {	if (!$('#WikiaArticleComments').length) return;	// configuration, uses default settings if	// external PlonkConfig object hasn't been specified	var config = {		useEffects: false	};	if (typeof(PlonkConfig) != "undefined")		$.extend(config, PlonkConfig);	// These two variables are only used for passing info	// from $('.toggle-button-comments-by-user').click	// to $('.toggle-button-comment').click	var useAllVisibleState = false;	var allVisibleState = true;	// Text and buttons that are displayed	var textHide = ["Hide Post", "Hide Posts By User"];	var textShow = ["Show Post", "Show Posts By User"];	var HTML1 = '' + textHide[0] + ' ';	var HTML2 = '' + textHide[1] + ' ';	// Add in the html	$('.SpeechBubble')	.find('.speech-bubble-message') .prepend(HTML1 + HTML2) .find('.article-comm-text'); // CSS rules for the buttons var shownCSS = { border: '1px solid #CCC', float: 'none', position: 'relative', margin: '0px 10px 0px auto', top: '-6px' };	var hiddenCSS = { border: '1px solid red', float: 'none', position: 'relative', margin: '0px 10px 0px auto', top: '-6px' };	// Styling and handler to	// show/hide a single comment $('.toggle-button-comment') .css(shownCSS) .click(function {		var visible = ($(this).text == textHide[0]);		if (useAllVisibleState) {			visible = allVisibleState;		}		// Hide/show the comment, w or w/o effects		if (config.useEffects) {			$(this).parents('.SpeechBubble').find('.article-comm-text')[visible ? 'hide' : 'show']					('blind', Math.min(800, Math.max(150, Math.round($(this).next.height))) );		} else {			$(this).parents('.SpeechBubble').find('.article-comm-text')			.css('display', visible ? 'none' : 'block');		}		$(this).css(visible ? hiddenCSS : shownCSS);		$(this).text(visible ? textShow[0] : textHide[0]);		if (useAllVisibleState) {			$(this).next.text(visible ? textShow[1] : textHide[1]);			$(this).next.css(visible ? hiddenCSS : shownCSS);		}	});

// Styling and handler to	// show/hide all comments by users $('.toggle-button-comments-by-user') .css(shownCSS) .click(function {		var visible = ($(this).text == textHide[1]);		useAllVisibleState = true;		allVisibleState = visible;		var user = $(this).parents('.SpeechBubble').attr('data-user');		var SpeechBubble = $('.SpeechBubble');		var numComments = SpeechBubble.size;		for (var i = 0; i < numComments; i++) {			if ($(SpeechBubble[i]).attr('data-user') == user) {				$(SpeechBubble[i]).find('.toggle-button-comment').click;			}		}		$(this).text(visible ? textShow[1] : textHide[1]);		useAllVisibleState = false;	}); });