<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.runerealm.org/index.php?action=history&amp;feed=atom&amp;title=MediaWiki%3AGadget-fightcaverotations-core.js</id>
	<title>MediaWiki:Gadget-fightcaverotations-core.js - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.runerealm.org/index.php?action=history&amp;feed=atom&amp;title=MediaWiki%3AGadget-fightcaverotations-core.js"/>
	<link rel="alternate" type="text/html" href="https://wiki.runerealm.org/index.php?title=MediaWiki:Gadget-fightcaverotations-core.js&amp;action=history"/>
	<updated>2026-04-11T05:09:57Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.1</generator>
	<entry>
		<id>https://wiki.runerealm.org/index.php?title=MediaWiki:Gadget-fightcaverotations-core.js&amp;diff=42196&amp;oldid=prev</id>
		<title>Alex at 11:06, 20 October 2024</title>
		<link rel="alternate" type="text/html" href="https://wiki.runerealm.org/index.php?title=MediaWiki:Gadget-fightcaverotations-core.js&amp;diff=42196&amp;oldid=prev"/>
		<updated>2024-10-20T11:06:13Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;a href=&quot;https://wiki.runerealm.org/index.php?title=MediaWiki:Gadget-fightcaverotations-core.js&amp;amp;diff=42196&amp;amp;oldid=867&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>Alex</name></author>
	</entry>
	<entry>
		<id>https://wiki.runerealm.org/index.php?title=MediaWiki:Gadget-fightcaverotations-core.js&amp;diff=867&amp;oldid=prev</id>
		<title>Alex: Created page with &quot;// This gadget updates the predicted rotation times on TzHaar Fight Cave/Rotations. Made by Gau Cho, but it was Fjara&#039;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() + &#039;:&#039; + (&#039;0&#039; + ti...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.runerealm.org/index.php?title=MediaWiki:Gadget-fightcaverotations-core.js&amp;diff=867&amp;oldid=prev"/>
		<updated>2024-10-13T00:37:36Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;// This gadget updates the predicted rotation times on &lt;a href=&quot;/index.php?title=TzHaar_Fight_Cave/Rotations&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;TzHaar Fight Cave/Rotations (page does not exist)&quot;&gt;TzHaar Fight Cave/Rotations&lt;/a&gt;. Made by Gau Cho, but it was Fjara&amp;#039;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() + &amp;#039;:&amp;#039; + (&amp;#039;0&amp;#039; + ti...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;// This gadget updates the predicted rotation times on [[TzHaar Fight Cave/Rotations]]. Made by Gau Cho, but it was Fjara&amp;#039;s idea&lt;br /&gt;
&lt;br /&gt;
const ROTATION_CYCLE = 16&lt;br /&gt;
&lt;br /&gt;
function mod(a, n) {&lt;br /&gt;
    return a - (n * Math.floor(a/n));&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function getMinutesFromMidnight(time) {&lt;br /&gt;
    // Gets minutes from UTC midnight&lt;br /&gt;
    return time.getUTCHours()*60 + time.getUTCMinutes()&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function formatTime(time) {&lt;br /&gt;
    // Formats time (using the local timezone)&lt;br /&gt;
    return time.getHours() + &amp;#039;:&amp;#039; + (&amp;#039;0&amp;#039; + time.getMinutes()).slice(-2)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function getNextRotationTime(rotationID, time, nthCycle) {&lt;br /&gt;
    // Gets the time of the nth next cycle for the desired rotation, where the 0th cycle is the next time the rotation occurs&lt;br /&gt;
    if(rotationID &amp;lt; 0 || rotationID &amp;gt;= ROTATION_CYCLE) throw RangeError(&amp;#039;rotationID invalid&amp;#039;)&lt;br /&gt;
    const minutesFromMidnight = getMinutesFromMidnight(time)&lt;br /&gt;
    const offsetInMinutes = mod(rotationID - minutesFromMidnight, ROTATION_CYCLE)&lt;br /&gt;
    return new Date(time.getTime() + offsetInMinutes*60000 + nthCycle*ROTATION_CYCLE*60000)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function updateTimes() {&lt;br /&gt;
    const curTime = new Date()&lt;br /&gt;
    &lt;br /&gt;
    // Unhighlight the old row that was highlighted&lt;br /&gt;
    $(&amp;#039;#rotation-table .table-yes&amp;#039;).removeClass(&amp;#039;table-yes&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
    // Update the times of all the rows&lt;br /&gt;
    for(var rotationID = 0; rotationID &amp;lt; ROTATION_CYCLE; rotationID++) {&lt;br /&gt;
        // Calculated the next two desired times&lt;br /&gt;
        var nextRotationTime = getNextRotationTime(rotationID, curTime, 0)&lt;br /&gt;
        var thereafterRotationTime = getNextRotationTime(rotationID, curTime, 1)&lt;br /&gt;
&lt;br /&gt;
        // rotationID 0 and 15 refer to the same rotation - this is the special case of the rotation that lasts for 2 minutes&lt;br /&gt;
        // 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)&lt;br /&gt;
        const rotationIDSelector = rotationID === 15 ? 0 : rotationID&lt;br /&gt;
        if(rotationID === 15) {&lt;br /&gt;
            // 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&lt;br /&gt;
            if(nextRotationTime.getTime() === curTime.getTime() + 15*60000) {&lt;br /&gt;
                nextRotationTime = new Date(nextRotationTime.getTime() - 16*60000)&lt;br /&gt;
                thereafterRotationTime = new Date(thereafterRotationTime.getTime() - 16*60000)&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        // Highlight the new current row&lt;br /&gt;
        if(nextRotationTime.getTime() === curTime.getTime()) {&lt;br /&gt;
            $(&amp;#039;#rotation-&amp;#039; + rotationIDSelector).addClass(&amp;#039;table-yes&amp;#039;)&lt;br /&gt;
        }&lt;br /&gt;
        // Update the times&lt;br /&gt;
        $(&amp;#039;#rotation-&amp;#039; + rotationIDSelector + &amp;#039; &amp;gt; .rotation-time-first&amp;#039;).text(formatTime(nextRotationTime))&lt;br /&gt;
        $(&amp;#039;#rotation-&amp;#039; + rotationIDSelector + &amp;#039; &amp;gt; .rotation-time-second&amp;#039;).text(formatTime(thereafterRotationTime))&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Update the current time in the prose&lt;br /&gt;
    $(&amp;#039;#rotation-time&amp;#039;).text(formatTime(curTime))&lt;br /&gt;
&lt;br /&gt;
    // Run the script at the exact moment that the minutes number changes&lt;br /&gt;
    const timeToNextMinute = 60000 - (curTime.getTime() % 60000)&lt;br /&gt;
    setTimeout(updateTimes, timeToNextMinute)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
$(updateTimes)&lt;/div&gt;</summary>
		<author><name>Alex</name></author>
	</entry>
</feed>