Last active
April 27, 2025 20:13
-
-
Save EugenyB/ce058593062fc63d07662b297d548a8e to your computer and use it in GitHub Desktop.
confirm.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let myConfirmDialog = document.getElementById("myconfirm"); | |
| myConfirmDialog.addEventListener('show.bs.modal', function (event) { | |
| let button = event.relatedTarget; | |
| let link = button.getAttribute('data-bs-link'); | |
| let id = button.getAttribute('data-bs-id'); | |
| let text = button.getAttribute('data-bs-text'); | |
| let modalTitle = document.getElementById('staticWarningLabel'); | |
| modalTitle.textContent = 'Delete: ' + text + ' (' + id + ')'; | |
| let modalText = myConfirmDialog.querySelector('.modal-text'); | |
| modalText.textContent = text + ' (' + id + ')'; | |
| let deleteButton = myConfirmDialog.querySelector('.delete-button'); | |
| deleteButton.setAttribute('href', link) | |
| }); | |
| // bandits | |
| let myAddBanditDialog = document.getElementById("add_bandit"); | |
| myAddBanditDialog.addEventListener('show.bs.modal', function (event) { | |
| let button = event.relatedTarget; | |
| let link = button.getAttribute('data-bs-link'); | |
| let form = document.getElementById("add_bandit_form"); | |
| form.setAttribute('action', link); | |
| let name = button.getAttribute('data-bs-name'); | |
| let nickname = button.getAttribute('data-bs-nickname'); | |
| let birthday = button.getAttribute('data-bs-birthday'); | |
| let gang = button.getAttribute('data-bs-gang'); | |
| let crimeType = button.getAttribute('data-bs-crimetype'); | |
| let crimeCount = button.getAttribute('data-bs-crimecount'); | |
| let idField = document.getElementById("b_id"); | |
| let nameEdit = document.getElementById("b_name"); | |
| let nickNameEdit = document.getElementById("b_nickname"); | |
| let birthdayEdit = document.getElementById("b_birthday"); | |
| let gangEdit = document.getElementById("b_gang"); | |
| let crimeTypeEdit = document.getElementById("b_crimetype"); | |
| let crimeCountEdit = document.getElementById("b_crimecount"); | |
| let approveButton = document.getElementById("approve_button"); | |
| let dialogTitle = myAddBanditDialog.querySelector('.modal-title'); | |
| if (button.getAttribute('data-bs-ident') === '#add') { | |
| idField.value = '0'; | |
| nameEdit.value = ''; | |
| nickNameEdit.value = ''; | |
| birthdayEdit.value = ''; | |
| gangEdit.value = ''; | |
| crimeTypeEdit.value = ''; | |
| crimeCountEdit.value = ''; | |
| approveButton.textContent = "Add"; | |
| dialogTitle.textContent = "Add Bandit"; | |
| } else { | |
| idField.value = button.getAttribute('data-bs-id'); | |
| nameEdit.value = name; | |
| nickNameEdit.value = nickname; | |
| birthdayEdit.value = birthday; | |
| gangEdit.value = gang; | |
| crimeTypeEdit.value = crimeType; | |
| crimeCountEdit.value = crimeCount; | |
| dialogTitle.textContent = "Edit Bandit"; | |
| approveButton.textContent = "Update"; | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment