User:Akrivus/Code

SpoilerAlert with Variable Questions, Replies, and Different Colors Put this is in your MediaWiki:Common.js (function {     var cats = mw.config.get('wgCategories'),         spoiler = $.inArray('Spoilers', cats) !== -1,         underconstruction  = $.inArray('Under Construction',cats) !== -1;     window.SpoilerAlert = {};     window.SpoilerAlert.isSpoiler = function  {             return spoiler || underconstruction;     };     if (spoiler && underconstruction) {         window.SpoilerAlert.question = ;         window.SpoilerAlert.no = ;         window.SpoilerAlert.yes = ;     } else if (spoiler) {         window.SpoilerAlert.question = ;         window.SpoilerAlert.no = ;         window.SpoilerAlert.yes = ;     } else if (underconstruction) {         window.SpoilerAlert.question = ;         window.SpoilerAlert.no = ;         window.SpoilerAlert.yes = '';     } }); importScriptPage('MediaWiki:SpoilerAlert.js'); Put this in your? MediaWiki:SpoilerAlert.js, it doesn't matter if it doesn't exist. $(function {     "use strict";     window.SpoilerAlert = (function (my, console, Math) { my = $.extend({            question: 'QUESTION',             yes: 'YES',             no: 'NO',             isSpoiler: function  {                 return (/^Spoiler\:/.test(document.title));             },             back: false         }, my); // If my is undefined/null/not-object then jQuery will ignore it         var wgArticleId = (window.mediaWiki && window.mediaWiki.config && window.mediaWiki.config.get('wgArticleId')) || window.wgArticleId; var dialog =  +  +  +  +  +  +  +  + '

<table id="dialog" border="0" cellpadding="20" style="-moz-box-shadow: 0px 0px 20px #000000; -webkit-box-shadow: 0px 0px 20px #000000; box-shadow: 0px 0px 20px #000000; background-image: -moz-radial-gradient(top, #EBEBEB 5%, #C8C8C8 95%); background-image: -o-radial-gradient(top, #EBEBEB 5%, #C8C8C8 95%); background-image: -webkit-gradient(radial, left top, left bottom, color-stop(5%, #EBEBEB), color-stop(1, #C8C8C8)); background-image: -webkit-radial-gradient(top, #EBEBEB 5%, #C8C8C8 95%); background-image: radial-gradient(to bottom, #EBEBEB 5%, #C8C8C8 95%); -moz-border-radius: 15px; border-radius: 15px; border: 2px solid #BCBCBC; color: #3A3A3A;">  ' +                    my.question + '   ' +                    ' ' + my.no + ' ' + '  ' +                    ' ' + my.yes + ' ' + ' ';        function getBackgroundColor  { var color = $('#WikiaPageBackground').css('            if ('transparent' !== color) return color;             color = $('#WikiaPage').css(' if ('transparent' !== color) return color; color = $('section.module', '#WikiaRail').css('            if ('transparent' !== color) return color;             console.log('SpoilerAlert: Cannot determine color');             return color;         }         // Use LocalStorage, it doesn't get sent to the server every HTTP request         var ids = $.storage.get('SpoilerAlertJS');         // Backwards compatibility. This block can be removed after a week or so         if (!ids) {             ids = $.cookies.get('spoilers');             if (ids) { // Old cookie found, convert to local storage                 ids = ids.split(',');                 $.cookies.del('spoilers', {hoursToLive:0, path:'/', domain: location.host});                 $.storage.set('SpoilerAlertJS', ids);             } else {                 ids = [];             }         }         if (my.isSpoiler && -1 === $.inArray(wgArticleId, ids)) {             var article = $('article#WikiaMainContent'); var articleHeight = article.height; var dialogHeight; $(' ' + dialog + ' ').appendTo(article).css({                position: 'absolute',                 top: 0, left: 0,                 right: 0, bottom: 0,                 zIndex: 2000000001,                 backgroundColor: getBackgroundColor,                 minHeight: (dialogHeight = $('#dialog').height)             }); var dialogPadding = 100; var topRelativeToWindow = Math.round(                ($(window).height - dialogHeight) / 2 - $('#WikiaArticle').offset.top             ); var topRelativeToArticle = Math.round((articleHeight - dialogHeight) / 2); console.log(                'window.height: ', $(window).height,                 ', WikiaArticle.offset.top: ', $('#WikiaArticle').offset.top,                 ', articleHeight:', articleHeight,                 ', dialogHeight:', dialogHeight,                 ', topRelativeToWindow:', topRelativeToWindow,                 ', topRelativeToArticle: ', topRelativeToArticle             ); $('#dialog').css({                position: 'absolute',                 left: Math.round(($('#WikiaArticle').width  - $('#dialog').width ) / 2) + 'px',                 top:  Math.max(Math.min(topRelativeToWindow, topRelativeToArticle), dialogPadding) + 'px'             }); $('#no').click(function {                 $('#dialog').remove;                 if (my.back) {                     if (history.length) {                         history.back;                     } else {                         location.href = location.protocol + '//' + location.host;                     }                 }             }); $('#yes').click(function {                 $('#dialog').remove;                 $('#blackout').fadeOut(1600, function  { $(this).remove; });                ids.push(wgArticleId);                 $.storage.set('SpoilerAlertJS', ids);             }); }        return my; }) (window.SpoilerAlert, window.console || { log: $.noop }, Math); });  Change some of the variables in there and you're finished!