Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1557,6 +1557,89 @@ <h2 id="sgHeader" class="accordion-header">
</div>
</form>
</div>
<div class="modal" tabindex="-1" id="confirmDeleteRoundModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Delete Round?</h5>
<button
type="button"
class="btn-close"
data-bs-dismiss="modal"
aria-label="Close"
></button>
</div>
<div class="modal-body">
<p>Do you really want to delete that round?</p>
</div>
<div class="modal-footer">
<button
type="button"
class="btn btn-secondary"
data-bs-dismiss="modal"
>
No, Cancel
</button>
<button
type="button"
id="confirmDeleteBtn"
class="btn btn-primary"
onClick=""
>
Yes, Delete Round
</button>
</div>
</div>
</div>
</div>

<div class="modal" tabindex="-1" id="confirmDeleteRoundModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Delete Round?</h5>
<button
type="button"
class="btn-close"
data-bs-dismiss="modal"
aria-label="Close"
onclick="javascript:void(0);"
></button>
</div>
<div class="modal-body">
<p>Do you really want to delete that round?</p>
<p id='deleteWarning' style="color: red;">
This action cannot be undone!
</p>
</div>
<div class="modal-footer">
<button
type="button"
class="btn btn-secondary"
data-bs-dismiss="modal"
>
No, Cancel
</button>
<button
type="button"
id="confirmDeleteBtn"
class="btn btn-primary"
onClick=""
>
Yes, Delete Round
</button>
<button
type="button"
id="confirmDeleteBtn2"
class="btn btn-danger"
onClick="deleteRound(roundId)"
>
Yes, Permanently Delete
</button>
</div>
</div>
</div>
</div>
</main>
<script
src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"
Expand Down
70 changes: 70 additions & 0 deletions scripts/roundsMode.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,76 @@ const thisRound = document.getElementById("r-" + GlobalUserData.rounds[rowIndex]
writeRoundToTable(thisRound,rowIndex);
}

/*************************************************************************
* @function deleteRound
* @desc
* Deletes a round from the "Rounds" table and from local storage
* @param roundId -- the unique id of the round to be deleted
* @returns -- true if round could be deleted, false otherwise
*************************************************************************/
function deleteRound(roundId) {
GlobalUserData.rounds = GlobalUserData.rounds.filter(function (round) {
return round.roundNum !== roundId;
});

document.addEventListener('click', function() {
console.log("Round deleted: " + roundId);
});
}

/*************************************************************************
* @function confirmDelete
* @desc
* Present pop-up modal dialog asking user to confirm delete operation
* @param roundId -- the unique id of the round to be deleted
* @returns -- true if user confirms delete, false otherwise
*************************************************************************/
function confirmDelete(roundId) {
var roundId = 1;

let modal = new bootstrap.Modal(
document.getElementById("confirmDeleteRoundModal")
);

let confirmBtn = document.getElementById("confirmDeleteBtn");
confirmBtn.addEventListener("click", function (event) {
event.preventDefault();
console.log("deleting round with id " + roundId);

for (var i = 0; i <= GlobalRoundsTable.rows.length; i++) {
let row = GlobalRoundsTable.rows[i];
if (row.id === "r-" + roundId) {
GlobalRoundsTable.deleteRow(i);
break;
}
}

deleteRound(roundId);

localStorage.setItem(
GlobalUserData.accountInfo.email,
JSON.stringify(GlobalUserData)
);

GlobalRoundsTableCaption.innerHTML =
"Table displaying " +
(GlobalRoundsTable.rows.length - 1) +
" speedgolf rounds";

modal.hide();
});

modal.show();

return true;
}

undeclaredGlobalVariable = "This will be a global variable";

function updateRoundsList(userId, timestamp, data, extraParam) {
console.log("Updating rounds for user: " + userId);
}

/*************************************************************************
* @function populateRoundsTable
* @desc
Expand Down