-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
189 lines (174 loc) · 7.27 KB
/
index.html
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>3D Filament Tier List</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 20px;
background-color: #f4f4f9;
}
h1 {
text-align: center;
}
.tier {
margin-bottom: 30px;
}
.tier h2 {
background-color: #444;
color: white;
padding: 10px;
margin: 0;
text-align: center;
}
.filament-container {
display: flex;
flex-wrap: wrap;
gap: 15px;
padding: 15px;
}
.filament {
border: 1px solid #ccc;
padding: 15px;
border-radius: 8px;
background-color: #fff;
flex: 1 1 calc(33% - 20px); /* 3 columns */
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
transition: transform 0.2s ease;
}
.filament:hover {
transform: translateY(-5px);
}
.filament h3 {
margin-top: 0;
color: #333;
}
.filament p, .filament ul {
margin: 0 0 10px;
font-size: 14px;
}
.filament ul {
padding-left: 20px;
}
.filament a {
color: #007bff;
text-decoration: none;
font-weight: bold;
}
.filament a:hover {
text-decoration: underline;
}
.more-info {
display: none; /* Hidden by default */
}
.read-more {
color: #007bff;
cursor: pointer;
font-weight: bold;
text-decoration: underline;
}
footer {
margin-top: 40px;
text-align: center;
font-size: 14px;
color: #666;
}
footer a {
color: #007bff;
text-decoration: none;
}
footer a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<h1>3D Filament Tier List</h1>
<div id="tiers"></div>
<script>
async function loadFilaments() {
try {
const response = await fetch('filaments.json');
if (!response.ok) throw new Error('Network response was not ok');
const filaments = await response.json();
const tiers = {};
// Organize filaments by tier
filaments.forEach(filament => {
const tier = filament.tier ?? "Other";
if (!tiers[tier]) tiers[tier] = [];
tiers[tier].push(filament);
});
// Define the correct tier order
const tierOrder = ["S", "A", "B", "C", "F", "Other"];
// Render each tier section in the correct order
const tiersContainer = document.getElementById('tiers');
tierOrder.forEach(tier => {
if (tiers[tier]) {
const tierDiv = document.createElement("div");
tierDiv.classList.add("tier");
// Title for each tier
tierDiv.innerHTML = `<h2>Tier ${tier}</h2><div class="filament-container"></div>`;
const container = tierDiv.querySelector(".filament-container");
// Add filaments within the tier
tiers[tier].forEach(filament => {
const name = filament.name ?? "Unknown";
const description = filament.description ?? "No description available.";
const pros = filament.pros ?? "Not specified.";
const cons = filament.cons ?? "Not specified.";
const link = filament.link ?? "#";
const nozzleTemp = filament.printing_parameters?.nozzle_temp ?? "Not specified";
const bedTemp = filament.printing_parameters?.bed_temp ?? "Not specified";
const maxStrengthTemp = filament.printing_parameters?.max_strength_temp ?? "Not specified";
const filamentDiv = document.createElement("div");
filamentDiv.classList.add("filament");
filamentDiv.innerHTML = `
<h3>${name}</h3>
<p><strong>Description:</strong> ${description}</p>
<div class="more-info">
<p><strong>Pros:</strong> ${pros}</p>
<p><strong>Cons:</strong> ${cons}</p>
<p><strong>Printing Parameters:</strong></p>
<ul>
<li><strong>Nozzle Temperature:</strong> ${nozzleTemp}</li>
<li><strong>Bed Temperature:</strong> ${bedTemp}</li>
<li><strong>Max Strength Temperature:</strong> ${maxStrengthTemp}</li>
</ul>
<p><a href="${link}" target="_blank">Learn More</a></p>
</div>
<span class="read-more">Read More</span>
`;
// Add event listener for "Read More"
const readMoreBtn = filamentDiv.querySelector('.read-more');
const moreInfoDiv = filamentDiv.querySelector('.more-info');
readMoreBtn.addEventListener('click', () => {
if (moreInfoDiv.style.display === 'none') {
moreInfoDiv.style.display = 'block';
readMoreBtn.textContent = 'Read Less';
} else {
moreInfoDiv.style.display = 'none';
readMoreBtn.textContent = 'Read More';
}
});
container.appendChild(filamentDiv);
});
tiersContainer.appendChild(tierDiv);
}
});
} catch (error) {
console.error('Failed to load filaments:', error);
document.getElementById('tiers').innerHTML = `<p>Error loading filaments. Please try again later.</p>`;
}
}
loadFilaments();
</script>
<footer>
<p>
<a href="https://github.com/rubenayla/3d-filament-tier-list" target="_blank">GitHub Repository</a> |
Zack Freedman's video: <a href="https://youtu.be/weeG9yOp3i4" target="_blank">The 3D Filament Tier List! Which Should YOU Use?</a>
</p>
</footer>
</body>
</html>