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 */         function isEnabled(module){ var c;             switch (module){ case "chatHacks": c = getCookie("customization", 1); break; case "tabComplete": c = getCookie("customization", 2); break; case "multiKick": c = getCookie("customization", 3); break; case "multiBan": c = getCookie("customization", 4); break; case "multiPM": c = getCookie("customization", 5); break; case "stopSideScroll": c = getCookie("customization", 6); break; case "ignoreURL": c = getCookie("customization", 7); break; case "chatTags": c = getCookie("customization", 8); break; case "chatCommands": c = getCookie("customization", 9); break; case "chatBlockButton": c = getCookie("customization", 10); break; default: return false; }         }          var chatOptions = config.chatOptions || { 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);