Responsive UI, reworked project loading script and WIP automatic featured section.
This commit is contained in:
parent
0a7017e38d
commit
ed347bcfca
6 changed files with 88 additions and 41 deletions
1
featured.json
Normal file
1
featured.json
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
["aboukkit"]
|
||||||
|
|
@ -2,8 +2,10 @@
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<link rel="stylesheet" href="styles.css">
|
<link rel="stylesheet" href="styles.css" media="screen">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<script src="project.js"></script>
|
||||||
|
<script src="featured.js" defer></script>
|
||||||
<title>NBeta</title>
|
<title>NBeta</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
@ -23,7 +25,7 @@
|
||||||
<p>This is a project that aims to preserve Minecraft Beta mods and plugins through archives of documentation and JARs and showcase new plugins for beta.</p>
|
<p>This is a project that aims to preserve Minecraft Beta mods and plugins through archives of documentation and JARs and showcase new plugins for beta.</p>
|
||||||
<div id="featured"><h2>featured projects</h2>
|
<div id="featured"><h2>featured projects</h2>
|
||||||
<div id="featuredHelper">
|
<div id="featuredHelper">
|
||||||
<div class="featuredProject">
|
<!-- <div class="featuredProject">
|
||||||
<a href="project.html?id=aboukkit">
|
<a href="project.html?id=aboukkit">
|
||||||
<img src="images/projects/aboukkit.png">
|
<img src="images/projects/aboukkit.png">
|
||||||
<p>Aboukkit</p>
|
<p>Aboukkit</p>
|
||||||
|
|
@ -41,7 +43,7 @@
|
||||||
<img src="images/projects/hats.png">
|
<img src="images/projects/hats.png">
|
||||||
<p>Hats</p>
|
<p>Hats</p>
|
||||||
<p>by AleksandarHaralanov</p>
|
<p>by AleksandarHaralanov</p>
|
||||||
</div>
|
</div> -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
|
|
||||||
11
index.js
Normal file
11
index.js
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
const featuredHelper = document.querySelector("#featuredHelper")
|
||||||
|
|
||||||
|
async function loadFeatured() {
|
||||||
|
const response = await fetch(`bananas.json`);
|
||||||
|
if (!response.ok) {
|
||||||
|
featuredHelper.innerHTML = `
|
||||||
|
<p>Oops! Failed to fetch featured projects...</p>
|
||||||
|
`
|
||||||
|
throw new Error("Failed to fetch featured projects JSON");
|
||||||
|
}
|
||||||
|
}
|
||||||
15
project.html
15
project.html
|
|
@ -2,12 +2,12 @@
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<link rel="stylesheet" href="styles.css">
|
<link rel="stylesheet" href="styles.css" media="screen">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>NBeta</title>
|
<title>NBeta</title>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
||||||
<script src="MinecraftColorCodes.3.7.js"></script>
|
<!-- <script src="MinecraftColorCodes.3.7.js"></script> -->
|
||||||
<script src="project.js" defer></script>
|
<script src="project.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="everythingHelper">
|
<div id="everythingHelper">
|
||||||
|
|
@ -32,5 +32,14 @@
|
||||||
<main id="projectDescription">
|
<main id="projectDescription">
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
<script>
|
||||||
|
const downloadButton = document.querySelector("#projectHeader button");
|
||||||
|
const header = document.querySelector("#projectHeader");
|
||||||
|
const headerTitle = document.querySelector("#projectHeader h1");
|
||||||
|
const subtitle = document.querySelector("#projectHeader p");
|
||||||
|
const main = document.querySelector("main");
|
||||||
|
const logo = document.querySelector("#projectHeader img");
|
||||||
|
loadProject(projectID, headerTitle, subtitle, main, logo);
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
62
project.js
62
project.js
|
|
@ -1,42 +1,32 @@
|
||||||
const downloadButton = document.querySelector("#projectHeader button");
|
|
||||||
const header = document.querySelector("#projectHeader");
|
|
||||||
const headerTitle = document.querySelector("#projectHeader h1");
|
|
||||||
const subtitle = document.querySelector("#projectHeader p");
|
|
||||||
const main = document.querySelector("main");
|
|
||||||
const logo = document.querySelector("#projectHeader img");
|
|
||||||
|
|
||||||
const queryString = window.location.search;
|
const queryString = window.location.search;
|
||||||
const urlParams = new URLSearchParams(queryString);
|
const urlParams = new URLSearchParams(queryString);
|
||||||
const projectID = urlParams.get('id');
|
const projectID = urlParams.get('id');
|
||||||
|
|
||||||
function loadProject() {
|
async function getProjectJSON(id = projectID) {
|
||||||
var jsonXhr = new XMLHttpRequest();
|
const response = await fetch(`projects/${id}/project.json`);
|
||||||
jsonXhr.open("GET", "projects/" + projectID + "/project.json", true);
|
if (!response.ok) throw new Error("Failed to fetch project JSON");
|
||||||
|
return response.json();
|
||||||
jsonXhr.onreadystatechange = function () {
|
|
||||||
if (jsonXhr.readyState === 4 && jsonXhr.status === 200) {
|
|
||||||
var jsonData = JSON.parse(jsonXhr.responseText);
|
|
||||||
headerTitle.innerText = jsonData.project.title;
|
|
||||||
subtitle.innerText = jsonData.project.subtitle;
|
|
||||||
console.log(jsonData);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var mdXhr = new XMLHttpRequest();
|
|
||||||
mdXhr.open("GET", "projects/" + projectID + "/description.md", true);
|
|
||||||
|
|
||||||
mdXhr.onreadystatechange = function () {
|
|
||||||
if (mdXhr.readyState === 4 && mdXhr.status === 200) {
|
|
||||||
const html = marked.parse(
|
|
||||||
mdXhr.responseText.replace(/^[\u200B\u200C\u200D\u200E\u200F\uFEFF]/,"")
|
|
||||||
)
|
|
||||||
main.appendChild(html.replaceColorCodes());
|
|
||||||
console.log(html.replaceColorCodes());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
jsonXhr.send();
|
|
||||||
mdXhr.send();
|
|
||||||
logo.src = "projects/" + projectID + "/logo.png";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loadProject();
|
async function getProjectDescription(obj, id = projectID) {
|
||||||
|
const response = await fetch(`projects/${id}/description.md`);
|
||||||
|
if (response.ok) {
|
||||||
|
const text = await response.text();
|
||||||
|
obj.innerHTML = marked.parse(text.replace(/^[\u200B\u200C\u200D\u200E\u200F\uFEFF]/, ""));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadProject(id = projectID, objTitle, objSubtitle, objDescription, objLogo) {
|
||||||
|
try {
|
||||||
|
const jsonData = await getProjectJSON(id);
|
||||||
|
|
||||||
|
if (objTitle) objTitle.innerText = jsonData.project.title;
|
||||||
|
if (objSubtitle) objSubtitle.innerText = jsonData.project.subtitle;
|
||||||
|
|
||||||
|
if (objDescription) await getProjectDescription(objDescription, id);
|
||||||
|
if (objLogo) objLogo.src = `projects/${id}/logo.png`;
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error loading project:", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
38
styles.css
38
styles.css
|
|
@ -1,7 +1,6 @@
|
||||||
* {
|
* {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@font-face {
|
@font-face {
|
||||||
|
|
@ -13,6 +12,7 @@ body {
|
||||||
font-family: Minecraft, 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
font-family: Minecraft, 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||||
background-color: black;
|
background-color: black;
|
||||||
color:white;
|
color:white;
|
||||||
|
font-size : clamp(1.2rem, .2vw, 2rem);
|
||||||
}
|
}
|
||||||
|
|
||||||
header {
|
header {
|
||||||
|
|
@ -79,6 +79,7 @@ button:hover {
|
||||||
#everythingHelper {
|
#everythingHelper {
|
||||||
max-width: 60%;
|
max-width: 60%;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
|
transform: .2s;
|
||||||
}
|
}
|
||||||
|
|
||||||
#headerLinks {
|
#headerLinks {
|
||||||
|
|
@ -140,7 +141,8 @@ button:hover {
|
||||||
}
|
}
|
||||||
|
|
||||||
#projectTitleSubtitle {
|
#projectTitleSubtitle {
|
||||||
|
margin-top: auto;
|
||||||
|
margin-bottom: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
#projectHeader {
|
#projectHeader {
|
||||||
|
|
@ -161,6 +163,12 @@ button:hover {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#projectHeader img {
|
||||||
|
outline: 2px solid gray;
|
||||||
|
width: 5vw;
|
||||||
|
height: 5vw;
|
||||||
|
}
|
||||||
|
|
||||||
#projectDescription li {
|
#projectDescription li {
|
||||||
margin-left: 20px;
|
margin-left: 20px;
|
||||||
list-style-type: "> ";
|
list-style-type: "> ";
|
||||||
|
|
@ -168,4 +176,30 @@ button:hover {
|
||||||
|
|
||||||
#projectDescription h1, h2 {
|
#projectDescription h1, h2 {
|
||||||
margin-bottom: 8px;
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media only screen and (max-width: 1280px) {
|
||||||
|
|
||||||
|
#everythingHelper {
|
||||||
|
max-width: 80%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#linksBox {
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
#linksBox * {
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@media only screen and (max-width: 300px) {
|
||||||
|
|
||||||
|
#everythingHelper {
|
||||||
|
max-width: 90%;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue