MediaWiki:Common.js: различия между версиями
Материал из Space Station 14 Вики
Kerisar (обсуждение | вклад) мНет описания правки |
Kerisar (обсуждение | вклад) мНет описания правки |
||
Строка 39: | Строка 39: | ||
// console.log(responseDataServers); | // console.log(responseDataServers); | ||
// } | // } | ||
// let serversStatus = { | // let serversStatus = { | ||
// main: { | // main: { | ||
Строка 66: | Строка 65: | ||
// }, | // }, | ||
// }; | // }; | ||
function getServersInfo(connect) { | function getServersInfo(connect) { | ||
return new Promise((resolve, reject) => { | return new Promise((resolve, reject) => { | ||
Строка 74: | Строка 71: | ||
xhr.onload = function() { | xhr.onload = function() { | ||
if (xhr.status >= 200 && xhr.status < 300) { | if (xhr.status >= 200 && xhr.status < 300) { | ||
const serverInfo = JSON.parse(xhr.responseText); | |||
resolve(serverInfo); | |||
} else { | } else { | ||
reject('Ошибка при выполнении запроса: ' + xhr.status); | reject('Ошибка при выполнении запроса: ' + xhr.status); | ||
} | } | ||
}; | }; | ||
Строка 85: | Строка 83: | ||
}); | }); | ||
} | } | ||
Строка 102: | Строка 101: | ||
"https://thumb.cloud.mail.ru/weblink/thumb/xw1/LLmd/Qui7Xbp6g"); | "https://thumb.cloud.mail.ru/weblink/thumb/xw1/LLmd/Qui7Xbp6g"); | ||
jsTest.appendChild(kerisarPicture); | jsTest.appendChild(kerisarPicture); | ||
getServersInfo('https://game2.station14.ru/main/server/status') | |||
.then(serverInfo => { | |||
console.log("serverInfo", serverInfo) | |||
}) | |||
.catch(error => { | |||
console.error(error); | |||
}); | |||
} | } | ||
$(document).ready(function() { | $(document).ready(function() { | ||
kerisarTest(); | |||
}); | }); | ||
Версия от 16:40, 20 июня 2024
// const serversConnectors = ['https://game2.station14.ru/main/server/status', // 'https://game2.station14.ru/nova/server/status', // 'https://game2.station14.ru/athara/server/status', // 'https://game2.station14.ru/solaris/server/status', // 'https://game2.station14.ru/echo/server/status', // 'https://game2.station14.ru/elysium/server/status', // 'https://game2.station14.ru/nebula/server/status', // 'https://game2.station14.ru/wl/server/status', // 'https://arles.station14.ru/frontier-main/server/status', // 'https://game1.station14.ru/marines-main/server/status', // 'https://game.stalkers14.xyz/status', // ]; // function getServersStatus() { // //console.log(serversConnectors); // const responseDataServers = []; // for (var i = 0; i < serversConnectors.length; i++) { // //console.log(serversConnectors[i]); // const xhr = new XMLHttpRequest(); // xhr.open('GET', serversConnectors[i], true); // xhr.onload = function() { // if (xhr.status >= 200 && xhr.status < 300) { // const responseData = JSON.parse(xhr.responseText); // const stringData = JSON.stringify(responseData); // responseDataServers.push(stringData); // //console.log(responseData); // const jsTest = document.getElementById("jsTest"); // const divServer = document.createElement('div'); // divServer.textContent = stringData; // jsTest.appendChild(divServer); // } else { // console.error('Ошибка при выполнении запроса: ' + xhr.status); // } // }; // xhr.onerror = function() { // console.error('Ошибка при выполнении запроса'); // }; // xhr.send(); // } // console.log(responseDataServers); // } // let serversStatus = { // main: { // connect: "https://game2.station14.ru/main/server/status" // }, // nova: { // connect: "https://game2.station14.ru/nova/server/status" // }, // athara: { // connect: "https://game2.station14.ru/athara/server/status" // }, // solaris: { // connect: "https://game2.station14.ru/solaris/server/status" // }, // echo: { // connect: "https://game2.station14.ru/echo/server/status" // }, // elysium: { // connect: "https://game2.station14.ru/elysium/server/status" // }, // nebula: { // connect: "https://game2.station14.ru/nebula/server/status" // }, // wl: { // connect: "https://game2.station14.ru/wl/server/status" // }, // }; function getServersInfo(connect) { return new Promise((resolve, reject) => { const xhr = new XMLHttpRequest(); xhr.open('GET', connect, true); xhr.onload = function() { if (xhr.status >= 200 && xhr.status < 300) { const serverInfo = JSON.parse(xhr.responseText); resolve(serverInfo); } else { reject('Ошибка при выполнении запроса: ' + xhr.status); } }; xhr.onerror = function() { reject('Ошибка при выполнении запроса'); }; xhr.send(); }); } function kerisarTest() { console.log("Проверка консоли"); const currentUrl = window.location.href; console.log("currentUrl", currentUrl); const jsTest = document.getElementById("jsTest"); console.log("jsTest", jsTest); const buttonTest = document.createElement('button'); buttonTest.classList.add('testButtonJs'); buttonTest.textContent = "Привет, я кнопка. Пока я ничего не делаю"; jsTest.appendChild(buttonTest); const kerisarPicture = document.createElement('img'); kerisarPicture.setAttribute('src', "https://thumb.cloud.mail.ru/weblink/thumb/xw1/LLmd/Qui7Xbp6g"); jsTest.appendChild(kerisarPicture); getServersInfo('https://game2.station14.ru/main/server/status') .then(serverInfo => { console.log("serverInfo", serverInfo) }) .catch(error => { console.error(error); }); } $(document).ready(function() { kerisarTest(); }); /*WikiEditor/Викификатор*/ if ($.inArray(mw.config.get('wgAction'), ['edit', 'submit']) !== -1) { mw.loader.load( '//ru.wikipedia.org/w/index.php?title=MediaWiki:Gadget-wikificator.js&action=raw&ctype=text/javascript' ); } var customizeToolbar = function() { $('#wpTextbox1').wikiEditor('addToToolbar', { 'section': 'advanced', 'group': 'format', 'tools': { 'wikify': { label: 'Викификатор', type: 'button', icon: '//upload.wikimedia.org/wikipedia/commons/0/06/Wikify-toolbutton.png', action: { type: 'callback', execute: function(context) { Wikify(); } } } } }); }; if ($.inArray(mw.config.get('wgAction'), ['edit', 'submit']) !== -1) { mw.loader.using('user.options', function() { if (mw.user.options.get('usebetatoolbar')) { mw.loader.using('ext.wikiEditor.toolbar', function() { $(document).ready(customizeToolbar); }); } }); }