User:Sophiedp/global.js

/* Cache check settings */ window.topLevelCat = '';

/* QuickTools settings */ var QuickToolsAdvancedtop = false;

/* AnchoredRollback settings */ anchoredRollbackBot = true;

/* Show removed replies */ $(".message-removed.hide").removeClass("hide");

/* FastDelete settings */ var fdButtons = []; fdButtons.push({   'summary': 'Housekeeping',    'label': 'HK' });

/* AjaxRC settings */ window.ajaxPages = ["Blog:Recent_posts","Special:Chat","Special:WikiActivity","Special:RecentChanges","Special:Watchlist","Special:Log","Special:Contributions"]; window.ajaxIndicator = 'http://vignette2.wikia.nocookie.net/dev/images/8/82/Facebook_throbber.gif'; window.ajaxRefresh = 30000; window.AjaxRCRefreshText = 'Auto-refresh'; window.AjaxRCRefreshHoverText = 'Automatically refresh the page';

/* Make RC show bot edits */ //@author-Foodbandlt var url = window.location.href; if (wgPageName == "Special:RecentChanges") { if (url.indexOf("hidebots=") == -1 && url.indexOf("?") == -1) { window.location.href = window.location.href + "?hidebots=0"; } else if (url.indexOf("hidebots=") == -1 && url.indexOf("?") !== -1) { window.location.href = window.location.href + "&hidebots=0"; } } else if (wgPageName == "Special:Newwikis") { if (url.indexOf("language=") == -1 && url.indexOf("?") == -1) { window.location.href = window.location.href + "?language=en"; } else if (url.indexOf("language=") == -1 && url.indexOf("?") != -1) { window.location.href = window.location.href + "&language=en"; } }

/* Remove help from the global nav menu */ $('.wds-global-navigation__user-menu > div > ul.wds-list > li:has(a[data-tracking-label="global-navigation-user-help"])').remove;

/* QuickCreateUserPage */ //Modified version of QuickCreateUserPage if (wgCityId !== "621556" && wgCityId !== "177") { $('', {       id: 'qcup',    }).html('Create user page') .prependTo('.toolbar .tools') .click(function {       $.ajax( { type: 'POST', url: mw.util.wikiScript( 'api' ), dataType: 'json', data: { action: 'edit', title: 'User:Sophiedp', summary: 'Creating user page', text: '', format: 'json', token: mw.user.tokens.get( 'editToken' ) }       } ).done( function ( data ) { if ( data.edit.result === 'Success' ) { new BannerNotification("Successfully created page!","confirm").show; } else { new BannerNotification("An error occurred.","error").show; }       } ).fail( function ( data ) { new BannerNotification("An error occurred.","error").show; } );   }); }

//———————————————————————————————— ! ! ! ————————————————————————————————// /* Place imports below this line. Place everything else above this line. */

/* BotoneraPopups */ importArticles({   type: "script",    articles: [        'u:dev:MediaWiki:BotoneraPopups/BotoneraPopups.js',        'u:dev:MediaWiki:BotoneraPopups/WikiArticle.js',        'u:dev:MediaWiki:BotoneraPopups/UILang/en.js',        'u:dev:MediaWiki:BotoneraPopups/code.js'    ] }); importStylesheetPage('BotoneraPopups/code.css', 'dev');

/* Staff/VSTF/Bot/Helper highlights */ importStylesheetPage('Highlight/code.css', 'dev');

/* WLB highlights */ importStylesheetPage('MediaWiki:WLBhighlight.css', 'wlb');

/* Imports */ importArticles({   type: "script",    articles: [        'u:steven-universe:MediaWiki:BoardThreadAlerts.js',        'u:dev:MediaWiki:CodeEditor.js',        'u:dev:MediaWiki:CacheCheck/code.js',        'u:dev:MediaWiki:HeaderLinks/code.js',        'u:dev:MediaWiki:NoImageLightbox/code.js',        'u:dev:MediaWiki:AjaxTemplate/code.js',        'u:dev:MediaWiki:RevealAnonIP/usercode.js',        'u:dev:MediaWiki:MarkBlocked.js',        'u:dev:MediaWiki:FindAndReplace/code.js',        'u:dev:MediaWiki:Wikimarks/code.js',        'u:dev:MediaWiki:AjaxRC/code/js',        'u:dev:MediaWiki:LastEdited/code.js',        'u:dev:MediaWiki:AjaxUndo/code.js',        'u:dev:MediaWiki:FixWantedFiles/code.js',        'u:dev:MediaWiki:SignatureCheck/code.js',        'u:dev:MediaWiki:WallGreetingButton/code.js',        'u:dev:MediaWiki:AntiUnicruft/code.js',        'u:dev:MediaWiki:UnsafeScripts/personal.js', 'u:dev:MediaWiki:GlobalEditcount/code.js', 'u:dev:MediaWiki:PageRenameAuto-update/code.js', 'u:dev:MediaWiki:OldFilePages/code.js', 'u:dev:MediaWiki:FileUsageAuto-update/code.js', 'u:dev:MediaWiki:CategoryRenameAuto-update/code.js', 'u:dev:MediaWiki:QuickDiff/code.js', 'u:dev:MediaWiki:WHAM/code.2.js', 'u:dev:MediaWiki:MarkForDeletion/code.js', 'u:dev:MediaWiki:AnchoredRollback/code.js', 'u:dev:MediaWiki:Quick_Management/code.js', 'u:dev:MediaWiki:QuickToolsv2/code.js', 'u:dev:MediaWiki:Rollback/code.js', 'u:dev:MediaWiki:AbuseLogRC.js', 'u:dev:MediaWiki:ContribsLink/code.js', 'u:dev:MediaWiki:DupImageList/code.js', 'u:dev:MediaWiki:DisplayTimer/code.js', 'u:dev:MediaWiki:FastDelete/code.js', 'u:dev:MediaWiki:Linksweeper/code.js', 'u:dev:MediaWiki:RecentChangesMultiple/code.2.js' ] });

//———————————————————————————————— ! ! ! ————————————————————————————————// /* Place imports above this line. Place chat javascript below this line. */

/* Make only run in chat */ if ( wgCanonicalSpecialPageName == 'Chat' ) {

/* Pings */ // Using a double backslash '\\b' is a substitute for a barrier: word\\b would trigger on forword but not on wordgame, etc. var PING_LIST = [ "zach", "soph" ];

var PING_SOUND = 'http://images.wikia.com/monchbox/images/0/01/Beep-sound.ogg';

// Ask our end-user if we want notifications for the script. Notification.requestPermission;

// Function itself. console.log("Pingchecking activated!"); var afterChat = function (chat) { var t = chat.attributes.text, n = chat.attributes.name, isInline = chat.attributes.isInlineAlert || false, context = mainRoom.viewDiscussion.chatUL.children.last; if (new RegExp(PING_LIST.join('|'), 'mi').test(t)) { $(' ', {       id: 'ping',        src: PING_SOUND,        autoplay: true    }).appendTo('body'); // Display desktop notifications. if (Notification.permission === 'granted') { new Notification(n + " pinged you!", {           body: t,            icon: context.children('.avatar').attr('src').slice(0, -2) + '150'        }); }   // Change the look of the triggered message. context.children('.message').wrap(''); } var chatMain = mainRoom.viewDiscussion.chatDiv[0]; if (chatMain.scrollHeight - chatMain.scrollTop - chatMain.clientHeight > 150) return; mainRoom.viewDiscussion.scrollToBottom; }; mainRoom.model.chats.bind('afteradd', afterChat);

/* //Wait for chat to load mw.loader.using('mediawiki.util', function {   var loader = setInterval(function { if (typeof mainRoom !== "undefined") { mw.util.addCSS('.Chat li .boundary {display:none;}'); chatTimestampsMain; console.log('Chat Timestamps loaded'); clearInterval(loader); }   }, 200); }); $.fn.firstNotContinued = function { var $this = $(this); return !$this.hasClass('continued') ? $this : $this.prevAll(':not(.continued)').first; }; function parseTimestamp(el, native) { if (native.attributes.timeStamp) { var date = new Date(native.attributes.timeStamp), hours = (date.getHours.toString.length == 1 ? '0' : '') + date.getHours, minutes = (date.getMinutes.toString.length == 1 ? '0' : '') + date.getMinutes, seconds = (date.getSeconds.toString.length == 1 ? '0' : '') + date.getSeconds; el.firstNotContinued.find('.time').html(' [ ' + hours + ':' + minutes + ':' + seconds + ' ] '); } } function bindAll(func) { window.mainRoom.model.chats.bind('afteradd', func); window.mainRoom.model.privateUsers.bind('add', function(u) {       window.mainRoom.chats.privates[u.attributes.roomId].model.chats.bind('afteradd', func);    }); } function chatTimestampsMain { bindAll(function (child) {       parseTimestamp($('#entry-' + child.cid), child);    }); var $LIs = $('.Chat ul li'); $.each(mainRoom.model.chats.models, function(i, el) {       parseTimestamp($LIs.eq(i), el);    }); }
 * Chat Timestamps
 * @description Create/refine timestamps for each message or alert in chat to be in the format of HH:MM:SS
 * @author Ozuzanna

/* Imports */ importScriptPage('User:Sophiedp/chat.js', 'embercastle'); importScriptPage('MediaWiki:EscapeEmoticons/code.js', 'dev'); importScriptPage('MediaWiki:NewMessageCount.js', 'dev'); /* Hide/Show chat rail button */ $('.User').first.before(' 150 ? &quot;0px&quot; : &quot;150px&quot;;$(&quot;.Chat, .Write&quot;).css({right:toggleWidth});var txt = ($(&quot;.HideRailButton&quot;).text == &quot;Hide Rail&quot;) ? &quot;Show Rail&quot; : &quot;Hide Rail&quot;;$(&quot;.HideRailButton&quot;).text(txt);">Hide Rail ');

/* PrivateChatList responsive design */ // The actual thing that calculates the height and stuff var calcRail = function { var nodes = [].slice.call(document.querySelectorAll('#Rail > *:not(#WikiChatList)')); var height = 0; nodes.forEach(function(el) {      height = height + (el.scrollHeight - 1);    }); if (height > window.innerHeight / 2) height = window.innerHeight / 2; document.getElementById('WikiChatList').style.height = (document.getElementById('Rail').offsetHeight - height - 70) + 'px'; }; // Bind function to window resize $(window).resize(calcRail); // select the target node var targets = [].slice.call(document.querySelectorAll('#PrivateChatList, #WikiChatList')); // create an observer instance var observer = new MutationObserver(function(mutations) { mutations.forEach(function(mutation) { if (mutation.type == 'attributes' && mutation.attributeName == 'style') return; calcRail; }); }); // configuration of the observer: var config = { attributes: true, childList: true, characterData: true, subtree: true }; // pass in the target node, as well as the observer options targets.forEach(function(target) {   observer.observe(target, config); }); // execute all that observer stuff when the window loads $(function {   mw.util.addCSS('#PrivateChatList {max-height: 40vh !important; overflow-y: auto;} #WikiChatList {overflow-y: auto; max-height: 666vh;} #Rail {overflow: hidden !important;}');    calcRail;    var interval = setInterval(calcRail, 200);    // clear the interval after the window is fully loaded    setTimeout(function { clearInterval(interval); }, 15000); });

} //keep this