User:Aspallar/common.js

// window.nullEditDelay = 2000;

importArticles({   type: 'script',    articles: [        'u:dev:MediaWiki:PurgeButton/code.js',        'u:dev:MediaWiki:MassNullEdit/code.js',        'u:dev:MediaWiki:ClipboardCopy.js',        'u:dev:MediaWiki:NullEditButton/code.js',        // 'u:dev:MediaWiki:AnalyticsShortcut.js'    ] });

// append elapsed days to the date in QueryDeck text/ $(function {   'use strict';    $('.mdw-daysago').each(function  { var that = $(this); var match = /[A-Za-z]+\s+\d+,\s+\d+/.exec(that.text); if (match) { var days = Math.floor((Date.now - Date.parse(match[0])) / (1000 * 60 * 60 * 24)); if (!isNaN(days)) that.append(' [' + days + ' days]'); }   }); });

//analytics shortcut $(function {    'use strict';    mw.util.addCSS( '.wds-community-header #analytics-header-btn svg { height: 18px }' );

$( '', {       href: mw.util.getUrl( 'Special:Analytics' ),        class: 'wds-button wds-is-secondary',        title: 'Bad News',        id: 'analytics-header-btn',        html: '   '    } ).insertBefore( '.wds-community-header .wds-community-header__wiki-buttons .wds-dropdown' ); });

$('#mw-clearyourcache').remove;

// copy article title to clipboard when title clicked. $(function {   'use strict';    $('h1.page-header__title').css('cursor', 'pointer').click(function  { var that = $(this); var color = that.css('color'); that.css('color','red'); navigator.clipboard.writeText('Duplicate of ' + that.text + '').then(function {            setTimeout(function  { that.css('color', color); }, 200);       });    }); });

// my tools option to make all links oprn in blank window (function ($) {   'use strict';    function openBlank(event) {        event.preventDefault;        $('a').attr('target', '_blank');    }    function addMyToolsOption {        var link = $('')            .append($('').attr({href: '#'}).text('Open Blank'))            .click(openBlank);         $('#my-tools-menu').prepend(link);    }    $(addMyToolsOption); }(jQuery));

(function($) {   'use strict';    /*global mw */

var pageName = mw.config.get('wgTitle'); if (pageName.substring(0, 6) !== 'Decks/') return;

$('.UserProfileActionButton > .wikia-menu-button > ul, .page-header__contribution-buttons .wds-list').append(       $('').append( $('', {               href: mw.util.getUrl('User:Aspallar/Sandbox/Deck', { deck: pageName.substring(6) }),                text: 'Test Builder',                title: 'Edit with the test deck builder'            }) )   ); }(jQuery));

// ============================================================================ // COPY FROM HERE TO END // ========================================================================== // ImportDeck // // Version 1.4.0 // Author: Aspallar // // Provides a user friendly way to import a deck from Magic Arena // without the user having to edit any wikitext. // // ** Please do not edit this code directly in the wikia. // ** Instead use the git repository https://github.com/Aspallar/WikiLua // // (function ($) { //    /* global mw*/ //     'use strict';

//    if (document.getElementById('mdw-import-deck') === null || $('#mdw-disabled-js').attr('data-importdeck-1-4-0')) //        return;

//    var newDeckTemplate = ''; //    var translation = null;

//    function wikiApiCall(data, method) { //        data.format = 'json'; //        return $.ajax({ //             data: data, //             dataType: 'json', //             url: mw.config.get('wgScriptPath') + '/api.php', //             type: method //         }); //    }

//    function removeIncludes(contents) { //        return contents.replace(/<[\/]?noinclude>|<[\/]?includeonly>/g, ''); //    }

//    function invalidTitle(title) { //        return /#|\?/g.test(title); //    }

//    function showWorking { //        $('#mdw-working').show; //    }

//    function hideWorking { //        $('#mdw-working').hide; //    }

//    function showForm { //        $('#mdw-import-deck').fadeIn(400); //    }

//    function showBadEntries(badEntries) { //        var safeBadEntries = []; //        badEntries.forEach(function (entry) { //             safeBadEntries.push(mw.html.escape(entry)); //         }); //        var content = safeBadEntries.join(' '); //        $('#mdw-import-badentries-content').html(content); //        $('#mdw-import-badentries').fadeIn(400); //    }

//    function hideBadEntries { //        $('#mdw-import-badentries').hide; //    }

//    function controlsDisabled(disabled) { //        $('#mdw-import-button').prop('disabled', disabled); //        $('input[name="mdw-import-lang"').prop('disabled', disabled); //    }

//    function disableControls { //        controlsDisabled(true); //    }

//    function enableControls { //        controlsDisabled(false); //    }

//    function showPreviewMessage(message, isError) { //        var span = $(' ').text(message); //        if (isError) span.addClass('mdw-error'); //        $('#mdw-import-preview-message').html(span); //        setTimeout(function  { //             $('#mdw-import-preview-message').empty; //         }, 3000); //    }

//    function fetchNewDeckTemplate { //        // var deferred = $.Deferred; //        // deferred.resolve('start/n$1/nend '); //        // return deferred.promise; //        return $.get(mw.util.getUrl('Template:NewDeck', {action: 'raw'})); //    }

//    function fetchTranslation(langCode) { //        return $.get(mw.util.getUrl('MediaWiki:Custom-Cards-' + langCode, {action: 'raw'})); //    }

//    function displayError(name, message) { //        $('#mdw-import-' + name + '-error').html('* ' + message); //        return false; //    }

//    function unexpectedError(message) { //        displayError('unexpected', 'An unexpected error occurred: ' + message); //    }

//    function validateDeckName { //        var name = $('#mdw-import-deckname').val.trim; //        if (name.length === 0) //            return displayError('deckname', 'A deck name is required.'); //        else if (invalidTitle(name)) //            return displayError('deckname', 'Invalid deck name.'); //        else //            return true; //    }

//    function validateDeckDef { //        var deckdef = $('#mdw-import-deckdef').val.trim; //        if (deckdef.length === 0) //            return displayError('deckdef', 'You must enter a deck definition'); //        else //            return true; //    }

//    function redirectToTitle(title) { //        window.location = mw.util.getUrl(title); //    }

//    function handleCreateError(error) { //        enableControls; //        if (error.code === 'articleexists') { //            displayError('deckname', 'Deck name already in use.'); //            $('#mdw-import-deckname').focus; //        } else if (error.code === 'invalidtitle') { //            displayError('deckname', 'Invalid deck name.'); //            $('#mdw-import-deckname').focus; //        } else { //            unexpectedError(error.info); //        } //     }

//    function replaceCurlyQuotesWithApostrophe(s) { //        return s.replace(/[\u2018\u2019]/g, '\''); //    }

//    function correctCardName(name) { //        return replaceCurlyQuotesWithApostrophe(name) //            .replace(/\/+/g, ' // ') //            .replace(/\s\s+/g, ' '); //    }

//    function translateCard(entry) { //        if (translation === null) //            return entry; //        var match = /(\d+)\s+(.*?)(?=\s+\/\/|\s+\(|$)/.exec(entry); //         if (!match) //             return entry; //         var translatedName = translation[match[2].toLowerCase.trim]; //         if (translatedName === undefined) //             return entry; //         return match[1] + ' ' + translatedName; //     }

//    function getDeckText(deckEntries) { //        var translated = []; //        deckEntries.forEach(function (entry) { //             translated.push(translateCard(entry)); //         }); //        return translated.join('\n'); //    }

//    function createDeckPage(name, deckEntries, originalText) { //        disableControls; //        showWorking; //        mw.loader.using('mediawiki.api').then(function  { //             var content = newDeckTemplate.replace('$1', getDeckText(deckEntries)) + //                 '\n\n'; //             var title = 'Decks/' + name; //             new mw.Api.post({ //                action: 'edit', //                title: title, //                summary: 'Imported deck', //                createonly: 'yes', //                text: content, //                token: mw.user.tokens.get('editToken') //            }).done(function(result) { //                hideWorking; //                if (result.error === undefined) { //                    redirectToTitle(title); //                } else { //                    handleCreateError(result.error); //                } //             }).fail(function(code, result) { //                unexpectedError(code + (code === 'http' ? ' ' + result.textStatus : '')); //            }); //         }); //     }

//    function parseDeckDef(deckdef) { //        var maxLength = $('#mdw-import-deck').attr('data-maxcardlength') || 40; //        var result = { validEntries: [], badEntries: [], sideboardCount: 0 }; //        deckdef.split('\n').forEach(function (entry) { //             entry = entry.trim; //             if (entry.length === 0) { //                 ++result.sideboardCount; //                 result.validEntries.push('--- sideboard ---'); //             } else if (entry.length > maxLength) { //                 result.badEntries.push(entry.substring(0, maxLength) + '... (too long)'); //            } else if (/^\d+\s+.*\S.*$/.test(entry)) { //                 result.validEntries.push(correctCardName(entry)); //             } else { //                 result.badEntries.push(entry); //             } //         }); //        return result; //    }

//    function clickImport { //        hideBadEntries; //        $('.mdw-error').html(''); //        var nameValid = validateDeckName ; //        var deckdefValid = validateDeckDef; //        if (deckdefValid) { //            var text = $('#mdw-import-deckdef').val.trim; //            var result = parseDeckDef(text); //            if (result.badEntries.length > 0) //                showBadEntries(result.badEntries); //            if (result.sideboardCount > 1) //                displayError('deckdef', 'Import contains more than one sideboard.'); //            if (nameValid && result.badEntries.length === 0 && result.sideboardCount <= 1) //                createDeckPage($('#mdw-import-deckname').val, result.validEntries, text); //        } //     }

//    function showTranslationLoadFail(langCode) { //        $.showCustomModal( //             'Load Error', //             ' Failed to load translation data (' + langCode + '). Defaulting back to English. ', { //             id: 'mdw-loadfail-dialog', //             width: 350, //             buttons: [{ //                 id: 'mdw-loadfail-dialog-ok', //                 message: 'OK', //                 defaultButton: true, //                 handler: function  { //                     $('#mdw-loadfail-dialog').closeModal; //                 } //             }] //         }); //    }

//    function parseTranslation(data) { //        var trans = {}; //        data.split('\n').forEach(function (entry) { //             var match = /^(.*)?\|(.*)$/.exec(entry); //             if (match) //                 trans[match[1].toLowerCase] = match[2]; //         }); //        return trans; //    }

//    function changeLanguage { //        /*jshint -W040 */ // allow old school jquery use of this //        var langCode = $(this).val; //        if (langCode === 'en') { //            translation = null; //        } else { //            disableControls; //            fetchTranslation(langCode).done(function (data) { //                 translation = parseTranslation(data); //                 enableControls; //             }).fail(function  { //                 showTranslationLoadFail(langCode); //                 $('#mdw-import-english').prop('checked', true); //                 translation = null; //                 enableControls; //             }); //        } //     }

//    function wikiParse(text) { //        var deferred = $.Deferred; //        wikiApiCall({ //             action: 'parse', //             disablepp: 1, //             prop: 'text', //             text: text //         }, 'POST').done(function (response) { //             if (response && response.parse && response.parse.text) { //                 var text = response.parse.text['*']; //                 deferred.resolve(text); //             } else { //                 deferred.reject('Unknown response from parse template'); //             } //         }).fail(function  { //             deferred.reject('Network error while parsing template'); //         }); //        return deferred.promise; //    }

//    function previewDeck(deckEntries) { //        var deckTemplate = ''; //        wikiParse(deckTemplate).done(function (deckHtml) { //             var deckPreview = $('#mdw-import-deck-preview'); //             deckPreview.html(deckHtml).find('a').attr('target', '_blank'); //             tooltips.applyTooltips(deckPreview.get(0)); //             $('#mdw-import-preview').show('fast', function { //                magicArena.charts.refresh; //            }); //         }).fail(function (error) { //             $('#mdw-db-preview-button').val('Preview Deck'); //             showPreviewMessage(error, true); //             $('#mdw-db-preview').hide; //         }); //    }

//    function clickPreview { //        /*jshint -W040 */ // allow old school jquery this //        hideBadEntries; //        $('.mdw-error').html(''); //        var deckdefValid = validateDeckDef; //        if (deckdefValid) { //            var text = $('#mdw-import-deckdef').val.trim; //            var result = parseDeckDef(text); //            if (result.badEntries.length > 0) //                showBadEntries(result.badEntries); //            if (result.sideboardCount > 1) //                displayError('deckdef', 'Import contains more than one sideboard.'); //            if (result.badEntries.length === 0 && result.sideboardCount <= 1) { //                $(this).val('Update Preview'); //                previewDeck(result.validEntries); //            } //         } //     }

//    function createForm { //        /*jshint multistr:true*/ //        $('#mdw-import-deckname-span') //            .append(''); //        $('#mdw-import-deckdef-span') //            .append(' '); //        var importBtn = $('') //            .click(clickImport); //        var previewBtn = $('') //            .click(clickPreview); //        $('#mdw-import-button-span').append(importBtn).append(' ').append(previewBtn); //        var languages = $('  English \ //              Deutsch \ //              Español \ //              Français \ //             <input type="radio" name="mdw-import-lang" value="it"> Italiano \ //             <input type="radio" name="mdw-import-lang" value="pt-br"> Português '); //        languages.find('input[name="mdw-import-lang"]').change(changeLanguage); //        $('#mdw-lang-span').replaceWith(languages); //    }

//    function initialize { //        $('#mdw-working').html($(' ', { //            src: mw.config.get('stylepath') + '/common/images/ajax.gif' //        })); //         showWorking; //        fetchNewDeckTemplate.done(function (template) { //             newDeckTemplate = removeIncludes(template); //             createForm; //             hideWorking; //             showForm; //             $('#mdw-import-deckname').focus; //         }).fail(function  { //             hideWorking; //             $('#mdw-import-deck').html(' Failed to load new deck template. '); //            showForm; //         }); //    }

//    $(document).ready(initialize);

// }(jQuery));

// Deck deletion helper (function ($) {   /*global mw */    'use strict';

if (mw.config.get('wgAction') !== 'delete' || mw.config.get('wgTitle').substring(0, 6) !== 'Decks/') return;

function submitClick { /* jshint -W040 */ // allow old school jquery use of this var that = $(this); $('#wpReason').val(that.attr('data-other')); $('#wpDeleteReasonList').val(that.attr('data-reason')); }

function deleteButton(text, reason, otherText) { var input = $('<input type="submit" class="mdw-deckdelete-button">') .val(text) .attr('data-reason', reason) .attr('data-other', otherText) .click(submitClick); return $('   ').append($('<td class="mw-submit">').append(input)); }

function initialize { $('#mw-deleteconfirm-table tbody') .append(deleteButton('Random deck name', 'Housekeeping', 'Please don\'t give decks a name consisting of nothing but random characters')) .append(deleteButton('Random deck name 2', 'Housekeeping', 'Please don\'t use a random sequence of characters in a deck name.')) .append(deleteButton('Not an arena deck', 'Housekeeping', 'Not an MTG:Arena deck. Contains cards not in the game.')) .append(deleteButton('Test deck', 'Housekeeping', 'Someone\'s test import')) .append(deleteButton('Too few cards', 'Housekeeping', 'Invalid deck, not enough cards')) .append(deleteButton('Too many cards', 'Housekeeping', 'Invalid deck, too many cards')) .append(deleteButton('Outdated Meta', 'Housekeeping', 'Outdated meta')) .append(deleteButton('Invalid deck', 'Housekeeping', 'Invalid deck')) .append(deleteButton('Poor deck name', 'Housekeeping', 'Poor deck name')) .append(deleteButton('Bad deck contents (Vandalism)', 'Vandalism', 'Unacceptable deck contents')) .append(deleteButton('Unacceptable deck name (Vandalism)', 'Vandalism', 'Unacceptable deck name')) .append(deleteButton('Test Cleanup', 'Housekeeping', 'Cleanup after test')); $('#wpWatch').prop('checked', false); }

$(initialize);

}(jQuery));

// List deck menu option (function($) {   'use strict';    /*global mw */    var pageName = mw.config.get('wgTitle');    if (pageName.substring(0, 6) !== 'Decks/')        return;

var author = $('#mw-content-text a[href^="/wiki/User:"'); author = (author.length > 0) ? author.attr('href').substring(11) : 'Anonymous';

$('.UserProfileActionButton > .wikia-menu-button > ul, .page-header__contribution-buttons .wds-list').append(       $('<li>').append( $('<a>', {               href: mw.util.getUrl('Deck List Editor', { author: author, deck: pageName.substring(6) }),                text: 'List Deck',                title: 'List the deck using the Deck List Editor'            }) )   );

}(jQuery));

// Test List Deck (function($) {   'use strict';    /*global mw */    var pageName = mw.config.get('wgTitle');    if (pageName.substring(0, 6) !== 'Decks/')        return;

var author = $('#mw-content-text a[href^="/wiki/User:"'); author = (author.length > 0) ? author.attr('href').substring(11) : 'Anonymous';

$('.UserProfileActionButton > .wikia-menu-button > ul, .page-header__contribution-buttons .wds-list').append(       $('<li>').append( $('<a>', {               href: mw.util.getUrl('User:Aspallar/Sandbox/dle', { author: author, deck: pageName.substring(6) }),                text: 'List Deck (Test)',                title: 'List the deck using the Deck List Editor'            }) )   );

}(jQuery));

