MediaWiki:Common.js: различия между версиями

Страница интерфейса MediaWiki
Нет описания правки
Метка: ручная отмена
Нет описания правки
 
(не показано 111 промежуточных версий этого же участника)
Строка 2: Строка 2:
/* Лого сайта
/* Лого сайта
Shegare */
Shegare */
document.getElementsByClassName('citizen-header__logo')[0].innerHTML = '<div class="logo1"><a href="https://spacestories.club/index.php?title=Заглавная страница" class="mw-logo citizen-header__button" title="Перейти на заглавную страницу"><img class="mw-logo-icon" src="/resources/assets/logo.png" alt="" aria-hidden="true" height="32" width="32"</a></div><div class="logo2"><a href="https://spacestories.club/index.php?title=Colonial_Marines" class="mw-logo citizen-header__button" title="Перейти на заглавную страницу CM"><img class="mw-logo-icon" src="/images/0/0d/CMlog.png" alt="" aria-hidden="true" height="32" width="32"></a></div>';
document.getElementsByClassName('citizen-header__logo')[0].innerHTML = '<div class="logo1"><a href="https://spacestories.club/index.php?title=Заглавная страница" class="mw-logo citizen-header__button" title="Перейти на заглавную страницу"><img class="mw-logo-icon" src="/resources/assets/logo.png" alt="" aria-hidden="true" height="32" width="32"></a></div><div class="logo2"><a href="https://spacestories.club/index.php?title=Colonial_Marines" class="mw-logo citizen-header__button" title="Перейти на заглавную страницу CM"><img class="mw-logo-icon" src="/images/0/0d/CMlog.png" alt="" aria-hidden="true" height="32" width="32"></a></div>';
 


