Repository navigation
Expand file tree
/
Copy pathjslearn.js
More file actions
84 lines (79 loc) · 2.79 KB
/
Copy pathjslearn.js
File metadata and controls
84 lines (79 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// This JS file is for the main index
const gameContainer = document.querySelector("#games-container");
const odinContainer = document.querySelector("#odin-container");
const projectCard = document.querySelectorAll(".projectCard");
const navbarContainer = document.querySelector("#navbarContent");
// array of obj
const navLibrary = [
{"AlwinRay.dev": "https://alwinray.dev"}
];
const projectsLibrary = [
{
title: "Calculator",
description: "Web calculator, currently can only do the basics, will add onto it later",
type: "odin",
aTag: "projects/calculator/calculator.html"
},
{
title: "Etch-A-Sketch",
description: "Web app that lets users draw and sketch on a virtual canvas, written in HTML, CSS, and JS.",
type: "game",
aTag: "projects/etch-a-sketch/etch.html"
},
{
title: "Rock-Paper-Scissors",
description: "Classic in-person game turned into a game against a computer. Try your luck.",
type: "game",
aTag: "projects/RockPaperScissors/rps.html"
},
{
title: "Tic-Tac-Toe",
description: "Classic Tic-Tac-Toe game, get three in a row before your opponent does.",
type: "game",
aTag: "projects/TicTac/tictac.html"
},
{
title: "To-Do List",
description: "Keep track of your reminders.",
type: "odin",
aTag: "projects/ToDo/todo.html"
},
{
title: "Odin Library",
description: "Web app to manage a personal book library. Users can add books with details like title, author, and pages, and view them in a list.",
type: "odin",
aTag: "Odin/Odin_Library/library.html"
},
];
// have a consistent navbar throughout each project
// first clear current html in navbar
navbarContainer.innerHTML = '';
navLibrary.forEach(item => {
for(let [key, value] of Object.entries(item)){
let navHTML = document.createElement('div');
navHTML.innerHTML = `
<a href="${value}" class="nav-item nav-link">${key}</a>
`;
navHTML.classList.add("navbar-nav");
navbarContainer.append(navHTML);
}
});
// dynamically output the projects into containers from projectsLibrary array
if(document.querySelector("#WebDev-home")){ // checks if were in the home page
console.log("web dev true");
projectsLibrary.forEach(item => {
// quick check
// console.log(item.title, item.type);
let card = `
<a class="projectCard" href="${item.aTag}">
<h4>${item.title}</h4>
<p>${item.description}</p>
</a>
`;
if(item.type == "game"){
gameContainer.innerHTML += card;
}else if(item.type == "odin"){
odinContainer.innerHTML += card;
}
});
}