MediaWiki:ChatTimestamps/code.js

/*
 * Chat Timestamps
 * @description Create/refine timestamps for each message or alert in chat to be in the format of HH:MM:SS
 * @author Ozuzanna

//Timeout used to give mainRoom a chance to load setTimeout(function {	var time,	seconds,	minutes,	hours;	//add CSS for custom time	mw.util.addCSS('.custom-time { font-weight:normal; color: #9C9C9C; float: right; font-size: 12px;}');

mainRoom.model.chats.bind("afteradd", function (child) {		time = new Date;		hours = time.getHours;		minutes = time.getMinutes;		seconds = time.getSeconds;		if (hours > 12)			hours -= 12;		if (minutes < 10)			minutes = "0" + minutes;		if (seconds < 10)			seconds = "0" + seconds;		//remove existing time, if any		if ($('#entry-' + child.cid).children('.time').length)			$('#entry-' + child.cid).children('.time').remove;		//add the custom time		$('#entry-' + child.cid).append(' ' + hours + ':' + minutes + ':' + seconds + ' ');			}); }, 10000);