MediaWiki:Chat.js/options.js

/**************/ /*Chat options*/ /**************/ /* /Change how chat looks and functions using an interface. /Uses cookies to store the changes. /A potential solution to all your chathacks problems. /version 1.0.1 /Coded by Callofduty4 and Madnessfan34537 /* /Much thanks to the Call of Duty Wiki Chat, /who supported and helped this the whole way through. /It has been much appreciated. Thank you! /* /WARNING /Make sure you are not loading MediaWiki:Chat.js/load.js /with MediaWiki:Chat-edit-count. /Load it with MediaWiki:Chat-welcome-message, or this /will malfunction badly. /* /To do: /Improve the interface // 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; // **** Stuff to do as soon as chat is loaded **** // Check if user is chatmod or admin if ( $.inArray('chatmoderator', wgUserGroups) > -1 || $.inArray('sysop', wgUserGroups) > -1 ) { multiKickDisplayer = ''; } else { multiKickDisplayer = 'disabled="disabled"'; }

if ( wgServer == 'http://callofduty.wikia.com' ) { ignoreURLDisplayer = ''; } else { ignoreURLDisplayer = 'disabled="disabled"'; } // Add HTML for the interface $('body').append(' Options   Colour changes Enter a colour name</a> or colour hex</a> Chat background <input type="text" name="backgroundColourinput" id="backgroundColourinput" value="' + backgroundColour + '"/>  Surround <input type="text" name="surroundColourinput" id="surroundColourinput" value="' + surroundColour + '"/>   Font colour <input type="text" name="fontColourinput" id="fontColourinput" value="' + fontColour + '"/>  <p style="font-size:120%; font-weight:bold; font-style:italic;">Font  Font family <select id="fontList"><option value="arial" style="font-family:arial;">Arial <option value="courier new" style="font-family:courier new;">Courier new <option value="georgia" style="font-family:georgia;">Georgia <option value="palatino linotype" style="font-family:palatino linotype;">Palatino linotype <option value="Comic Sans MS" style="font-family:Comic Sans MS;">Comic sans <option value="tahoma" style="font-family:tahoma;">Tahoma <option value="Trebuchet MS" style="font-family:Trebuchet MS;">Trebuchet MS <option value="Verdana" style="font-family:Verdana;">Verdana <option value="Lucida Console" style="font-family:Lucida Console;">Lucida Console   <p style="font-size:120%; font-weight:bold; font-style:italic;">Added functionality <input type="checkbox" name="chatHacks" value="chatHacks" id="chatHacks" ' + chatHacksChecker + '/> Enable chathacks</a>    <input type="checkbox" name="multiPM" value="multiPM" id="multiPM" ' + multiPMChecker + '/> Enable multi PM</a> <input type="checkbox" name="tabComplete" value="tabComplete" id="tabComplete" ' + tabCompleteChecker + '/>Enable tab complete</a>   <input type="checkbox" name="searchBar" value="searchBar" id="searchBar" ' + searchBarChecker + '/>Enable search bar</a> <input type="checkbox" name="multiKick" value="multiKick" id="multiKick" '  + multiKickDisplayer +  multiKickChecker + '/>Enable multi kick</a>    <input type="checkbox" name="ignoreURL" value="ignoreURL" id="ignoreURL" ' + ignoreURLDisplayer + ignoreURLChecker + '/>Ignore URL in main chat <input type="checkbox" name="stopSideScroll" value="stopSideScroll" id="stopSideScroll" ' + stopSideScrollChecker + '/>Stop the sidescroll bar to appear after someone spams Update!</a> Cancel</a>  '); $('#optionsWindow').hide; // Hide it to start with // Add Options button $('.Rail').prepend('<div onclick="openOptions" style="margin:auto; cursor: pointer; font-size:150%; bottom:4px; padding-bottom:2px; border-bottom: 1px solid #CCCCCC; width:90%;" align="center"><img src="http://www.derehamreclaim.co.uk/_images-pages/icon-hammerSpanner.jpg" width="18px"/> Options '); window.onload=loadChatSkin // Load the current configuration