|
|
|
||||||||||||||||||||||||
MediaWiki:Tibiadrome.js: mudanças entre as edições
Ir para navegação
Ir para pesquisar
m |
m |
||
| (19 revisões intermediárias por 2 usuários não estão sendo mostradas) | |||
| Linha 1: | Linha 1: | ||
if (typeof mw !== 'undefined') { | if (typeof mw !== 'undefined') { | ||
mw.loader. | mw.loader.addScriptTag('/index.php?title=MediaWiki:luxon.min.js&action=raw&ctype=text/javascript', ready) | ||
} | } | ||
function ready () { | function ready () { | ||
$('#tibiadrome_cal').html('' + | $('#tibiadrome_cal').html('' + | ||
'<table | '<table style="width:100%; margin:0px;">' + | ||
'<tbody>' + | '<tbody>' + | ||
'<tr>' + | '<tr>' + | ||
'<td><b>Rotação | '<td colspan="2" style="font-size:14px; width:100%; text-align:center; vertical-align:top; border-bottom:1px dashed #999;"><b>Rotação Número <span id="tibiadrome_rot"></span></b></td>' + | ||
'</tr>' + | '</tr>' + | ||
'<tr>' + | '<tr>' + | ||
'<td><b> | '<td style="width:50%; text-align:center; vertical-align:top; border-bottom:1px dashed #999;"><b>Início:</b></td>' + | ||
'<td | '<td style="width:50%; text-align:center; vertical-align:top; border-bottom:1px dashed #999;"><b>Fim:</b></td>' + | ||
'</tr>' + | '</tr>' + | ||
'<tr>' + | '<tr>' + | ||
'<td> | '<td style="width:50%; text-align:center; vertical-align:top; border-bottom:1px dashed #999;" id="tibiadrome_start">-</td>' + | ||
'<td id="tibiadrome_end">-</td>' + | '<td style="width:50%; text-align:center; vertical-align:top; border-bottom:1px dashed #999;" id="tibiadrome_end">-</td>' + | ||
'</tr>' + | '</tr>' + | ||
'</td></tr></tbody></table>') | '</td></tr></tbody></table>') | ||
updateTibiadrome() | |||
setInterval(updateTibiadrome, 60 * 1000) | setInterval(updateTibiadrome, 60 * 1000) | ||
} | } | ||
function updateTibiadrome () { | function updateTibiadrome () { | ||
const secondRotation = luxon.DateTime.fromSeconds( | const secondRotation = luxon.DateTime.fromSeconds(1627459200).setZone('Europe/Berlin') // July 28, 2021 10:00:00 (CEST) | ||
const now = luxon.DateTime.now().setZone('Europe/Berlin') | const now = luxon.DateTime.now().setZone('Europe/Berlin') | ||
let rot = 2 | let rot = 2 | ||
Edição atual tal como às 13h53min de 28 de novembro de 2023
if (typeof mw !== 'undefined') {
mw.loader.addScriptTag('/index.php?title=MediaWiki:luxon.min.js&action=raw&ctype=text/javascript', ready)
}
function ready () {
$('#tibiadrome_cal').html('' +
'<table style="width:100%; margin:0px;">' +
'<tbody>' +
'<tr>' +
'<td colspan="2" style="font-size:14px; width:100%; text-align:center; vertical-align:top; border-bottom:1px dashed #999;"><b>Rotação Número <span id="tibiadrome_rot"></span></b></td>' +
'</tr>' +
'<tr>' +
'<td style="width:50%; text-align:center; vertical-align:top; border-bottom:1px dashed #999;"><b>Início:</b></td>' +
'<td style="width:50%; text-align:center; vertical-align:top; border-bottom:1px dashed #999;"><b>Fim:</b></td>' +
'</tr>' +
'<tr>' +
'<td style="width:50%; text-align:center; vertical-align:top; border-bottom:1px dashed #999;" id="tibiadrome_start">-</td>' +
'<td style="width:50%; text-align:center; vertical-align:top; border-bottom:1px dashed #999;" id="tibiadrome_end">-</td>' +
'</tr>' +
'</td></tr></tbody></table>')
updateTibiadrome()
setInterval(updateTibiadrome, 60 * 1000)
}
function updateTibiadrome () {
const secondRotation = luxon.DateTime.fromSeconds(1627459200).setZone('Europe/Berlin') // July 28, 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() + ')')
}