Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

MediaWiki:Common.js: Difference between revisions

MediaWiki interface page
Content deleted Content added
imported>76561198045853337
m Undo revision 6928 by 76561198045853337 (talk)
imported>76561198045853337
No edit summary
Line 50: Line 50:
var maxWidth = Math.max.apply(null, pages.map(function(page) { return page.offsetWidth }));
var maxWidth = Math.max.apply(null, pages.map(function(page) { return page.offsetWidth }));
var maxHeight = Math.max.apply(null, pages.map(function(page) { return page.offsetHeight }));
var maxHeight = Math.max.apply(null, pages.map(function(page) { return page.offsetHeight }));
console.log(maxWidth);
pages.forEach(function(page) {
pages.forEach(function(page) {
page.style.cssText = 'min-width: ' + maxWidth + '; min-height: ' + maxHeight + ';';
page.style.cssText = 'min-width: ' + maxWidth + '; min-height: ' + maxHeight + ';';

Revision as of 01:52, 6 August 2021

/* Any JavaScript here will be loaded for all users on every page load. */
/*
     const countDownDate = 'January 21 2021 07:00:00 GMT+0000';

    function getTimeRemaining(endtime) {
        const total = Date.parse(endtime) - Date.parse(new Date());
        const seconds = Math.floor((total / 1000) % 60);
        const minutes = Math.floor((total / 1000 / 60) % 60);
        const hours = Math.floor((total / (1000 * 60 * 60)) % 24);
        const days = Math.floor(total / (1000 * 60 * 60 * 24));
        return {
          total: total, 
          days: days, 
          hours: hours,  
          minutes: minutes, 
          seconds: seconds
        };
    }
    function tick(id, endtime) {
      const clock = document.getElementById(id);
      if(clock != null)
      {
    	const t = getTimeRemaining(endtime);
    	clock.innerHTML = t.days + "d " + t.hours + "h " + t.minutes + "m " + t.seconds + "s ";
        if (t.total <= 0) { clearInterval(timeinterval); }
      }
    }

    function initializeClock(id, endtime) {
        const timeinterval = setInterval(function() { tick(id, endtime) }, 1000);
        tick(id, endtime);
    }

    initializeClock('launch_timer', countDownDate);
*/

function setupPagination() {
  document.querySelectorAll('.mw-parser-output .upgrade_panel').forEach(function(infobox) {
  	Array.from(infobox.getElementsByClassName('upgrade_page_button')).forEach(function(button) {
      button.parentElement.onclick = function(e) {
        e.preventDefault();
        var level = button.dataset.level;
        Array.from(infobox.getElementsByClassName('upgrade_page')).forEach(function(page) { page.classList.toggle('hidden', page.dataset.page != level) });
        Array.from(infobox.getElementsByClassName('upgrade_page_button')).forEach(function(btn) { btn.classList.toggle('active', btn === button) });
        infobox.getElementsByClassName('upgrade_put_level')[0].textContent = button.getElementsByClassName('upgrade_get_level')[0].textContent;
      };
    });

	var pages = Array.from(infobox.getElementsByClassName('upgrade_page'));
	var maxWidth = Math.max.apply(null, pages.map(function(page) { return page.offsetWidth }));
	var maxHeight = Math.max.apply(null, pages.map(function(page) { return page.offsetHeight }));
	console.log(maxWidth);
	pages.forEach(function(page) {
		page.style.cssText = 'min-width: ' + maxWidth + '; min-height: ' + maxHeight + ';';
	});
  });
}

setupPagination();
🍪 We use cookies to keep session information to provide you a better experience.