User:Mfaizsyahmi/object.js

// Hidden Jodl Head. Random position. probability of occurring is 20% for October

// puts Jodl at a random place in page function placeJodl { if ( $('div#jodl').length == 0) return false // terminate if jodl doesn't exist var jodltop = Math.random * ($('body').height-80); var jodlleft = Math.random * ($('body').width-80); $('div#jodl').css({"top":jodltop + "px","left":jodlleft + "px"}); }

// stuff to exec when jodl is taunted by clicking function tauntJodl { if ( $('div#jodl').length == 0) return false // terminate if jodl doesn't exist var num = Math.floor(Math.random*3); if (num == 0) { $('audio#jodl1').get(0).play; } else if (num == 1) { $('audio#jodl2').get(0).play; } else if (num == 2) { $('audio#jodl3').get(0).play; }	placeJodl

//OCTOBER SPECIFIC jodlstatic = Number( $('style.jodl').attr('data-staticopacity') ) + 0.005 $('style.jodl').attr('data-staticopacity', jodlstatic).html('body.mediawiki:after{opacity:' +jodlstatic+ '!important}') var dt = new Date if ( dt.getMonth==10 ) $.cookie("HPW-jodlstatic", jodlstatic, { expires: 33 - dt.getDate }); }

//spawns a Jodl function spawnJodl { if ( $('div#jodl').length ) return false // abort if Jodl already exist $('body').append(' '); $('div#jodl').css({		"background-image":"url(http://images2.wikia.nocookie.net/hitlerparody/images/9/99/Jodlhead.png)",		"position":"absolute",		"width":"80px", "height":"80px",		"z-index":"2012"	}).append('     ' /* problems with older IDM */	).click( function {		tauntJodl	}); placeJodl }

function getSelectionText { var text = ""; if (window.getSelection) { text = window.getSelection.toString; } else if (document.selection && document.selection.type != "Control") { text = document.selection.createRange.text; }	return text; }

//OCTOBER SPECIFIC $('body').append(' ') var jodlstatic = ( $.cookie("HPW-jodlstatic") == null) ?0.04 :Number( $.cookie("HPW-jodlstatic") ) $('style.jodl').attr('data-staticopacity',jodlstatic).html('body.mediawiki:after{opacity:' +jodlstatic+ '!important}') if (Math.random < 0.2) spawnJodl

// monitor Jodl summoning activities jodlMantra = "Jodl" jodlMantrahit = 0 $('.WikiaArticle').unbind('mouseup').mouseup( function (e) {	if ( $('div#jodl').length ) return false	var sel = getSelectionText	var n = jodlMantra.search(sel)	if (n == -1) {		jodlMantrahit = 0	} else if (n == jodlMantrahit) {		jodlMantrahit += sel.length	} else {		jodlMantrahit = 0	}	console.log(sel, jodlMantrahit)	if (jodlMantrahit >=4) {		spawnJodl		$('audio#jodl1').get(0).play;		//alert('jodl summoned!')	} });