/* Перенос page-info в конец footer-places
/* Перенос page-info в конец footer-places
Строка 9: Строка 8:
document.getElementById('footer-places').insertAdjacentHTML('afterEnd', document.getElementsByClassName('page-info')[0].innerHTML);
document.getElementById('footer-places').insertAdjacentHTML('afterEnd', document.getElementsByClassName('page-info')[0].innerHTML);
document.getElementsByClassName('page-info')[0].innerHTML = null;
document.getElementsByClassName('page-info')[0].innerHTML = null;


/* Begin логика цвета через headerColor
/* Begin логика цвета через headerColor
Shegare */
Shegare */
if(document.getElementsByClassName('headerColor').length >= 1) {
if (document.getElementsByClassName('headerColor').length >= 1) {


var isValidColor = function(color) {
  var isValidColor = function (color) {
  var el = document.createElement('div');
    var el = document.createElement('div');
  el.style.backgroundColor = color;
    el.style.backgroundColor = color;
  return el.style.backgroundColor ? true : false;
    return el.style.backgroundColor ? true : false;
};
  };


    var header = document.getElementsByClassName('headerColor');
  var header = document.getElementsByClassName('headerColor');
  var colorBorder = '';
  var colorBtn = '';
  var i = 0;


     var colorBorder = '';
  for (; header[0].innerHTML[i] !== '|' && i < header[0].innerHTML.length; i++) {
     var colorBtn = '';
     colorBorder += header[0].innerHTML[i];
  }
  i++;
  for (; i < header[0].innerHTML.length; i++) {
     colorBtn += header[0].innerHTML[i];
  }


    var i = 0;
  if (isValidColor(colorBorder) && isValidColor(colorBtn) && header[0].innerHTML.length > 0) {
    for(; header[0].innerHTML[i] !== '|' && i < header[0].innerHTML.length; i++)
    headerRender(colorBorder, colorBtn);
     {
    document.body.addEventListener('click', function () {
        colorBorder += header[0].innerHTML[i];
      headerRender(colorBorder, colorBtn);
    }
    });
    i++;
  } else {
    for(; i < header[0].innerHTML.length; i++)
    throw "headerColor";
    {
  }
        colorBtn += header[0].innerHTML[i];
}
 
function headerRender(colorBorder, colorBtn) {
  var array = document.querySelectorAll('h1, h2, h3 , h4, h5');
  for (var i = 0; i < array.length; i++) {
     if (array[i].className === 'citizen-section-heading') {
      array[i].querySelector('.citizen-sections-enabled,.citizen-section-indicator').style.background = colorBtn;
      array[i].querySelector('.citizen-sections-enabled,.citizen-section-indicator').style.boxShadow = ('0 0 20px 0px ' + colorBtn + 'cc');
      array[i].querySelector('.mw-headline').style.borderImage = ('linear-gradient(to right top, ' + colorBorder + ', black)');
      array[i].querySelector('.mw-headline').style.borderImageSlice = '1';
    } else if (array[i].className === 'citizen-section-heading citizen-section-heading--collapsed') {
      array[i].querySelector('.citizen-sections-enabled,.citizen-section-heading--collapsed,.citizen-section-indicator').style.background = 'black';
      array[i].querySelector('.citizen-sections-enabled,.citizen-section-heading--collapsed,.citizen-section-indicator').style.boxShadow = 'unset';
     }
     }
  }
}
/* End логика цвета через headerColor
Shegare */
/* Begin sidebar для ролей
Shegare */
if (document.getElementsByClassName('JobsTableContainer').length >= 1) {
  document.getElementById('content').insertAdjacentHTML('afterbegin', document.getElementsByClassName('JobsTableContainer')[0].innerHTML);
  document.getElementById('IdJobsTableContainer1').id = 'IdJobsTableContainer2';
  document.getElementById('content').style.display = 'flex';
  document.getElementById('bodyContent').style.minHeight = '1350px';
}
/* ----------------------------------------------------------Данте------------------------------------------------------------------------ */
/*Год 25*/
(function () {
  var snowflakes = [];
  var numSnowflakes = 50;
  var snowActive = localStorage.getItem('snowActive') === 'true';
  var toggleButton;
  var snowInterval;


if(isValidColor(colorBorder) && isValidColor(colorBtn) && header[0].innerHTML.length > 0) {
  function createSnowflake() {
    headerRender (colorBorder, colorBtn);
    var snowflake = document.createElement('div');
    snowflake.className = 'snowflake';
    snowflake.innerHTML = '&#10052;';
    snowflake.style.left = Math.random() * 100 + 'vw';
    snowflake.style.animationDuration = 5 + Math.random() * 5 + 's';
    snowflake.style.fontSize = Math.random() * 10 + 10 + 'px';
    snowflake.style.animationDelay = Math.random() * 5 + 's';
    document.body.appendChild(snowflake);
    snowflakes.push(snowflake);
    setTimeout(function () {
      snowflake.remove();
      snowflakes.splice(snowflakes.indexOf(snowflake), 1);
    }, 10000);
  }


    document.body.addEventListener('click', function() {
  function startSnowfall() {
        headerRender(colorBorder, colorBtn);
    if (snowActive) return;
    });
    snowActive = true;
}
    localStorage.setItem('snowActive', 'true');
     else {
     for (var i = 0; i < numSnowflakes; i++) {
    throw "headerColor";
      setTimeout(createSnowflake, i * 200);
     }
     }
}
    snowInterval = setInterval(createSnowflake, 300);
  }


function headerRender (colorBorder, colorBtn) {
  function stopSnowfall() {
     var array = document.querySelectorAll('h1, h2, h3 , h4, h5');
     snowActive = false;
     for(var i = 0; i < array.length; i++)
    localStorage.setItem('snowActive', 'false');
    {
    clearInterval(snowInterval);
        if (array[i].className === 'citizen-section-heading') {
     for (var i = 0; i < snowflakes.length; i++) {
            array[i].querySelector('.citizen-sections-enabled,.citizen-section-indicator').style.background = colorBtn;
      snowflakes[i].remove();
            array[i].querySelector('.citizen-sections-enabled,.citizen-section-indicator').style.boxShadow  = ('0 0 20px 0px ' + colorBtn + 'cc');
    }
            array[i].querySelector('.mw-headline').style.borderImage = ('linear-gradient(to right top, ' + colorBorder + ', black)');
    snowflakes = [];
            array[i].querySelector('.mw-headline').style.borderImageSlice = '1';
  }


        }
  function toggleSnowfall() {
        else if(array[i].className === 'citizen-section-heading citizen-section-heading--collapsed') {
    if (snowActive) {
            array[i].querySelector('.citizen-sections-enabled,.citizen-section-heading--collapsed,.citizen-section-indicator').style.background = 'black';
      stopSnowfall();
            array[i].querySelector('.citizen-sections-enabled,.citizen-section-heading--collapsed,.citizen-section-indicator').style.boxShadow = 'unset';
      toggleButton.classList.remove('snow-on');
        }
      toggleButton.classList.add('snow-off');
    } else {
      startSnowfall();
      toggleButton.classList.remove('snow-off');
      toggleButton.classList.add('snow-on');
     }
     }
}
  }
/* End логика цвета через headerColor
Shegare */


  function createToggleButton() {
    var bodyContainer = document.querySelector('body');
    toggleButton = document.createElement('div');
    toggleButton.id = 'snow-toggle';
    toggleButton.className = snowActive ? 'snow-on' : 'snow-off';
    toggleButton.innerHTML = '⛄';
    toggleButton.onclick = toggleSnowfall;


/* Begin sidebar для ролей
    bodyContainer.appendChild(toggleButton);
Shegare */
  }


if(document.getElementsByClassName('JobsTableContainer').length >= 1) {
  if (document.readyState === 'loading') {
document.getElementById('content').insertAdjacentHTML('afterbegin', document.getElementsByClassName('JobsTableContainer')[0].innerHTML);
     document.addEventListener('DOMContentLoaded', function () {
document.getElementById('IdJobsTableContainer1').id = 'IdJobsTableContainer2';
      createToggleButton();
document.getElementById('content').style.display = 'flex';
      if (snowActive) startSnowfall();
document.getElementById('bodyContent').style.minHeight = '1350px';
}
/* ----------------------------------------------------------Данте------------------------------------------------------------------------*/
mw.loader.using(['mediawiki.util'], function () {
     var customItems = document.querySelectorAll('.custom-item');
    Array.prototype.forEach.call(customItems, function (item) {
        var link = item.querySelector('a') || item.querySelector('.custom-text a');
        if (link) {
            item.style.cursor = 'pointer';
            item.addEventListener('click', function () {
                window.location.href = link.href;
            });
        }
     });
     });
  } else {
    createToggleButton();
    if (snowActive) startSnowfall();
  }
})();
/*Год 25*/
/* ----------------------------------------------------------Главное меню лора------------------------------------------------------------------------ */
document.querySelectorAll('.custom-item').forEach(function(item) {
  item.addEventListener('click', function() {
    window.location.href = item.querySelector('a').getAttribute('href');
  });
});
});