// Analytics Enhancements !function{"use strict";if("Analytics"===mw.config.get("wgCanonicalSpecialPageName")&&/sysop|staff|content-team-member|helper|wiki-manager/.test(mw.config.get("wgUserGroups").join)){var n,a="mdw-analytics-views",i="mdw-analytics-edits",o="mdw-analytics-visibility",r=365;$(function{n=function{var e=localStorage.getItem(o);return e?JSON.parse(e):{number_of_pageviews:!1,edits_per_day:!1,top_viewed_pages:!1,geolocation:!1,most_visited_files:!1,desktop_vs_mobile:!1,browser_breakdown:!1,top_search_terms:!1,logged_in_out:!1}},$("#PageHeader").remove,$("#analytics_confidential_header").remove,$("#analytics_report_time").remove,$("#analytics_wrapper").css("padding-top","0"),function{var e=setInterval(function{0<$(".last30").length&&(clearInterval(e),b)},100)}})}function s{var e=navigator.userAgent;return-1!==e.indexOf("Windows")&&-1!==e.indexOf("Firefox")?"\r\n":"\n"}function c(e,t){new BannerNotification(e,"notify",void 0,t).show}function d(e){return new Date(1e3*e).toISOString.substr(0,10)}function u(e){return void 0===e?"":e}function l(a,n,i){Object.keys(n).forEach(function(e){var t=a[e];void 0===t&&(t=a[e]={}),t[i]=n[e]})}function e(e,t){var a=function(e,t){var a={};return l(a,t,"edits"),l(a,e,"views"),a}(e,t);return Object.keys(a).sort.map(function(e){var t=a[e];return[d(e),u(t.views),u(t.edits)].join(",")}).join(s)}function g(e){var t=localStorage.getItem(e);return t?JSON.parse(t):{}}function p(e,t){var a=function(e,t){var a=!1,n=$.extend(e,t),i=Object.keys(n);return i.length>r&&(i.slice(0,i.length-r).forEach(function(e){delete n[e]}),a=!0),{wasTrimmed:a,data:n}}(g(e),t);return localStorage.setItem(e,JSON.stringify(a.data)),a.wasTrimmed}function t{var e,t;try{e=p(a,sectionsData.number_of_pageviews.per_day),t=p(i,sectionsData.edits_per_day)}catch(e){console.error(e),c("There was a problem whilst saving current data. Data may not be saved.")}(t||e)&&c("Saved analytics data is at max capacity ("+r+" days)",5e3)}function f(e,t,a,n){return $(" ",{src:"https://vignette.wikia.nocookie.net/magicarena/images/"+e,alt:t,title:a,width:"24",height:"24"}).css({float:"right",margin:"5px"}).click(n)}function m(e){return f("8/88/Copyicon.svg/revision/latest?cb=20190815182005","Copy Icon","Copy to clipboard",e)}function v(e){return f("5/5d/Saveicon.svg/revision/latest?cb=20190816012418","Saved Icon","Copy saved data to clipboard",e)}function _(e,t){var a=$(e.target);e.stopPropagation,a.css("background-color","grey"),navigator.clipboard.writeText(function(t){return Object.keys(t).map(function(e){return[d(e),t[e]].join(",")}).join(s)}(t)).then(function{setTimeout(function{a.css("background-color","")},100)})}function y(e){var t=$(e.target);t.next.toggle;var a=t.parent.attr("id");n[a]=!n[a],function(e){localStorage.setItem(o,JSON.stringify(e))}(n)}function w{$.showCustomModal("Confirm Data Purge"," You are about to delete all saved analytics data. Are you sure you wish to continue? ",{id:"mdw-confirmpurge-dialog",width:350,buttons:[{message:"Continue",defaultButton:!0,handler:function{localStorage.removeItem(a),localStorage.removeItem(i),$("#mdw-confirmpurge-dialog").closeModal,setTimeout(function{c("Saved analytics data has been purged.",5e3),t},500)}},{message:"Cancel",defaultButton:!0,handler:function{$("#mdw-confirmpurge-dialog").closeModal}}]})}function b{$(".grid_box_header").css("cursor","pointer").click(y).next.hide.next.remove,$("#number_of_pageviews > .grid_box_header").append(v(function{_(event,g(a))})).append(m(function(e){_(e,sectionsData.number_of_pageviews.per_day)})),$("#edits_per_day > .grid_box_header").append(v(function{_(event,g(i))})).append(m(function(e){_(e,sectionsData.edits_per_day)})),$("#analytics_header").append($(" Purge Saved Data ").css({width:"33%","margin-right":"4px"}).click(w),$(" Copy Current Views and Edits ").css({width:"33%","margin-right":"4px"}).click(function{navigator.clipboard.writeText(e(sectionsData.number_of_pageviews.per_day,sectionsData.edits_per_day))}),$(" Copy Saved Views and Edits ").css({width:"33%"}).click(function{navigator.clipboard.writeText(e(g(a),g(i)))})).css("margin-bottom","10px"),$("#edits_per_day").attr("style","grid-area: top_search_terms;"),$("#top_search_terms").attr("style","grid-area: edits_per_day;"),$("#top_viewed_pages").attr("style","grid-area: geolocation;"),$("#geolocation").attr("style","grid-area: top_viewed_pages;"),function(t){Object.keys(t).forEach(function(e){t[e]&&$("#"+e).children.eq(1).show})}(n),setTimeout(t,500)}};

