MediaWiki:Common.js

From AIOWiki
Jump to navigation Jump to search

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
//START OF podcast videos
function showPodcasts(){
    $("#showPodcastYoutube").click(function(){ 
        $("#hiddenPodcastVideo").find("embed").height(175);
	    $("#hiddenPodcastVideo").find("embed").width(213);
	    $("#hiddenPodcastVideo").toggle();
    });
}
mw.hook( 'wikipage.content' ).add( showPodcasts );
//end of hidden podcast videos

//START OF TIMER CODE
function importTimer(){
    $.getScript("https://www.aiowiki.com/w/index.php?title=Mediawiki:TinyTimer.js&action=raw&ctype=text/javascript");    
    $.getScript("https://www.aiowiki.com/w/index.php?title=MediaWiki:Common.js/mainpage.js&action=raw&ctype=text/javascript");
    $.getScript("https://www.aiowiki.com/w/index.php?title=Mediawiki:Audio.js&action=raw&ctype=text/javascript");    
}
mw.hook( 'wikipage.content' ).add( importTimer );
//END OF TIMER CODE

//END OF MAIN PAGE FUNCTIONS

/*START OF OPEN EXTERNAL LINKS IN NEW TAB*/
$( document ).ready( function() {
    var alinks = document.getElementById('content').getElementsByTagName("a");
    var tablink, sitename;
    for (var i = 0, leng = alinks.length; i < leng; i++) {
        tablink = alinks[i];
        if (tablink.className.indexOf("external") !== -1 && tablink.href.indexOf(mw.config.get( 'wgServer' ) !== 0) ){
            tablink.target = "_blank";
        }
    }
});
/*END OF OPEN EXTERNAL LINKS IN NEW TAB*/

//  Folding Multi Wiki Tabs
function showMultiTab(index1, index2){
    $(".foldtabSet").eq(index1).each(function (){
        $(this).find(".foldtabBox").each(function hideTabs(){
    		$(this).hide();
		});
		$(this).find(".foldtabBox").eq(index2).each(function hideTabs(){
			$(this).show();
		});		
        $(this).find(".foldtabHead a").each(function removeClass(){
    		$(this).removeClass("selected");
		});		
    	$(this).find(".foldtabHead a").eq(index2).each(function addClass(){
			$(this).addClass("selected");
		});		
	});   
}

function loadMultiTabs(){
    $(".foldtabSet").each(function showtabs(index1){
        $(this).find(".foldtabHead").each(function showTabsHeader(){
    		$(this).show();
    		$(this).children('a').each(function linkifyHeader(index2){
    			$(this).removeAttr("title");
    			$(this).attr('href', 'javascript:showMultiTab(\'' + index1 + '\',\'' + index2 + '\');');
    		});
    	});
    	$(this).find(".foldtabBox").each(function hideTabs(){
    		$(this).hide();
    	});
        showMultiTab(index1, 0 );
    });
}
mw.hook( 'wikipage.content' ).add( loadMultiTabs );
//            END Folding Multi Wiki Tabs

/* Episode Table */
function tabTable() {
    $( '[id^=tab]:empty' ).remove();
    $( '[id^=tab]' ).hide();
    $( '[id^=tab]' ).first().show();
}

function changeTab(num) {
    $( '[id^=tab]' ).hide();
    var id = '#tab' + num;
    $(id).show();
}
mw.hook( 'wikipage.content' ).add( tabTable );

/* Spoilers */
function spoilerToggle() {
    $('#spoilerText').show();
    $('#spoilerHead').hide();    
}
 
/* remove tool tip when we have our own tips*/
$(document).ready(function(){
    $(".tip a").removeAttr("title");
});
 
/* sort characters by last name */
$(document).ready(function(){
    $( "td .character_name" ).each(function() {
        var name = $( this ).first().text();
        var names = name.split(" ");
        names.reverse();
        names.join();
        $(this).parent().attr("data-sort-value",names);
    });
});
 
/* sort actors by last name */
$(document).ready(function(){
    $( "td .actor_name" ).each(function() {
        var name = $( this ).first().text();
        var names = name.split(" ");
        names.reverse();
        names.join();
        $(this).parent().attr("data-sort-value",names);
    });

$('audio').each(function(){
  $(this).attr('controls',false);
});
});

// Random quote generator.
if (mw.config.get( 'wgPageName' ) == "Adventures_in_Odyssey_Wiki:Random_Quote_Generator")
{
    $("#loading").ajaxStart(function(){
       $(this).show();
       document.getElementById( 'refreshQuote' ).style.display = 'none';
    }).ajaxStop(function(){
       $(this).hide();
       document.getElementById( 'refreshQuote' ).style.display = '';
    });
    
    function refreshQuote() {
        $('#quote').load(document.URL + ' #quote');
    }
}

$( ".hide-parent" ).parent().remove();
if ($('#club-album-appearances').children().first().children().length === 0){
    $('#club-album-appearances-header').remove();
    $('#club-album-appearances').remove();
}
if ($('#series-album-appearances').children().first().children().length === 0){
    $('#series-album-appearances-header').remove();
    $('#series-album-appearances').remove();
}

mw.loader.load( '/w/index.php?title=MediaWiki:Ethat-search.js&action=raw&ctype=text/javascript' );
mw.loader.load( '/w/index.php?title=MediaWiki:CharacterIntersetion.js&action=raw&ctype=text/javascript' );