MediaWiki:Gadget-rightsfilter.js: Difference between revisions

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
Content deleted Content added
Applying update ( http://commons.wikimedia.org/w/index.php?diff=57977420&oldid=57959850, http://commons.wikimedia.org/w/index.php?oldid=57977816#New_version_of_rightsfilter.js )
https://secure.wikimedia.org/wikipedia/commons/w/index.php?title=MediaWiki_talk:Gadget-rightsfilter.js&oldid=57990760#Update
Line 13: Line 13:
*/
*/
// Guard against double inclusions
// Guard against double inclusions
if (typeof(filterLists) == 'undefined') {
if ( typeof filterLists === 'undefined' ) {
window.filterLists = {
window.filterLists = {
i18n: {
i18n: {
Line 38: Line 38:
'filter-portlet-description': 'Abrir um filtro interativo baseado em expressões regulares',
'filter-portlet-description': 'Abrir um filtro interativo baseado em expressões regulares',
'filter-gadget-page': 'MediaWiki:Gadget-rightsfilter.js',
'filter-gadget-page': 'MediaWiki:Gadget-rightsfilter.js',
'filter-rights-list-instructions': 'Filtre a lista de privilégios separados por espaços usando uma expressão regular.<br/>',
'filter-rights-list-instructions': 'Filtre a lista de privilégios separados por espaços usando uma expressão regular.',
'filter-other-list-instructions': 'Filtre a representação desta lista em texto simples usando uma expressão regular.<br/>',
'filter-other-list-instructions': 'Filtre a representação desta lista em texto simples usando uma expressão regular.',
'filter-legend': 'Filtro para listas <li>',
'filter-legend': 'Filtro para listas <li>',
'filter-option-added': 'Direitos adicionados',
'filter-option-added': 'Direitos adicionados',
Line 53: Line 53:
}
}
},
},
rightsLogOnly: (document.location.href.indexOf('type=rights') > -1 || document.location.href.indexOf('Log/rights') > -1),
rightsLogOnly: (document.location.href.indexOf( 'type=rights' ) !== -1 || document.location.href.indexOf( 'Log/rights' ) !== -1),
lastClicked: false,
lastClicked: false,
load: function () {
load: function() {
var interface = filterLists.i18n.en;
var portletlink, int = filterLists.i18n.en;


// Define language fallbacks
// Define language fallbacks
Line 62: Line 62:


// Replace default English interface by translation if available
// Replace default English interface by translation if available
$.extend(true, interface, filterLists.i18n[ mw.config.get( 'wgUserLanguage' ) ]);
$.extend( true, int, filterLists.i18n[ mw.config.get( 'wgUserLanguage' ) ] );


// Define interface messages
// Define interface messages
mw.messages.set( interface );
mw.messages.set( int );


// Create portlet link
// Create portlet link
mw.util.addPortletLink(
portletlink = mw.util.addPortletLink(
'p-cactions',
'p-cactions',
'#',
'javascript:filterLists.buildForm()',
mw.msg( 'filter-portlet-text' ),
mw.msg( 'filter-portlet-text' ),
'ca-rxfilter',
'ca-rxfilter',
mw.msg( 'filter-portlet-description' )
mw.msg( 'filter-portlet-description' )
);
);
// Display form
// Bind click handler
$(portletlink).click( function( e ) {
if (window.AutoLoadLogsFilter || mw.util.getParamValue('lifilter') || mw.util.getParamValue('lifilterexpr')) {
e.preventDefault();
filterLists.buildForm();
});
// Display form direclty ?
if ( window.AutoLoadLogsFilter || mw.util.getParamValue( 'lifilter' ) || mw.util.getParamValue( 'lifilterexpr' ) ) {
filterLists.buildForm();
filterLists.buildForm();
}
}
},
},


getURL: function (showPopUp) {
getURL: function( showPopUp ) {
var data = {
var data = {
withJS : mw.msg( 'filter-gadget-page' ),
withJS: mw.msg( 'filter-gadget-page' ),
lifilter : '1',
lifilter: '1',
lifilterexpr : $('#rfRegex').val()
lifilterexpr: $( '#rfRegex' ).val()
},
},
url = window.location.href;
url = window.location.href;
if(!$('#rfCase').attr('checked')) {
if ( !$( '#rfCase' ).attr( 'checked' ) ) {
data.lifiltercase = '1';
data.lifiltercase = '1';
}
}
if(this.lastClicked == '1') {
if ( this.lastClicked == '1' ) {
data.lifilterhilight = '1';
data.lifilterhilight = '1';
}
}
if($('#rfInvert').attr('checked')) {
if ( $( '#rfInvert' ).attr( 'checked' ) ) {
data.lifilterinv = '1';
data.lifilterinv = '1';
}
}
url += ((url.indexOf('?') > -1)? '&' : '?') + $.param(data);
url += ( url.indexOf( '?' ) !== -1 ? '&' : '?' ) + $.param( data );
if (showPopUp) {
if ( showPopUp ) {
prompt('', url);
prompt( '', url );
} else {
} else {
return url;
return url;
Line 105: Line 110:
},
},


buildForm: function () {
buildForm: function() {
var value, casing, inverted, $pageTop, $fieldSet, $legend, $sel,
var value, casing, inverted, fieldsetHtml,
$pageTop, $fieldSet, $legend, $sel,
instructions = (this.rightsLogOnly) ?
instructions = this.rightsLogOnly ?
mw.msg( 'filter-rights-list-instructions' ) :
mw.msg( 'filter-rights-list-instructions' )
mw.msg( 'filter-othe-list-instructions' );
: mw.msg( 'filter-othe-list-instructions' );


$('#ca-rxfilter').hide();
$( '#ca-rxfilter' ).hide();
$pageTop = $('#contentSub, #topbar');
$pageTop = $( '#contentSub, #topbar' );
if (!$pageTop.length) {
if ( !$pageTop.length ) {
return;
return;
}
}


// Set up config
// Set up config
value = mw.util.getParamValue('lifilterexpr');
value = mw.util.getParamValue( 'lifilterexpr' );
casing = (mw.util.getParamValue('lifiltercase') == '1');
casing = mw.util.getParamValue( 'lifiltercase' ) == '1';
inverted = (mw.util.getParamValue('lifilterinv') == '1');
inverted = mw.util.getParamValue( 'lifilterinv' ) == '1';


// Generate the form
// Generate the form
$fieldSet = $('<fieldset id="rightsFilter"></fieldset>');
$fieldSet = $( '<fieldset id="rightsFilter"></fieldset>' ).text( instructions );
$legend = $( '<legend></legend>' ).text( mw.msg( 'filter-legend' ) );
$fieldSet.append( $legend );
fieldsetHtml = '';


if ( this.rightsLogOnly ) {
$fieldSet.append(instructions);
fieldsetHtml += '<select id=rfSelect>';

fieldsetHtml += '<option>' + mw.html.escape(mw.msg( 'filter-option-added' )) + '</option>';
$legend = $('<legend></legend>');
$legend.text(mw.msg( 'filter-legend' ));
fieldsetHtml += '<option>' + mw.html.escape(mw.msg( 'filter-option-removed' )) + '</option>';
fieldsetHtml += '<option>' + mw.html.escape(mw.msg( 'filter-option-added-or-removed' )) + '</option>';
$fieldSet.append($legend);
fieldsetHtml += '<option>' + mw.html.escape(mw.msg( 'filter-option-added-removed-static' )) + '</option>';
if (this.rightsLogOnly) {
$sel = $('<select id=rfSelect></select>');
fieldsetHtml += '</select>';

$sel.append('<option>' + mw.msg( 'filter-option-added' ) + '</option>');
$sel.append('<option>' + mw.msg( 'filter-option-removed' ) + '</option>');
$sel.append('<option>' + mw.msg( 'filter-option-added-or-removed' ) + '</option>');
$sel.append('<option>' + mw.msg( 'filter-option-added-removed-static' ) + '</option>');

$fieldSet.append($sel);
}
}
$fieldSet.append('<label for="rfRegex">' + mw.msg( 'filter-regex-label' ) + '</label><input id="rfRegex">');
fieldsetHtml += '<label for="rfRegex">' + mw.html.escape(mw.msg( 'filter-regex-label' )) + '</label><input id="rfRegex">';
$fieldSet.append('<input id="rfInvert" type="checkbox"><label for="rfInvert">' + mw.msg( 'filter-invert-label' ) + '</label>');
fieldsetHtml += '<input id="rfInvert" type="checkbox"><label for="rfInvert">' + mw.html.escape(mw.msg( 'filter-invert-label' )) + '</label>';


$fieldSet.append('<input id="rfCase" type="checkbox"><label for="rfCase">' + mw.msg( 'filter-case-label' ) + '</label>');
fieldsetHtml += '<input id="rfCase" type="checkbox"><label for="rfCase">' + mw.html.escape(mw.msg( 'filter-case-label' )) + '</label>';
$fieldSet.append('<button type="button" value="0">' + mw.msg( 'filter-filter-button' ) + '</button>');
fieldsetHtml += '<button type="button" value="0">' + mw.html.escape(mw.msg( 'filter-filter-button' )) + '</button>';
$fieldSet.append('<button type="button" value="1">' + mw.msg( 'filter-highlight-button' ) + '</button>');
fieldsetHtml += '<button type="button" value="1">' + mw.html.escape(mw.msg( 'filter-highlight-button' )) + '</button>';
$fieldSet.append('<br/><a href="javascript:filterLists.getURL(true)">' + mw.msg( 'filter-link-text' ) + '</a>');
fieldsetHtml += '<br/><a href="javascript:filterLists.getURL(true)">' + mw.html.escape(mw.msg( 'filter-link-text' )) + '</a>';


// Inject the html into the fieldset
$fieldSet.append( fieldsetHtml );


$pageTop.after($fieldSet);
$pageTop.after( $fieldSet );


//Set passed values
// Set passed values
$('#rfRegex').val(value);
$( '#rfRegex ' ).val( value );
$('#rfCase').attr('checked', !casing);
$( '#rfCase' ).attr( 'checked', !casing );
$('#rfInvert').attr('checked', inverted);
$( '#rfInvert' ).attr( 'checked', inverted );
$('#rfRegex').focus();
$( '#rfRegex' ).focus();


//Bind click and change handlers
// Bind click and change handlers
$('#rightsFilter').find('input').bind('keyup change', function () {
$( '#rightsFilter' ).find( 'input' ).bind( 'keyup change', function(e) {
filterLists.filterLi();
filterLists.filterLi();
});
});
$fieldSet.find('button').click(function () {
$fieldSet.find( 'button' ).click( function(e) {
filterLists.lastClicked = $(this).val();
filterLists.lastClicked = $(this).val();
filterLists.filterLi();
filterLists.filterLi();
});
});


if (value) {
if ( value ) {
this.filterLi(mw.util.getParamValue('lifilterhilight') == '1');
this.filterLi( mw.util.getParamValue( 'lifilterhilight' ) == '1' );
}
}
},
},


filterLi: function (hilight) {
filterLi: function(hilight) {
var type, invert, search, flags, rx, listItems, rightrx;
var type, invert, search, flags, rx, listItems, rightrx;

//grab options from form
// Grab options from form
if (this.rightsLogOnly) {
if ( this.rightsLogOnly ) {
type = $('#rfSelect').attr('selectedIndex');
type = $( '#rfSelect' ).attr( 'selectedIndex' );
}
}
invert = $('#rfInvert').attr('checked');
invert = $( '#rfInvert' ).attr( 'checked' );
search = $('#rfRegex').val();
search = $( '#rfRegex' ).val();
flags = ($('#rfCase').attr('checked')) ? 'ig' : 'g';
flags = $( '#rfCase' ).attr( 'checked' ) ? 'ig' : 'g';
hilight = (hilight || this.lastClicked == '1') ? true : false;
hilight = ( hilight || this.lastClicked == '1' ) ? true : false;


try{
try{
rx = new RegExp(search, flags);
rx = new RegExp( search, flags );
} catch (err){
} catch (err){
mw.log( err );
mw.log( err );
}
}


//grab the list of all <li> in the content
// Grab the list of all <li> in the content
listItems = $('#bodyContent').find('li');
listItems = $( '#bodyContent' ).find( 'li' );
if (!listItems.length) {
if ( !listItems.length ) {
return;
return;
}
}


//the regex used to grab the Special:Log/rights changes
// The regex used to grab the Special:Log/rights changes
rightrx = /^.*?User\:.*? from (.*?) to (.*?) \u200E.*?$/i;
rightrx = /^.*?User\:.*? from (.*?) to (.*?) \u200E.*?$/i;

//iterate
// Iterate
listItems.each(function () {
listItems.each(function() {
var look, oldr, newr, oldrl, newrl, remr, addr,
var look, oldr, newr, oldrl, newrl, remr, addr,
$this = $(this);
$this = $(this);

if (this.rightsLogOnly) {
if ( this.rightsLogOnly ) {
//Special:Log/rights
oldr = $this.text().replace(rightrx, '$1');
// Special:Log/rights
oldr = $this.text().replace(rightrx, '$1' );
newr = $this.text().replace(rightrx, '$2');
newr = $this.text().replace(rightrx, '$2' );
oldrl = oldr.split(', ');
oldrl = oldr.split( ', ' );
newrl = newr.split(', ');
newrl = newr.split( ', ' );
for (var j = 0; j < oldrl.length; j++) {
for ( var j = 0; j < oldrl.length; j++ ) {
for (var k = 0; k < newrl.length; k++) {
for ( var k = 0; k < newrl.length; k++ ) {
if (oldrl[j] == newrl[k]) {
if ( oldrl[j] == newrl[k] ) {
oldrl[j] = '';
oldrl[j] = '';
newrl[k] = '';
newrl[k] = '';
Line 217: Line 224:
addr = newrl.join();
addr = newrl.join();
switch (type) {
switch (type) {
case 0:
case 0:
look = addr;
look = addr;
break;
break;
case 1:
case 1:
look = remr;
look = remr;
break;
break;
case 2:
case 2:
look = remr + ' ' + addr;
look = remr + ' ' + addr;
break;
break;
case 3:
case 3:
look = oldr + ' ' + newr;
look = oldr + ' ' + newr;
break;
break;
}
}
} else {
} else {
Line 235: Line 242:
}
}
$this.show();
$this.show();
$this.css('background-color', '');
$this.css( 'background-color', '' );
if ((look.search(rx) != -1 && !invert) || (look.search(rx) == -1 && invert)) {
if ( ( look.search( rx ) !== -1 && !invert ) || ( look.search( rx ) === -1 && invert ) ) {
if (hilight) {
if ( hilight ) {
$this.css('background-color', '#ffff99');
$this.css( 'background-color', '#ffff99' );
}
}
} else {
} else {
if (!hilight) {
if ( !hilight ) {
$this.hide();
$this.hide();
}
}
Line 249: Line 256:
};
};


//When to enable all this
// When to enable all this
$( document ).ready( function() {
$(function () {
if (mw.config.get( 'wgAction' ) == 'history'
if (
mw.config.get( 'wgAction' ) === 'history'
|| mw.util.getParamValue('lifilter')
|| mw.util.getParamValue( 'lifilter' )
|| (
|| (mw.config.get( 'wgCanonicalSpecialPageName' ) && mw.config.get( 'wgCanonicalSpecialPageName' ).match(/^(Activeusers|CheckUser|Contributions|Ipblocklist|LinkSearch|Log|Search|(Uncategoriz|Unus|Want)ed(categori|templat)es|Wantedfiles|(Short|Long|Ancient|Uncategorized|Unwatched|Wanted|Protected|Deadend|Lonely|New)pages|Fewestrevisions|Withoutinterwiki|(Double|Broken)Redirects|Protectedtitles|CrossNamespaceLinks|Recentchanges|Categories|Disambiguations|Listredirects|GlobalUsers|GlobalBlockList|Listusers|Watchlist|Most(linked|revisions|categories)|Nuke|Whatlinkshere)$/i))) {
mw.config.get( 'wgCanonicalSpecialPageName' )
&& mw.config.get( 'wgCanonicalSpecialPageName' ).match(/^(Activeusers|CheckUser|Contributions|Ipblocklist|LinkSearch|Log|Search|(Uncategoriz|Unus|Want)ed(categori|templat)es|Wantedfiles|(Short|Long|Ancient|Uncategorized|Unwatched|Wanted|Protected|Deadend|Lonely|New)pages|Fewestrevisions|Withoutinterwiki|(Double|Broken)Redirects|Protectedtitles|CrossNamespaceLinks|Recentchanges|Categories|Disambiguations|Listredirects|GlobalUsers|GlobalBlockList|Listusers|Watchlist|Most(linked|revisions|categories)|Nuke|Whatlinkshere)$/i)
)
) {
filterLists.load();
filterLists.load();
}
}

});
});

} // end if (guard)
} // end if guard

Revision as of 12:02, 13 August 2011

/**
 * Log filter script
 *
 * Created by [[w:User:Splarka|Splarka]]
 * Amended by [[b:User:Mike.lifeguard]] & [[User:Lupo]]
 * Partially rewritten by DieBuche
 *
 * <li> element Filter Script, version [0.2]
 * Should currently work on all known skins (with a #contentSub or #topbar)
 *
 * mw.util.wikiGetlink( mw.config.get( 'wgPageName' ) ) + '?' +
 * 'withJS=MediaWiki:Gadget-rightsfilter.js&lifilter=1&lifilterexpr=TEST&lifiltercase&lifilterhilight&lifilterinv'
 */
// Guard against double inclusions
if ( typeof filterLists === 'undefined' ) {
window.filterLists = {
	i18n: {
		'en': {
			'filter-portlet-text': 'Filter',
			'filter-portlet-description': 'Open interactive log entry regex filter thingy',
			'filter-gadget-page': 'MediaWiki:Gadget-rightsfilter.js',
			'filter-rights-list-instructions': 'Regex filter the space-delimited list of rights.',
			'filter-other-list-instructions': 'Regex filter the plain text representation of this list.',
			'filter-legend': 'Filter <li> list',
			'filter-option-added': 'Added rights',
			'filter-option-removed': 'Removed rights',
			'filter-option-added-or-removed': 'Added OR removed',
			'filter-option-added-removed-static': 'Added/removed/static',
			'filter-regex-label': 'Regex string:',
			'filter-invert-label': 'Invert',
			'filter-case-label': 'Case insensitive',
			'filter-filter-button': 'Filter',
			'filter-highlight-button': 'Highlight',
			'filter-link-text': 'Link to this filtered list'
		},
		'pt': {
			'filter-portlet-text': 'Filtro',
			'filter-portlet-description': 'Abrir um filtro interativo baseado em expressões regulares',
			'filter-gadget-page': 'MediaWiki:Gadget-rightsfilter.js',
			'filter-rights-list-instructions': 'Filtre a lista de privilégios separados por espaços usando uma expressão regular.',
			'filter-other-list-instructions': 'Filtre a representação desta lista em texto simples usando uma expressão regular.',
			'filter-legend': 'Filtro para listas <li>',
			'filter-option-added': 'Direitos adicionados',
			'filter-option-removed': 'Direitos removidos',
			'filter-option-added-or-removed': 'Adicionado OU removido',
			'filter-option-added-removed-static': 'Adicionado/removido/estático',
			'filter-regex-label': 'Expressão regular:',
			'filter-invert-label': 'Inverter',
			'filter-case-label': 'Não distinguir maiúsculas e minúsculas',
			'filter-filter-button': 'Filtrar',
			'filter-highlight-button': 'Destacar',
			'filter-link-text': 'Link para esta lista filtrada'
		}
	},
	rightsLogOnly: (document.location.href.indexOf( 'type=rights' ) !== -1 || document.location.href.indexOf( 'Log/rights' ) !== -1),
	lastClicked: false,
	load: function() {
		var portletlink, int = filterLists.i18n.en;

		// Define language fallbacks
		filterLists.i18n['pt-br'] = filterLists.i18n.pt;

		// Replace default English interface by translation if available
		$.extend( true, int, filterLists.i18n[ mw.config.get( 'wgUserLanguage' ) ] );

		// Define interface messages
		mw.messages.set( int );

		// Create portlet link
		portletlink = mw.util.addPortletLink(
			'p-cactions',
			'#',
			mw.msg( 'filter-portlet-text' ),
			'ca-rxfilter',
			mw.msg( 'filter-portlet-description' )
		);
		// Bind click handler
		$(portletlink).click( function( e ) {
			e.preventDefault();
			filterLists.buildForm();
		});
		// Display form direclty ?
		if ( window.AutoLoadLogsFilter || mw.util.getParamValue( 'lifilter' ) || mw.util.getParamValue( 'lifilterexpr' ) ) {
			filterLists.buildForm();
		}
	},

	getURL: function( showPopUp ) {
		var	data = {
				withJS: mw.msg( 'filter-gadget-page' ),
				lifilter: '1',
				lifilterexpr: $( '#rfRegex' ).val()
			},
			url = window.location.href;
		if ( !$( '#rfCase' ).attr( 'checked' ) ) {
			data.lifiltercase = '1';
		}
		if ( this.lastClicked == '1' ) {
			data.lifilterhilight = '1';
		}
		if ( $( '#rfInvert' ).attr( 'checked' ) ) {
			data.lifilterinv = '1';
		}
		url += ( url.indexOf( '?' ) !== -1 ? '&' : '?' ) + $.param( data );
		if ( showPopUp ) {
			prompt( '', url );
		} else {
			return url;
		}
	},

	buildForm: function() {
		var	value, casing, inverted, fieldsetHtml,
			$pageTop, $fieldSet, $legend, $sel,
			instructions = this.rightsLogOnly ?
				mw.msg( 'filter-rights-list-instructions' )
				: mw.msg( 'filter-othe-list-instructions' );

		$( '#ca-rxfilter' ).hide();
		$pageTop = $( '#contentSub, #topbar' );
		if ( !$pageTop.length ) {
			return;
		}

		// Set up config
		value = mw.util.getParamValue( 'lifilterexpr' );
		casing = mw.util.getParamValue( 'lifiltercase' ) == '1';
		inverted = mw.util.getParamValue( 'lifilterinv' ) == '1';

		// Generate the form
		$fieldSet = $( '<fieldset id="rightsFilter"></fieldset>' ).text( instructions );
		$legend = $( '<legend></legend>' ).text( mw.msg( 'filter-legend' ) );
		$fieldSet.append( $legend );
		fieldsetHtml = '';

		if ( this.rightsLogOnly ) {
			fieldsetHtml += '<select id=rfSelect>';
			fieldsetHtml += '<option>' + mw.html.escape(mw.msg( 'filter-option-added' )) + '</option>';
			fieldsetHtml += '<option>' + mw.html.escape(mw.msg( 'filter-option-removed' )) + '</option>';
			fieldsetHtml += '<option>' + mw.html.escape(mw.msg( 'filter-option-added-or-removed' )) + '</option>';
			fieldsetHtml += '<option>' + mw.html.escape(mw.msg( 'filter-option-added-removed-static' )) + '</option>';
			fieldsetHtml += '</select>';
		}
		fieldsetHtml += '<label for="rfRegex">' + mw.html.escape(mw.msg( 'filter-regex-label' )) + '</label><input id="rfRegex">';
		fieldsetHtml += '<input id="rfInvert" type="checkbox"><label for="rfInvert">' + mw.html.escape(mw.msg( 'filter-invert-label' )) + '</label>';

		fieldsetHtml += '<input id="rfCase" type="checkbox"><label for="rfCase">' + mw.html.escape(mw.msg( 'filter-case-label' )) + '</label>';
		fieldsetHtml += '<button type="button" value="0">' + mw.html.escape(mw.msg( 'filter-filter-button' )) + '</button>';
		fieldsetHtml += '<button type="button" value="1">' + mw.html.escape(mw.msg( 'filter-highlight-button' )) + '</button>';
		fieldsetHtml += '<br/><a href="javascript:filterLists.getURL(true)">' + mw.html.escape(mw.msg( 'filter-link-text' )) + '</a>';

		// Inject the html into the fieldset
		$fieldSet.append( fieldsetHtml );

		$pageTop.after( $fieldSet );

		// Set passed values
		$( '#rfRegex ' ).val( value );
		$( '#rfCase' ).attr( 'checked', !casing );
		$( '#rfInvert' ).attr( 'checked', inverted );
		$( '#rfRegex' ).focus();

		// Bind click and change handlers
		$( '#rightsFilter' ).find( 'input' ).bind( 'keyup change', function(e) {
			filterLists.filterLi();
		});
		$fieldSet.find( 'button' ).click( function(e) {
			filterLists.lastClicked = $(this).val();
			filterLists.filterLi();
		});

		if ( value ) {
			this.filterLi( mw.util.getParamValue( 'lifilterhilight' ) == '1' );
		}
	},

	filterLi: function(hilight) {
		var type, invert, search, flags, rx, listItems, rightrx;

		// Grab options from form
		if ( this.rightsLogOnly ) {
			type = $( '#rfSelect' ).attr( 'selectedIndex' );
		}
		invert = $( '#rfInvert' ).attr( 'checked' );
		search = $( '#rfRegex' ).val();
		flags = $( '#rfCase' ).attr( 'checked' ) ? 'ig' : 'g';
		hilight = ( hilight || this.lastClicked == '1' ) ? true : false;

		try{
			rx = new RegExp( search, flags );
		} catch (err){
			mw.log( err );
		}

		// Grab the list of all <li> in the content
		listItems = $( '#bodyContent' ).find( 'li' );
		if ( !listItems.length ) {
			return;
		}

		// The regex used to grab the Special:Log/rights changes
		rightrx = /^.*?User\:.*? from (.*?) to (.*?) \u200E.*?$/i;

		// Iterate
		listItems.each(function() {
			var look, oldr, newr, oldrl, newrl, remr, addr,
				$this = $(this);

			if ( this.rightsLogOnly ) {
				// Special:Log/rights
				oldr = $this.text().replace(rightrx, '$1' );
				newr = $this.text().replace(rightrx, '$2' );
				oldrl = oldr.split( ', ' );
				newrl = newr.split( ', ' );
				for ( var j = 0; j < oldrl.length; j++ ) {
					for ( var k = 0; k < newrl.length; k++ ) {
						if ( oldrl[j] == newrl[k] ) {
							oldrl[j] = '';
							newrl[k] = '';
						}
					}
				}
				remr = oldrl.join();
				addr = newrl.join();
				switch (type) {
					case 0:
						look = addr;
						break;
					case 1:
						look = remr;
						break;
					case 2:
						look = remr + ' ' + addr;
						break;
					case 3:
						look = oldr + ' ' + newr;
						break;
				}
			} else {
				//Any other list of <li> objects
				look = $this.text();
			}
			$this.show();
			$this.css( 'background-color', '' );
			if ( ( look.search( rx ) !== -1 && !invert ) || ( look.search( rx ) === -1 && invert ) ) {
				if ( hilight ) {
					$this.css( 'background-color', '#ffff99' );
				}
			} else {
				if ( !hilight ) {
					$this.hide();
				}
			}
		});
	}
};

// When to enable all this
$( document ).ready( function() {
	if (
		mw.config.get( 'wgAction' ) === 'history'
		|| mw.util.getParamValue( 'lifilter' )
		|| (
			mw.config.get( 'wgCanonicalSpecialPageName' )
			&& mw.config.get( 'wgCanonicalSpecialPageName' ).match(/^(Activeusers|CheckUser|Contributions|Ipblocklist|LinkSearch|Log|Search|(Uncategoriz|Unus|Want)ed(categori|templat)es|Wantedfiles|(Short|Long|Ancient|Uncategorized|Unwatched|Wanted|Protected|Deadend|Lonely|New)pages|Fewestrevisions|Withoutinterwiki|(Double|Broken)Redirects|Protectedtitles|CrossNamespaceLinks|Recentchanges|Categories|Disambiguations|Listredirects|GlobalUsers|GlobalBlockList|Listusers|Watchlist|Most(linked|revisions|categories)|Nuke|Whatlinkshere)$/i)
			)
	) {
		filterLists.load();
	}

});

} // end if guard