// Random page !function{"use strict";if(-1===["User","Special","MediaWiki"].indexOf(mw.config.get("wgCanonicalNamespace"))){var n,t="random-page";$(function{$("#my-tools-menu").prepend($("<li>").append($("<a>",{href:"#",id:"mdw-random-page",click:e}))),o&&a})}function o{var e=sessionStorage.getItem(t);return null===e||($("#mdw-random-page").text("Toggle Random (active)"),$("span.wds-community-header__counter-value").css("color","red").html(++e),sessionStorage.setItem(t,e),n=setTimeout(function{window.location="/wiki/Special:RandomPage"},6e3),!1)}function a{$("#mdw-random-page").text("Toggle Random (inactive)"),clearTimeout(n)}function e(e){e.preventDefault,null!==sessionStorage.getItem(t)?(sessionStorage.removeItem(t),a):(sessionStorage.setItem(t,"-1"),o)}};

// Query Decks Admin Tool !function(n){"use strict";if("Special:QueryDecks"===mw.config.get("wgPageName")){var s=Date.now;n(function{n(".page-header__title").text("Deck Queries"),n("title").text("Deck Queries"),n("#mw-content-text").html(" Fetching queried decks... "),function{var e=n.Deferred,t=mw.config.get("wgScriptPath")+"/api.php?action=query&format=json&generator=categorymembers&gcmtitle=Category:Queried_Deck&gcmlimit=500&prop=revisions&rvprop=content";return n.getJSON(t).done(function(a){var o=[];a.query&&a.query.pages&&Object.keys(a.query.pages).forEach(function(e){for(var t,r=/^\{\{QueryDeck\|(.+?)\|(.+?)[\|\{}]/gm,n=a.query.pages[e],s=n.revisions[0]["*"],i=[];null!==(t=r.exec(s));)i.push(u({text:t[1],dateText:t[2]}));i.sort(function(e,t){return t.seconds-e.seconds}),o.push({title:n.title,queries:i})}),e.resolve(o)}),e.promise}.done(function(e){e.sort(function(e,t){var r=0<e.queries.length?e.queries[0].seconds:0;return(0<t.queries.length?t.queries[0].seconds:0)-r}),t(e)})})}else n(function{n("#my-tools-menu").prepend(n("<li>").append(n("<a>").attr({href:mw.util.getUrl("Special:QueryDecks")}).text("Queried Decks")))});function u(e){e.seconds=-1,e.days=-1;var t=/[A-Za-z]+\s+\d+,\s+\d+/.exec(e.dateText);if(t){var r=s-Date.parse(t[0]),n=Math.floor(r/864e5);isNaN(n)||(e.seconds=r,e.days=n)}return e}function i(e){return e.length<=60?e.substring(0,60):e.substring(0,60)+"..."}function t(e){var r=n(' ');e.forEach(function(e){var t=n(" ").append(n(" ").html(function(e){return n("<a>",{target:"_blank",href:mw.util.getUrl(e),text:e})}(e.title))).append(n(" ").html(function(e){return 0===e.length?-1:e[0].days}(e.queries))).append(n(" ").html(function(e){if(0===e.length)return"";for(var t=i(e[0].text),r=1;r<e.length;r++)t+=" "+i(e[r].text);return t}(e.queries)));r.append(t)}),n("#mw-content-text").html(r).prepend(n(" ").text(e.length+" Queried Decks").css("font-weight","bold")).append(n(" ").text("A days value of -1 means that the query date is unknown").css("font-style","italic")),mw.loader.using("jquery.tablesorter",function{r.tablesorter({cssHeader:""}),r.find("th").css("cursor","pointer").find("div").remove})}}(jQuery);