Skip to content

Commit

Permalink
Revert "removed legacy toggle"
Browse files Browse the repository at this point in the history
This reverts commit 9113901.
  • Loading branch information
BotSpace committed Aug 25, 2024
1 parent ec7c64f commit e4e8597
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@
<div id="toggle-keyboard-style" class="toggle-round"><div class="toggle-nub"></div></div>
</div>

<div class="settings-label">Old packet style (for robots coded before 2-14-24)</div>

<div class="settings-toggle">
<div id="toggle-legacy" class="toggle-round"><div class="toggle-nub"></div></div>
</div>

<div class="settings-label">Help/Info!</div>

<div class="settings-toggle">
Expand Down
13 changes: 13 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ let hackSpacerElement = document.getElementById("hack-spacer");

let toggleMobile = document.getElementById('toggle-mobile-layout');
let toggleKeyboardWASD = document.getElementById('toggle-keyboard-style');
let toggleLegacyPacket = document.getElementById('toggle-legacy');
let toggleInfo = document.getElementById('toggle-info');

// --------------------------- state management ------------------------------------ //
Expand All @@ -31,14 +32,17 @@ if (localStorage.getItem(toggleMobile.id) == null) {
document.addEventListener('DOMContentLoaded', function () {
updateMobileSlider(toggleMobile, toggleState=false);
updateSlider(toggleKeyboardWASD, toggleState=false);
updateSlider(toggleLegacyPacket, toggleState=false);
updateInfoSlider(toggleInfo, toggleState=false);

toggleMobile.onmousedown = updateMobileSlider.bind(null, toggleMobile, toggleState=true)
toggleKeyboardWASD.onmousedown = updateSlider.bind(null, toggleKeyboardWASD, toggleState=true)
toggleLegacyPacket.onmousedown = updateSlider.bind(null, toggleLegacyPacket, toggleState=true)
toggleInfo.onmousedown = updateInfoSlider.bind(null, toggleInfo, toggleState=true)

toggleMobile.ontouchstart = updateMobileSlider.bind(null, toggleMobile, toggleState=true)
toggleKeyboardWASD.ontouchstart = updateSlider.bind(null, toggleKeyboardWASD, toggleState=true)
toggleLegacyPacket.ontouchstart = updateSlider.bind(null, toggleLegacyPacket, toggleState=true)
toggleInfo.ontouchstart = updateInfoSlider.bind(null, toggleInfo, toggleState=true)

window.setInterval(renderLoop, 40); // call renderLoop every num milliseconds
Expand Down Expand Up @@ -139,6 +143,15 @@ function renderLoop() {
}
}

if (localStorage.getItem(toggleLegacyPacket.id) === 'true') {
rawPacket[0] = rawPacket[1]
rawPacket[1] = rawPacket[2]
rawPacket[2] = rawPacket[3]
rawPacket[3] = rawPacket[4]
rawPacket[4] = rawPacket[5]
rawPacket[5] = rawPacket[6]
}

if (!document.hasFocus()) { rawPacket.fill(0, 0, 20); }

//console.log(rawPacket)
Expand Down

0 comments on commit e4e8597

Please sign in to comment.