Bureaucrats, editor, Interface administrators, Administrators (Semantic MediaWiki), Curators (Semantic MediaWiki), Editors (Semantic MediaWiki), Administrators
47,390
edits
(Created page with "// This gadget updates the predicted rotation times on TzHaar Fight Cave/Rotations. Made by Gau Cho, but it was Fjara's idea const ROTATION_CYCLE = 16 function mod(a, n) { return a - (n * Math.floor(a/n)); } function getMinutesFromMidnight(time) { // Gets minutes from UTC midnight return time.getUTCHours()*60 + time.getUTCMinutes() } function formatTime(time) { // Formats time (using the local timezone) return time.getHours() + ':' + ('0' + ti...") |
No edit summary |
||
Line 1:
"use strict";
// This gadget updates the predicted rotation times on [[TzHaar Fight Cave/Rotations]]. Made by Gau Cho, but it was Fjara's idea
function mod(a, n) {
}
function getMinutesFromMidnight(time) {
}
function formatTime(time) {
}
function getNextRotationTime(rotationID, time, nthCycle) {
if
}
function updateTimes() {
$('#rotation-table .table-yes').removeClass('table-yes')▼
for(var rotationID = 0; rotationID < ROTATION_CYCLE; rotationID++) {▼
// Calculated the next two desired times▼
var nextRotationTime = getNextRotationTime(rotationID, curTime, 0)▼
// Update the times of all the rows
// rotationID 0 and 15 refer to the same rotation - this is the special case of the rotation that lasts for 2 minutes▼
// We highlight if the time matches either rotationID 0 or 15, but display the time for rotationID 15 as it is 1 minute earlier (so we do rotationID 0 and then after rotationID 15)▼
const rotationIDSelector = rotationID === 15 ? 0 : rotationID▼
var nextRotationTime =
// We need to handle the edge case where we are in the second minute, in which case the rotation time will display to be 16 minutes too late▼
if(nextRotationTime.getTime() === curTime.getTime() + 15*60000) {▼
nextRotationTime = new Date(nextRotationTime.getTime() - 16*60000)▼
thereafterRotationTime = new Date(thereafterRotationTime.getTime() - 16*60000)▼
}▼
▲
▲
$('#rotation-' + rotationIDSelector).addClass('table-yes')▼
if (rotationID === 15)
▲
// Update the times▼
$('#rotation-' + rotationIDSelector + ' > .rotation-time-first').text(formatTime(nextRotationTime))▼
$('#rotation-' + rotationIDSelector + ' > .rotation-time-second').text(formatTime(thereafterRotationTime))▼
}
//
▲ }
▲
▲
}
$('#rotation-time').text(formatTime(curTime));
const timeToNextMinute = 60000 - (curTime.getTime() % 60000)▼
setTimeout(updateTimes, timeToNextMinute)▼
}▼
// Run the script at the exact moment that the minutes number changes
$(updateTimes)▼
▲}
▲$(updateTimes);
|