|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | + <head> |
| 4 | + <meta charset="utf-8"> |
| 5 | + <meta name="viewport" content="width=device-width, initial-scale=1"> |
| 6 | + <title>BlockifyVR | Project Gallery</title> |
| 7 | + <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-KK94CHFLLe+nY2dmCWGMq91rCGa5gtU4mk92HdvYe+M/SXH301p5ILy+dN9+nJOZ" crossorigin="anonymous"> |
| 8 | + <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script> |
| 9 | + <link rel="icon" type="image/svg+xml" href="/Website/Resources/favicon.svg"> |
| 10 | + <link rel="stylesheet" href="/Resources/styles.css"> |
| 11 | + <script> |
| 12 | + const id = new URLSearchParams(window.location.search).get("q"); |
| 13 | + |
| 14 | + fetch('/projects/projects.json') |
| 15 | + .then(response => response.json()) |
| 16 | + .then(data => { |
| 17 | + if (id) { |
| 18 | + if (!data[id]) { |
| 19 | + window.location.href = '/404.html'; |
| 20 | + } else { |
| 21 | + loadProject(id, data); |
| 22 | + } |
| 23 | + } else { |
| 24 | + loadGallery(data); |
| 25 | + } |
| 26 | + }) |
| 27 | + .catch(error => { |
| 28 | + console.error('Error fetching project gallery data:', error); |
| 29 | + const alert = document.createElement("div"); |
| 30 | + alert.innerHTML = `<b>Error Loading Projects</b>`; |
| 31 | + alert.setAttribute("class", "alert alert-danger"); |
| 32 | + alert.style.color = "darkred"; |
| 33 | + document.getElementById("projectContainer").append(alert); |
| 34 | + }); |
| 35 | + |
| 36 | + function loadGallery(data) { |
| 37 | + if (data.length == 0) { |
| 38 | + const container = ` |
| 39 | + <h1>Project Gallery</h1> |
| 40 | + <div class="container text-center" style="padding-top: 10px; padding-left: 10%; padding-right: 10%"> |
| 41 | + <div id="gallery" style="padding-top: 25px;"> |
| 42 | + </div> |
| 43 | + </div>`; |
| 44 | + document.getElementById("projectContainer").appendChild(document.createRange().createContextualFragment(container)); |
| 45 | + |
| 46 | + const alert = document.createElement("div"); |
| 47 | + alert.innerHTML = "<b>No Projects Found</b>"; |
| 48 | + alert.setAttribute("class", "alert alert-success"); |
| 49 | + alert.style.color = "darkgreen"; |
| 50 | + document.getElementById("gallery").prepend(alert); |
| 51 | + } else { |
| 52 | + const container = ` |
| 53 | + <h1>Project Gallery</h1> |
| 54 | + <div class="container text-center" style="padding-top: 10px; padding-left: 10%; padding-right: 10%"> |
| 55 | + <input id="projectSearch" style="color: darkgreen;" type="text" class="form-control" placeholder="Search for a project..." onkeyup="searchProject(value)"> |
| 56 | + <div id="gallery" style="padding-top: 25px;" class="text-start row row-cols-1 row-cols-md-3 g-4"> |
| 57 | + </div> |
| 58 | + </div>`; |
| 59 | + document.getElementById("projectContainer").appendChild(document.createRange().createContextualFragment(container)); |
| 60 | + |
| 61 | + const gallery = document.getElementById("gallery"); |
| 62 | + data.forEach(element => { |
| 63 | + let card = |
| 64 | + `<div id="${data.indexOf(element)}" class="col project"> |
| 65 | + <a href="/projects?q=${data.indexOf(element)}"> |
| 66 | + <div class="card" style="width: auto; border-radius: 8px;"> |
| 67 | + <img src="/projects/${element}/thumbnail.png" class="card-img-top" style="padding: 10px; border-radius: 15px"> |
| 68 | + <div class="card-body"> |
| 69 | + <h5 class="card-title text-truncate" style="margin-bottom: 0; color: darkgreen;">${element.slice(element.indexOf("/") + 1, element.lastIndexOf("/"))}</h5> |
| 70 | + </div> |
| 71 | + </div> |
| 72 | + </a> |
| 73 | + </div>`; |
| 74 | + gallery.appendChild(document.createRange().createContextualFragment(card)); |
| 75 | + }); |
| 76 | + } |
| 77 | + } |
| 78 | + |
| 79 | + function loadProject(id, data) { |
| 80 | + const html = ` |
| 81 | + <h1>${data[id].slice(data[id].indexOf("/") + 1, data[id].lastIndexOf("/"))}</h1> |
| 82 | + <h5 style="padding-bottom: 25px;">${data[id].slice(0, data[id].indexOf("/"))}</h5> |
| 83 | + <iframe style="border-radius: 8px; border: none;" src="/projects/${data[id]}/index.html"></iframe>`; |
| 84 | + |
| 85 | + document.getElementById("projectContainer").appendChild(document.createRange().createContextualFragment(html)); |
| 86 | + } |
| 87 | + |
| 88 | + function searchProject(value) { |
| 89 | + let projects = document.querySelectorAll(".project"); |
| 90 | + console.log(value); |
| 91 | + const searchQuery = value.toLowerCase(); |
| 92 | + |
| 93 | + projects.forEach(project => { |
| 94 | + const h5 = project.querySelector("h5").textContent.toLowerCase(); |
| 95 | + if (h5.includes(searchQuery)) { |
| 96 | + project.style.removeProperty("display"); |
| 97 | + } else { |
| 98 | + project.style.display = "none"; |
| 99 | + } |
| 100 | + }); |
| 101 | + } |
| 102 | + </script> |
| 103 | + |
| 104 | + <style> |
| 105 | + html, body { |
| 106 | + height: 100%; |
| 107 | + margin: 0; |
| 108 | + } |
| 109 | + |
| 110 | + body { |
| 111 | + display: flex; |
| 112 | + flex-direction: column; |
| 113 | + min-height: 100vh; |
| 114 | + } |
| 115 | + |
| 116 | + #projectContainer { |
| 117 | + flex: 1; |
| 118 | + display: flex; |
| 119 | + flex-direction: column; |
| 120 | + padding: 50px 10%; |
| 121 | + } |
| 122 | + |
| 123 | + #projectContainer iframe { |
| 124 | + flex: 1; |
| 125 | + border-radius: 8px; |
| 126 | + width: 100%; |
| 127 | + border: none; |
| 128 | + } |
| 129 | + </style> |
| 130 | + </head> |
| 131 | + <body class="d-flex flex-column min-vh-100" style="height: 100%;"> |
| 132 | + <nav class="navbar navbar-expand-lg" data-bs-theme="dark" style="background-color:#128211;"> |
| 133 | + <div class="container-fluid"> |
| 134 | + <a class="navbar-brand disabled"><img src="../../Resources/logo.svg" class="img-fluid position-relative" alt="scratch vr extension header image" style="width: 50px;"></a> |
| 135 | + <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation"> |
| 136 | + <span class="navbar-toggler-icon"></span> |
| 137 | + </button> |
| 138 | + <div class="collapse navbar-collapse" id="navbarNavDropdown"> |
| 139 | + <ul class="navbar-nav me-auto"> |
| 140 | + <li class="nav-item"> |
| 141 | + <a class="nav-link" href="/">Home</a> |
| 142 | + </li> |
| 143 | + <li class="nav-item"> |
| 144 | + <a class="nav-link" href="/documentation/">Documentation</a> |
| 145 | + </li> |
| 146 | + <li class="nav-item"> |
| 147 | + <a class="nav-link active" aria-current="page" href="/projects/">Project Gallery</a> |
| 148 | + </li> |
| 149 | + </ul> |
| 150 | + </div> |
| 151 | + </div> |
| 152 | + </nav> |
| 153 | + <div class="text-center" id="projectContainer" style="padding: 50px 10%;"> |
| 154 | + |
| 155 | + </div> |
| 156 | + <footer class="mt-auto footer-dark"> |
| 157 | + <div class="container-fluid d-flex align-items-center justify-content-center"> |
| 158 | + <p><b><br/>Not affiliated with Scratch, the Scratch Team, or the Scratch Foundation.</b> |
| 159 | + Created by <a href="https://scratch.mit.edu/users/-MasterMath-"><b>@-MasterMath-</b></a> on <a href="https://scratch.mit.edu">Scratch.</a></p> |
| 160 | + </div> |
| 161 | + </footer> |
| 162 | + </body> |
| 163 | +</html> |
0 commit comments