|
|
|
||||||||||||||||||||||||
MediaWiki:Tibiadrome.js: mudanças entre as edições
Ir para navegação
Ir para pesquisar
m |
|||
| Linha 1: | Linha 1: | ||
if (typeof mw !== 'undefined') { | if (typeof mw !== 'undefined') { | ||
mw.loader.load('/index.php?title=MediaWiki:luxon.min.js&action=raw&ctype=text/javascript') | mw.loader.load('/index.php?title=MediaWiki:luxon.min.js&action=raw&ctype=text/javascript') | ||
ready() | setTimeout(wait, 100) | ||
} | |||
function wait () { | |||
if (typeof luxon !== 'undefined') { | |||
setTimeout(wait, 100) | |||
} else { | |||
ready() | |||
} | |||
} | } | ||
| Linha 21: | Linha 29: | ||
'</tr>' + | '</tr>' + | ||
'</td></tr></tbody></table>') | '</td></tr></tbody></table>') | ||
updateTibiadrome() | |||
setInterval(updateTibiadrome, 60 * 1000) | setInterval(updateTibiadrome, 60 * 1000) | ||
} | } | ||
Edição das 20h17min de 21 de novembro de 2023
if (typeof mw !== 'undefined') {
mw.loader.load('/index.php?title=MediaWiki:luxon.min.js&action=raw&ctype=text/javascript')
setTimeout(wait, 100)
}
function wait () {
if (typeof luxon !== 'undefined') {
setTimeout(wait, 100)
} else {
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>')
updateTibiadrome()
setInterval(updateTibiadrome, 60 * 1000)
}
function updateTibiadrome () {
const secondRotation = luxon.DateTime.fromSeconds(1627372800).setZone('Europe/Berlin') // July 27, 2021 10:00:00 (CEST)
const now = luxon.DateTime.now().setZone('Europe/Berlin')
let rot = 2
for (let i = 0; secondRotation.plus({ days: i * 14 }) < now; i++) {
rot = 2 + i
}
const start = luxon.DateTime.fromSeconds(secondRotation.plus({ days: (rot - 2) * 14 }).toUnixInteger())
const end = luxon.DateTime.fromSeconds(secondRotation.plus({ days: (rot - 1) * 14 }).toUnixInteger())
const f = luxon.DateTime.DATETIME_SHORT
f.timeZoneName = 'short'
$('#tibiadrome_rot').text('#' + rot)
$('#tibiadrome_start').text(start.toLocaleString(f) + ' (' + start.toRelative() + ')')
$('#tibiadrome_end').text(end.toLocaleString(f) + ' (' + end.toRelative() + ')')
}