User:Phillycj/chat2.js

/**************/ /*Chat options*/ /**************/ /* /Change how chat looks using an interface. Uses cookies to store the changes /A potential solution to all your chathacks problems /version 0.1 /Written by Callofduty4 // defining various global variables var backgroundColour = null; var chatHacksEnabled = null; // function to set a cookie function setCookie( cookie_name, data ) { document.cookie = cookie_name + "=" + data + "; max-age=" + 60*60*24*365 + "; path=/; domain=callofduty.wikia.com" ; } // function to get a cookie function getCookie( cookie_name ) { var i, x, y, cookie_array = document.cookie.split(";"); for (i=0; i<cookie_array.length; i++) { x = cookie_array[i].substr(0,cookie_array[i].indexOf("=")); y = cookie_array[i].substr(cookie_array[i].indexOf("=")+1); x = x.replace(/^\s+|\s+$/g,""); if (x == cookie_name) { return unescape(y); }	} } // called when chat is loaded to update the skin function loadChatSkin { var cookie_string = getCookie("customisation"); var style_objects = cookie_string.split(", "); $('.WikiaPage').css({"background-color":style_objects[0]}); if (style_objects[1] == "true") { importScriptPage("User:Phillycj/chat.js","c"); } } function openOptions { $('#optionsWindow').show; $('body').append(' '); } function cancelChanges { $('#optionsWindow').hide; $('.blackout').hide; } function updateCookie { backgroundColour = $('#backgroundColourinput').val if (document.getElementById('chatHacks').checked == 1) { chatHacksEnabled = "true"; }	else { chatHacksEnabled = "false"; }	setDaCookie; updateChatSkin; $('#optionsWindow').hide; $('.blackout').hide; } function updateChatSkin { $('.WikiaPage').css({"background-color":backgroundColour}); if (chatHacksEnabled == "true") { importScriptPage("User:Phillycj/chat.js","c"); } } function setDaCookie { setCookie("customisation", backgroundColour + ", " + chatHacksEnabled); } /* debug stuff function alerter { var message = getCookie("customisation"); alert(message); } $('body').append(' Options [EXPERIMENTAL]   Enter a colour hex   Enable chathacks Update! Cancel  '); $('#optionsWindow').hide; //$('Alerter</a> ').prependTo('.Rail'); //$('<div onclick="loadChatSkin" style="left:50%; margin-left:2px;margin-right:2px; display:inline; text-align: center; cursor: pointer;" align="center">Load</a> ').prependTo('.Rail'); $('<div onclick="openOptions" style="left:50%; margin-left:2px;margin-right:2px; display:inline; text-align: center; cursor: pointer;" align="center">Options</a> ').prependTo('.Rail'); window.onload=loadChatSkin