Jump to content

User:SarahStierch/vector.js: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
No edit summary
added userinfo.js
Line 9: Line 9:


importScript("User:Writ Keeper/Scripts/teahouseTalkbackLink.js");
importScript("User:Writ Keeper/Scripts/teahouseTalkbackLink.js");
importScript("User:PleaseStand/userinfo.js");


addOnloadHook(teahouseMenu);
addOnloadHook(teahouseMenu);

Revision as of 16:30, 21 April 2012

addOnloadHook(teahouseNavbar);

function teahouseNavbar()
{
var theDiv = document.getElementById("teahouseNavbar");
if(theDiv != null)
theDiv.style.display="";
}

importScript("User:Writ Keeper/Scripts/teahouseTalkbackLink.js");
importScript("User:PleaseStand/userinfo.js");

addOnloadHook(teahouseMenu);
 
function teahouseMenu()
{
	if(wgPageName.substring(0,5) == "User:" || wgPageName.substring(0,10) == "User_talk:")
	{
		var pageMoves
		pageMoves = document.getElementById("ca-pagemoves");
		if(pageMoves == null)
		{
			pageMoves = document.getElementById("ca-move");
		}
		var inviteEntry = document.createElement("li");
		var talkbackEntry = document.createElement("li");
		var inviteForm = populateListEntry(inviteEntry);
		var talkbackForm = populateListEntry(inviteEntry);
		inviteForm.id = "THInviteButton";
		talkbackForm.id = "THTalkbackButton";
		inviteForm.innerHTML = "<a href = '#' onclick = 'postTHInvite(); return;' title = 'Post an invitation to the Teahouse'>TH Invite</a>";
		talkbackForm.innerHTML = "<a href = '#' onclick = 'postTHTalkback(); return;' title = 'Post talkback for the Teahouse'>TH Talkback</a>";
		pageMoves.parentNode.insertBefore(inviteEntry, pageMoves);
		pageMoves.parentNode.insertBefore(talkbackEntry, pageMoves);
	}
}
 
function populateListEntry(listEntry)
{
	var form = document.createElement("form");
	var slashLocation = wgTitle.indexOf("/");
	form.style.display = "inline-block";
	form.method = "POST";
	if(slashLocation > 0)
	{
		form.action = "http://en.wikipedia.org/wiki/User_talk:" + wgTitle.substring(0, wgTitle.indexOf("/")) + "?action=submit&section=new";
	}
	else
	{
		form.action = "http://en.wikipedia.org/wiki/User_talk:" + wgTitle + "?action=submit&section=new";
	}
	listEntry.appendChild(form);
	return form;
}
 
function postTHInvite()
{	
	var date = new Date();
	var inviteEntry = document.getElementById("THInviteButton");
	inviteEntry.innerHTML = inviteEntry.innerHTML + '<input type="hidden" name="wpTextbox1" value="{{Wikipedia:Teahouse/Invitation}} I, and the rest of the hosts, would be more than happy to answer any questions you have! ~~'+'~~">\n<input type="hidden" name="wpSection" value="new">\n<input type="hidden" name="wpEditToken" value="' + mw.user.tokens.get( 'editToken' ) + '">\n<input type="hidden" name="wpStarttime" value="' + date.getYear() + (date.getMonth() + 1) + date.getDate() + date.getHours() + date.getMinutes() + date.getSeconds() + '">\n<input type="hidden" name="wpEdittime" value="' + date.getYear() + (date.getMonth() + 1) + date.getDate() + date.getHours() + date.getMinutes() + date.getSeconds() + '">\n<input type="hidden" name="wpSummary" value="Welcome to Wikipedia: check out the Teahouse!">';
	inviteEntry.submit();
}
 
function postTHTalkback()
{
	var date = new Date();
	var talkbackEntry = document.getElementById("THTalkbackButton");
	talkbackEntry.innerHTML = talkbackEntry.innerHTML + '<input type="hidden" name="wpTextbox1" value="{{Wikipedia:Teahouse/Teahouse talkback|WP:Teahouse/Questions|ts='+'~~'+'~~'+'}}">\n<input type="hidden" name="wpSection" value="new">\n<input type="hidden" name="wpEditToken" value="' + mw.user.tokens.get( 'editToken' ) + '">\n<input type="hidden" name="wpStarttime" value="' + date.getYear() + (date.getMonth() + 1) + date.getDate() + date.getHours() + date.getMinutes() + date.getSeconds() + '">\n<input type="hidden" name="wpEdittime" value="' + date.getYear() + (date.getMonth() + 1) + date.getDate() + date.getHours() + date.getMinutes() + date.getSeconds() + '">\n<input type="hidden" name="wpSummary" value="Teahouse talkback: you\'ve got messages!">';
	talkbackEntry.submit();
}