|
|
|
||||||||||||||||||||||||
MediaWiki:Tibiadrome.js: mudanças entre as edições
Ir para navegação
Ir para pesquisar
m |
m |
||
| Linha 25: | Linha 25: | ||
function updateTibiadrome () { | function updateTibiadrome () { | ||
const secondRotation = | const secondRotation = 1627372800 // July 27, 2021 10:00:00 (CEST) | ||
const now = new Date() | const now = new Date() | ||
let rot = 2 | let rot = 2 | ||
for (let i = 0; secondRotation + i * 14 * 24 * 60 * 60 | for (let i = 0; secondRotation + i * 14 * 24 * 60 * 60 < now; i++) { | ||
rot = 2 + i | rot = 2 + i | ||
} | } | ||
const start = moment.unix(secondRotation + (rot - 2) * 14 * 24 * 60 * 60) | |||
const end = moment.unix(secondRotation + (rot - 1) * 14 * 24 * 60 * 60) | |||
$('#tibiadrome_rot').text(rot) | $('#tibiadrome_rot').text(rot) | ||
$('#tibiadrome_start').text(( | $('#tibiadrome_start').text(start.format('L LTS') + ' (' + start.fromNow() + ')') | ||
$('#tibiadrome_end').text(( | $('#tibiadrome_end').text(end.format('L LTS') + ' (' + end.fromNow() + ')') | ||
} | } | ||
Edição das 19h32min de 21 de novembro de 2023
if (typeof mw !== 'undefined') {
mw.loader.load('moment')
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 = 1627372800 // July 27, 2021 10:00:00 (CEST)
const now = new Date()
let rot = 2
for (let i = 0; secondRotation + i * 14 * 24 * 60 * 60 < now; i++) {
rot = 2 + i
}
const start = moment.unix(secondRotation + (rot - 2) * 14 * 24 * 60 * 60)
const end = moment.unix(secondRotation + (rot - 1) * 14 * 24 * 60 * 60)
$('#tibiadrome_rot').text(rot)
$('#tibiadrome_start').text(start.format('L LTS') + ' (' + start.fromNow() + ')')
$('#tibiadrome_end').text(end.format('L LTS') + ' (' + end.fromNow() + ')')
}