-
Notifications
You must be signed in to change notification settings - Fork 1
/
featured.html
102 lines (96 loc) · 3.99 KB
/
featured.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
<!DOCTYPE html>
<html lang="en">
<head>
<title>Featured | gnaw</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta charset="UTF-8">
<meta name="background-color" content="#010409">
<meta name="theme-color" content="#0d1117">
<link rel="icon" sizes="512x512" href="images/icon.png">
<link rel="icon" sizes="64x64" href="images/icon64.png">
<link rel="manifest" href="manifest.webmanifest">
<link rel="stylesheet" href="styles.css">
<script src="theme.js"></script>
<script>
function fetchFeatured() {
fetch('https://corsproxy.io/?https://api.scratch.mit.edu/studios/27205657/projects')
.then(response => response.json())
.then(data => {
var exploreContainer = document.getElementById('featured-container');
var exploreHTML = '';
Promise.all(data.map(project => fetchProjectStats(project.id)))
.then(statsData => {
data.forEach((project, index) => {
var thumbnailUrl = `https://uploads.scratch.mit.edu/get_image/project/${project.id}_480x360.png`;
var stats = statsData[index].stats;
exploreHTML += `
<div class="project read">
<div class="thumbnail-container">
<a href="project.html?project=${project.id}"><img src="${thumbnailUrl}" alt="Project Thumbnail" class="thumbnail"></a>
</div>
<div class="project-info">
<h3 style='margin:0;'><a href="project.html?project=${project.id}">${project.title}</a></h3>
<p>
<em>by <a href='profile.html?username=${project.username}'>${project.username}</a></em>
| Views: ${stats.views} | Loves: ${stats.loves} | Favorites: ${stats.favorites}
</p>
</div>
</div>`;
});
exploreContainer.innerHTML = exploreHTML;
});
})
.catch(error => {
console.error('Error:', error);
});
}
function fetchProjectStats(projectId) {
return fetch(`https://corsproxy.io/?https://api.scratch.mit.edu/projects/${projectId}`)
.then(response => response.json());
}
window.addEventListener("load", function() {
fetchFeatured();
});
</script>
</head>
<body>
<div class="nav">
<div class="inner-nav">
<div class="nav-item">
<a class="icon desktop" href="index.html">gnaw</a>
<a class="icon mobile" href="index.html">g</a>
</div>
<div class="nav-item desktop" style="justify-content: right;">
<a class="icon desktop nvl" href="explore.html">Explore</a>
<a class="icon desktop nvl" href="featured.html">Featured</a>
</div>
</div>
</div>
<div class="page">
<div class="header">
<h1>Featured</h1>
<i>Projects from the Turbowarp featured section</i>
</div>
<div id="featured-container"></div>
<div class="about">
<div id="about">
<a href="index.html" style="font-weight: bold; ">gnaw</a> / <a href="https://discord.com/users/797570703419244594">discord</a> / <a href="mailto:[email protected]">email me</a> / <a href="profile.html?username=3r1s_s">profile</a> / <a href="https://github.com/3r1s-s">github</a> / <a href="health.html">health</a> / <a href="about.html">about</a> / <a href="settings.html">settings</a> /
</div>
</div>
<div class="mobile-nav">
<div class="mobile-nav-item">
<a href="index.html"><i class="material-symbols-outlined">home</i></a>
</div>
<div class="mobile-nav-item">
<a href="featured.html"><i class="material-symbols-outlined">star</i></a>
</div>
<div class="mobile-nav-item">
<a href="explore.html"><i class="material-symbols-outlined">globe</i></a>
</div>
<div class="mobile-nav-item">
<a href="settings.html"><i class="material-symbols-outlined">settings</i></a>
</div>
</div>
</div>
</body>
</html>