File "my-data-20250309165608.ejs"
Full Path: /home/wiomgjqe/neduas.store/v1/partials/my-data-20250309165608.ejs
File size: 1.58 KB
MIME-type: text/html
Charset: utf-8
<script>
function showAlert(message, status){
var alert = document.getElementById("alert")
var type = status == 1 ? "alert-success": "alert-danger"
var removeClass = status == 1 ? "alert-danger": "alert-success"
if (alert.classList.contains(removeClass)){
alert.classList.remove(removeClass)
}
alert.style.display = ""
alert.classList.add(type);
document.getElementById("alert-text").innerText = message;
}
document.getElementById("alert-close").addEventListener("click", function(){
document.getElementById("alert").style.display = "none"
})
var query = window.location.search.substring(1).split("&").map((v) => v.split("="));
var path = {
location: window.location.origin,
query: Object.fromEntries(query)
};
function deleteData(type, from, obj){
var shouldDelete = window.confirm(`Are you sure you want to delete ${obj.server_name || obj.name} ${obj.server_name ? "and all it's services" : ""} from your ${from}`)
if (shouldDelete){
var url = path.location + "/v3?id=" + path.query.id + "&from=" + type + "&qid=" + obj.id;
fetch(url, {
method: "delete",
headers: {
"Content-Type": "application/json"
},
})
.then(res=>res.json())
.then(data=>{
showAlert(data.message, data.status)
if(data.status == 1){
var el = document.getElementById(type + "-" + obj.id);
el?.remove();
}
}).catch(err=>{
console.error("error deleting data: ", err)
showAlert("An Error occurred while deleting this data.\nPlease Try Again", 2)
})
}
}
</script>