User:Mainframe98/common.js

/** */ ( function ( mw, $ ) {
 * Adds a Sandbox button, originally from https://www.wikidata.org/wiki/MediaWiki:Gadget-mySandbox.js, but that version used a localized subpagename.
 * Tweaked to remove redundancy

$( document ).ready( function {        var conf = {            portletLabel: 'Zandbak',            portletTooltip: 'Ga naar de zandbak',        };        var title, url;        title = new mw.Title( 'Special:MyPage/Sandbox' );

url = new mw.Uri( title.getUrl );

mw.util.addPortletLink(           'p-personal',            url,            conf.portletLabel,            'pt-mysandbox',            conf.portletTooltip,            null,            '#pt-preferences'        ); }); }( mediaWiki, jQuery ) ); mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Hoo_man/tagger.js&action=raw&ctype=text/javascript');

/* Mark for (Speedy) Deletion Adapted to use Template:Speedy */ /* Customization */ /* window.MarkForDeletion = { promptedDeleteReason: "Out of project scope" }; /* Source: http://dev.wikia.com/wiki/MarkForDeletion, used revision 47639 */ /* $(function {   "use strict";    if(mw.config.get("wgAction") !== "view" || mw.config.get("wgNamespaceNumber") === -1 || mw.config.get("wgUserName") === null) {        return;    }    var i18n = {        buttonTitle: "Mark for speedy deletion",        spam: "spam",        prompt: "Enter delete reason to quickly mark this page for speedy deletion",        error: "An error occurred while marking the page for speedy deletion"    };    function setDeleteNotice(deleteReason) {        $.ajax({ type: "POST", url: mw.util.wikiScript('api'), data: { action: "edit", title: mw.config.get("wgPageName"), summary: "Marked for speedy deletion because: " + deleteReason, token: mw.user.tokens.get("csrfToken"), prependtext: "{" + "{speedy|" + deleteReason + "}}\n", format: "json", nocreate: "1" },           success: function(d) { if(d && d.error && d.error.code) { new BannerNotification(i18n.error + ": " + d.error.code, 'error').show; } else { window.location.reload; }           },            error: function { new BannerNotification(i18n.error, 'error').show; }       });    }    function initDeleteNoticeButton {        // don't create duplicate buttons        if ($("#mark-for-deletion-link").length > 0) {            return;        }        var $button = $(mw.html.element("a", {            id: "mark-for-deletion-link",            style: "cursor: pointer;"        }, i18n.buttonTitle)), $toolbar, $insertLinkHere;        // create button        $button.click(function { var promptedDeleteReason = i18n.spam; if (window.MarkForDeletion && typeof window.MarkForDeletion.promptedDeleteReason === "string") { promptedDeleteReason = window.MarkForDeletion.promptedDeleteReason; }           var deleteReason = window.prompt(i18n.prompt, promptedDeleteReason); if (typeof deleteReason === "string" && deleteReason.length > 0) { setDeleteNotice(deleteReason); }       });        // add button to toolbar        $toolbar = $("#p-tb");        if ($toolbar.length > 0) {            $toolbar.find("ul").append($button);        }        $("#mark-for-deletion-link").wrap("");    }

initDeleteNoticeButton; });