User:An0num0us/wikia.js

// Highlight Table

//Load multiple cookie from warframe.wikia.com //Check for tables with certain data //If table / get value and split it in single numbers //Save multiple cookies. Amount = table types. Join data with sepPg //For type checker

$(document).ready(function {	//Classes	var ratOver = 'hoverHl',       ratClick = 'freezeHl',        tableClass = '.highlight',        tabExist = $('table'+tableClass);	//Templates	var temps = [		'.weapon',		'.frames'	];	//Table Elements	var $tab = $('table' + tableClass),		$tr = $tab.find('tr');		$td = $tr.find('td');	//Additional	var sepTab = '.',		sepPg = '!',		cookie,		pageName,		cookiePref='HLTab',		code = 0,		cell = [],		base64url = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';	function loadCookie(tabAmount){        var cookieName = cookiePref + '-' + code,			pageCookies,			tableCookies,			iPg,			itab,			i,			j,			k;		cookie=[];		if (getCookie(cookieName) !== null) {            pageCookies = getCookie(cookieName).split(sepPg);            while (cookie.length < tabAmount) {cookie.push([])}            console.log(pageCookies,cookie);        }	}	/*function codeCookie{ for (var i = 0;i 0) { tabCookies +=sepTab } console.log('first',tabCookies,tabInx,cookie); for ( i = 0; i < Math.ceil(cookie[tabInx].length / 6);i++) { console.log('second',Math.ceil(cookie[tabInx].length / 6,cookie[tabInx])); k = cookie[tabInx][6 * i]; console.log('third',k); for (j = 1; j < 6; j++) { k = 2*k + ((6 * i + j < cookie[tabInx.length]) ? cookie[tabInx][6*i + j] : 0); }               tabCookies += base64url.charAt(k); }		}		z++; console.log(z); pageCookies = []; if (getCookie(cookieName) !== null) { pageCookies = getCookie(cookieName).split(sepPg); for (pgInx = 0; pgInx < pageCookies.length; pgInx++) { updated = 1; pageCookies[pgInx] = tabCookies; }		}		if (updated === 0) { pageCookies.push(tableCookies); }		console.log(pageCookies,pageCookies.join(sepPg)); createCookie(cookieName,pageCookies.join(sepPg),365,'/'); }	//Setting Highlight function setHl(el,cs) { $(el).removeClass(ratOver).removeClass(ratClick); switch (cs) { case 1: $(el).addClass(ratOver); break; case 2: $(el).addClass(ratClick); break; default: }	}   if (tabExist.length > 0) { loadCookie(tabExist.length); tabExist.each(function(tabInx){           cell[tabInx] = $(this).find('td');            while (cookie[tabInx].length < cell[tabInx].length) {                cookie[tabInx].push(0);            }            while (cookie[tabInx].length > cell[tabInx].length) {                cookie[tabInx].pop;            }            cell[tabInx].each(function(cellInx){ setHl(this,cookie[tabInx][cellInx]); //Mouse Events $(this).hover(                   function(e){                        if(e.target.className !== 'navboxgroup') setHl(this,1);                    },                    function(e){                        if(e.target.className !== 'navboxgroup') setHl(this,cookie[tabInx][cellInx]);//$(this).removeClass(ratOver);                }).click(function(e){                    if (e.target.tagName !== 'A' && e.target.tagName !== 'IMG' && e.target.className !== 'navboxgroup'){                        cookie[tabInx][cellInx] = 2 - cookie[tabInx][cellInx];                        setHl(this,cookie[tabInx][cellInx]);                        saveCookie;                    }                }); });       });	} });