doritosYuh

Untitled

Jul 20th, 2025
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.50 KB | Source Code | 0 0
  1. // Delete Project Functionality
  2. // Copy below into javascript:
  3.   deleteProjectBtn.addEventListener("click", () => {
  4.     const selectedProject = projectDropdown.value;
  5.     if (!selectedProject) {
  6.       alert("Please select a project to delete first.");
  7.       return;
  8.     }
  9.  
  10.     if (confirm(`Are you sure you want to delete project "${selectedProject}"? This cannot be undone.`)) {
  11.       deleteProject(currentUser.uid, selectedProject);
  12.     }
  13.   });
  14.  
  15.   async function deleteProject(uid, projectName) {
  16.     try {
  17.       const projectRef = db.collection("users").doc(uid)
  18.         .collection("projects").doc(projectName);
  19.  
  20.       await projectRef.delete();
  21.  
  22.       alert(`Project "${projectName}" deleted successfully.`);
  23.  
  24.       // Refresh the dropdown
  25.       populateProjectDropdown(uid);
  26.  
  27.       // Hide navigation buttons since project was deleted
  28.       document.getElementById("highlightRandomBtn").classList.add("hidden");
  29.       document.getElementById("prevHighlightBtn").classList.add("hidden");
  30.       document.getElementById("nextHighlightBtn").classList.add("hidden");
  31.  
  32.     } catch (err) {
  33.       console.error("Error deleting project:", err);
  34.       alert("Failed to delete project: " + err.message);
  35.     }
  36.   }
  37.  
  38. // Copy below into CSS
  39.  #deleteProjectBtn {
  40.       background-color: #f44336;
  41.       color: white;
  42.       margin-top: 10px;
  43.     }
  44.  
  45.     #deleteProjectBtn:hover {
  46.       background-color: #d32f2f;
  47.     }
  48.  
  49. // Copy below into HTML
  50. <button id="deleteProjectBtn">Delete Project</button>
  51.  
Advertisement
Add Comment
Please, Sign In to add comment