Community Central
Community Central
No edit summary
No edit summary
Line 78: Line 78:
 
//Add a RC button
 
//Add a RC button
 
function CreateRecentChangesButtons() {
 
function CreateRecentChangesButtons() {
$('a.wikia-button[data-id$="wikiactivity"]').append('<a data-id="recentchanges" class="wikia-button secondary" accesskey="g" title="RecentChanges" href="/wiki/Special:RecentChanges"><img height="0" width="0" class="sprite activity" src="http://images1.wikia.nocookie.net/common/skins/common/blank.gif">Recent Changes</a>');
+
$('section header div.buttons a:first-child').after('<a data-id="recentchanges" class="wikia-button secondary" accesskey="g" title="RecentChanges" href="/wiki/Special:RecentChanges"><img height="0" width="0" class="sprite activity" src="http://images1.wikia.nocookie.net/common/skins/common/blank.gif">Recent Changes</a>');
 
}
 
}
   

Revision as of 10:45, 31 May 2011

/* Finchelfanno1's chat hacks */
/* get all personal code files in chat */
/* Important: you must click the chat button in the rail for this to work. */
/* Very important: Chat is still a beta feature. Chat hacks may break as the feature is changed and updated, as it is a work in progress. */
$(setTimeout('ChatCheck()', 200));
 
function ChatCheck() {
	if($('.chat-join button').length != 0) {
		$('.chat-join button').replaceWith('<a class="wikia-button" onclick="OpenChatWindow()"><img src="http://images.wikia.com/common/__cb36140/extensions/wikia/Chat/images/chat_icon.png" style="margin-right:3px;">Join the Chat</a>');
	} else {
		setTimeout('ChatCheck()', 200);
	}
}
 
function OpenChatWindow() {
	window.chatwindow = window.open('/index.php?title=Special:Chat&useskin=wikia');
	window.chatwindow.onload = function () {
		//addOnloadHook, importScript, and importStylesheet
		window.chatwindow.$('body').prepend('<script>\nfunction importScript(b){var a=wgScript+"?title="+encodeURIComponent(b.replace(/ /g,"_")).replace(/%2F/ig,"/").replace(/%3A/ig,":")+"&action=raw&ctype=text/javascript";return importScriptURI(a)}\nfunction importScriptURI(a){var b=document.createElement("script");b.setAttribute("src",a);b.setAttribute("type","text/javascript");document.getElementsByTagName("head")[0].appendChild(b);return b}\nfunction importScriptPage(b,d){var a="/index.php?title="+encodeURIComponent(b.replace(/ /g,"_")).replace("%2F","/").replace("%3A",":")+"&action=raw&ctype=text/javascript";if(typeof d=="string"){if(d.indexOf("://")==-1){a="http://"+d+".wikia.com"+a}else{a=d+a}}return importScriptURI(a)}\nfunction importStylesheet(a){return importStylesheetURI(wgScript+"?action=raw&ctype=text/css&title="+encodeURIComponent(a.replace(/ /g,"_")))}\nfunction importStylesheetURI(b,d){var a=document.createElement("link");a.type="text/css";a.rel="stylesheet";a.href=b;if(d){a.media=d}document.getElementsByTagName("head")[0].appendChild(a);return a}\nfunction importStylesheetPage(b,d){var a="/index.php?title="+encodeURIComponent(b.replace(/ /g,"_")).replace("%2F","/").replace("%3A",":")+"&action=raw&ctype=text/css";if(typeof d=="string"){if(d.indexOf("://")==-1){a="http://"+d+".wikia.com"+a}else{a=d+a}}return importStylesheetURI(a)}\n//This isn\'t the same as the regular addOnloadHook, because the regular one runs from a script tag in the body that I don\'t feel like appending. It\'s easier to just make it $(function), which is essentially equivalent\nfunction addOnloadHook(func) {$(func);}\n</script>');
		//global.js
		window.chatwindow.importScriptURI('http://community.wikia.com/index.php?title=User:' + wgUserName + '/global.js&action=raw&ctype=text/javascript');
		//wikia.js
		window.chatwindow.importScriptURI(wgServer + '/index.php?title=User:' + wgUserName + '/wikia.js&action=raw&ctype=text/javascript');
		//global.css
		window.chatwindow.importStylesheetURI('http://community.wikia.com/index.php?title=User:' + wgUserName + '/global.css&action=raw&ctype=text/css');
		//wikia.css
		window.chatwindow.importStylesheetURI(wgServer + '/index.php?title=User:' + wgUserName + '/wikia.css&action=raw&ctype=text/css');
 
		//These are my chat hacks. If you don't want them, you can delete this line.

//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;
	appTo = ($('#WikiaPageHeader').length) ? $('#WikiaPageHeader') : $('.firstHeading');
	appTo.append('&nbsp;<span style="font-size: xx-small; line-height: 100%;" id="ajaxRefresh"><span id="ajaxToggleText">AJAX:</span><input type="checkbox" style="position:relative; top:2px;" id="ajaxToggle"><a onclick="loadPageData()" style="cursor:pointer; margin-top:1px;" class="wikia-button secondary">Refresh now</a>&nbsp;&nbsp;<span style="display: none;" id="ajaxLoadProgress"><img src="http://images2.wikia.nocookie.net/dev/images/8/82/Facebook_throbber.gif" style="vertical-align: baseline;" border="0" alt="Refreshing page" /></span></span>');
	$('#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(); CustomRollbacks();}
	});
	$('#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() {
	cC = ($('#WikiaArticle').length) ? '#WikiaArticle' : '#bodyContent';
	$(cC).load(location.href + ' ' + cC + ' > *', function (data) { 
		if (doRefresh) {ajaxTimer = setTimeout('loadPageData();', 60000);}
	});
}
if(readCookie('globalJS' + wgUserName) == 'true') {addOnloadHook(function () { 
	for (i in ajaxPages) {
		if (wgPageName == ajaxPages[i] && $('#ajaxToggle').length == 0) {preloadAJAXRL();}
	}
});}

//Add a RC button
function CreateRecentChangesButtons() {
        $('section header div.buttons a:first-child').after('<a data-id="recentchanges" class="wikia-button secondary" accesskey="g" title="RecentChanges" href="/wiki/Special:RecentChanges"><img height="0" width="0" class="sprite activity" src="http://images1.wikia.nocookie.net/common/skins/common/blank.gif">Recent Changes</a>');
}

addOnloadHook(CreateRecentChangesButtons);