User:Lelouch Di Britannia/Chat.js/options.js

function setCookie(b,c){var a=wgServer.split("//")[1];document.cookie=b+"="+c+"; max-age="+60*60*24*150+"; path=/; domain="+a}function getCookie(f,e){var a,b,c=document.cookie.split(";");for(var g=0;g<c.length;g++){a=c[g].substr(0,c[g].indexOf("="));b=c[g].substr(c[g].indexOf("=")+1);a=a.replace(/^\s+|\s+$/g,"");if(a==f){var d=b.split(", ");return unescape(d[e])}}}function isEnabled(a){var b;switch(a){case"chatHacks":b=getCookie("customisation",2);break;case"tabComplete":b=getCookie("customisation",4);break;case"multiKick":b=getCookie("customisation",5);break;case"multiPM":b=getCookie("customisation",6);break;case"searchBar":b=getCookie("customisation",7);break;case"stopSideScroll":b=getCookie("customisation",9);break;case"ignoreURL":b=getCookie("customisation",8);break;default:return false}return(b==="true")}var chatOptions={look:{fontColor:getCookie("customisation",1),fontFamily:getCookie("customisation",3),surroundColor:getCookie("customisation",10),selfPostColor:getCookie("customisation",11),backgroundColor:getCookie("customisation",0),modalIcon:"http://www.derehamreclaim.co.uk/_images-pages/icon-hammerSpanner.jpg"},modules:{chatHacks:{element:"#chatHacks",enabled:isEnabled("chatHacks"),loaded:false,load:function{if($("#pingspan").length>0||this.loaded){return}importScriptPage("MediaWiki:Chat.js/options.js/options.js","creepypasta");this.loaded=true}},tabComplete:{element:"#tabComplete",enabled:isEnabled("tabComplete"),loaded:false,load:function{importScriptPage("User:Joeytje50/tabinsert.js","rs");this.loaded=true}},multiKick:{element:"#multiKick",enabled:isEnabled("multiKick"),loaded:false,load:function{if((!wgUserGroups.indexOf("chatmoderator")&&!wgUserGroups.indexOf("sysop")&&!wgUserGroups.indexOf("staff")&&!wgUserGroups.indexOf("helper")&&!wgUserGroups.indexOf("user"))||$("multiKickerButton").length){return}importScriptPage("User:Madnessfan34537/multikick.js","cod");$('Multikick').appendTo(".Write");this.loaded=true}},multiPM:{element:"#multiPM",enabled:isEnabled("multiPM"),loaded:false,load:function{importScriptPage("MediaWiki:Chat.js/multipms.js","cod");this.loaded=true}},searchBar:{element:"#searchBar",enabled:isEnabled("searchBar"),loaded:false,load:function{importScriptPage("MediaWiki:Chat.js/searchbar.js","cod");this.loaded=true}},ignoreURL:{element:"#ignoreURL",enabled:isEnabled("ignoreURL"),loaded:false,load:function{$("head").append('li[data-user="CPwikiCHATlogger"] {display:none;} ');this.loaded=true}},stopSideScroll:{element:"#stopSideScroll",enabled:isEnabled("stopSideScroll"),loaded:false,load:function{$("head").append('#WikiaPage .Chat .message { word-wrap: break-word; } ');this.loaded=true}}}};function updateChatSkin{$("body").css({"background-color":chatOptions.look.surroundColor});$(".WikiaPage").css({"background-color":chatOptions.look.backgroundColor,color:chatOptions.look.fontColor,"font-family":chatOptions.look.fontFamily});$(".Chat").css({"font-family":chatOptions.look.fontFamily});$(".Rail").css({"font-family":chatOptions.look.fontFamily});$(".ChatHeader").css({"background-color":chatOptions.look.backgroundColor,"font-family":chatOptions.look.fontFamily});var c=document.createElement("style");c.innerHTML=".Chat .you{background:"+chatOptions.look.selfPostColor+" !important;}";$("head").append(c);$('.Write [name="message"]').css({color:chatOptions.look.fontColor});$(".Write .message").css({"background-color":chatOptions.look.backgroundColor});$(".ChatHeader .User .username").css({color:chatOptions.look.fontColor});for(var a in chatOptions.modules){if(chatOptions.modules.hasOwnProperty(a)){var b=chatOptions.modules[a];if(typeof b.enabled==="boolean"&&b.enabled&&!b.loaded){b.load}}}}function openOptions{var a=$.showCustomModal("Options",' Colour changes Enter a colour name or colour hex Chat background   Self-post background    Surround    Font colour   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 <option value="Cursive" @font-face{font-family: Cursive; src: url(http://fonts.googleapis.com/css?family=Dr+Sugiyama);} style="font-family:Cursive;">Cursive   <p style="font-size:120%; font-weight:bold; font-style:italic;">Added functionality <input type="checkbox" name="chatHacks" value="chatHacks" id="chatHacks"/> Enable chathacks</a>    <input type="checkbox" name="multiPM" value="multiPM" id="multiPM"/> Enable multi PM</a> <input type="checkbox" name="tabComplete" value="tabComplete" id="tabComplete"/>Enable tab complete</a>   <input type="checkbox" name="searchBar" value="searchBar" id="searchBar"/>Enable search bar</a> <input type="checkbox" name="multiKick" value="multiKick" id="multiKick" />Enable multi kick</a>    <input type="checkbox" name="ignoreURL" value="ignoreURL" id="ignoreURL"/>Ignore URL in main chat <input type="checkbox" name="stopSideScroll" value="stopSideScroll" id="stopSideScroll"/>Stop the sidescroll bar to appear after someone spams ',{id:"optionsWindow",width:600,buttons:[{id:"cancel",message:"Cancel",handler:function{cancelChanges}},{id:"updateCookie",defaultButton:true,message:"Update!",handler:function{updateCookie}}]});$(".close").click(cancelChanges);if(chatOptions.modules.chatHacks.enabled){$("#chatHacks").attr("checked",true)}if(chatOptions.modules.multiPM.enabled){$("#multiPM").attr("checked",true)}if(chatOptions.modules.tabComplete.enabled){$("#tabComplete").attr("checked",true)}if(chatOptions.modules.searchBar.enabled){$("#searchBar").attr("checked",true)}if(chatOptions.modules.multiKick.enabled){$("#multiKick").attr("checked",true)}if(chatOptions.modules.ignoreURL.enabled){$("#ignoreURL").attr("checked",true)}if(chatOptions.modules.stopSideScroll.enabled){$("#stopSideScroll").attr("checked",true)}if(!wgUserGroups.indexOf("chatmoderator")&&!wgUserGroups.indexOf("sysop")&&!wgUserGroups.indexOf("staff")&&!wgUserGroups.indexOf("helper")&&!wgUserGroups.indexOf("vstf")){$("#multiKick").attr("disabled",true)}if(wgServer!=="http://callofduty.wikia.com"){$("#ignoreURL").attr("disabled",true)}$("select option[value='"+chatOptions.look.fontFamily+"']").attr("selected","selected");$("body").append('<div style="height: 100%; width: 100%; z-index: 2000000001; opacity: 0.65; display: block;" data-opacity="0.65" class="blackout"> ')}function cancelChanges{$("#optionsWindow").remove;$(".blackout").remove}function updateCookie{chatOptions.look.backgroundColor=$("#backgroundColourinput").val;chatOptions.look.fontColor=$("#fontColourinput").val;chatOptions.look.fontFamily=$("#fontList").val;chatOptions.look.surroundColor=$("#surroundColourinput").val;chatOptions.look.selfPostColor=$("#selfPostColourinput").val;for(var a in chatOptions.modules){if(chatOptions.modules.hasOwnProperty(a)){var b=chatOptions.modules[a];if(typeof b.element!="undefined"&&$(b.element).attr("checked")){b.enabled=true}else{b.enabled=false}}}setCookie("customisation",chatOptions.look.backgroundColor+", "+chatOptions.look.fontColor+", "+chatOptions.modules.chatHacks.enabled+", "+chatOptions.look.fontFamily+", "+chatOptions.modules.tabComplete.enabled+", "+chatOptions.modules.multiKick.enabled+", "+chatOptions.modules.multiPM.enabled+", "+chatOptions.modules.searchBar.enabled+", "+chatOptions.modules.ignoreURL.enabled+", "+chatOptions.modules.stopSideScroll.enabled+", "+chatOptions.look.surroundColor+", "+chatOptions.look.selfPostColor);updateChatSkin;cancelChanges}if(!$("#chatOptionsButton").length){$(".Rail").prepend('<div id="chatOptionsButton" 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="'+chatOptions.look.modalIcon+'" width="18px"/> Options ')}window.onload=updateChatSkin;