MediaWiki:Common.js: различия между версиями
Kerisar (обсуждение | вклад) м пробуем через fetch |
Kerisar (обсуждение | вклад) м Отмена версии 102932, сделанной Kerisar (обсуждение) Метка: отмена |
||
| Строка 34: | Строка 34: | ||
const serversStatus = [{ | const serversStatus = [{ | ||
name: "server-main", | name: "server-main", | ||
connect: "https://game2.station14.ru/main/server/status", | connect: "https://api.codetabs.com/v1/proxy/?quest=https://game2.station14.ru/main/server/status", | ||
serverconnect: "ss14s://game2.station14.ru/main/server" | serverconnect: "ss14s://game2.station14.ru/main/server" | ||
}, { | }, { | ||
name: "server-nova", | name: "server-nova", | ||
connect: "https://game2.station14.ru/nova/server/status", | connect: "https://api.codetabs.com/v1/proxy/?quest=https://game2.station14.ru/nova/server/status", | ||
serverconnect: "ss14s://game2.station14.ru/nova/server" | serverconnect: "ss14s://game2.station14.ru/nova/server" | ||
}, { | }, { | ||
name: "server-athara", | name: "server-athara", | ||
connect: "https://game2.station14.ru/athara/server/status", | connect: "https://api.codetabs.com/v1/proxy/?quest=https://game2.station14.ru/athara/server/status", | ||
serverconnect: "ss14s://game2.station14.ru/athara/server" | serverconnect: "ss14s://game2.station14.ru/athara/server" | ||
}, { | }, { | ||
name: "server-solaris", | name: "server-solaris", | ||
connect: "https://game2.station14.ru/solaris/server/status", | connect: "https://api.codetabs.com/v1/proxy/?quest=https://game2.station14.ru/solaris/server/status", | ||
serverconnect: "ss14s://game2.station14.ru/solaris/server" | serverconnect: "ss14s://game2.station14.ru/solaris/server" | ||
}, { | }, { | ||
name: "server-echo", | name: "server-echo", | ||
connect: "https://game2.station14.ru/echo/server/status", | connect: "https://api.codetabs.com/v1/proxy/?quest=https://game2.station14.ru/echo/server/status", | ||
serverconnect: "ss14s://game2.station14.ru/echo/server" | serverconnect: "ss14s://game2.station14.ru/echo/server" | ||
}, { | }, { | ||
name: "server-elysium", | name: "server-elysium", | ||
connect: "https://game2.station14.ru/elysium/server/status", | connect: "https://api.codetabs.com/v1/proxy/?quest=https://game2.station14.ru/elysium/server/status", | ||
serverconnect: "ss14s://game2.station14.ru/elysium/server" | serverconnect: "ss14s://game2.station14.ru/elysium/server" | ||
}, { | }, { | ||
name: "server-nebula", | name: "server-nebula", | ||
connect: "https://game2.station14.ru/nebula/server/status", | connect: "https://api.codetabs.com/v1/proxy/?quest=https://game2.station14.ru/nebula/server/status", | ||
serverconnect: "ss14s://game2.station14.ru/nebula/server" | serverconnect: "ss14s://game2.station14.ru/nebula/server" | ||
}, { | }, { | ||
name: "server-wl", | name: "server-wl", | ||
connect: "https://game2.station14.ru/wl/server/status", | connect: "https://api.codetabs.com/v1/proxy/?quest=https://game2.station14.ru/wl/server/status", | ||
serverconnect: "ss14s://game2.station14.ru/wl/server" | serverconnect: "ss14s://game2.station14.ru/wl/server" | ||
}, { | }, { | ||
name: "server-frontier", | name: "server-frontier", | ||
connect: "corvaxforge.ru/server/frontier/status", | connect: "https://api.codetabs.com/v1/proxy/?quest=corvaxforge.ru/server/frontier/status", | ||
serverconnect: "ss14s://corvaxforge.ru/server/frontier" | serverconnect: "ss14s://corvaxforge.ru/server/frontier" | ||
}, { | }, { | ||
name: "server-fallout", | name: "server-fallout", | ||
connect: "corvaxforge.ru/server/fallout/status", | connect: "https://api.codetabs.com/v1/proxy/?quest=corvaxforge.ru/server/fallout/status", | ||
serverconnect: "ss14s://corvaxforge.ru/server/fallout" | serverconnect: "ss14s://corvaxforge.ru/server/fallout" | ||
}, { | }, { | ||
name: "server-marines", | name: "server-marines", | ||
connect: "https://game1.station14.ru/marines-main/server/status", | connect: "https://api.codetabs.com/v1/proxy/?quest=https://game1.station14.ru/marines-main/server/status", | ||
serverconnect: "ss14s://game1.station14.ru/marines-main/server" | serverconnect: "ss14s://game1.station14.ru/marines-main/server" | ||
}, { | }, { | ||
name: "server-wega", | name: "server-wega", | ||
connect: "https://arles.station14.ru/wega-main/server/status", | connect: "https://api.codetabs.com/v1/proxy/?quest=https://arles.station14.ru/wega-main/server/status", | ||
serverconnect: "ss14s://arles.station14.ru/wega-main/server" | serverconnect: "ss14s://arles.station14.ru/wega-main/server" | ||
} | } | ||
]; | ]; | ||
function | function getXHRInfo(url) { | ||
return new Promise(function(resolve, reject) { | |||
var xhr = new XMLHttpRequest(); | |||
xhr.open('GET', url, true); | |||
xhr.onload = function() { | |||
if (xhr.status >= 200 && xhr.status < 300) { | |||
resolve(JSON.parse(xhr.responseText)); | |||
} else { | |||
reject('Ошибка при выполнении запроса: ' + xhr.status); | |||
} | |||
}; | |||
xhr.onerror = function() { | |||
reject('Ошибка при выполнении запроса'); | |||
}; | |||
xhr.send(); | |||
}); | |||
} | } | ||
function updateServerInfoByConnect(connect, name) { | function updateServerInfoByConnect(connect, name) { | ||
getServerTime().then(function(currentUnixTime) { | getServerTime().then(function(currentUnixTime) { | ||
return | return getXHRInfo(connect).then(function(serverData) { | ||
var unixStartRound = getUnixTime(serverData.round_start_time); | var unixStartRound = getUnixTime(serverData.round_start_time); | ||
var timeDisplay = unixStartRound ? secondsToDHM(currentUnixTime - unixStartRound) : "–"; | var timeDisplay = unixStartRound ? secondsToDHM(currentUnixTime - unixStartRound) : "–"; | ||