User:Lost Labyrinth/chat.js

// function to set a cookie function setCookie( cookie_name, data ) { var splitServer = wgServer.split("//"); var domain = splitServer[1]; document.cookie = cookie_name + "=" + data + "; max-age=" + 60*60*24*150 + "; path=/; domain=" + domain ; } // function to get a cookie function getCookie( cookie_name, pos ) { 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) { var style_objects = y.split(", "); return unescape(style_objects[pos]); }	} }

// defining various global variables var backgroundColour = getCookie("customisation", 0); var fontColour = getCookie("customisation", 1); var chatHacksEnabled = getCookie("customisation", 2); var fontChoice = getCookie("customisation", 3); var tabCompleteEnabled = getCookie("customisation", 4); var multiKickEnabled = getCookie("customisation", 5); var multiPMEnabled = getCookie("customisation", 6); var searchBarEnabled = getCookie("customisation", 7); var ignoreURLEnabled = getCookie("customisation", 8); var stopSideScrollEnabled = getCookie("customisation", 9); var surroundColour = getCookie("customsation", 10); var chatHacksLoaded = false; var tabCompleteLoaded = false; var multiKickLoaded = false; var multiKickDisplayer = ""; var ignoreURLDisplayer = ""; //to stop non-admins/chatmods being able to load the multikick script var multiPMLoaded = false; var searchBarLoaded = false; var ignoreURLLoaded = false; var stopSideScrollLoaded = false; // called when chat is loaded to update the skin function loadChatSkin { $('body').css({"background-color":surroundColour}); $('.WikiaPage').css({"background-color":backgroundColour, "color":fontColour, "font-family":fontChoice}); $('.Chat').css({"font-family":fontChoice}); $('.Rail').css({"font-family":fontChoice}); $('.ChatHeader').css({"background-color":backgroundColour, "font-family":fontChoice}); if (chatHacksEnabled == "true") { importScriptPage("User:Monchoman45/ChatHacks.js","c"); chatHacksLoaded = true; }	if (tabCompleteEnabled == "true") { importScriptPage("User:Joeytje50/tabinsert.js","rs"); tabCompleteLoaded = true; }		if (multiKickEnabled == "true") { importScriptPage("User:Madnessfan34537/multikick.js","cod"); $('Multikick').appendTo('.Write'); // to prevent issues with the button not loading multiKickLoaded = true; }	if (multiPMEnabled == "true") { importScriptPage("MediaWiki:Chat.js/multipms.js","cod"); multiPMLoaded = true; }	if (searchBarEnabled == "true") { importScriptPage("MediaWiki:Chat.js/searchbar.js","cod"); searchBarLoaded = true; }	if (ignoreURLEnabled == "true") { $('head').append('li[data-user="URL"] {display:none;} '); ignoreURLLoaded = true; }   if (stopSideScrollEnabled == "true") { $('head').append('#WikiaPage .Chat .message { word-wrap: break-word; } '); stopSideScrollLoaded = true; } } // function to open the options interface function openOptions { $("select option[value='" + fontChoice + "']").attr("selected","selected"); // sets the font selector to the one chosen currently $('#optionsWindow').show; $('body').append(' '); } function cancelChanges { $('#optionsWindow').hide; $('.blackout').hide; } // function to grab all the inputted values and assign them to variables function updateCookie { backgroundColour = $('#backgroundColourinput').val; fontColour = $('#fontColourinput').val; fontChoice = $('#fontList').val; surroundColour = $('#surroundColourinput').val; if (document.getElementById('chatHacks').checked == 1) { chatHacksEnabled = "true"; }	else { chatHacksEnabled = "false"; }	if (document.getElementById('tabComplete').checked == 1) { tabCompleteEnabled = "true"; }	else { tabCompleteEnabled = "false"; }	if (document.getElementById('multiKick').checked == 1) { multiKickEnabled = "true"; }	else { multiKickEnabled = "false"; }	if (document.getElementById('multiPM').checked == 1) { multiPMEnabled = "true"; }	else { multiPMEnabled = "false"; }	if (document.getElementById('searchBar').checked == 1) { searchBarEnabled = "true"; }	else { searchBarEnabled = "false"; }	if (document.getElementById('ignoreURL').checked == 1) { ignoreURLEnabled = "true"; }	else { ignoreURLEnabled = "false"; }	if (document.getElementById('stopSideScroll').checked == 1) { stopSideScrollEnabled = "true"; }	else { stopSideScrollEnabled = "false"; }	setDaCookie; updateChatSkin; $('#optionsWindow').hide; $('.blackout').hide; } // function to update the skin after the settings are saved function updateChatSkin { $('body').css({"background-color":surroundColour}); $('.WikiaPage').css({"background-color":backgroundColour, "color":fontColour, "font-family":fontChoice}); $('.Chat').css({"font-family":fontChoice}); $('.Rail').css({"font-family":fontChoice}); $('.ChatHeader').css({"background-color":backgroundColour, "font-family":fontChoice}); if (chatHacksLoaded == false && chatHacksEnabled == "true" && $('#pingspan').length <= 0) { importScriptPage("User:Monchoman45/ChatHacks.js","c"); chatHacksLoaded = true; }	if (tabCompleteLoaded == false && tabCompleteEnabled == "true") { importScriptPage("User:Joeytje50/tabinsert.js","rs"); }	if (multiKickLoaded == false && multiKickEnabled == "true" && $('#multiKickerButton').length <= 0) { importScriptPage("User:Madnessfan34537/multikick.js","cod"); }	if (multiKickEnabled == "true") { $('Multikick').appendTo('.Write'); // to prevent issues with the button not loading }	if (multiPMLoaded == false && multiPMEnabled == "true") { importScriptPage("MediaWiki:Chat.js/multipms.js","cod"); }	if (searchBarLoaded == false && searchBarEnabled == "true") { importScriptPage("MediaWiki:Chat.js/searchbar.js","cod"); }	if (ignoreURLLoaded == false && ignoreURLEnabled == "true") { $('head').append('li[data-user="URL"] {display:none;} '); }	if (stopSideScrollLoaded == false && stopSideScrollEnabled == "true") { $('head').append('#WikiaPage .Chat .message {word-wrap: break-word; } '); } } // function to set the cookie function setDaCookie { setCookie("customisation", backgroundColour + ", " + fontColour + ", " + chatHacksEnabled + ", " + fontChoice + ", " + tabCompleteEnabled + ", " + multiKickEnabled + ", " + multiPMEnabled + ", " + searchBarEnabled + ", " + ignoreURLEnabled + ", " + stopSideScrollEnabled + ", " + surroundColour); } // functions to check if various scripts are loaded, so the buttons can be checked by default function checkIfChatHacksEnabled { if (chatHacksEnabled == "true") { return("checked"); }	else { return(""); } } function checkIfTabCompleteEnabled { if (tabCompleteEnabled == "true") { return("checked"); }	else { return(""); } } function checkIfMultiKickEnabled { if (multiKickEnabled == "true") { return("checked"); }	else { return(""); } } function checkIfMultiPMEnabled { if (multiPMEnabled == "true") { return("checked"); }	else { return(""); } } function checkIfSearchBarEnabled { if (searchBarEnabled == "true") { return("checked"); }	else { return(""); } } function checkIfIgnoreURLEnabled { if (ignoreURLEnabled == "true") { return("checked"); }	else { return(""); } } function checkIfStopSideScrollEnabled { if (stopSideScrollEnabled == "true") { return("checked"); }	else { return(""); } } // Variables to check various checkboxes var chatHacksChecker = checkIfChatHacksEnabled; var tabCompleteChecker = checkIfTabCompleteEnabled; var multiKickChecker = checkIfMultiKickEnabled; var multiPMChecker = checkIfMultiPMEnabled; var searchBarChecker = checkIfSearchBarEnabled; var ignoreURLChecker = checkIfIgnoreURLEnabled; var stopSideScrollChecker = checkIfStopSideScrollEnabled;