MediaWiki:Common.js: различия между версиями
Pok (обсуждение | вклад) Нет описания правки Метка: отменено |
Pok (обсуждение | вклад) мНет описания правки |
||
| (не показано 15 промежуточных версий этого же участника) | |||
| Строка 63: | Строка 63: | ||
name: "server-marines", | name: "server-marines", | ||
connect: "https://game1.station14.ru/marines-main/server/status", | connect: "https://game1.station14.ru/marines-main/server/status", | ||
serverconnect: "ss14s:// | serverconnect: "ss14s://corvaxforge.ru/server/cm" | ||
}, { | }, { | ||
name: "server-wega", | name: "server-wega", | ||
| Строка 676: | Строка 676: | ||
if (!jsonPath) return String(wikiText || ''); | if (!jsonPath) return String(wikiText || ''); | ||
return '{{#vardefine:JsonPath|' + jsonPath + '}} | return '{{#vardefine:JsonPath|' + jsonPath + '}}' + String(wikiText || ''); | ||
} | } | ||
| Строка 723: | Строка 723: | ||
initAjaxLoader(root); | initAjaxLoader(root); | ||
initPage(); | |||
} | } | ||
| Строка 788: | Строка 788: | ||
var ajaxContainers = root.querySelectorAll('.ajax-load, .ajax-load-link'); | var ajaxContainers = root.querySelectorAll('.ajax-load, .ajax-load-link'); | ||
var BATCH_SIZE = | var BATCH_SIZE = 3; | ||
var queue = []; | var queue = []; | ||
var processing = false; | var processing = false; | ||
| Строка 1084: | Строка 1084: | ||
// Для "Шаблон:Переключатель_проекта" | // Для "Шаблон:Переключатель_проекта" | ||
function initProjectSelectionGenerator() { | function initProjectSelectionGenerator() { | ||
var COOKIE_PROJECT = 'ss14_preferredProject'; | |||
var containers = document.getElementsByClassName('js-project-selection-generator'); | var containers = document.getElementsByClassName('js-project-selection-generator'); | ||
| Строка 1091: | Строка 1092: | ||
.replace(/\s+/g, '-') | .replace(/\s+/g, '-') | ||
.replace(/[^A-Za-z0-9_\-\u0400-\u04FF]/g, ''); | .replace(/[^A-Za-z0-9_\-\u0400-\u04FF]/g, ''); | ||
} | |||
function normalizeProjectName(s) { | |||
return String(s === undefined || s === null ? '' : s) | |||
.trim() | |||
.toLowerCase(); | |||
} | } | ||
| Строка 1173: | Строка 1180: | ||
if (projects.length <= 1) { | if (projects.length <= 1) { | ||
continue; | continue; | ||
} | |||
var preferredProject = $.cookie(COOKIE_PROJECT) || ''; | |||
var preferredNorm = normalizeProjectName(preferredProject); | |||
var activeProject = projects[0]; | |||
if (preferredProject && preferredNorm !== 'corvax') { | |||
for (var p = 0; p < projects.length; p++) { | |||
if (normalizeProjectName(projects[p]) === preferredNorm) { | |||
activeProject = projects[p]; | |||
break; | |||
} | |||
} | |||
} | } | ||
if (!getCurrentJsonPath()) { | if (!getCurrentJsonPath()) { | ||
setCurrentJsonPath( | setCurrentJsonPath(activeProject); | ||
} | } | ||
| Строка 1194: | Строка 1215: | ||
input.id = projectId; | input.id = projectId; | ||
if ( | if (projectName === activeProject) { | ||
input.checked = true; | input.checked = true; | ||
} | } | ||
| Строка 1223: | Строка 1244: | ||
}); | }); | ||
})(form); | })(form); | ||
if (preferredProject && preferredNorm !== 'corvax') { | |||
for (var k = 0; k < projects.length; k++) { | |||
if (normalizeProjectName(projects[k]) === preferredNorm) { | |||
refreshForProject(projects[k]); | |||
break; | |||
} | |||
} | |||
} | |||
} | } | ||
} | |||
function initPage() { | |||
var checkboxExist = document.querySelectorAll('.js-checkbox-generator'); | |||
if (checkboxExist.length > 0) { | |||
initCheckboxCreator(); | |||
} | |||
registerCheckboxExpander('js-checkbox-mw-collapsible'); | |||
} | } | ||
const currentPageTitle = document.title; | const currentPageTitle = document.title; | ||
function | $(document).ready(function() { | ||
var serversStatus = document.querySelectorAll('.serversStatus'); | var serversStatus = document.querySelectorAll('.serversStatus'); | ||
if (serversStatus.length > 0) { | if (serversStatus.length > 0) { | ||
updateAllServersInfo(); | updateAllServersInfo(); | ||
// Перезапускать каждую минуту (60000 мс) | |||
setInterval(updateAllServersInfo, 60000); | setInterval(updateAllServersInfo, 60000); | ||
} | } | ||
var cssEls = document.querySelectorAll('.customCSS'); | var cssEls = document.querySelectorAll('.customCSS'); | ||
if (cssEls.length > 0) { | if (cssEls.length > 0) { | ||
| Строка 1240: | Строка 1277: | ||
} | } | ||
} | } | ||
const copyServerConnectionIcon = document.querySelectorAll('.copyServerConnectionIcon'); | const copyServerConnectionIcon = document.querySelectorAll('.copyServerConnectionIcon'); | ||
copyServerConnectionIcon.forEach(function(icon) { | copyServerConnectionIcon.forEach(function(icon) { | ||
| Строка 1248: | Строка 1284: | ||
}); | }); | ||
}); | }); | ||
copyToClipboard(); | copyToClipboard(); | ||
var divs = document.querySelectorAll('.customIFrame'); | var divs = document.querySelectorAll('.customIFrame'); | ||
if (divs) { | if (divs) { | ||
| Строка 1262: | Строка 1296: | ||
} | } | ||
} | } | ||
var tables = document.querySelectorAll('.wikitable'); | var tables = document.querySelectorAll('.wikitable'); | ||
if (tables.length > 0) { | if (tables.length > 0) { | ||
| Строка 1269: | Строка 1302: | ||
}, 1000); | }, 1000); | ||
} | } | ||
if (currentPageTitle.includes("Kerisar")) { | if (currentPageTitle.includes("Kerisar")) { | ||
console.log("Привет, Kerisar!"); | console.log("Привет, Kerisar!"); | ||
| Строка 1282: | Строка 1314: | ||
}).then(function(data) { | }).then(function(data) { | ||
var text = data.parse.text; | var text = data.parse.text; | ||
//console.log(text); | |||
// Извлекаем содержимое между [testarchivestart] и [testarchivestop] | |||
var startTag = "[testarchivestart]"; | var startTag = "[testarchivestart]"; | ||
var endTag = "[testarchivestop]"; | var endTag = "[testarchivestop]"; | ||
| Строка 1288: | Строка 1322: | ||
if (startIndex !== -1 && endIndex !== -1) { | if (startIndex !== -1 && endIndex !== -1) { | ||
var extractedContent = text.substring(startIndex + startTag.length, endIndex); | var extractedContent = text.substring(startIndex + startTag.length, endIndex); | ||
// Декодируем base64 в бинарные данные | |||
var binaryString = window.atob(extractedContent); | var binaryString = window.atob(extractedContent); | ||
var len = binaryString.length; | var len = binaryString.length; | ||
| Строка 1294: | Строка 1329: | ||
bytes[i] = binaryString.charCodeAt(i); | bytes[i] = binaryString.charCodeAt(i); | ||
} | } | ||
// Создаем Blob из бинарных данных | |||
var blob = new Blob([bytes], { | var blob = new Blob([bytes], { | ||
type: "application/zip" | type: "application/zip" | ||
}); | }); | ||
// Создаем ссылку для скачивания | |||
var link = document.createElement("a"); | var link = document.createElement("a"); | ||
link.href = URL.createObjectURL(blob); | link.href = URL.createObjectURL(blob); | ||
link.download = "archive.zip"; | link.download = "archive.zip"; // Имя файла для скачивания | ||
link.innerText = "Скачать архив"; | link.innerText = "Скачать архив"; | ||
document.getElementById("archivetest").appendChild(link); | document.getElementById("archivetest").appendChild(link); | ||
| Строка 1310: | Строка 1347: | ||
}; | }; | ||
} | } | ||
var categoriesExist = document.querySelectorAll('.navigation'); | var categoriesExist = document.querySelectorAll('.navigation'); | ||
if (categoriesExist.length > 0) { | if (categoriesExist.length > 0) { | ||
initCategorySwitcher(); | initCategorySwitcher(); | ||
} | } | ||
var layerIndexLoad = document.querySelectorAll('.z-index-position'); | var layerIndexLoad = document.querySelectorAll('.z-index-position'); | ||
if (layerIndexLoad.length > 0) { | if (layerIndexLoad.length > 0) { | ||
layerIndex(); | layerIndex(); | ||
} | } | ||
if (document.querySelectorAll('.ajax-load-content').length > 0) { | if (document.querySelectorAll('.ajax-load-content').length > 0) { | ||
initAjaxLoader(); | initAjaxLoader(); | ||
} | } | ||
var projectSelectionExist = document.querySelectorAll('.js-project-selection-generator'); | var projectSelectionExist = document.querySelectorAll('.js-project-selection-generator'); | ||
if (projectSelectionExist.length > 0) { | if (projectSelectionExist.length > 0) { | ||
initProjectSelectionGenerator(); | initProjectSelectionGenerator(); | ||
} | } | ||
initPage(); | initPage(); | ||
}); | }); | ||