User:Auron~Guardian/ChatPlugins.js

if (typeof(FlashTitle)=="undefined") { //Make sure Monchoman45's ChatHacks isn't loaded /** * Wikia ChatPlugins * Change some options on Special:Chat to make it easier * to use and more useful in general. * * 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. * * Created from ChatOptions * by Callofduty4, Madnessfan34537, and Sactage */

// Load Dependencies if (typeof(api)=="undefined") { importScriptPage('Stable/API/code.js', 'gamedezyner'); } if (typeof(chatPluginsCustom)!="undefined") { if (typeof(chatPluginsCustom.staffIcon)=="undefined") { chatPluginsCustom.staffIcon = "http://img1.wikia.nocookie.net/__cb20140626173406/gamedezyner/images/6/60/StaffIcon.png"; } if (typeof(chatPluginsCustom.modIcon)=="undefined") { chatPluginsCustom.modIcon= "http://img1.wikia.nocookie.net/__cb20140626173343/gamedezyner/images/8/89/ModIcon.png"; } if (typeof(chatPluginsCustom.pingSound)=="undefined") { chatPluginsCustom.pingSound = "http://images.wikia.com/gamedezyner/images/7/7e/PingSound.ogg"; } if (typeof(chatPluginsCustom.loadedFrom)=="undefined") { chatPluginsCustom.loadedFrom = "chat.js"; } } else { chatPluginsCustom = { staffIcon: "http://img1.wikia.nocookie.net/__cb20140626173406/gamedezyner/images/6/60/StaffIcon.png", modIcon: "http://img1.wikia.nocookie.net/__cb20140626173343/gamedezyner/images/8/89/ModIcon.png", pingSound: "http://images.wikia.com/gamedezyner/images/7/7e/PingSound.ogg", loadedFrom: "MediaWiki:Chat.js" } }

var chatPlugins = { release: { version: 0.9, branch: "Stable" }, custom: { staffIcon: chatPluginsCustom.staffIcon, modIcon: chatPluginsCustom.modIcon, pingSound: chatPluginsCustom.pingSound // forcedModules: chatPluginsCustom.forcedModules, // forcedSettings: chatPluginsCustom.forcedSettings, // disabledModules: chatPluginsCustom.disabledModules }, module: function(id, name, loadScript) { this.enabled = function { return chatPlugins.cookie.arrays.modules[this.id]; } this.id = id; this.loaded = false; this.modOnly = false; this.adminOnly = false; this.loadScript = loadScript; this.name = name; }, modules: { }, // Register our Modules pages: { list: {}, save: function { // Save all registered cookie arrays to respective cookies for (i in Object.keys(chatPlugins.pages.list)) { api.functions.editPage("User:" + wgUserName + "/ChatPlugins/" + chatPlugins.pages.list[Object.keys(chatPlugins.pages.list)[i]].name,chatPlugins.pages.list[Object.keys(chatPlugins.pages.list)[i]].value); } }, load: function { // Save all registered cookie arrays to respective cookies for (i in Object.keys(chatPlugins.pages.list)) { if (typeof(api.functions.getPageContents("User:" + wgUserName + "/ChatPlugins/" + chatPlugins.pages.list[Object.keys(chatPlugins.pages.list)[i]].name))!="string") { var content = ""; } else { content = api.functions.getPageContents("User:" + wgUserName + "/ChatPlugins/" + chatPlugins.pages.list[Object.keys(chatPlugins.pages.list)[i]].name); } chatPlugins.pages.list[Object.keys(chatPlugins.pages.list)[i]].value = content; } } }, cookie: { arrays: { version: [], modules: [] }, get: function(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) { return y; } } }, set: function (cookie_name,data) { var domain = wgServer.split("//")[1]; document.cookie = cookie_name + "=" + data + "; max-age=" + 60*60*24*150 + "; path=/; domain=" + domain; }, load: function { // Load all registered cookie arrays from respective cookies for (i in Object.keys(chatPlugins.cookie.arrays)) { chatPlugins.cookie.arrays[Object.keys(chatPlugins.cookie.arrays)[i]] = chatPlugins.cookie.get("chatPlugins"+Object.keys(chatPlugins.cookie.arrays)[i].charAt(0).toUpperCase + Object.keys(chatPlugins.cookie.arrays)[i].slice(1)).split(","); } }, save: function { // Save all registered cookie arrays to respective cookies for (i in Object.keys(chatPlugins.cookie.arrays)) { chatPlugins.cookie.set("chatPlugins"+Object.keys(chatPlugins.cookie.arrays)[i].charAt(0).toUpperCase + Object.keys(chatPlugins.cookie.arrays)[i].slice(1),chatPlugins.cookie.arrays[Object.keys(chatPlugins.cookie.arrays)[i]].toString); } }, reset: function { //Reset cookie data to default modules = Object.keys(chatPlugins.modules); for ( i in Object.keys(chatPlugins.modules) ) { module = chatPlugins.modules[modules[i]]; chatPlugins.cookie.arrays.modules[module.id] = 0; } chatPlugins.cookie.arrays.version[0] = chatPlugins.release.version; chatPlugins.cookie.save; } }, menu: { loaded: false, load: function {

$(".WikiaPage").append(' &#x25BC;&#x25BC;&#x25BC; Chat Plugins: Options   '); $("head").append('.chatPluginsMenu{position:absolute;left:0px;right:150px;top:100%;text-align:center;padding-bottom:5px;}.chatPluginsMenuButton{cursor:pointer;margin-bottom:5px;}.chatPluginsMenu,.Chat,.Write,.Rail{transition:bottom 1s,right 1s,top 1s;}.WikiaPage{overflow:hidden;}.button{margin:5px;} '); $("head").append('.chatPluginsMenu{top:'+($(".WikiaPage").height-15)+'px;}.Chat{bottom:65px;}.Write,.Rail{bottom:15px;} '); $("#chatPluginsMenuButton").html("&#x25B2;&#x25B2;&#x25B2;"); $("#chatPluginsMenuButton").click(function { if ($("#chatPluginsMenu.open").length==0 && $("#RailButton.open").length==0) { $("#chatPluginsMenuControl").html('.chatPluginsMenu{top:'+($(".WikiaPage").height-$(".chatPluginsMenu").height)+'px;}.Chat{bottom:'+(60+$(".chatPluginsMenu").height)+'px;}.Write,.Rail{bottom:'+(10+$(".chatPluginsMenu").height)+'px;}'); $("#chatPluginsMenuButton").html("&#x25BC;&#x25BC;&#x25BC;"); $("#chatPluginsMenu").addClass("open"); } else { $("#chatPluginsMenuControl").html('.chatPluginsMenu{top:'+($(".WikiaPage").height-15)+'px;}.Chat{bottom:65px;}.Write,.Rail{bottom:15px;}'); $("#chatPluginsMenuButton").html("&#x25B2;&#x25B2;&#x25B2;"); $("#chatPluginsMenu").removeClass("open"); } });

var $inspector = $(" ").css('display', 'none').addClass('selected'); $(".Rail").append($inspector); $("head").append(' #chatPluginsMenuButton:hover{background:'+$inspector.css("background-color")+';} '); $inspector.remove; chatPlugins.menu.loaded = true; $("#chatPluginsButton").click(chatPlugins.menu.open); }, add: function(id, title) { if (!chatPlugins.menu.loaded) { chatPlugins.menu.load; }

$('#chatPluginsMenuContent').append('' + title + ' '); $('#'+id).hover(function { $(this).css("background-color","#cce1ef") },function { $(this).css("background-color",$('#WikiaPage').css("background-color")) }); //Need to load background color from style }, width: function { if ($("body").width<700) { return $("body").width-100; } else { return 600; } }, open: function { var $optionsWindowHTML = $.showCustomModal( "Options", ' ' +

' Please select the features you would like to enable: ' + ' ' + ' Note: Clicking Save will refresh the chat. ', { id: "optionsWindow", width: chatPlugins.menu.width, buttons: [ { id: "cancel", message: "Cancel", handler: chatPlugins.menu.cancel }, { id: "save", defaultButton: true, message: "Save", handler: chatPlugins.menu.save } ] }); $(".close").click(chatPlugins.menu.cancel); $(".blackout").click(chatPlugins.menu.cancel); $(".blackout").addClass("chatPlugins"); chatPluginsTable = ""; modules = Object.keys(chatPlugins.modules); for (i=0;i Enable ' + module.name + ' '; if (typeof(module.settingsID)!="undefined"){ chatPluginsTable += ' (Settings)'; } chatPluginsTable += ' '; } else { chatPluginsTable += '  Enable ' + module.name + ' '; if (typeof(module.settingsID)!="undefined"){ chatPluginsTable += ' (Settings)'; } chatPluginsTable += ' '; } if ((modules.length % 2)!=1) { chatPluginsTable += ' '; } $('#chatPluginsTable').html(chatPluginsTable); } for (i=0;i<modules.length;i++) { module = chatPlugins.modules[modules[i]]; if (module.enabled==1) { $('input[name="' + module.name + '"]').attr("checked",true); } if (module.modOnly && wgUserGroups.indexOf("chatmoderator") == -1 && wgUserGroups.indexOf("sysop") == -1) { $('input[name="' + module.name + '"]').attr("checked",false); $('input[name="' + module.name + '"]').attr("disabled",true); } if (module.adminOnly && wgUserGroups.indexOf("sysop") == -1) { $('input[name="' + module.name + '"]').attr("checked",false); $('input[name="' + module.name + '"]').attr("disabled",true); } $("#"+module.settingsID).click(module.settingsFunction); $("#"+module.settingsID).click(chatPlugins.menu.cancel); } }, save: function { modules = Object.keys(chatPlugins.modules); checked = $(".chatOption:checked"); unchecked = $(".chatOption:not(:checked)"); cookieString = ""; for ( i in Object.keys(chatPlugins.modules) ) { module = chatPlugins.modules[modules[i]]; if ($('input[name="' + module.name + '"]:checked').length > 0) { chatPlugins.cookie.arrays.modules[module.id] = 1; } else { chatPlugins.cookie.arrays.modules[module.id] = 0; } } chatPlugins.cookie.save; chatPlugins.menu.cancel; if (chatPluginsCustom.loadedFrom == "w:c:Special:MyPage/global.js") { chatPlugins.reload; } else { window.location.reload; } }, cancel: function { $('#optionsWindow').remove; $('.blackout.chatPlugins').remove; } }, load: function { if (typeof(chatPlugins.cookie.get("chatPluginsVersion"))=="undefined") { // Is ChatPlugins version saved in cookie? If not, initialize cookies for first time and continue loading. chatPlugins.cookie.reset; chatPlugins.alert("Welcome to ChatPlugins! Installed version "+chatPlugins.release.version+" "+chatPlugins.release.branch+"!"); chatPlugins.alert("Please be sure to set your settings the way you want!"); console.log({Info: "Cookie",Data: "Cookies Initialized for first run"}); chatPlugins.loading = true; } else { if (isNaN(parseFloat(chatPlugins.cookie.get("chatPluginsVersion")))) { // Is ChatPlugins version cookie invalid? If so, reset cookies to default values and continue loading. chatPlugins.cookie.reset; chatPlugins.alert("Something went wrong, but we caught it! Your chat settings had to be reset though :("); chatPlugins.alert("Please change your settings to your liking."); console.log({Error: "Cookie",Data: "Invalid cookies. Cookies were reset."}); chatPlugins.loading = true; } else { if (parseFloat(chatPlugins.cookie.get("chatPluginsVersion"))>chatPlugins.release.version) { // Is ChatPlugins version older than last load? If so, alert user and stop loading. chatPlugins.alert("Error! You have used a newer version of ChatPlugins before! Please use the newest version!"); console.log({Error: "Unknown",Result: "Aborting"}); chatPlugins.loading = false; } if (parseFloat(chatPlugins.cookie.get("chatPluginsVersion"))==chatPlugins.release.version) { // Is ChatPlugins version the same as last load? If so, log and continue loading. console.log({Info:"Cookie",Data:"Version match. Continuing load."}); chatPlugins.loading = true; } if (parseFloat(chatPlugins.cookie.get("chatPluginsVersion"))<chatPlugins.release.version) { // Is ChatPlugins version newer than last load? If so, alert the user to the upgrade and continue loading. chatPlugins.cookie.set("chatPluginsVersion",chatPlugins.release.version.toString); chatPlugins.alert("Welcome to ChatPlugins! Upgraded to version "+chatPlugins.release.version+" "+chatPlugins.release.branch+"!"); chatPlugins.alert("Please be sure to check that your settings are set the way you want!"); chatPlugins.loading = true; } } } if (chatPlugins.loading) { chatPlugins.cookie.load; var modulekeys = Object.keys(chatPlugins.modules) var modulesarray = []; for (i in modulekeys) { var selectmodule = chatPlugins.modules[modulekeys[i]]; if (selectmodule.enabled == true) { modulesarray.push(selectmodule.loadScript); } } importArticles({ type:'script', articles: modulesarray }); if (chatPluginsCustom.loadedFrom == "w:c:Special:MyPage/global.js" || chatPluginsCustom.loadedFrom == "bookmark") { $("#ChatHeader .public.wordmark").append(''); $("#chatRefreshButton").click(function { chatPlugins.reload; }); $(document).on("keydown", function(e){ if ((e.which || e.keyCode) == 116) { e.preventDefault; chatPlugins.reload; } }); } chatPlugins.menu.load; $("head").append(''); $('head').append('<style type="text/css">#WikiChatList {overflow:auto;padding-bottom:10px;height:60%;resize:vertical;} #Rail {overflow:hidden;} #Rail h1.private {display:block !important;} #Rail .WikiChatList li {display:block !important}.User {resize: none;}.User.chat-mod .username:after { background-image: url(' + chatPlugins.custom.modIcon + ');background-position: 0px;background-size: 16px;}.User.staff .username:after { background-image: url(' + chatPlugins.custom.staffIcon + ');background-position: 0px;background-size:16px;} ') chatPlugins.loading = false; chatPlugins.loaded = true; $("body").append(' ChatPlugins Version ' + chatPlugins.release.version + ' ' + chatPlugins.release.branch + ' Loaded successfully from ' + chatPluginsCustom.loadedFrom + ' - Help</a> '); var bgcolor = $("body").css("background-color"); bgcolor = bgcolor.substring(4, bgcolor.length-1).replace(/ /g, ).split(','); var bgbrightness = Math.round(((parseInt(bgcolor[0]) * 299) + (parseInt(bgcolor[1]) * 587) + (parseInt(bgcolor[2]) * 114)) /1000); if (bgbrightness < 125) { $("#chatPluginsInfo").css("color","white"); $("#chatPluginsInfoLink").css("color","lightblue"); } else { $("#chatPluginsInfo").css("color","black"); $("#chatPluginsInfoLink").css("color","#006cb0"); } console.log({Info:"ChatPlugins",Data:"Successfully Loaded!"}); } }, alert: function(text) { newInlineAlert = new models.InlineAlert; newInlineAlert.attributes.text = text; mainRoom.model.chats.add(newInlineAlert); }, settings: { open: function(title,content,width,save) {

$.showCustomModal( title, '<form method="" name="" class="WikiaForm "> ' + content + ' ', { id: "settingsWindow", width: width, buttons: [ { id: "cancel", message: "Cancel", handler: chatPlugins.settings.cancel }, { id: "save", defaultButton: true, message: "Save", handler: save } ] }); $(".close").click(chatPlugins.settings.cancel); $(".blackout:not(.chatPlugins)").addClass("chatSettings") }, cancel: function { $('#settingsWindow').remove; $(".blackout.chatSettings").remove } }, reload: function { window.chatwindow = window.open('/wiki/Special:Chat?useskin=wikia', wgDBname + 'chat' + Math.round(Math.random*100)); window.chatwindow.onload = function { window.chatwindow.importScriptPage('User:' + wgUserName + '/global.js', 'c'); window.chatwindow.importScriptPage('User:' + wgUserName + '/wikia.js'); if (api.functions.getPageContents("MediaWiki:Chat.js").indexOf("Stable/ChatPlugins/code.js")==-1) { window.chatwindow.chatPluginsCustom = { loadedFrom: chatPluginsCustom.loadedFrom } window.chatwindow.importScriptPage('Testing/ChatPlugins/code.js', 'gamedezyner'); } } window.chatwindow.closeopener = true; } }; // If this is a reloaded window, kill old window if (window.opener!=null) { if(typeof(window.closeopener)!="undefined") { window.opener.close; } } chatPlugins.modules = { //Register the modules pings: new chatPlugins.module(0, "Pings", "w:c:gamedezyner:" + chatPlugins.release.branch + "/ChatPlugins/Modules/pings.js"), // Pings multiPM: new chatPlugins.module(1, "Multi PM", "w:c:gamedezyner:" + chatPlugins.release.branch + "/ChatPlugins/Modules/multiPM.js"), // Multi PM multiKick: new chatPlugins.module(2, "Multi Kick", "w:c:gamedezyner:" + chatPlugins.release.branch + "/ChatPlugins/Modules/multiKick.js"), // Multi Kick style: new chatPlugins.module(3, "Style", "w:c:gamedezyner:" + chatPlugins.release.branch + "/ChatPlugins/Modules/style.js"), // Chat Style tabComplete: new chatPlugins.module(4, "Tab Complete", "w:c:gamedezyner:" + chatPlugins.release.branch + "/ChatPlugins/Modules/tabComplete.js"), // Tab Complete afkButton: new chatPlugins.module(5, "AFK Button", "w:c:gamedezyner:" + chatPlugins.release.branch + "/ChatPlugins/Modules/afkButton.js"), // AFK Button slashCommands: new chatPlugins.module(6, "Slash Commands", "w:c:gamedezyner:" + chatPlugins.release.branch + "/ChatPlugins/Modules/slashCommands.js"), // Slash Commands // mobileFriendly: new chatPlugins.module(7, "Mobile Friendly Chat", "w:c:gamedezyner:" + chatPlugins.release.branch + "/ChatPlugins/Modules/mobileFriendly.js"), // Mobile Friendly Resize blockBan: new chatPlugins.module(8, "Block-Ban", "w:c:gamedezyner:" + chatPlugins.release.branch + "/ChatPlugins/Modules/blockBan.js") }

// Initialize the script chatPlugins.load; $(window).resize(function { $("#chatPluginsMenuControl").html('.chatPluginsMenu{top:'+($(".WikiaPage").height-15)+'px;}.Chat{bottom:65px;}.Write,.Rail{bottom:15px;}'); $("#chatPluginsMenuButton").html("&#x25B2;&#x25B2;&#x25B2;"); $("#chatPluginsMenu").removeClass("open"); }); $("#chatPluginsMenuControl").html('.chatPluginsMenu{top:'+($(".WikiaPage").height-15)+'px;}.Chat{bottom:65px;}.Write,.Rail{bottom:15px;}'); $("#chatPluginsMenuButton").html("&#x25B2;&#x25B2;&#x25B2;"); $("#chatPluginsMenu").removeClass("open"); $("#chatPluginsMenuButton").html("&#x25B2;&#x25B2;&#x25B2;"); $("#chatPluginsMenu").removeClass("open"); } else { chathacksAlert = new models.InlineAlert; chathacksAlert.attributes.text = 'You are loading Monchoman45\'s ChatHacks script. ChatPlugins is not compatible with ChatHacks, and has been disabled.'; mainRoom.model.chats.add(chathacksAlert); chathacksAlert = new models.InlineAlert; chathacksAlert.attributes.text = 'Please disable ChatPlugins or ChatHacks. If you need assistance, please contact Gamedezyner</a>'; mainRoom.model.chats.add(chathacksAlert);

}