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
|
|
@ -335,17 +335,41 @@ class deleteBtn{
|
|||
this.channel = channel;
|
||||
this.delete = document.querySelector("#channel-delete");
|
||||
|
||||
this.delete.addEventListener('click', this.promptDelete.bind(this));
|
||||
this.setupInput();
|
||||
}
|
||||
|
||||
promptDelete(){
|
||||
var confirm = window.prompt(`Warning: You are about to nuke ${this.channel} off of the face of the fucking planet, no taksie-backsies. \n \n Type in ${this.channel} to confirm.`);
|
||||
this.deleteChannel(confirm);
|
||||
setupInput(){
|
||||
this.delete.addEventListener('click', () => {new deleteAccountPopup(this.channel)});
|
||||
}
|
||||
|
||||
async deleteChannel(confirm){
|
||||
if(this.channel === confirm){
|
||||
utils.ajax.deleteChannel(this.channel, confirm);
|
||||
}
|
||||
|
||||
class deleteAccountPopup{
|
||||
constructor(channel){
|
||||
this.channel = channel;
|
||||
this.popup = new canopyUXUtils.popup("nukeChannel", true, this.asyncConstructor.bind(this));
|
||||
}
|
||||
|
||||
asyncConstructor(){
|
||||
this.prompt = document.querySelector("#delete-channel-popup-prompt");
|
||||
this.label = document.querySelector("#delete-channel-popup-content");
|
||||
|
||||
//Fill channel label
|
||||
this.label.innerHTML = this.label.innerHTML.replaceAll("[CHANNEL]", this.channel);
|
||||
|
||||
this.setupInput();
|
||||
}
|
||||
|
||||
setupInput(){
|
||||
this.prompt.addEventListener("keydown", this.nukeAccount.bind(this));
|
||||
}
|
||||
|
||||
async nukeAccount(event){
|
||||
if(event.key == "Enter"){
|
||||
console.log(this.channel);
|
||||
if(this.channel === event.target.value){
|
||||
await utils.ajax.deleteChannel(this.channel, event.target.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue