All pastes #548782 Raw Edit

Something

public text v1 · immutable
·published 2007-06-07 21:12 UTC
rendered paste body
<div align="center"><script language="JavaScript">

var cookieExp = new Date();
cookieExp.setMonth(cookieExp.getMonth()+1);
/*
var cookiePath = "/research/pjirc/";
var cookieDomain = "127.0.0.1";
*/
var cookiePath = "/chat/";
var cookieDomain = "www.gtanet.com";

var cookieSecure = 0;

var ircNick = getCookie("gtanet_java_irc_nick");

if(ircNick == null)
	ircNick = "Enter your nickname";

function changeDiv(id, text)
{
	if (document.getElementById)
	{
		document.getElementById(id).innerHTML = '';
		document.getElementById(id).innerHTML = text;
	}
	else if (document.all)
	{
		document.all[id].innerHTML = text;
	}
	else if (document.layers)
	{
		document.layers[id].document.open();
		document.layers[id].document.write(text);
		document.layers[id].document.close();
	}
}

function paintLoginBox()
{
	var loginText = "";
	loginText += "<table width=\"400\" height=\"400\"><tr><td valign=\"middle\" align=\"center\">";
	loginText += "<form name=\"loginForm\" id=\"loginForm\" action=\"\" onSubmit=\"javascript:return false\">";
	loginText += "<div style=\"float: left; width: 75px; text-align: left\">Nick: </div><input style=\"width: 300px\" type=\"textbox\" name=\"nick\" value=\""+ircNick+"\"><br /><br />";
	loginText += "<div style=\"float: left; width: 75px; text-align: left\">Channel: </div><select name=\"rooms\" style=\"width: 300px\">";
loginText += "<option value=\"gtaseries\" style=\"color: blue\" selected>[CHAT] GTA Series</option>";
loginText += "<option value=\"gta\">[CHAT] General Chat</option>";
loginText += "<option value=\"pgc\">[CHAT] Public Gang Chat</option>";
loginText += "<option value=\"gtalcs\">[GAME] GTA Liberty City Stories</option>";
loginText += "<option value=\"sanandreas\">[GAME] GTA San Andreas Chat</option>";
loginText += "<option value=\"gtamodding\">[MODS] GTA Modding Chat</option>";
loginText += "<option value=\"myriad\">[ MOD] Myriad Island Chat</option>";
loginText += "<option value=\"gtalc\">[ MOD] GTA Liberty City Chat</option>";
loginText += "<option value=\"vc-mp\">[ MOD] VC:MP :: www.gtamultiplayer.com/vc-mp</option>";
loginText += "<option value=\"sa-mp\">[ MOD] SA:MP :: www.sa-mp.com</option>";
	loginText += "</select><br><br>";
	loginText += "<input type=\"button\" value=\"Start Chatting...\" onClick=\"javascript:checkNickname();\">";
	loginText += "</form>";
	loginText += "</td></tr></table>";
	changeDiv("pjircFrame", loginText);

	document.loginForm.nick.focus();
}

function checkNickname()
{
	if(document.loginForm.nick.value == "" || document.loginForm.nick.value == "Enter your nickname")
		alert("You must enter a nickname.");
	else
	{
		setCookie("gtanet_java_irc_nick", document.loginForm.nick.value, cookieExp, cookiePath, cookieDomain, cookieSecure);
		var appletText = "";
		appletText += "<applet code=IRCApplet.class archive=\"irc.jar,pixx.jar\" width=640 height=400>";
		appletText += "<param name=\"CABINETS\" value=\"irc.cab,securedirc.cab,pixx.cab\">";
		appletText += "<param name=\"host\" value=\"irc.gtanet.com\">";
		appletText += "<param name=\"port\" value=\"8067\">";
		appletText += "<param name=\"nick\" value=\""+document.loginForm.nick.value+"\">";
		appletText += "<param name=\"alternatenick\" value=\""+document.loginForm.nick.value+"2\">";
		appletText += "<param name=\"userid\" value=\"jGNUser\">";
		appletText += "<param name=\"name\" value=\"Java GTANet User\">";
		appletText += "<param name=\"gui\" value=\"pixx\">";
		appletText += "<param name=\"lngextension\" value=\"txt\">";
		appletText += "<param name=\"pixx:lngextension\" value=\"txt\">";
		appletText += "<param name=\"command1\" value=\"join #"+document.loginForm.rooms.value+"\">";
		appletText += "</applet>";
		changeDiv("pjircFrame", appletText);
	}
}

/**
 * Sets a Cookie with the given name and value.
 *
 * name       Name of the cookie
 * value      Value of the cookie
 * [expires]  Expiration date of the cookie (default: end of current session)
 * [path]     Path where the cookie is valid (default: path of calling document)
 * [domain]   Domain where the cookie is valid
 *              (default: domain of calling document)
 * [secure]   Boolean value indicating if the cookie transmission requires a
 *              secure transmission
 */
function setCookie(cName, cValue, cExpires, cPath, cDomain, cSecure)
{
	document.cookie = cName + "=" + escape(cValue) +
		((cExpires) ? "; expires=" + cExpires.toGMTString() : "") +
		((cPath) ? "; path=" + cPath : "") +
		((cDomain) ? "; domain=" + cDomain : "") +
		((cSecure) ? "; secure" : "");
}

/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

/**
 * Deletes the specified cookie.
 *
 * name      name of the cookie
 * [path]    path of the cookie (must be same as path used to create cookie)
 * [domain]  domain of the cookie (must be same as domain used to create cookie)
 */
function deleteCookie(name, path, domain)
{
    if (getCookie(name))
    {
        document.cookie = name + "=" +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}

</script>