/*-*/
/* ----------------------------------------------------------Главное меню планет------------------------------------------------------------------------ */
mw.loader.using(['mediawiki.util'], function () {
document.addEventListener("DOMContentLoaded", function () {
    var customItems = document.querySelectorAll('.custom-item');
  var cards = document.querySelectorAll(".planet-card");
    Array.prototype.forEach.call(customItems, function (item) {
  var panel = document.querySelector(".description-panel");
        var link = item.querySelector('a') || item.querySelector('.custom-text a');
  var planetName = panel.querySelector(".planet-name");
        if (link) {
  var planetDescription = panel.querySelector(".planet-description");
            item.style.cursor = 'pointer';
 
            item.addEventListener('click', function () {
  Array.prototype.forEach.call(cards, function (card) {
                window.location.href = link.href;
    card.addEventListener("click", function () {
            });
      var name = card.querySelector("h3").textContent;
        }
      var description = card.getAttribute("data-description");
    });
 
      planetName.textContent = name;
      planetDescription.textContent = description;
 
      Array.prototype.forEach.call(cards, function (c) {
        c.classList.remove("active");
      });
      card.classList.add("active");


    var colors = ['#6a0dad', '#ff4500', '#1e90ff', '#32cd32', '#ffa500', '#ff1493'];
      panel.scrollIntoView({ behavior: "smooth", block: "center" });
    Array.prototype.forEach.call(customItems, function (item, index) {
        item.style.borderColor = colors[index % colors.length];
        item.addEventListener('mouseover', function () {
            this.style.backgroundColor = colors[index % colors.length];
            this.style.color = '#fff';
        });
        item.addEventListener('mouseout', function () {
            this.style.backgroundColor = '#2a2a2a';
            this.style.color = '#ccc';
        });
     });
     });
  });
});
});

