• Welcome to the Kancolle Wiki!
  • If you have any questions regarding site content, account registration, etc., please visit the KanColle Wiki Discord

Changes

Jump to navigation Jump to search
m
no edit summary
Line 1: Line 1: −
/**
+
function filterTable(){
* Scrolling text
+
$("table.filterable").each(function(){
*
+
var i=0;
* Copied from zh.kcwiki.moe
+
var cols;
*/
+
$(this).find("tr:first-child th, tr:first-child td").each(function(){
 +
if (!$(this).hasClass("unfilterable")){
 +
cols=[];
 +
$(this).closest("table").find("tr td:nth-child("+(i+1)+")").each(function(){
 +
cols.push($(this).text());
 +
});
 +
cols = arrayUnique(cols);
 +
l=0;
 +
for (j=0; j<cols.length; j++){
 +
t=charLength(cols[j]);
 +
if (l<t) l=t;
 +
}
 +
$(this).css("position","relative");
 +
$(this).html('<a href="javascript:void(0)" class="showFilterMenu">'+$(this).html()+'▼</a>');
 +
$(this).append($('<div class="filterMenu hidden" style="position: absolute; top: '+$(this).height()+35+'px; left: 0; width: '+(50+l*7)+'px; text-align: left; padding: 5px; border: 1px #333333 solid; -moz-border-radius: 8px; -webkit-border-radius: 8px; border-radius: 8px; background: inherit; z-index: 1"></div>'));
 +
for (j=0; j<cols.length; j++){
 +
$(this).find(".filterMenu").append('<div><input type="checkbox" value="'+cols[j]+'" col="'+(i+1)+'" class="filterOption" checked>'+cols[j]+'</div>');
 +
}
 +
}
 +
i++;
 +
});
 +
$(this).find("tr:nth-child(n+1)").attr("condition", 0);
 +
});
 +
$(".showFilterMenu").click(function(){
 +
if ($(this).parent().find(".filterMenu:visible").length){
 +
$(".filterMenu").slideUp(150);
 +
}else{
 +
$(".filterMenu").slideUp(150);
 +
$(this).parent().find(".filterMenu").slideDown(150);
 +
}
 +
});
 +
$(document).mouseup(function(e){
 +
var container = $(".filterMenu");
 +
    if (!container.is(e.target) && container.has(e.target).length === 0){
 +
        container.slideUp(150);
 +
    }
 +
});
 +
$(".filterOption").click(function(){
 +
col=$(this).attr("col");
 +
val=$(this).val();
 +
if ($(this).is(":checked")) chg=1; else chg=-1;
 +
$(this).closest("table").find("tr:nth-child(n+1)").each(function(){
 +
if ($(this).find("td:nth-child("+col+")").text()==val){
 +
var cond=$(this).attr("condition");
 +
cond=Number(cond)+chg;
 +
$(this).attr("condition", cond);
 +
if (cond===0) $(this).show();
 +
else $(this).hide();
 +
}
 +
});
 +
});
 +
}
 +
 
 +
function arrayUnique(a) {
 +
    return a.reduce(function(p, c) {
 +
        if (p.indexOf(c) < 0) p.push(c);
 +
        return p;
 +
    }, []);
 +
}
   −
function AutoScroll(objNotice) {
+
function charLength(s){
    $(objNotice).find("ul:first").animate({
+
return s.length+(encodeURI(s).split(/%..|./).length-1-s.length)/2;
        marginTop:"-25px"
  −
    },500,function(){
  −
        $(this).css({marginTop: "0px"}).find("li:first").appendTo(this);
  −
    });
   
}
 
}
  −
$(document).ready(function() {
  −
    setInterval('AutoScroll("#scrollDiv")',5000);
  −
    //image loading effect
  −
    $('img').on('load', function(e){
  −
        var target = $(this);
  −
        target.css('opacity', 0).animate({opacity: 1}, 1000);
  −
  });
  −
});
     −
  −
mw.hook( 'wikipage.content' ).add( createCollapseButtons );
  −
  −
/**
  −
* Dynamic Navigation Bars (experimental)
  −
*
  −
* Description: See [[Wikipedia:NavFrame]].
  −
* Maintainers: UNMAINTAINED
  −
*/
  −
  −
/* set up the words in your language */
  −
var NavigationBarHide = '[' + collapseCaption + ']';
  −
var NavigationBarShow = '[' + expandCaption + ']';
  −
var indexNavigationBar = 0;
  −
   
