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

Страница интерфейса MediaWiki
Нет описания правки
Метка: ручная отмена
Нет описания правки
Строка 1: Строка 1:
/* Лого сайта
if (!document.querySelector('.logo1')) {
Shegare */
  document.getElementsByClassName('citizen-header__logo')[0].innerHTML = `
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>';
    <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>`;
}


if (document.getElementsByClassName('page-info').length > 0 && document.getElementById('footer-places')) {
  document.getElementById('footer-places').insertAdjacentHTML('afterEnd', document.getElementsByClassName('page-info')[0].innerHTML);
  document.getElementsByClassName('page-info')[0].innerHTML = '';
}


/* Перенос page-info в конец footer-places
if (document.getElementsByClassName('headerColor').length >= 1) {
Shegare */
  var isValidColor = function(color) {
document.getElementById('footer-places').insertAdjacentHTML('afterEnd', document.getElementsByClassName('page-info')[0].innerHTML);
    var el = document.createElement('div');
document.getElementsByClassName('page-info')[0].innerHTML = null;
    el.style.backgroundColor = color;
    return el.style.backgroundColor ? true : false;
  };


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


/* Begin логика цвета через headerColor
  for (; header[0].innerHTML[i] !== '|' && i < header[0].innerHTML.length; i++) {
Shegare */
    colorBorder += header[0].innerHTML[i];
if(document.getElementsByClassName('headerColor').length >= 1) {
  }


var isValidColor = function(color) {
  i++;
  var el = document.createElement('div');
  for (; i < header[0].innerHTML.length; i++) {
  el.style.backgroundColor = color;
    colorBtn += header[0].innerHTML[i];
  return el.style.backgroundColor ? true : false;
  }
};


     var header = document.getElementsByClassName('headerColor');
  if (isValidColor(colorBorder) && isValidColor(colorBtn)) {
 
    headerRender(colorBorder, colorBtn);
     var colorBorder = '';
     document.body.addEventListener('click', function() {
     var colorBtn = '';
      headerRender(colorBorder, colorBtn);
     });
  } else {
     throw "headerColor";
  }
}


    var i = 0;
function headerRender(colorBorder, colorBtn) {
     for(; header[0].innerHTML[i] !== '|' && i < header[0].innerHTML.length; i++)
  var array = document.querySelectorAll('h1, h2, h3, h4, h5');
     {
  for (var i = 0; i < array.length; i++) {
        colorBorder += header[0].innerHTML[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';
     }
     }
    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() {
if (document.getElementsByClassName('JobsTableContainer').length >= 1) {
        headerRender(colorBorder, colorBtn);
  document.getElementById('content').insertAdjacentHTML('afterbegin', document.getElementsByClassName('JobsTableContainer')[0].innerHTML);
    });
  document.getElementById('IdJobsTableContainer1').id = 'IdJobsTableContainer2';
}
  document.getElementById('content').style.display = 'flex';
    else {
  document.getElementById('bodyContent').style.minHeight = '1350px';
    throw "headerColor";
    }
}
}


function headerRender (colorBorder, colorBtn) {
function filterEvents(category) {
    var array = document.querySelectorAll('h1, h2, h3 , h4, h5');
  const events = document.querySelectorAll('.event');
    for(var i = 0; i < array.length; i++)
  events.forEach(event => {
     {
     if (event.dataset.category === category) {
        if (array[i].className === 'citizen-section-heading') {
      event.style.display = 'block';
            array[i].querySelector('.citizen-sections-enabled,.citizen-section-indicator').style.background = colorBtn;
    } else {
            array[i].querySelector('.citizen-sections-enabled,.citizen-section-indicator').style.boxShadow  = ('0 0 20px 0px ' + colorBtn + 'cc');
      event.style.display = 'none';
            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';
}
/*полигон данте*/

Версия от 04:04, 17 ноября 2024

if (!document.querySelector('.logo1')) {
  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>`;
}

if (document.getElementsByClassName('page-info').length > 0 && document.getElementById('footer-places')) {
  document.getElementById('footer-places').insertAdjacentHTML('afterEnd', document.getElementsByClassName('page-info')[0].innerHTML);
  document.getElementsByClassName('page-info')[0].innerHTML = '';
}

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 = '', 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)) {
    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';
    }
  }
}

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';
}

function filterEvents(category) {
  const events = document.querySelectorAll('.event');
  events.forEach(event => {
    if (event.dataset.category === category) {
      event.style.display = 'block';
    } else {
      event.style.display = 'none';
    }
  });
}