Текущая версия от 08:18, 30 ноября 2024

/* ----------------------------------------------Блок Shegare ---------------------------------------------------------------------------------*/
/* Лого сайта
Shegare */
document.getElementsByClassName('citizen-header__logo')[0].innerHTML = '<div class="logo1"><a href="https://spacestories.club/index.php?title=Заглавная страница" class="mw-logo citizen-header__button" title="Перейти на заглавную страницу"><img class="mw-logo-icon" src="/resources/assets/logo.png" alt="" aria-hidden="true" height="32" width="32"></a></div><div class="logo2"><a href="https://spacestories.club/index.php?title=Colonial_Marines" class="mw-logo citizen-header__button" title="Перейти на заглавную страницу CM"><img class="mw-logo-icon" src="/images/0/0d/CMlog.png" alt="" aria-hidden="true" height="32" width="32"></a></div>';

/* Перенос page-info в конец footer-places
Shegare */
document.getElementById('footer-places').insertAdjacentHTML('afterEnd', document.getElementsByClassName('page-info')[0].innerHTML);
document.getElementsByClassName('page-info')[0].innerHTML = null;

/* Begin логика цвета через headerColor
Shegare */
if (document.getElementsByClassName('headerColor').length >= 1) {

  var isValidColor = function (color) {
    var el = document.createElement('div');
    el.style.backgroundColor = color;
    return el.style.backgroundColor ? true : false;
  };

  var header = document.getElementsByClassName('headerColor');
  var colorBorder = '';
  var colorBtn = '';
  var i = 0;

  for (; header[0].innerHTML[i] !== '|' && i < header[0].innerHTML.length; i++) {
    colorBorder += header[0].innerHTML[i];
  }
  i++;
  for (; i < header[0].innerHTML.length; i++) {
    colorBtn += header[0].innerHTML[i];
  }

  if (isValidColor(colorBorder) && isValidColor(colorBtn) && header[0].innerHTML.length > 0) {
    headerRender(colorBorder, colorBtn);
    document.body.addEventListener('click', function () {
      headerRender(colorBorder, colorBtn);
    });
  } else {
    throw "headerColor";
  }
}

function headerRender(colorBorder, colorBtn) {
  var array = document.querySelectorAll('h1, h2, h3 , h4, h5');
  for (var i = 0; i < array.length; i++) {
    if (array[i].className === 'citizen-section-heading') {
      array[i].querySelector('.citizen-sections-enabled,.citizen-section-indicator').style.background = colorBtn;
      array[i].querySelector('.citizen-sections-enabled,.citizen-section-indicator').style.boxShadow = ('0 0 20px 0px ' + colorBtn + 'cc');
      array[i].querySelector('.mw-headline').style.borderImage = ('linear-gradient(to right top, ' + colorBorder + ', black)');
      array[i].querySelector('.mw-headline').style.borderImageSlice = '1';
    } else if (array[i].className === 'citizen-section-heading citizen-section-heading--collapsed') {
      array[i].querySelector('.citizen-sections-enabled,.citizen-section-heading--collapsed,.citizen-section-indicator').style.background = 'black';
      array[i].querySelector('.citizen-sections-enabled,.citizen-section-heading--collapsed,.citizen-section-indicator').style.boxShadow = 'unset';
    }
  }
}
/* End логика цвета через headerColor
Shegare */

