User:Saftzie/common.js

// importScript('User:Tyilo/peng_test.js'); /* */ // ============================================================ // Author: User:Quarenon // Name: pengLocations.js // Version: 1.0 // Description: Adds row marking to the penguin locations //             table on the DnD Locations article. // ============================================================ $(document).ready(function {	var pengCookieLen = 20;	var pengCookie = getCookie('pengLocations').split();	var pengHidden = false;	function pengHighlight(el, val) {		var cssText = ;		if (val == '2') {			cssText = '#CCC !important';		} else if (val == '1') {			cssText = '#CFC !important';		}		$(el).css('background-color', cssText); //		if (pengHidden) { //			$(el).children('td:not(.pengToggle)').css('background-color', cssText); //		} else { //			$(el).children('td').css('background-color', cssText); //		}	}	function pengSave {		setCookie('pengLocations', pengCookie.join(''), 7);	}	if (wgPageName == 'User:Saftzie/Sandbox') { // (wgPageName == 'Distractions_and_Diversions_Locations' || wgPageName == 'Distractions_and_Diversions_Locations/Penguin_Hide_and_Seek') { alert("Version: 1");		while (pengCookie.length < pengCookieLen) { pengCookie.push('0'); }		$('#penglocations tr').each(function(i) {			pengHighlight(this, pengCookie[i]);			$(this).mouseover(function { pengHighlight(this, 2); }).mouseout(function { pengHighlight(this, pengCookie[i]); }).click(function(e) { if(e.target.tagName === 'A') { // Don't highlight when clicking links return; }				pengCookie[i] = 1 - pengCookie[i]; pengHighlight(this, pengCookie[i]); pengSave; });		});		$('#penglocations').append(			$(' ').append( $(' ').attr('colspan', '7').append(					$(' ').attr('type', 'button').val('Reset marked locations').click(function { $('#penglocations tr').each(function(i) {							pengCookie[i] = '0';							pengHighlight(this, pengCookie[i]);						}); /* .each(function(i) { */						pengSave;					}) /* .click(function { */				).append( /* .append( */ $(' ').attr('type', 'button').val('Toggle visibility').click(function {						// $('#penglocations img').hide;						if (pengHidden) {							$("#penglocations .pengToggle").show;						} else {							$("#penglocations .pengToggle").hide;						}						pengHidden = !pengHidden;						// var cells = document.getElementById('penglocations').getElementsByClassName('pengToggle');						// alert('Hey!');						// alert(cells.length);					}) /* .click(function { */				) /* .append( */			) /* .append( */		); /* .append( */	} /* if (wgPagename) { */ }); /* (document).ready(function { */ /* */