Replaced window.prompt()/alert() with custom popup

This commit is contained in:
rainbow napkin 2024-12-05 03:46:44 -05:00
parent 8ccb9003cc
commit ee5a8d9516
14 changed files with 138 additions and 63 deletions

View file

@ -155,21 +155,41 @@ class passwordResetPrompt{
}
}
class deleteAccountPrompt{
class deleteAccountButton{
constructor(){
this.deleteLink = document.querySelector('#account-settings-delete-link');
this.setupEvent();
this.setupInput();
}
setupEvent(){
if(this.deleteLink != null){
this.deleteLink.addEventListener("click",this.deletePrompt);
}
setupInput(){
this.deleteLink.addEventListener("click",this.deletePrompt.bind(this));
}
async deletePrompt(event){
const pass = window.prompt("Warning: You are about to nuke your account off of the face of the fucking planet, no taksie-backsies.\n \n (todo: replace with dialog that has obscured password input) \n Enter your password to confirm.");
await utils.ajax.deleteAccount(pass);
this.popup = new deleteAccountPopup();
}
}
class deleteAccountPopup{
constructor(){
this.popup = new canopyUXUtils.popup("nukeUser", true, this.asyncConstructor.bind(this));
}
asyncConstructor(){
this.passwordPrompt = document.querySelector("#delete-account-popup-password");
this.setupInput();
}
setupInput(){
this.passwordPrompt.addEventListener("keydown", this.nukeAccount.bind(this));
}
async nukeAccount(event){
if(event.key == "Enter"){
await utils.ajax.deleteAccount(event.target.value);
}
}
}
@ -178,4 +198,4 @@ new profileTextEditPrompt("signature");
new profileTextEditPrompt("bio", true);
new profileImgEditPrompt();
new passwordResetPrompt();
new deleteAccountPrompt();
new deleteAccountButton();