User:Suppa chuppa/bubble.js

//

function setCookie(name, value, expires) { name = 'bubble_' + name;

var d = new Date; d.setDate(d.getDate + expires); document.cookie = name + '=' + escape(value) + ((expires == null) ? '' : ';expires=' + d.toGMTString) + ';path=/'; } function getCookie(name) { name = 'bubble_' + name;

if (document.cookie.length > 0) { var start = document.cookie.indexOf(name + '='); if (start != -1) { start = start + name.length + 1; var end = document.cookie.indexOf(';', start); if (end == -1) { end = document.cookie.length; }			return unescape(document.cookie.substring(start, end)); } 	}	return '0'; }

var date;

$.ajax({	url: 'http://runescape.wikia.com/api.php',	dataType: 'json',	data: {		format: 'json',		action: 'query',		page: 'MediaWiki:Communitymessages-notice-msg',		prop: 'revisions',		rvprop: 'timestamp'	},	success: function(response) {		var time = response.query.pages.page.revisions.rev.timestamp + '';		date = new Date(time.substring(0,4), time.substring(5,7)-1, time.substring(8, 10), time.substring(11,13), time.substring(14,16), time.substring(17,19), 0);	} });

var last = getCookie('anon_bubble'); var show = true; if(date && Date.parse(new Date) - Date.parse(date) > 172800000000) show = false; else show = last=='0'?true:false; show=false; if(show && wgUserGroups == null) { $.ajax({		url: 'http://runescape.wikia.com/api.php',		dataType: 'json',		data: {			format: 'json',			action: 'parse', 			page: 'MediaWiki:Communitymessages-notice-msg'		},		success: function(data) {		$(' ' + data.parse.text['*'] + ' ').prependTo('footer#WikiaFooter');

$('#WikiaNotifications').css('position', 'fixed').css('top', 'auto').css('bottom', '5px');

$('a.sprite.close-notification').click(function {			$('#WikiaNotifications').empty;		});

$('span small a').attr('href', '#');

$('#close small a').attr('title', 'Dismiss this message'); $('#close').click(function {			setCookie('anon_bubble', new Date, 7);			$('#WikiaNotifications').empty;		}); }	}); }

//