No edit summary Tags: Manual revert Reverted |
No edit summary Tag: Reverted |
||
Line 76: | Line 76: | ||
$table.prepend($tableHeader); | $table.prepend($tableHeader); | ||
$table.find('> tbody > tr').first().appendTo($tableHeader); | $table.find('> tbody > tr').first().appendTo($tableHeader); | ||
$table.DataTable(); | $table.DataTable({ | ||
responsive: true, | |||
columnDefs: [ | |||
{ responsivePriority: 1, targets: 0 }, | |||
{ responsivePriority: 2, targets: -1 } | |||
] | |||
}); | |||
}); | }); | ||
} | } |
Revision as of 13:04, 14 February 2024
mw.hook('wikipage.content').add(function($content) { var $bandcamp = $content.find( '.bandcamp:not(.loaded)' ); if ( !$bandcamp.length ) return; $bandcamp.each( function() { var elem = $( this ); var width = elem.attr( 'data-width' ), height = elem.attr( 'data-height' ), data_src = elem.attr( 'data-src' ); if ( !/^https?:\/\/bandcamp\.com\//.test( data_src ) ) return; elem.empty(); var is_px = [ true, true ]; // width, height if ( /%/.test( width ) || !/\d+/.test( width ) ) is_px[ 0 ] = false; if ( /%/.test( height ) ) is_px[ 1 ] = false; var frame_width = parseFloat( width, 10 ) || 100; frame_height = height ? ( parseFloat( height, 10 ) || 'auto' ) : ''; $( '<iframe />', { style: 'border: 0', width: frame_width + ( is_px[ 0 ] ? 'px' : '%' ), height: frame_height + ( frame_height ? ( is_px[ 1 ] ? 'px': '%' ) : '' ), src: data_src }).appendTo( elem ); elem.addClass( 'loaded' ); }); }); if(!players) { var players = document.querySelectorAll(".player-wrapper"); players.forEach((player)=>{ let btn = player.querySelector(".btn"); let record = player.querySelector(".record"); let toneArm = player.querySelector(".tone-arm"); let song = player.querySelector(".my-song"); let slider = player.querySelector(".slider"); btn.addEventListener("click", () => { if (record.classList.contains("on")) { record.classList.remove("on"); toneArm.classList.remove("play"); song.pause(); } else { record.classList.add("on"); toneArm.classList.add("play"); setTimeout(() => { song.play(); }, 1000); } }); slider.addEventListener("input", (e) => { song.volume = Number(e.target.value); }); }) } /** * Name: DataTables.js * Author: KockaAdmiralac <wikia@kocka.tech> * Description: Loads CSS and JavaScript from https://datatables.net and * initializes all tables with the `datatable` class as data tables */ (function($, mw) { 'use strict'; var initialized = false, queue = []; function process($content) { $content.find('.datatable:not(.datatable-loaded)').each(function() { var $table = $(this).addClass('datatable-loaded'), $tableHeader = $('<thead>'); $table.prepend($tableHeader); $table.find('> tbody > tr').first().appendTo($tableHeader); $table.DataTable({ responsive: true, columnDefs: [ { responsivePriority: 1, targets: 0 }, { responsivePriority: 2, targets: -1 } ] }); }); } function initialize($content) { if (initialized) { process($content); } else { queue.push($content); } } mw.loader.load('https://cdn.datatables.net/1.13.7/css/jquery.dataTables.css', 'text/css'); mw.loader.getScript('https://cdn.datatables.net/1.13.7/js/jquery.dataTables.js').then(function() { initialized = true; queue.forEach(process); }); mw.hook('wikipage.content').add(initialize); mw.hook('datatables.loaded').fire(); })(jQuery, mediaWiki);