Skip to content

Commit 6864334

Browse files
Fix - Tech tree flow
Add - Review randomization
1 parent 6907895 commit 6864334

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed

app/views/admin/weekly_overview.html.erb

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,14 @@
461461
<% end %>
462462
</div>
463463

464+
<!-- Randomize Toggle -->
465+
<div style="margin-bottom: 1rem;">
466+
<label style="display: flex; align-items: center; gap: 0.5rem; cursor: pointer; font-size: 1rem; font-weight: 500; color: #402b20;">
467+
<input type="checkbox" id="randomize-toggle" checked style="width: 18px; height: 18px; cursor: pointer;">
468+
<span>Randomize Order</span>
469+
</label>
470+
</div>
471+
464472
<!-- Users Count -->
465473
<div style="margin-bottom: 1rem; font-size: 0.9rem; color: #6b5b4a;">
466474
Showing <%= @user_data.count %> user<%= @user_data.count == 1 ? '' : 's' %>
@@ -622,3 +630,54 @@
622630
<% end %>
623631
</div>
624632
</div>
633+
634+
<script>
635+
(function() {
636+
const usersGrid = document.querySelector('.users-grid');
637+
const randomizeToggle = document.getElementById('randomize-toggle');
638+
639+
if (!usersGrid || !randomizeToggle) return;
640+
641+
// Store original order
642+
let originalCards = Array.from(usersGrid.children);
643+
let currentlyRandomized = false;
644+
645+
// Fisher-Yates shuffle algorithm
646+
function shuffleArray(array) {
647+
const shuffled = [...array];
648+
for (let i = shuffled.length - 1; i > 0; i--) {
649+
const j = Math.floor(Math.random() * (i + 1));
650+
[shuffled[i], shuffled[j]] = [shuffled[j], shuffled[i]];
651+
}
652+
return shuffled;
653+
}
654+
655+
function randomizeUsers() {
656+
const cards = Array.from(usersGrid.children);
657+
const shuffled = shuffleArray(cards);
658+
659+
// Clear and re-append in random order
660+
usersGrid.innerHTML = '';
661+
shuffled.forEach(card => usersGrid.appendChild(card));
662+
currentlyRandomized = true;
663+
}
664+
665+
function restoreOriginalOrder() {
666+
usersGrid.innerHTML = '';
667+
originalCards.forEach(card => usersGrid.appendChild(card));
668+
currentlyRandomized = false;
669+
}
670+
671+
// Randomize on page load (since toggle is checked by default)
672+
randomizeUsers();
673+
674+
// Toggle randomization when checkbox changes
675+
randomizeToggle.addEventListener('change', function() {
676+
if (this.checked) {
677+
randomizeUsers();
678+
} else {
679+
restoreOriginalOrder();
680+
}
681+
});
682+
})();
683+
</script>

config/tech_tree_data.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
"title": "CPU Upgrade 3",
8484
"price": 600,
8585
"description": "the latest gen and super quick (Ryzen AI 5 340)",
86-
"requires": "Framework 13",
86+
"requires": "CPU Upgrade 2",
8787
"purchased": false
8888
},
8989
"up5": {

0 commit comments

Comments
 (0)