Dantes (обсуждение | вклад) Нет описания правки |
Dantes (обсуждение | вклад) Нет описания правки |
||
| Строка 83: | Строка 83: | ||
(function () { | (function () { | ||
try { | |||
var years = [ | |||
3029, 3024, 3022, 3015, 3005, 3000, 2995, 2980, 3002, 3000, 3029, 2980, | |||
2976, 2971, 2971, 2970, 2970, 2935, 2930, 2930, 2929, 2927, 2922, 2890, | |||
2837, 2829, 2818, 2818, 2815, 2786, 2786, 2785, 2785, 2785, 2785, 2781, | |||
2678, 2652, 2578, 2562, 2556, 2487, 2460, 2461, 2400, 2398 | |||
]; | |||
var events = { | |||
3029: "Подписание 'Брохвицкого Акта'.", | |||
3024: "ИИ Станции от NanoTrasen активно используется.", | |||
3022: "Строительство посольства Брохвицы в Щебельграде.", | |||
3015: "Объявление нового амбициозного проекта.", | |||
3005: "ИИ Станции становится неотъемлемой частью инфраструктуры.", | |||
3000: "NanoTrasen начинает внедрение ИИ Станции.", | |||
2995: "Представление ИИ Станции.", | |||
2980: "Начало разработки проекта ИИ Станции.", | |||
2398: "Первые шаттлы с колонистами прибывают на Спаньелу." | |||
}; | |||
var timelineContainer = document.querySelector('.timeline-container'); | |||
var datesContainer = document.querySelector('.dates'); | |||
var timelineHeight = timelineContainer.offsetHeight; | |||
var yearSpacing = timelineHeight / (years.length - 1); | |||
var positions = {}; // Для избегания перекрытий | |||
years.forEach(function (year, index) { | |||
if (events[year]) { | |||
var topPosition = index * yearSpacing; | |||
// Создаем элемент для даты | |||
var dateElement = document.createElement('div'); | |||
dateElement.className = 'date'; | |||
dateElement.textContent = year; | |||
dateElement.style.top = topPosition + 'px'; | |||
// Создаем элемент для события | |||
var eventElement = document.createElement('div'); | |||
eventElement.className = 'event'; | |||
eventElement.textContent = events[year]; | |||
eventElement.style.top = topPosition + 'px'; | |||
// Избегаем перекрытий | |||
var leftOffset = 20; // Отступ от линии | |||
while (Object.values(positions).some(function (pos) { return Math.abs(pos - topPosition) < 40; })) { | |||
leftOffset += 150; // Сдвигаем вправо | |||
topPosition += 20; // Добавляем немного вертикального отступа | |||
} | |||
eventElement.style.left = leftOffset + 'px'; | |||
positions[year] = topPosition; | |||
// Добавляем элементы в DOM | |||
datesContainer.appendChild(dateElement); | |||
datesContainer.appendChild(eventElement); | |||
} | |||
}); | |||
} catch (error) { | |||
console.error("Ошибка:", error); | |||
} | |||
})(); | })(); | ||
Версия от 14:57, 17 ноября 2024
/* Лого сайта
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';
}
/*полигон данте*/
(function () {
try {
var years = [
3029, 3024, 3022, 3015, 3005, 3000, 2995, 2980, 3002, 3000, 3029, 2980,
2976, 2971, 2971, 2970, 2970, 2935, 2930, 2930, 2929, 2927, 2922, 2890,
2837, 2829, 2818, 2818, 2815, 2786, 2786, 2785, 2785, 2785, 2785, 2781,
2678, 2652, 2578, 2562, 2556, 2487, 2460, 2461, 2400, 2398
];
var events = {
3029: "Подписание 'Брохвицкого Акта'.",
3024: "ИИ Станции от NanoTrasen активно используется.",
3022: "Строительство посольства Брохвицы в Щебельграде.",
3015: "Объявление нового амбициозного проекта.",
3005: "ИИ Станции становится неотъемлемой частью инфраструктуры.",
3000: "NanoTrasen начинает внедрение ИИ Станции.",
2995: "Представление ИИ Станции.",
2980: "Начало разработки проекта ИИ Станции.",
2398: "Первые шаттлы с колонистами прибывают на Спаньелу."
};
var timelineContainer = document.querySelector('.timeline-container');
var datesContainer = document.querySelector('.dates');
var timelineHeight = timelineContainer.offsetHeight;
var yearSpacing = timelineHeight / (years.length - 1);
var positions = {}; // Для избегания перекрытий
years.forEach(function (year, index) {
if (events[year]) {
var topPosition = index * yearSpacing;
// Создаем элемент для даты
var dateElement = document.createElement('div');
dateElement.className = 'date';
dateElement.textContent = year;
dateElement.style.top = topPosition + 'px';
// Создаем элемент для события
var eventElement = document.createElement('div');
eventElement.className = 'event';
eventElement.textContent = events[year];
eventElement.style.top = topPosition + 'px';
// Избегаем перекрытий
var leftOffset = 20; // Отступ от линии
while (Object.values(positions).some(function (pos) { return Math.abs(pos - topPosition) < 40; })) {
leftOffset += 150; // Сдвигаем вправо
topPosition += 20; // Добавляем немного вертикального отступа
}
eventElement.style.left = leftOffset + 'px';
positions[year] = topPosition;
// Добавляем элементы в DOM
datesContainer.appendChild(dateElement);
datesContainer.appendChild(eventElement);
}
});
} catch (error) {
console.error("Ошибка:", error);
}
})();