Benutzer:WWWIG/monobook.js: Unterschied zwischen den Versionen

Aus Watch-Wiki
Zur Navigation springen Zur Suche springen
Zeile 103: Zeile 103:
 
function CheckBadWord( t_text ) {
 
function CheckBadWord( t_text ) {
  
for ( t_Word = 0; t_Word < t_blackwordlist.length; t_Word++ ) {
+
if ( t_text ) {
  
if ( t_text.indexOf( t_blackwordlist[t_Word] ) != -1 )return true;
+
for ( t_Word = 0; t_Word < t_blackwordlist.length; t_Word++ ) {
  
 +
if ( String( t_text ).indexOf( t_blackwordlist[t_Word] ) != -1 ) return true;
 +
 +
}
 +
return false;
 
}
 
}
return false;
 
 
}
 
}
  

Version vom 11. September 2010, 11:21 Uhr

/* -- */
// my_vkdebug = true;

addOnloadHook( function () {
    LoadTemCatGenForm();
});

var t_wikiurl = wgServer + wgScriptPath + '/api.php';
var t_Files = new Array();
var t_FilesChecked = new Array();

t_blackwordlist = new Array(
'comment',
'porn',
'angel',
'fire',
'sex',
'animal',
'movies',
'film',
'gift',
'free',
'self',
'young',
'donna',
'teens',
'girls',
'craig',
'generic',
'extend',
'discount',
'pills',
'insurance',
'life',
'valium',
'robaxin',
'vimax',
'xtreme',
'bodybuilding',
'tits',
'total',
'gym',
'reverse',
'number'
);

function LoadTemCatGenForm() {

	if ( document.getElementById( 'InsertcheckRCForm' ) ) {
		out =	'<form method="get" style="width:100%" name="TemCatGenForm">' +
			'<fieldset><legend>Recentchanges</legend>' +
			'<div style="margin-top:.5em; margin-left:1em; margin-right:1em;">' +
			'<p><input type="button" value="Hole RC" ' +
			'title="" onClick="CheckRC()">&nbsp;' +
			'</p>' +
			'<label for="Status" style="vertical-align:top;">Status:</label>' +
			'<p id="Status" style="border: 1px solid #aaa; padding:.5em;height:75px;" > ...</p>' +
			'<div id="PreviewForm"></div>' +
			'<div id="InsertRCForm"></div>' +
			'</div></fieldset></form>';

		document.getElementById( 'InsertcheckRCForm' ).innerHTML = out;
	}
}

function CheckRC() {

	var t_parameters = '?action=query&format=json&list=recentchanges&rclimit=50&rctype=new&rcprop=user|comment|flags|timestamp|title|ids|sizes';
	var t_http_req = null;
	if (window.XMLHttpRequest) {t_http_req = new XMLHttpRequest();}
	else if (window.ActiveXObject) {t_http_req = new ActiveXObject("Microsoft.XMLHTTP");}
	t_http_req.open("GET", t_wikiurl + t_parameters, true);
	t_http_req.onreadystatechange = function() {
		if(t_http_req.readyState != 4) {
			document.getElementById('Status').innerHTML = 'RC-Liste wird angefordert ...';
		}
		if(t_http_req.readyState == 4 && t_http_req.status == 200) {
			GotRC( eval("(" + t_http_req.responseText + ")"), t_http_req.responseText );
		}
	}
	t_http_req.send(null);
}

function GotRC( queryData, rawData ) {

	if ( queryData.query && queryData.query.recentchanges ) {
		for ( t_Change = 0; t_Change < queryData.query.recentchanges.length; t_Change++ ) {
			if ( typeof queryData.query.recentchanges[t_Change].anon != 'undefined' ) {
				var t_File = new Array( queryData.query.recentchanges[t_Change].title,
							queryData.query.recentchanges[t_Change].revid,
							queryData.query.recentchanges[t_Change].user,
							queryData.query.recentchanges[t_Change].comment );
				t_Files.push( t_File );

		        } else {
			}
		}
	}

	CheckTitles();
}

function CheckBadWord( t_text ) {

	if ( t_text ) {

		for ( t_Word = 0; t_Word < t_blackwordlist.length; t_Word++ ) {

			if ( String( t_text ).indexOf( t_blackwordlist[t_Word] ) != -1 ) return true;

		}
		return false;
	}
}

function CheckTitles() {

	document.getElementById( 'InsertRCForm' ).innerHTML = '<hr style="margin-top:1em;"><ul>';

	while ( t_Files.length > 0 ) {
		t_FileToCheck = t_Files.splice( 0, 1 );

		// comment
		if ( CheckBadWord( t_FileToCheck[3] ) ) {
			document.getElementById( 'InsertRCForm' ).innerHTML +=  '<li>' + t_FileToCheck[0]+'/'+t_FileToCheck[1]+'/'+t_FileToCheck[2]+'/'+t_FileToCheck[3] + '</li>';
		}
	}

	document.getElementById( 'InsertRCForm' ).innerHTML += '</ul>';

}