|
|
|
||||||||||||||||||||||||
MediaWiki:Tibiadrome.js: mudanças entre as edições
Ir para navegação
Ir para pesquisar
m |
m |
||
| Linha 1: | Linha 1: | ||
if (typeof mw !== 'undefined') { | if (typeof mw !== 'undefined') { | ||
const luxon = '/index.php?title=MediaWiki:luxon.min.js&action=raw&ctype=text/javascript' | const luxon = '/index.php?title=MediaWiki:luxon.min.js&action=raw&ctype=text/javascript' | ||
mw.loader.using([luxon], ready) | mw.loader.using([luxon], ready) | ||
} | } | ||
| Linha 26: | Linha 25: | ||
function updateTibiadrome () { | function updateTibiadrome () { | ||
const secondRotation = | const secondRotation = luxon.fromSeconds(1627372800) // July 27, 2021 10:00:00 (CEST) | ||
const now = new DateTime().setZone('Europe/Berlin') | const now = new DateTime().setZone('Europe/Berlin') | ||
let rot = 2 | let rot = 2 | ||
| Linha 33: | Linha 32: | ||
} | } | ||
const start = | const start = luxon.fromSeconds(secondRotation + (rot - 2) * 14 * 24 * 60 * 60) | ||
const end = | const end = luxon.fromSeconds(secondRotation + (rot - 1) * 14 * 24 * 60 * 60) | ||
$('#tibiadrome_rot').text(rot) | $('#tibiadrome_rot').text(rot) | ||
$('#tibiadrome_start').text(start.toLocaleString( | $('#tibiadrome_start').text(start.toLocaleString(luxon.DATETIME_SHORT) + ' (' + start.toRelativeCalendar() + ')') | ||
$('#tibiadrome_end').text(end.toLocaleString( | $('#tibiadrome_end').text(end.toLocaleString(luxon.DATETIME_SHORT) + ' (' + end.toRelativeCalendar() + ')') | ||
} | } | ||
Edição das 19h53min de 21 de novembro de 2023
if (typeof mw !== 'undefined') {
const luxon = '/index.php?title=MediaWiki:luxon.min.js&action=raw&ctype=text/javascript'
mw.loader.using([luxon], ready)
}
function ready () {
$('#tibiadrome_cal').html('' +
'<table class="wikitable">' +
'<tbody>' +
'<tr>' +
'<td><b>Rotação Atual</b></td>' +
'<td id="tibiadrome_rot">-</td>' +
'</tr>' +
'<tr>' +
'<td><b>Iniciou em</b></td>' +
'<td id="tibiadrome_start">-</td>' +
'</tr>' +
'<tr>' +
'<td><b>Terminará em</b></td>' +
'<td id="tibiadrome_end">-</td>' +
'</tr>' +
'</td></tr></tbody></table>')
setInterval(updateTibiadrome, 1000)
}
function updateTibiadrome () {
const secondRotation = luxon.fromSeconds(1627372800) // July 27, 2021 10:00:00 (CEST)
const now = new DateTime().setZone('Europe/Berlin')
let rot = 2
for (let i = 0; secondRotation.plus({ days: i * 14 }) < now; i++) {
rot = 2 + i
}
const start = luxon.fromSeconds(secondRotation + (rot - 2) * 14 * 24 * 60 * 60)
const end = luxon.fromSeconds(secondRotation + (rot - 1) * 14 * 24 * 60 * 60)
$('#tibiadrome_rot').text(rot)
$('#tibiadrome_start').text(start.toLocaleString(luxon.DATETIME_SHORT) + ' (' + start.toRelativeCalendar() + ')')
$('#tibiadrome_end').text(end.toLocaleString(luxon.DATETIME_SHORT) + ' (' + end.toRelativeCalendar() + ')')
}