/**
 
/**
 
  * Shows and hides content and picture (if available) of navigation bars
 
  * Shows and hides content and picture (if available) of navigation bars
Line 53: Line 83:  
     /* if shown now */
 
     /* if shown now */
 
     if ( NavToggle.firstChild.data === NavigationBarHide ) {
 
     if ( NavToggle.firstChild.data === NavigationBarHide ) {
         for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
+
         for ( NavChild = NavFrame.firstChild; NavChild !== null; NavChild = NavChild.nextSibling ) {
 
             if ( $( NavChild ).hasClass( 'NavContent' ) || $( NavChild ).hasClass( 'NavPic' ) ) {
 
             if ( $( NavChild ).hasClass( 'NavContent' ) || $( NavChild ).hasClass( 'NavPic' ) ) {
 
                 NavChild.style.display = 'none';
 
                 NavChild.style.display = 'none';
Line 62: Line 92:  
     /* if hidden now */
 
     /* if hidden now */
 
     } else if ( NavToggle.firstChild.data === NavigationBarShow ) {
 
     } else if ( NavToggle.firstChild.data === NavigationBarShow ) {
         for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
+
         for ( NavChild = NavFrame.firstChild; NavChild !== null; NavChild = NavChild.nextSibling ) {
 
             if ( $( NavChild ).hasClass( 'NavContent' ) || $( NavChild ).hasClass( 'NavPic' ) ) {
 
             if ( $( NavChild ).hasClass( 'NavContent' ) || $( NavChild ).hasClass( 'NavPic' ) ) {
 
                 NavChild.style.display = 'block';
 
                 NavChild.style.display = 'block';
Line 97: Line 127:  
             * "collapsed" to the NavFrame itself, just like with collapsible tables.
 
             * "collapsed" to the NavFrame itself, just like with collapsible tables.
 
             */
 
             */
             for ( NavChild = NavFrame.firstChild; NavChild != null && !isCollapsed; NavChild = NavChild.nextSibling ) {
+
             for ( NavChild = NavFrame.firstChild; NavChild !== null && !isCollapsed; NavChild = NavChild.nextSibling ) {
 
                 if ( $( NavChild ).hasClass( 'NavPic' ) || $( NavChild ).hasClass( 'NavContent' ) ) {
 
                 if ( $( NavChild ).hasClass( 'NavPic' ) || $( NavChild ).hasClass( 'NavContent' ) ) {
 
                     if ( NavChild.style.display === 'none' ) {
 
                     if ( NavChild.style.display === 'none' ) {
Line 105: Line 135:  
             }
 
             }
 
             if ( isCollapsed ) {
 
             if ( isCollapsed ) {
                 for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
+
                 for ( NavChild = NavFrame.firstChild; NavChild !== null; NavChild = NavChild.nextSibling ) {
 
                     if ( $( NavChild ).hasClass( 'NavPic' ) || $( NavChild ).hasClass( 'NavContent' ) ) {
 
                     if ( $( NavChild ).hasClass( 'NavPic' ) || $( NavChild ).hasClass( 'NavContent' ) ) {
 
                         NavChild.style.display = 'none';
 
                         NavChild.style.display = 'none';
Line 128: Line 158:  
mw.hook( 'wikipage.content' ).add( createNavigationBarToggleButton );
 
mw.hook( 'wikipage.content' ).add( createNavigationBarToggleButton );
   −
/**
+
// Fix Table Header
* Collapsible tables
+
var TableHeadFix = function () {
*
+
    var obj, $table, $newtable, $win;
* @version 2.0.2 (2014-03-14)
+
    obj = this;
* @source https://www.mediawiki.org/wiki/MediaWiki:Gadget-collapsibleTables.js
  −
* @author [[User:R. Koot]]
  −
* @author [[User:Krinkle]]
  −
* @deprecated Since MediaWiki 1.20: Use class="mw-collapsible" instead which
  −
* is supported in MediaWiki core.
  −
*/
  −
/*global $, mw */
  −
var autoCollapse = 2;
  −
var collapseCaption = 'hide';
  −
var expandCaption = 'show';
   
   
 
   
function collapseTable( tableIndex ) {
+
    this.clonehead = function () {
var Button = document.getElementById( 'collapseButton' + tableIndex );
+
        $newtable = $table.clone();
var Table = document.getElementById( 'collapsibleTable' + tableIndex );
+
        $newtable.find('tr:gt(0)').remove();
 
   
 
   
if ( !Table || !Button ) {
+
        $newtable.css('top', '0');
return false;
+
        $newtable.css('position', 'fixed');
}
+
        // Fixed by kk @ 2015-04-03
 +
        $newtable.css('margin-top', '0');
 +
        $newtable.hide();
 +
    };
 
   
 
   
var Rows = Table.rows;
  −
var i;
   
   
 
   
if ( Button.firstChild.data === collapseCaption ) {
+
    this.check = function () {
for ( i = 1; i < Rows.length; i++ ) {
+
        if($table.size() === 0){
Rows[i].style.display = 'none';
+
            return;
}
+
        }
Button.firstChild.data = expandCaption;
+
        var scrollTop = $win.scrollTop();
} else {
+
        var start_offset = $table.offset();
for ( i = 1; i < Rows.length; i++ ) {
+
        if (scrollTop > start_offset.top && scrollTop <= (start_offset.top + $table.height())) {
Rows[i].style.display = Rows[0].style.display;
+
            $newtable.show();
}
+
        } else {
Button.firstChild.data = collapseCaption;
+
            $newtable.hide();
}
+
        }
}
+
    };
 
   
 
   
function createClickHandler( tableIndex ) {
+
    this.event = function () {
return function ( e ) {
+
        $win.bind('scroll', obj.check);
e.preventDefault();
+
    };
collapseTable( tableIndex );
  −
};
  −
}
  −
function createCollapseButtons()
  −
{
  −
    var tableIndex = 0;
  −
    var NavigationBoxes = new Object();
  −
    var Tables = getElementsByClassName(document, "table", "collapsible");
   
   
 
   
     for ( var i = 0; i < Tables.length; i++ ) {
+
     this.init = function (obj) {
            /* only add button and increment count if there is a header row to work with */
+
        $win = $(window);
            var HeaderRow = Tables[i].getElementsByTagName( "tr" )[0];
+
        $table = $(obj);
            if (!HeaderRow) continue;
+
        this.clonehead();
            var Header = HeaderRow.getElementsByTagName( "th" )[0];
+
        $table.after($newtable);
            if (!Header) continue;
   
   
 
   
            NavigationBoxes[ tableIndex ] = Tables[i];
+
        this.event();
            Tables[i].setAttribute( "id", "collapsibleTable" + tableIndex );
+
        this.check();
+
    };
            var Button     = document.createElement( "span" );
+
};
            var ButtonLink = document.createElement( "a" );
+
 
            var ButtonText = document.createTextNode( collapseCaption );
+
$(function() {
+
 
            Button.className = "collapseButton"//Styles are declared in Common.css
+
// Extension:SoundManager2Button
+
// TODO: initialize properly so this isn't needed
            ButtonLink.style.color = Header.style.color;
+
if (window.soundManager && window.soundManager.beginDelayedInit && !window.soundManager.enabled) {
            ButtonLink.setAttribute( "id", "collapseButton" + tableIndex );
+
console.debug('KLUDGE: calling window.soundManager.beginDelayedInit()');
            ButtonLink.setAttribute( "href", "javascript:collapseTable(" + tableIndex + ");" );
+
window.soundManager.beginDelayedInit();
            ButtonLink.appendChild( ButtonText );
+
}
+
 
            Button.appendChild( document.createTextNode( "[" ) );
+
// Table things
            Button.appendChild( ButtonLink );
+
 
            Button.appendChild( document.createTextNode( "]" ) );
+
    $(".showExtra").click(function() {
+
    $(this).closest("table").find(".extraRow").fadeIn("slow");$(this).closest("tr").remove();
            Header.insertBefore( Button, Header.childNodes[0] );
+
    });
            tableIndex++;
+
 
    }
+
    filterTable();
+
 
    var Tables = getElementsByClassName(document, "table", "collapsed");
+
    $('.fixtable').each(function(){
    for ( var i = 0; i < Tables.length; i++ ) {
+
    var tableHeadFix = new TableHeadFix();
        collapseTable( i );
+
    tableHeadFix.init(this);
    }
+
    });
+
 
    var Tables = getElementsByClassName(document, "table", "autocollapse");
+
     // Template:Map/ImageNode
    for ( var i = 0; i < Tables.length; i++ ) {
+
 
        if ( i >= autoCollapse ) {
+
    function supportTemplateMapImageNode() {
            collapseTable( i );
+
    $('.map-image > span > a').off('click');
        }  
+
    $('.map-image > span > a').click(function (e) {
    }  
+
        e.preventDefault();
}
+
    var $element = $($(this).attr('href'));
+
    var $container = $element.parent();
mw.hook( 'wikipage.content' ).add( createCollapseButtons );
+
    $container.scrollTop($container.scrollTop() - $container.offset().top + $element.offset().top);
 +
    });
 +
}
 +
supportTemplateMapImageNode();
 +
mw.hook('wikipage.content').add(supportTemplateMapImageNode);
 +
 
 +
// From gbf.wiki
 +
// Add a dynamic fixed header to tables with:
 +
// 1) table with "header-fixed" class
 +
// 2) a table row with "header-row" class
 +
// TODO: tablesorter, tabbertab, resize
 +
// mw.loader.using('jquery.tablesorter', function() {
 +
var tables = [];
 +
 
 +
function initializeStickyHeader() {
 +
var $tables = $('.header-fixed');
 +
 
 +
if ($tables.length == 0) return;
 +
 
 +
$tables.each(function(n) {
 +
  if ($(this).hasClass('header-fixed-done')) return;
 +
  if ($(this).hasClass('mw-collapsed')) {
 +
  console.debug('header-fixed: collapsed: ' + n)
 +
  $(this).find('.mw-collapsible-text').click(function() {
 +
  console.debug('header-fixed: click: ' + n)
 +
  setTimeout(function() { initializeStickyHeader(); }, 1000);
 +
  })
 +
  return;
 +
  }
 +
/*
 +
    var tabberTabParent = $(this).parent(".tabbertab")[0];
 +
    var originalStyleDisplay;
 +
    if (tabberTabParent) {
 +
    originalStyleDisplay = tabberTabParent.style.display;
 +
    tabberTabParent.style.visibility = "hidden";
 +
    tabberTabParent.style.display = "block";
 +
    }
 +
*/
 +
    var $headerRow = $(this).find('.header-row');
 +
    var $newHeaderContent = $('<tbody>');
 +
    $newHeaderContent.append($headerRow.clone());
 +
 
 +
    var $columnsOld = $headerRow.find('td:not([colspan]),th:not([colspan])');
 +
    var $newHeaderColgroup = $('<colgroup>');
 +
    for (var i = 0; i < $columnsOld.length; i++) {
 +
    $newHeaderColgroup.append($('<col>').css('width', $columnsOld[i].getBoundingClientRect().width));
 +
    }
 +
 
 +
    $(this).before(
 +
    $('<table>')
 +
        .addClass('header-fixed-helper')
 +
        .addClass('wikitable')
 +
        .css('position', 'sticky')
 +
        .css('top', '0')
 +
        .css('z-index', '9')
 +
        .css('display', 'none')
 +
        .css('background-color', '#fff')
 +
        .css('margin-top', '0')
 +
        .css('margin-bottom', '0')
 +
        .css('table-layout', 'fixed')
 +
        .append($newHeaderColgroup)
 +
        .append($newHeaderContent)
 +
    );
 +
    tables.push({ table: this, helper: this.previousSibling });
 +
    $(this.previousSibling).css('width', $(this).width() + 1);
 +
/*
 +
    if (tabberTabParent) {
 +
    tabberTabParent.style.visibility = "";
 +
    tabberTabParent.style.display = originalStyleDisplay;
 +
    }
 +
    */
 +
    $(this).addClass('header-fixed-done');
 +
    console.debug('header-fixed: fixed: ' + n)
 +
});
 +
}
 +
 
 +
$(window).on('scroll', function() {
 +
var scrollOffset = $(this).scrollTop();
 +
for (var i = 0; i < tables.length; i++) {
 +
var tableOffset = $(tables[i].table).offset().top;
 +
var tableHeight = $(tables[i].table).height();
 +
var helperHeight = $(tables[i].helper).height();
 +
if ((scrollOffset > tableOffset) && (scrollOffset < (tableOffset + tableHeight - helperHeight))) {
 +
    if ($(tables[i].helper).is(':hidden')) {
 +
    $(tables[i].helper).show();
 +
    }
 +
} else {
 +
    $(tables[i].helper).hide();
 +
}
 +
}
 +
});
 +
 
 +
/*
 +
var ts = $.fn.tablesorter;
 +
$.fn.tablesorter = function() {
 +
  ts.apply(this, arguments);
 +
  initializeStickyHeader();
 +
}
 +
*/
 +
setTimeout(function() { initializeStickyHeader(); }, 1000);
 +
//})
 +
 
 +
// Basic video support using <img> and <video> elements
 +
 
 +
$('.video').each(function () {
 +
var src = $(this).data('src') || '';
 +
var parts = src.split('.');
 +
var ext = parts[parts.length - 1] || '';
 +
if (ext === 'webp') {
 +
var a = $('<a>').addClass('image').attr('href', '/File:' + src);
 +
var img = $('<img>');
 +
for (var attr in $(this).data()) {
 +
img.attr(attr, (attr === 'src' ? 'https://en.kancollewiki.net/Special:Filepath/' : '') + $(this).data(attr));
 +
}
 +
a.append(img);
 +
      $(this).append(a);
 +
} else {
 +
var video = $('<video>').attr('controls', '');
 +
var source = $('<source>').attr('type', 'video/' + ext);
 +
for (var attr in $(this).data()) {
 +
var el = attr === 'src' || attr === 'type' ? source : video;
 +
el.attr(attr, (attr === 'src' ? 'https://en.kancollewiki.net/Special:Filepath/' : '') + $(this).data(attr));
 +
}
 +
video.append(source);
 +
      $(this).append(video);
 +
}
 +
});
   −
importArticles({
  −
    type: "script",
  −
    articles: [
  −
        "User:Gensui_Hime/js/countdown.js",
  −
        "MediaWiki:SoundManager2.js" ]
   
});
 
});
cssedit, gkautomate
6,926

edits

Navigation menu