File "my-data-20250315055058-20250315111840.ejs"

Full Path: /home/wiomgjqe/neduas.store/styles/my-data-20250315055058-20250315111840.ejs
File size: 1.53 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} from your ${from}`)
    if (shouldDelete){
      var url = path.location + "/v2?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>