|
13 | 13 | <h1 id="title">Mercury 2025</h1>
|
14 | 14 |
|
15 | 15 | <div id="pages_container">
|
16 |
| - <button id="reset_button" onclick="resetPageButton()">Reset Page</button> |
| 16 | + <button id="reset_button" onclick="resetAllButton()">Reset All</button> |
17 | 17 | </div>
|
18 | 18 |
|
19 | 19 | <div id="loadingOverlay">Submitting...</div>
|
@@ -514,7 +514,7 @@ <h1 id="title">Mercury 2025</h1>
|
514 | 514 | }
|
515 | 515 |
|
516 | 516 | // clearing old answers and enabling interactive elements
|
517 |
| - clearAllAnswers(true); |
| 517 | + clearAllAnswers(false); |
518 | 518 | document.body.style.pointerEvents = "auto";
|
519 | 519 | htmlGlobals.loadingOverlay.style.visibility = "hidden";
|
520 | 520 | submitting = false;
|
@@ -564,23 +564,17 @@ <h1 id="title">Mercury 2025</h1>
|
564 | 564 | localStorage.setItem('unsentSubmissions', JSON.stringify(newUnsentSubmissions));
|
565 | 565 | }
|
566 | 566 |
|
567 |
| - function clearPageAnswers(pageName) { |
| 567 | + function clearAllAnswers(ignoreResetTypes) { |
568 | 568 | for (const question of questionObjects) {
|
569 |
| - if (question.pageName !== pageName) continue; |
570 |
| - localStorage.removeItem(question.id); |
571 |
| - question.reset(); |
572 |
| - } |
573 |
| - } |
574 |
| - |
575 |
| - function clearAllAnswers() { |
576 |
| - for (const question of questionObjects) { |
577 |
| - if (question.resetType === RESET_TYPES.KEEP) continue; |
578 |
| - if (question.resetType === RESET_TYPES.INCREASE) { |
579 |
| - let value = localStorage.getItem(question.id) || 0; |
580 |
| - value = String(parseInt(value) + 1) |
581 |
| - localStorage.setItem(question.id, value); |
582 |
| - question.value = value; |
583 |
| - continue; |
| 569 | + if (!ignoreResetTypes) { |
| 570 | + if (question.resetType === RESET_TYPES.KEEP) continue; |
| 571 | + if (question.resetType === RESET_TYPES.INCREASE) { |
| 572 | + let value = localStorage.getItem(question.id) || 0; |
| 573 | + value = String(parseInt(value) + 1) |
| 574 | + localStorage.setItem(question.id, value); |
| 575 | + question.value = value; |
| 576 | + continue; |
| 577 | + } |
584 | 578 | }
|
585 | 579 | localStorage.removeItem(question.id);
|
586 | 580 | question.reset();
|
@@ -692,12 +686,14 @@ <h1 id="title">Mercury 2025</h1>
|
692 | 686 | }, false);
|
693 | 687 | }
|
694 | 688 |
|
695 |
| - function resetPageButton() { |
696 |
| - const userConfirmed = confirm("Are you sure you want to reset Page?"); |
| 689 | + function resetAllButton() { |
| 690 | + const userConfirmed = confirm("Are you sure you want to reset All?"); |
697 | 691 | if (userConfirmed) {
|
698 |
| - clearPageAnswers(localStorage.getItem('currentPage') || pageMaps[0].name); |
| 692 | + clearAllAnswers(true); |
| 693 | + displayPage(pageMaps[0].name); |
| 694 | + } else { |
| 695 | + displayPage(localStorage.getItem('currentPage') || pageMaps[0].name); |
699 | 696 | }
|
700 |
| - displayPage(localStorage.getItem('currentPage') || pageMaps[0].name); |
701 | 697 | }
|
702 | 698 |
|
703 | 699 | function initializeApp() {
|
|
0 commit comments