Add reset button
This commit is contained in:
parent
3a18609e33
commit
210c204f88
2 changed files with 37 additions and 24 deletions
|
|
@ -332,8 +332,17 @@
|
|||
</div>
|
||||
</details>
|
||||
|
||||
<!-- Buttons outside sections -->
|
||||
<!-- REMOVED BUTTONS FROM HERE -->
|
||||
<!-- Dangerous Reset All Button -->
|
||||
<div class="border-t border-red-300 pt-4 mt-6">
|
||||
<button onclick="resetAllSettings()" class="w-full bg-red-600 hover:bg-red-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5 inline-block mr-1 align-text-bottom">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126ZM12 15.75h.008v.008H12v-.008Z" />
|
||||
</svg>
|
||||
Reset ALL Settings to Defaults
|
||||
</button>
|
||||
<p class="mt-2 text-xs text-red-600 text-center">Warning: This will clear all saved customizations and board content.</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -850,7 +850,7 @@ function shuffleArray(array) {
|
|||
return array;
|
||||
}
|
||||
|
||||
// Function to reset settings and clear board
|
||||
// --- Function to reset ONLY board content/structure settings ---
|
||||
function resetSettings() {
|
||||
// Clear localStorage relevant ONLY to the board structure/content
|
||||
localStorage.removeItem(LS_BOARD_SIZE);
|
||||
|
|
@ -859,27 +859,6 @@ function resetSettings() {
|
|||
localStorage.removeItem(LS_MARKED_INDICES);
|
||||
localStorage.removeItem(LS_ORIGINAL_ITEMS); // User's raw input
|
||||
|
||||
// DO NOT clear these:
|
||||
// localStorage.removeItem(LS_CONFIG_OPEN);
|
||||
// localStorage.removeItem(LS_BACKGROUND_TYPE);
|
||||
// localStorage.removeItem(LS_SOLID_COLOR);
|
||||
// localStorage.removeItem(LS_GRADIENT_COLOR_1);
|
||||
// localStorage.removeItem(LS_GRADIENT_COLOR_1_OPACITY);
|
||||
// localStorage.removeItem(LS_GRADIENT_COLOR_2);
|
||||
// localStorage.removeItem(LS_GRADIENT_COLOR_2_OPACITY);
|
||||
// localStorage.removeItem(LS_GRADIENT_DIRECTION);
|
||||
// localStorage.removeItem(LS_HEADER_TEXT);
|
||||
// localStorage.removeItem(LS_HEADER_IMAGE_URL);
|
||||
// localStorage.removeItem(LS_MARKED_STYLE_TYPE);
|
||||
// localStorage.removeItem(LS_MARKED_COLOR);
|
||||
// localStorage.removeItem(LS_MARKED_IMAGE_URL);
|
||||
// localStorage.removeItem(LS_MARKED_COLOR_OPACITY);
|
||||
// localStorage.removeItem(LS_CELL_BORDER_COLOR); // Keep style on board reset
|
||||
// localStorage.removeItem(LS_CELL_BORDER_OPACITY);
|
||||
// localStorage.removeItem(LS_CELL_BG_COLOR);
|
||||
// localStorage.removeItem(LS_CELL_BG_OPACITY);
|
||||
// localStorage.removeItem(LS_CELL_BG_IMAGE_URL);
|
||||
|
||||
// Reset global variables for board content
|
||||
currentItems = [];
|
||||
displayedItems = [];
|
||||
|
|
@ -917,6 +896,31 @@ function resetSettings() {
|
|||
showNotification('Board settings reset. Generate a new board to apply.', 'success');
|
||||
}
|
||||
|
||||
// --- Function to reset ALL application settings ---
|
||||
function resetAllSettings() {
|
||||
if (confirm('Are you sure you want to reset ALL settings (styles, header, board content, etc.) to their defaults? This cannot be undone.')) {
|
||||
const keysToRemove = [];
|
||||
for (let i = 0; i < localStorage.length; i++) {
|
||||
const key = localStorage.key(i);
|
||||
if (key.startsWith('beango_')) {
|
||||
keysToRemove.push(key);
|
||||
}
|
||||
}
|
||||
|
||||
keysToRemove.forEach(key => {
|
||||
localStorage.removeItem(key);
|
||||
console.log(`Removed setting: ${key}`); // Optional: log removed keys
|
||||
});
|
||||
|
||||
showNotification('Resetting all settings to defaults...', 'warning', 1500); // Show brief message before reload
|
||||
|
||||
// Use a short delay before reload to ensure the notification is visible
|
||||
setTimeout(() => {
|
||||
location.reload();
|
||||
}, 1600); // Slightly longer than notification duration
|
||||
}
|
||||
}
|
||||
|
||||
// --- Helper to get indices of marked cells ---
|
||||
function getMarkedIndices() {
|
||||
const markedCells = document.querySelectorAll('#bingo-board .bingo-cell.marked');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue