User:HM100/Fast Delete code

/ ////// FAST DELETE /** * Ajax Fast Delete * @author Grunny * @version 2.1 * @notes Original FastDelete code was written by Splarka, and later modified by uberfuzzy and Grunny. */

(function($) {   "use strict";

// Don't load twice... if (typeof window.wkAjaxFastDelete !== 'undefined') { return false; }

window.wkAjaxFastDelete = { version: '2.2',

init: function {

if (wgNamespaceNumber === -1 || !window.fdButtons) { return; }           var deleteButtons = ''; switch (skin) { case 'uncyclopedia': case 'wowwiki': case 'monobook': if (!$('#ca-delete').length) { return; }                   deleteButtons = fdButtons.map(function(b) {                        var sum = b.summary;                        return '' + b.label + '';                    }).join(''); $('#p-cactions > .pBody > ul').append(deleteButtons); break;

case 'oasis': case 'wikia': if (!$('.wds-list #ca-delete').length) { return; }                   deleteButtons = fdButtons.map(function(b) {                        var sum = b.summary;                        return '' + b.label + '';                    }).join(' '); if ($('.UserProfileActionButton').exists) { $('.UserProfileActionButton').append(deleteButtons); } else if ($('.page-header__subtitle-blog-post').exists) { $('.page-header__subtitle-blog-post').append(deleteButtons); $('.page-header__blog-post-details').css('margin-right', '5px'); } else if ($('.WikiaPage .page-header_languages').exists) { $(deleteButtons).insertAfter('.WikiaPage .page-header__languages'); mw.util.addCSS('.WikiaPage .page-header__languages {margin-bottom: 12px;margin-right: 5px;}'); } else { $('.page-header__title').append(deleteButtons); }                   break; }           if ($('a[data-id="fastdelete"]').length) { $('a[data-id="fastdelete"]').click(function {                   wkAjaxFastDelete.ajaxDeleteAPage($(this).attr('data-summary'));                }); }       },

ajaxDeleteAPage: function(deleteReason) { var url = wgServer + wgScriptPath + '/api.php?action=query&prop=info&intoken=delete&titles=' + encodeURIComponent(wgPageName) + '&format=json'; $.getJSON(url, function(data) {               var editToken = data.query.pages[wgArticleId].deletetoken,                    url = wgServer + wgScriptPath + '/api.php?action=delete&title=' + encodeURIComponent(wgPageName) + '&reason=' + encodeURIComponent(deleteReason) + '&format=json&token=' + encodeURIComponent(editToken);                $.post(url, function { document.location.reload; });           });        }    };

$(document).ready(wkAjaxFastDelete.init);

}(jQuery)); //