User:Ultimate Dark Carnage/options.js

/** * ChatOptions * Change how Special:Chat looks and functions using an interface. * Uses cookies to store the changes. * A potential solution to all your chathacks problems. * * Many 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. * TODO: Improve user interface * * @version 2.0.1 * @author Callofduty4 * @author Madnessfan34537 * @author Sactage  */ /** * Table of Contents * 1 - Core functions * 2 - Configurations */ (function($, mw, config){   if (mw.config.get('wgCanonicalSpecialPageName') == 'Chat' || mw.config.get('wgPageName') == 'Special:Chat'){        /* 1 - Core functions */        /**         * Function to set a cookie         * @param cookie_name A string representing the cookie's name         * @param data The value of the cookie to be set         */         function setCookie(cooie_name, data){             var domain = wgServer.split('//')[1];             document.cookie =                 cookie_name + '=' + data +                '; max-age=' + 60*60*24*150 +                '; path=/; domain=' + domain;         }        /**         * Function to get a cookie's value         * @param cookie_name A string representing the cookie's name         * @param pos The index of the value to get from the cookie         * @return The string value of the cookie         */         function getCookie(cookie_name, pos){ var x, y, cookie_array = document.cookie.split(";"); for (var 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]); }	       }         }         /* 2 - Configurations */ /**         * Function to check if a chat options module is enabled * @since 1.3.0 * @author Sactage * @param name The name of the options module * @return boolean */         var modules = config.modules || { "chatHacks": { element: "#chatHacks", enabled: getCookie("customization", 0) === false, loaded: false, load: function{ importScriptPage("User:Ultimate_Dark_Carnage/options.js/chathacks.js", "c"); this.loaded = true; }             },              "tabComplete": { element: "#tabComplete", enabled: getCookie("customization", 1) === false, loaded: false, load: function{ importScriptPage("User:Ultimate_Dark_Carnage/options.js/tabComplete.js"); this.loaded = true; }             },              "multiKick": { element: "#multiKick", enabled: getCookie("customization", 2) === false, loaded: false, load: function{ importScriptPage("User:Ultimate_Dark_Carnage/options.js/multiKick.js"); this.loaded = true; }             },              "multiBan": { element: "#multiBan", enabled: getCookie("customization", 3) === false, loaded: false, load: function{ importScriptPage("User:Ultimate_Dark_Carnage/options.js/multiBan.js"); this.loaded = true; }             },              "multiPM": { element: "#multiPM", enabled: getCookie("customization", 4) === false, loaded: false, load: function{ importScriptPage("User:Ultimate_Dark_Carnage/options.js/multiPM.js"); this.loaded = true; }             },              "stopSideScroll": { element: "#stopSideScroll", enabled: getCookie("customization", 5) === false, loaded: false, load: function{ if (!$('style#stopSideScrollStyle').length){ $(document.head).append($(' ', { "type": "text/css", "id": "stopSideScrollingStyle", text: '.ChatWindow #WikiaPage .Chat .message { \ word-wrap: break-word; \ } \                             '                          }));                      }                      this.loaded = true; }             },              "chatTags": { element: "#multiPM", enabled: getCookie("customization", 6) === false, loaded: false, load: function{ importScriptPage("User:Ultimate_Dark_Carnage/options.js/multiKick.js"); this.loaded = true; }             },              "chatBlockButton": { element: "#multiPM", enabled: getCookie("customization", 7) === false, loaded: false, load: function{ importScriptPage("User:Ultimate_Dark_Carnage/options.js/multiKick.js"); this.loaded = true; }             },              "partyMode": { element: "#multiPM", enabled: getCookie("customization", 8) === false, loaded: false, load: function{ importScriptPage("User:Ultimate_Dark_Carnage/options.js/multiKick.js"); this.loaded = true; }             },              "nightChat": { element: "#multiPM", enabled: getCookie("customization", 9) === false, loaded: false, load: function{ importScriptPage("User:Ultimate_Dark_Carnage/options.js/multiKick.js"); this.loaded = true; }             },              "themeChanger": { element: "#multiPM", enabled: getCookie("customization", 10) === false, loaded: false, load: function{ importScriptPage("User:Ultimate_Dark_Carnage/options.js/multiKick.js"); this.loaded = true; }             }          };          var looks = config.looks || { look: { inlineAlert: getCookie("customization", 11), fontColor: getCookie("customization", 12), fontFamily: getCookie("customization", 13), surroundColor: getCookie("customization", 14), modalIcon: "http://img4.wikia.nocookie.net/__cb20140531235013/dev/images/c/c0/ChatOptionsIcon.png" }         };          if (!$('#ChatOptionsMenu').length){ $('.ChatWindow').append(function{                 var optionsHTML = {                      menuInactive:                        ' Options ',                      menuActive:                        ' \                            \                                 \                                    Options \                                    \                                \                                \                                \                            \                        '                  };                  return $(' ', { 'class': 'ChatOptionsMenu clearfix', 'id': 'ChatOptionsMenu', children: { ".initiate-options": { on: { "click": function{ $(this).parent('#ChatOptionsMenu').html.replaceWith(optionsHTML.menuActive); }                           }                        }                    }                  });              });          }    } })(jQuery, mediaWiki, window.chatOptions);