/* Begin sidebar для ролей
Shegare */
if (document.getElementsByClassName('JobsTableContainer').length >= 1) {
  document.getElementById('content').insertAdjacentHTML('afterbegin', document.getElementsByClassName('JobsTableContainer')[0].innerHTML);
  document.getElementById('IdJobsTableContainer1').id = 'IdJobsTableContainer2';
  document.getElementById('content').style.display = 'flex';
  document.getElementById('bodyContent').style.minHeight = '1350px';
}

/* ----------------------------------------------------------Данте------------------------------------------------------------------------ */

/*Год 25*/
(function () {
  var snowflakes = [];
  var numSnowflakes = 50;
  var snowActive = localStorage.getItem('snowActive') === 'true';
  var toggleButton;
  var snowInterval;

  function createSnowflake() {
    var snowflake = document.createElement('div');
    snowflake.className = 'snowflake';
    snowflake.innerHTML = '&#10052;';
    snowflake.style.left = Math.random() * 100 + 'vw';
    snowflake.style.animationDuration = 5 + Math.random() * 5 + 's';
    snowflake.style.fontSize = Math.random() * 10 + 10 + 'px';
    snowflake.style.animationDelay = Math.random() * 5 + 's';
    document.body.appendChild(snowflake);
    snowflakes.push(snowflake);
    setTimeout(function () {
      snowflake.remove();
      snowflakes.splice(snowflakes.indexOf(snowflake), 1);
    }, 10000);
  }

  function startSnowfall() {
    if (snowActive) return;
    snowActive = true;
    localStorage.setItem('snowActive', 'true');
    for (var i = 0; i < numSnowflakes; i++) {
      setTimeout(createSnowflake, i * 200);
    }
    snowInterval = setInterval(createSnowflake, 300);
  }

  function stopSnowfall() {
    snowActive = false;
    localStorage.setItem('snowActive', 'false');
    clearInterval(snowInterval);
    for (var i = 0; i < snowflakes.length; i++) {
      snowflakes[i].remove();
    }
    snowflakes = [];
  }

  function toggleSnowfall() {
    if (snowActive) {
      stopSnowfall();
      toggleButton.classList.remove('snow-on');
      toggleButton.classList.add('snow-off');
    } else {
      startSnowfall();
      toggleButton.classList.remove('snow-off');
      toggleButton.classList.add('snow-on');
    }
  }

  function createToggleButton() {
    var bodyContainer = document.querySelector('body');
    toggleButton = document.createElement('div');
    toggleButton.id = 'snow-toggle';
    toggleButton.className = snowActive ? 'snow-on' : 'snow-off';
    toggleButton.innerHTML = '⛄';
    toggleButton.onclick = toggleSnowfall;

    bodyContainer.appendChild(toggleButton);
  }

  if (document.readyState === 'loading') {
    document.addEventListener('DOMContentLoaded', function () {
      createToggleButton();
      if (snowActive) startSnowfall();
    });
  } else {
    createToggleButton();
    if (snowActive) startSnowfall();
  }
})();
/*Год 25*/
/* ----------------------------------------------------------Главное меню лора------------------------------------------------------------------------ */
document.querySelectorAll('.custom-item').forEach(function(item) {
  item.addEventListener('click', function() {
    window.location.href = item.querySelector('a').getAttribute('href');
  });
});

/* ----------------------------------------------------------Главное меню планет------------------------------------------------------------------------ */
document.addEventListener("DOMContentLoaded", function () {
  var cards = document.querySelectorAll(".planet-card");
  var panel = document.querySelector(".description-panel");
  var planetName = panel.querySelector(".planet-name");
  var planetDescription = panel.querySelector(".planet-description");

  Array.prototype.forEach.call(cards, function (card) {
    card.addEventListener("click", function () {
      var name = card.querySelector("h3").textContent;
      var description = card.getAttribute("data-description");

      planetName.textContent = name;
      planetDescription.textContent = description;

      Array.prototype.forEach.call(cards, function (c) {
        c.classList.remove("active");
      });
      card.classList.add("active");

      panel.scrollIntoView({ behavior: "smooth", block: "center" });
    });
  });
});