Replaced window.prompt()/alert() with custom popup
This commit is contained in:
parent
8ccb9003cc
commit
ee5a8d9516
14 changed files with 138 additions and 63 deletions
|
|
@ -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();
|
||||
Loading…
Add table
Add a link
Reference in a new issue