User:Monchoman45/vector.js

/************************************ vector stooff ************************************/ /* Note to self - a lot of this should be common.js w/ import to other relevant skin.js pages */

/* imports */ importScript('User:Monchoman45/common.js'); importScript('User:Monchoman45/toolbar.js'); /* cookie init */ function CheckCookie { if(readCookie('globalJS') == null) { createCookie('globalJS', 'true', 99999); }	$('#ca-watch, #ca-unwatch').before('  JS  '); } $(CheckCookie); function ToggleGlobalJSCookie { if(readCookie('globalJS') == 'true') { createCookie('globalJS', 'false', 99999); document.getElementById('GlobalJSText').innerHTML = 'Off'; }	else { createCookie('globalJS', 'true', 99999); document.getElementById('GlobalJSText').innerHTML = 'On'; }	window.location.reload(true); }

function UserLinks { //The "My" really annoys me. Must kill it	document.getElementById('pt-mytalk').getElementsByTagName('a')[0].innerHTML = 'Talk'; document.getElementById('pt-preferences').getElementsByTagName('a')[0].innerHTML = 'Preferences'; document.getElementById('pt-watchlist').getElementsByTagName('a')[0].innerHTML = 'Watchlist'; document.getElementById('pt-mycontris').getElementsByTagName('a')[0].innerHTML = 'Contribs'; } if(readCookie('globalJS') == 'true') {addOnloadHook(UserLinks);}

//ajax RecentChanges from dev.wikia /* * ADVANCED AJAX AUTO-REFRESHING ARTICLES * Code courtesy of "pcj" of Wowpedia. * Modified to work in my interface and to my liking by Monchoman45 */ if (!window.ajaxPages) {ajaxPages = ['Special:RecentChanges', 'Special:Watchlist', 'Special:Log'];} var ajaxTimer; var doRefresh = true; function preloadAJAXRL { if(readCookie('ajaxload-' + wgPageName) == null) {createCookie('ajaxload-' + wgPageName, 'on', 99999);} ajaxRLCookie = (readCookie('ajaxload-' + wgPageName) == 'on') ? true : false; $('#firstHeading').after(' AJAX: Refresh now    '); $('#ajaxLoadProgress').ajaxSend(function (event, xhr, settings){		if (location.href == settings.url) {$(this).show;}	}).ajaxComplete (function (event, xhr, settings) {		if (location.href == settings.url) {$(this).hide;}	}); $('#ajaxToggle').click(toggleAjaxReload); $('#ajaxToggle').attr('checked', ajaxRLCookie); if (readCookie('ajaxload-' + wgPageName) == 'on') {loadPageData;} } function toggleAjaxReload { if ($('#ajaxToggle').attr('checked') == true) { createCookie('ajaxload-' + wgPageName, 'on', 30); doRefresh = true; loadPageData; }	else { createCookie('ajaxload-' + wgPageName, 'off', 30); doRefresh = false; clearTimeout(ajaxTimer); } } function loadPageData { $('#bodyContent').load(location.href + ' #bodyContent > *', function (data) { 		if (doRefresh) {ajaxTimer = setTimeout('loadPageData;', 60000);}	}); } if(readCookie('globalJS') == 'true') {addOnloadHook(function { 	for (i in ajaxPages) {		if (wgPageName == ajaxPages[i] && $('#ajaxToggle').length == 0) {preloadAJAXRL;}	} });}