User:Kaldari/toolbaralert2.js

function texttype(targetDiv, text, intervalStart, intervalRange, callback){ var textTyperID = ++window.textTyperID; window.textTyper[textTyperID] = new function{ var textFinished = false; this.init = function{ var innerString=""; for(var i = 0; i < text.length; i++){ innerString+=" "+text[i]+" " }				document.getElementById(targetDiv).innerHTML = innerString; window.textTyper[textTyperID].type(0); }		this.type = function(i){ var target = document.getElementById(targetDiv).childNodes; if(i<text.length){ var to = intervalStart-(intervalRange/2); var from = intervalStart+(intervalRange/2); var interval = Math.floor(Math.random*(to-from+1)+from); target[i].style.display = 'inline'; setTimeout(function{					window.textTyper[textTyperID].type(++i);				},interval); }			else{ setTimeout(function{						textFinished=true;				},3000); if(callback) callback; }		}	};	window.textTyper[textTyperID].init; } (function { /*Function to prep variables on page load */	window.textTyperID=0;	window.textTyper = new Array; } );

( function( $, mw ) { $(document).ready(function { //$( '.usermessage' ).hide; var newMsgRevisionId = mw.config.get( 'wgUserNewMsgRevisionId' ); if ( newMsgRevisionId ) { $( '#pt-mytalk a' ).append( ':&#160; ' ); $( '#pt-mytalk a' ).css( {			'border-radius': '3px',			'background-color': '#2e6ebe',			'padding': '4px 10px', 'color': 'white'		} ); texttype('mw-echo-alert', 'You have new messages', 20, 0); } } ); } )( jQuery, mediaWiki );