MediaWiki:YTPlayer.js

// ============================================================ // BEGIN Dynamic Navigation Bars (experimental) // This script is from Wikipedia. For author attribution, please see http://en.wikipedia.org/w/index.php?title=MediaWiki:Common.js&action=history /* Test if an element has a certain class ************************************** * * Description: Uses regular expressions and caching for better performance. * Maintainers: User:Mike Dillon, User:R. Koot, User:SG */ var autoCollapse = 2; var collapseCaption = "hide"; var expandCaption = "show"; var hasClass = (function {    var reCache = {};    return function (element, className) {        return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className);   }; }); /** Dynamic Navigation Bars (experimental) ************************************* * *  Description: See NavFrame. * Maintainers: UNMAINTAINED */ // set up the words in your language var NavigationBarHide = '[' + collapseCaption + ']'; var NavigationBarShow = '[' + expandCaption + ']'; // set up max count of Navigation Bars on page, // if there are more, all will be hidden // NavigationBarShowDefault = 0; // all bars will be hidden // NavigationBarShowDefault = 1; // on pages with more than 1 bar all bars will be hidden var NavigationBarShowDefault = autoCollapse; // shows and hides content and picture (if available) of navigation bars // Parameters: //    indexNavigationBar: the index of navigation bar to be toggled function toggleNavigationBar(indexNavigationBar) {    var NavToggle = document.getElementById("NavToggle" + indexNavigationBar); var NavFrame = document.getElementById("NavFrame" + indexNavigationBar); if (!NavFrame || !NavToggle) { return false; }    // if shown now if (NavToggle.firstChild.data.substring(0,NavigationBarHide.length) == NavigationBarHide) { for (                var NavChild = NavFrame.firstChild;                 NavChild !== null;                 NavChild = NavChild.nextSibling             ) { if ( hasClass( NavChild, 'NavPic' ) ) { NavChild.style.display = 'none'; }            if ( hasClass( NavChild, 'NavContent') ) { NavChild.style.display = 'none'; }        }     NavToggle.firstChild.data = NavigationBarShow + ' ' + NavToggle.firstChild.data.substring(NavigationBarHide.length); // if hidden now } else if (NavToggle.firstChild.data.substring(0,NavigationBarShow.length) == NavigationBarShow) { for (                var NavChild = NavFrame.firstChild;                 NavChild !== null;                 NavChild = NavChild.nextSibling             ) { if (hasClass(NavChild, 'NavPic')) { NavChild.style.display = 'block'; }            if (hasClass(NavChild, 'NavContent')) { NavChild.style.display = 'block'; }        }     NavToggle.firstChild.data = NavigationBarHide + ' ' +NavToggle.firstChild.data.substring(NavigationBarShow.length); } }  // adds show/hide-button to navigation bars function createNavigationBarToggleButton {    var indexNavigationBar = 0; // iterate over all -elements var divs = document.getElementsByTagName("div"); for(            var i=0;              NavFrame = divs[i];              i++         ) { // if found a navigation bar if (hasClass(NavFrame, "NavFrame")) { indexNavigationBar++; // Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked) for(var j=0;j < NavFrame.childNodes.length;j++) { if (hasClass(NavFrame.childNodes[j], "NavHead")) { var NavToggle = document.createElement("a"); NavToggle.className = 'NavToggle'; NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar); NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');'); var NavToggleText = document.createTextNode(NavigationBarHide); NavToggle.appendChild(NavToggleText); NavFrame.childNodes[j].appendChild(NavToggle); }              // This is a hack particular to help.wikia for having the title clickable, meh if (hasClass(NavFrame.childNodes[j], "NavHeadToggle")) { var NavToggle = document.createElement("a"); NavToggle.className = 'NavToggleTitle'; NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar); NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');'); var NavToggleText = document.createTextNode(NavigationBarHide + ' ' + NavFrame.childNodes[j].firstChild.nodeValue); NavToggle.appendChild(NavToggleText); NavFrame.childNodes[j].appendChild(NavToggle); NavFrame.childNodes[j].firstChild.nodeValue=''; }            }             NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar); }    }     // if more Navigation Bars found than Default: hide all if (NavigationBarShowDefault < indexNavigationBar) { for(var i=1;i<=indexNavigationBar;i++) { toggleNavigationBar(i); }    }  }   addOnloadHook( createNavigationBarToggleButton ); // END Dynamic Navigation Bars (experimental) // ============================================================ // ============================================================ // ************************************************* // Pagetitle rewrite // // Rewrites the page's title, used by Template:Title // ************************************************* $(function{	var newTitle = $("#title-meta").html;	if (!newTitle) return;	var edits = $("#user_masthead_since").text;	$(".firstHeading,#WikiaUserPagesHeader h1,#WikiaPageHeader h1").html(newTitle);	$("#user_masthead_head h2").html(newTitle + "" + edits + " "); }); // ******************** // IRC AND CVNIRC LOGIN // ******************** $(function {   if ($('#IRClogin').length || $('#CVNIRClogin').length) {        var nick = '';        if (mw.config.get('wgUserName') === null) {            nick = 'Wikian' + Math.floor(Math.random * 100);        } else {            nick = mw.config.get('wgUserName').replace(/ /g, "_");        }        $('#IRClogin').html(' ');        $('#CVNIRClogin').html(' ');    } }); // **************** // Duplicate images // **************** if (mw.config.get('wgPageName') === "My_Little_Pony_Friendship_is_Magic_Wiki:Duplicate_images"){ importScriptPage('DupImageList/code.js', 'dev'); //please for the love of Celestia someone fix this darn thing (see talk page) } // *************** // Chat appearance // *************** // Change chat description if ($('section.ChatModule').length > 0){ $.get("/wiki/MediaWiki:Chat-headline?action=raw", function(result){		if ($('p.chat-name').length > 0){			$('p.chat-name').html(result);		}else{			var chatDescInt = setInterval(function { if ($('p.chat-name').length > 0){ $('p.chat-name').html(result); clearInterval(chatDescInt); }			}, 50);		}	}); } //********************************** // Support for Template:USERNAME //********************************** $(function {   if (window.disableUsernameReplace || mw.config.get('wgUserName') === null) return;    $('span.insertusername').html(mw.config.get('wgUserName')); }); // *** Custom user rights icons on userpages *** if ({'User':1, 'User_blog':1, 'User_talk':1}[mw.config.get('wgCanonicalNamespace')] || mw.config.get('wgPageName').indexOf('Special:Contributions') !== -1){ importScript('MediaWiki:Common.js/userRightsIcons.js'); } // Auto-insert link from anchor on Help:Red links // Please report anything that still doesn't work right, it may need more exceptions $(document).ready(function{   var redlink = window.location.hash;    if (mw.config.get('wgPageName') === 'Help:Red_links' && redlink !== '') {        redlink = redlink.slice(1);        if (redlink.charAt(0) === ':') { redlink = redlink.substring(1); }        if (redlink.substr(0, 5) !== 'File:') {            redlink = redlink.replace(/\./g, '%');        } else {            var head = redlink.substring(0, redlink.lastIndexOf('.'));            var tail = redlink.substring(redlink.lastIndexOf('.'));            redlink = head.replace(/\./g, '%') + tail;        }        $("#insertredlink a").attr("href", "/wiki/" + decodeURIComponent(redlink) + "?action=history");        $("#insertredlink a").css("font-weight", "bold");    } }); // Automatically uncheck "Leave a redirect behind" on files if (mw.config.get('wgPageName').indexOf('Special:MovePage/File:') !== -1) { $('input#wpLeaveRedirect').removeAttr('checked'); } // Support for multicolumn TOCs // Usage: //needs updating whenever Wikia gets around to fixing the new TOC at least partially // changing all #toc ul to #toc ol doesn't quite work $(window).load(function{ if ($(".toc-multicol #toc").size !== 0) {    $(function{ var x, tdToAppend, listToAppend, showtext = 'show', hidetext = 'hide'; $("#toc").css("width","100%"); //need to subtract 12px from this for padding for some reason $("#toc ul").html(" "); var liList = $("#toc ul li").toArray; $('table#toc ul').remove; if (liList.length % 3 === 0) { x = 0; }else{ x = 3 - (liList.length % 3); }		var perCol = (liList.length + x) / 3; for (var colNum=0; colNum < 3; colNum++){ listToAppend = ""; for (var i=0+(colNum*perCol); i<(perCol*(colNum+1)); i++){ if (typeof(liList[i]) == "undefined"){break;} tempElement = document.createElement("div"); tempElement.appendChild(liList[i]); listToAppend += tempElement.innerHTML; }			tdToAppend += '    '; }		$('#toc tbody').append(' '+tdToAppend+' '); $('#toc tbody tr:eq(0) td').attr("colspan", "3"); var indentFactor = 10; $("head").append(" .toclevel-1{padding-left: "+(indentFactor*1)+"px !important}.toclevel-2{padding-left: "+(indentFactor*2)+"px !important}.toclevel-3{padding-left: "+(indentFactor*3)+"px !important}.toclevel-4{padding-left: "+(indentFactor*4)+"px !important} "); $("#togglelink").off("click").click(function(e){e.preventDefault; $('#toc ul').slideToggle("fast");			if ($(this).text === showtext) { $(this).text(hidetext); } else { $(this).text(showtext); } }); if (!$('#toc ul').is(':hidden') && $('#togglelink').text === showtext) { $('#togglelink').text(hidetext); }   });  } }); // Alert contributors when they are editing with their bot flag set if ((mediaWiki.config.get("wgAction") === "edit" || mediaWiki.config.get("wgAction") === "submit") && mediaWiki.config.get("wgUserGroups").indexOf("bot") !== -1){ $("#EditPageHeader").after('NOTE: You are currently editing with your bot flag set. '); } //Add a "view source" button when the Edit button goes to Special:SignUp $(document).ready(function {   var $a = $('a[data-id="edit"]');    if ($a.length && $a.attr('href').indexOf('Special:SignUp') !== -1) {        $a.parent.children('ul.WikiaMenuElement').prepend( 'View source' );   } }); //Fix lazy-loaded tabbified profile images if ($("div.profile-image img.lzyPlcHld").length > 0){ $("div.profile-image img.lzyPlcHld").each(function{     $(this).attr("src", $(this).attr("data-src"));   }); } // http://dev.wikia.com/wiki/UserRightsRecord if ($('.rightsrecord').length) { importScriptPage('UserRightsRecord/code.js', 'dev'); } // Support for Template:Emote by Bobogoobo if ($('.emote-template').length || $('#WikiaArticleComments').length) { $(function {       function emotify($this) {            var emote = $this.text;            var url = emotes.match( new RegExp('\\n\\*\\s*(.*)\\n(?:\\*\\*.*\\n)*(?=.*' + emote.replace(/([.*+?^=!:${}|\[\]\/\\])/g, '\\$1') + //escape specials, from MDN ')', 'i'));           if (url) {                url = url[1];                $this.html($(' ', {'src':url, 'alt':emote}));            }        }        var emotes = '';        $.getJSON('/api.php?action=query&prop=revisions&titles=MediaWiki:Emoticons' + '&rvprop=content&format=json', function(data) { emotes = data.query.pages['28113'].revisions[0]['*']; // 28113 is the wgArticleId of MediaWiki:Emoticons $('.emote-template').each(function {               emotify($(this));            }); });       $('#WikiaArticleFooter').on('DOMNodeInserted', function { if ($('.emote-template').length === $('.emote-template img').length) { return; }           $('#WikiaArticleFooter .emote-template').each(function {                if (!($(this).children('img').length)) {                    emotify($(this));                }            }); });   }); } // Auto-redirect on Special:Search for SXXEXX by Bobogoobo $(function {   var search = mw.util.getParamValue('search');    if ( mw.config.get('wgPageName') === 'Special:Search' && search.length <= 6 && /S\d+E\d+/i.test(search) ) {       $('.results-wrapper p').html('Redirecting to episode...');        var s, e;        s = search.toLowerCase.split('e')[0].substr(1);        e = search.toLowerCase.split('e')[1];        $.getJSON('/api.php?action=edit&action=parse&text=&format=json', function(data) { var episode = (data.parse.text['*'].match(/\>(.*)\n\', { 'href':'/wiki/' + episode, 'text':episode }));               window.location.href = window.location.href.substring(0,                   window.location.href.lastIndexOf('/') + 1) + episode; } else { $('.results-wrapper p').html('Episode not found.'); }       });    } }); // Automatically add categories on Special:Upload, by Bobogoobo //To delete stored data: window.sessionStorage.removeItem('characterCategories') $(function {   if (mw.config.get('wgCanonicalSpecialPageName') !== 'Upload') {        return;    }    var $summary = $('#wpUploadDescription'), $filename = $('#wpDestFile'), eptest = /S\d+E\d+/i,      charCats = [], charCatsEG = [], shortcuts = {'EG':{}}, pending = 0,      nicknames = {'Lyra Heartstrings':'Lyra', 'Princess Luna':'Nightmare Moon'}, //be careful      ccStorage = window.sessionStorage.characterCategories;    function nameCat(input) {        return input.substring(9).replace(' images', );        //return 'Mr. Fluffykins';    }    function cat(str) {        if ($summary.val.indexOf( + 'Category:' + str + ) === -1) {            $summary.val($summary.val + ($summary.val ? '\n' : ) +  + 'Category:' + str + );       }    }    function profile { //profile images        if (/\sID\s/i.test($filename.val.replace(/_/g, ' '))) {            cat('Profile images');        }    }    function findCats(filename, isEG) {        var arr = isEG ? charCatsEG : charCats;        for (var i = 0; i < arr.length; i++) {            if (filename.indexOf(nameCat(arr[i])) !== -1) {                cat(arr[i].substring(9) + (isEG ? '/EG' : '')); //meow            }        }        if (isEG) {            $.each(shortcuts.EG, function(key, value) { if (filename.indexOf(nameCat(key)) !== -1) { cat(value.substring(9) + '/EG'); }           });        } else {            $.each(shortcuts, function(key, value) { if (filename.indexOf(nameCat(key)) !== -1 && key !== 'EG') { cat(value.substring(9)); }           });        }    }    $('#wpUploadDescription').closest('tr').after( '   Warning : ' + 'character category adding is experimental. It may not work correctly, ' + 'and it will only add characters fully named in the file name. ' +     'Please correct any erroneous categories and add missing ones. Report any issues ' + 'here. ' +     'Character category database loading... '   );    if (typeof ccStorage !== 'undefined') {        charCats = JSON.parse(ccStorage).charCats;        charCatsEG = JSON.parse(ccStorage).charCatsEG;        shortcuts = JSON.parse(ccStorage).shortcuts;        $('#char-cat-warning p').append('retrieved from storage.');    }    if (typeof window.sessionStorage !== 'undefined' && !window.sessionStorage.characterCategories) {    $.getJSON('/api.php?action=query&list=categorymembers&cmtitle=Category:Character images' + '&cmprop=title&cmlimit=max&format=json', function(data) { //will need update if we get over 500 of these pending += 1; function checkComplete { if (pending === 0 && charCats.length > 0) { $('#char-cat-warning p').append('done!'); if (typeof window.sessionStorage !== 'undefined') { window.sessionStorage.characterCategories = JSON.stringify({                       'charCats': charCats,                        'charCatsEG': charCatsEG,                        'shortcuts': shortcuts                    }); $('#char-cat-warning p').append(' Saved to browser session storage.'); }           }        }        function fEach(response) { pending += response.query.categorymembers.length; $.each(response.query.categorymembers, function(index, value) {               if (value.title === 'Category:Cutie Mark Crusaders images' || value.title === 'Category:Equestria Girls character images') {                   pending -= 1;                    return; //saw the EG category after doing everything else :P This is probably easier anyway                }                if (value.title.substring(value.title.length - 3) === '/EG') {                    charCatsEG.push(value.title.replace('/EG', ''));                    if (value.title.indexOf('Princess') !== -1) {                        shortcuts.EG[value.title.replace('Princess ', ).replace('/EG', )] = value.title.replace('/EG', );                   }                } else {                    charCats.push(value.title);                    if (value.title.indexOf('Princess') !== -1) {                        shortcuts[value.title.replace('Princess ', )] = value.title;                    }                    if (nicknames[nameCat(value.title)]) {                        shortcuts['Category:' + nicknames[nameCat(value.title)] + ' images'] = value.title;                    }                }                fGet(value.title);            }); }       function fGet(title) { $.getJSON('/api.php?action=query&list=categorymembers&cmtitle=' + title +             '&cmprop=title&cmtype=subcat&cmlimit=max&format=json', function(response) {                if (response.query.categorymembers.length) {                    fEach(response);                }                pending -= 1;                checkComplete;            }); }       fEach(data); pending -= 1; checkComplete; });}   $filename.change(function { var name = $filename.val.replace(/_/g, ' '); if ($summary.val.indexOf('[[Category:') !== -1) {           return;        } else if (name.substring(0, 6) === 'SLIDER') { //front page sliders            cat('Front page sliders');        } else if (eptest.test(name)) { //episodes            var match = name.match(eptest)[0].split(/e/i);            $.getJSON('/api.php?action=parse&text=&format=json', function(data) {                var episode = (data.parse.text['*'].match(/>(.*)\n</) || [0, 0])[1];                if (episode &&                    episode !== 'TBA' &&                     episode.indexOf(' ') === -1                ) {                    cat(episode + ' images');                    findCats(name, false);                    profile;                }            });        } else if (/\sEG(?:\s|\.png)/i.test(name)) { //Equestria Girls            cat('Equestria Girls images');            findCats(name, true);            profile;        } else if (name.substring(0, 7) === 'FANMADE') { //fanmade images            cat('Fanmade images');        }    });    $('#mw-upload-form').on('DOMNodeInserted', '#mw-upload-thumbnail', function(ev) {        if (ev.target.id === 'mw-upload-thumbnail') {            $filename.change;        }    }); }); // Snow yay $(document).ready(function {	if ($('#Snow').length > 0) {		importScript('MediaWiki:Snow.js');	} }); // List of ponies stripping script for [[list of ponies/fast]] by Bobogoobo //   AKA Ultra Fast Pony (wacarb don't sue me) $(function {    if (      mw.config.get('wgPageName') !== 'List_of_ponies/fast' ||      mw.util.getParamValue('action') ||      mw.util.getParamValue('oldid')    ) {        return;    }    var page = mw.util.getParamValue('loppage') || 'List_of_ponies',      fastpony = window.fastpony || [1, 9],      ponycols = window.fastcolumns || ($.inArray(8, fastpony) > -1 ? 1 : 1);        //change last 1 to 2 to enable multi-columns by default. Currently very slow.    if (page !== 'List_of_ponies') {        $('#lop-backlink').html('Back to the ').append($('', {            'href': '/wiki/List_of_ponies/fast',            'title': 'List of ponies/fast',            'text': 'full fast list'        })).append('.');        $('#lop-thislink').html('See the ').append($('', {            'href': '/wiki/' + page + (window.location.hash ? window.location.hash : ),            'title': page.replace(/_/g, ' '),            'text': 'full version of this page'        })).append('.');    }    $('#mw-content-text').after($(' ', {        'id': 'lopspinner',        'style': 'margin:auto;',        'src': 'http://slot1.images.wikia.nocookie.net/__cb62004/common/skins/common/progress-wheel.gif'    }));    $.getJSON('/api.php?action=parse&page=' + page + '&prop=text&format=json', function(data) {        if (data.error) {            $('#mw-content-text').append($(' ', {                'class': 'error',                'html': data.error.info            }));            $('#lop-thislink').remove;            return;        }        var $html = $(' ' + data.parse.text['*'] + ' '),          charpage = /See (.*)<\/a>\./, newTitle,          $thead, $tbody, $newTable, newRows = ' ';        newTitle = ($('#title-meta', $html).html || page.replace(/_/g, ' ')) + ' (fast)';        $('#WikiaPageHeader h1:first').html(newTitle);        document.title = newTitle + ' - ' + mw.config.get('wgSitename');        if (page === 'List_of_ponies') {            $('#toc', $html).parent.remove;            $('.listofponies', $html).nextUntil('noscript').remove;            $('a[href^="/wiki/List_of_"]', $html).each(function {                $(this).attr('href', '/wiki/List_of_ponies/fast?loppage=' +                   $(this).attr('href').replace('/wiki/', ));            });        }        $('.wikitable:first', $html).prev.remove;        $('.wikitable:first', $html).remove;        $('.listofponies', $html).css('width', 'auto');        $('.listofponies tr', $html).each(function {            var $first = $(this).children('td:nth-child(1)'),              $desc = $(this).children('td:nth-child(8)'),              match, link, toRemove;            if (              $.inArray(8, fastpony) === -1 &&              charpage.test($desc.html) &&              $desc.children('a:first').attr('title') !== 'List of ponies' //maybe duplicates should be marked somehow?            ) {                match = $desc.html.match(charpage)[1];                link = $('', {                    'href': '/wiki/' + encodeURIComponent(match.replace(/ /g, '_')),                    'title': match,                    'text': $first.text                })[0].outerHTML;                if ($first.children('b').length) {                    $first.html($(link).wrapInner(''));                } else if ($first.children('a').length) {                    $first.children('a:first').text('(poll)');                    $first.html(link + ' ' + $first.html);                } else {                    $first.html(link);                }            }            toRemove = $(this).children;            for (var i = 0; i < fastpony.length; i++) {                toRemove = toRemove.not(':nth-child(' + fastpony[i] + ')');            }            toRemove.remove;        });        if (ponycols > 1) {            $newTable = $('.listofponies', $html).clone.empty;            $thead = $('tr:first', $html);            for (var i = 1; i < ponycols; i++) {                $thead.append('<th class="unsortable" style="width:1em;"> ');                for (var j = 0; j < fastpony.length; j++) {                    $thead.append($thead.children('th').eq(j).clone);                }            }            $newTable.append($thead);            $tbody = $('tr:not(:first) td', $html);            for (var k = 1; k < $tbody.length + 1; k++) {                if (k % (fastpony.length * ponycols) === 0) {                    newRows += $tbody[k-1].outerHTML + '  ';                } else if (k % fastpony.length === 0) {                    newRows += $tbody[k-1].outerHTML + '  ';                } else {                    newRows += $tbody[k-1].outerHTML;                }            }            $newTable.append(newRows + ' ');            $('.listofponies', $html).replaceWith($newTable);        }        $('#mw-content-text').append($html.html);        // Load sortability, from Wikia/app/resources/mediawiki.page/mediawiki.page.ready.js        mw.loader.using('jquery.tablesorter', function {            $('table.sortable').tablesorter;        });        if (window.location.hash) { window.location.hash = window.location.hash; } // go to anchor if present    }).fail(function {        $('#mw-content-text').append($(' ', {            'class': 'error',            'html': 'An error occurred. Try refreshing the page.'        }));    }).always(function {        $('#lopspinner').remove;    }); }); // Automatically uncheck "Unlock further protect options" when protecting a page if (mw.config.get('wgAction') === 'protect') {    $('#mwProtectUnchained').removeAttr('checked'); } // Imports PonyStats by Bobogoobo // Applies to Special:BlankPage?blankspecial=ponystats //   ( http://mlp.wikia.com/wiki/Special:BlankPage?blankspecial=ponystats ) if (  mw.config.get('wgPageName') === 'Special:BlankPage' &&  mw.util.getParamValue('blankspecial') === 'ponystats' ) {    importScript('MediaWiki:Common.js/PonyStats.js'); } // All transcript lister by Bobogoobo // http://mlp.wikia.com/wiki/Special:BlankPage?blankspecial=transcripts $(function {    if (      mw.config.get('wgPageName') !== 'Special:BlankPage' ||      mw.util.getParamValue('blankspecial') !== 'transcripts'    ) {        return;    }    var $content = $('#mw-content-text > p'),      $heading = ($('#WikiaPageHeader').length ? $('#WikiaPageHeader') : $('.AdminDashboardArticleHeader')).children('h1'),      sections = [], sorting = [], total = 0, completed = 0;    function nospecials(str) {        return str.replace(/\W/g, );    }    $heading.html('Transcripts/All');    document.title = 'All Transcripts - ' + mw.config.get('wgSitename');    $content.html(      ' &lt; Transcripts</a> ' +      ' This page loads the full transcript of every episode and film in the show (may take some time). ' +      'It is made to help with searching every transcript at once. Please make any bug reports or suggestions ' +      'here</a>. ' +      ' ' +      '<h2 style="width:100%; text-align:center; margin-top:0; border-bottom:0;">Progress ' +      ' '    );    $.getJSON('/api.php?action=parse&page=Template:Transcripts&prop=links&format=json', function(data) {        data = data.parse.links;        for (var i = 2; i < data.length - 2; i++) { //episodes only            if (data[i].exists === ) {                sections.push(data[i]['*'].replace('Transcripts/', ));            }            if (i === 66) {                sections.push('My Little Pony Equestria Girls'); //add EG in chronological order as discussed                sorting.push();                total += 1;            }            sorting.push();            total += 1;        }        for (var j = 0; j < sections.length; j++) {            $content.append($(' ', {                'id': nospecials(sections[j]),                'html': $('', {                    'href': '/wiki/' + sections[j].replace(/ /g, '_'),                    'title': sections[j],                    'text': sections[j]                })            }));            (function(index) {                $.getJSON('/api.php?action=parse&prop=text|categories&format=json&page=Transcripts/' + sections[index],                  function(data) {                    if (data.parse.categories.length === 1) {                        sorting[index] = 'Season ' + data.parse.categories[0]['*'].replace(/[^\d]/g, );                    }                    data = data.parse.text['*'];                    data = data.substring(data.indexOf(' ') + 8,                      data.lastIndexOf('<table', data.lastIndexOf('<table') - 1));                    //everything between the infobox and the navbox is valid transcript...hopefully                    $('#' + nospecials(sections[index])).after(data);                    completed += 1;                    $('#transcripts-toc div').css('width', completed / total * 100 + '%');                    $('#transcripts-progress').text((completed / total * 100).toFixed(2));                    if (completed === total) {                        makeTOC;                    }                });            }(j));        }        function makeTOC {            $('#transcripts-toc h2').text('Contents');            $('#transcripts-toc table').html('   <td style="text-align:center; width:100%;">  ');            for (var i = 0; i < sorting.length; i++) {                if ((i === 0 || sorting[i] !== sorting[i-1]) && sorting[i]) {                    $('#transcripts-toc table tr:first').append('<td style="vertical-align:top;">' +                      '<h3 style="width:100%; text-align:center;">' + sorting[i] + ' </ul> ');                }                if (!sorting[i]) {                    if ($('#transcripts-toc table tr:last td').text) {                        $('#transcripts-toc table tr:last td').append(' • ');                    }                    $('#transcripts-toc table tr:last td').append($('', {                        'href': '#' + nospecials(sections[i]),                        'text': sections[i]                    }));                } else {                    $('#transcripts-toc table tr:first td:last ul').append($(' ').append($('', {                        'href': '#' + nospecials(sections[i]),                        'text': sections[i]                    })));                }            }            $('#transcripts-toc table td:last').attr('colspan', $('#transcripts-toc table tr:first td').length);        }        $.getJSON('/api.php?action=parse&text=&prop=text&disablepp=true&format=json',          function(data) {            $content.append(data.parse.text['*']);        });    }); }); // Imports non-720p image listing script by Bobogoobo // Applies to http://mlp.wikia.com/wiki/Special:BlankPage?blankspecial=non720 // See subpage for further documentation if (  mw.config.get('wgPageName') === 'Special:BlankPage' &&  mw.util.getParamValue('blankspecial') === 'non720' ) {    $('#mw-content-text').html(' This list is generated from subcategories of Category:Episode images. Please check whether an image is intended to be the size it is before reuploading it. Make any suggestions (including additional patterns that should be skipped) here</a>.  ');    importScript('MediaWiki:Common.js/Non720.js'); }