Update scripts.js
Browse files- scripts.js +40 -38
scripts.js
CHANGED
|
@@ -1,17 +1,28 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
-
function renderAppList(
|
| 7 |
const listContainer = document.getElementById('app-list-container');
|
| 8 |
listContainer.innerHTML = '';
|
| 9 |
-
|
| 10 |
const item = document.createElement('div');
|
| 11 |
item.className = 'grid-item';
|
| 12 |
-
item.style.
|
| 13 |
item.innerHTML = `
|
| 14 |
-
<img src="${app.
|
| 15 |
<h2>${app.name}</h2>
|
| 16 |
`;
|
| 17 |
item.addEventListener('click', () => showAppDetail(app));
|
|
@@ -19,36 +30,27 @@ function renderAppList(apps) {
|
|
| 19 |
});
|
| 20 |
}
|
| 21 |
|
| 22 |
-
function
|
| 23 |
-
const
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
<p>${app.description}</p>
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
| 31 |
`;
|
| 32 |
-
|
| 33 |
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
detailContainer.classList.remove('hidden');
|
| 39 |
-
renderAppDetail(app);
|
| 40 |
-
}
|
| 41 |
-
|
| 42 |
-
function backToList() {
|
| 43 |
-
const listContainer = document.getElementById('app-list-container');
|
| 44 |
-
const detailContainer = document.getElementById('app-detail-container');
|
| 45 |
-
listContainer.classList.remove('hidden');
|
| 46 |
-
detailContainer.classList.add('hidden');
|
| 47 |
-
}
|
| 48 |
-
|
| 49 |
-
document.addEventListener('DOMContentLoaded', async () => {
|
| 50 |
-
const apps = await fetchManifest();
|
| 51 |
-
renderAppList(apps);
|
| 52 |
-
|
| 53 |
-
document.getElementById('browse-button').addEventListener('click', backToList);
|
| 54 |
-
});
|
|
|
|
| 1 |
+
document.addEventListener('DOMContentLoaded', () => {
|
| 2 |
+
fetch('manifest.json')
|
| 3 |
+
.then(response => response.json())
|
| 4 |
+
.then(data => renderAppList(data));
|
| 5 |
+
|
| 6 |
+
document.getElementById('browse-button').addEventListener('click', () => {
|
| 7 |
+
const detailView = document.getElementById('app-detail');
|
| 8 |
+
if (detailView) {
|
| 9 |
+
detailView.remove();
|
| 10 |
+
}
|
| 11 |
+
fetch('manifest.json')
|
| 12 |
+
.then(response => response.json())
|
| 13 |
+
.then(data => renderAppList(data));
|
| 14 |
+
});
|
| 15 |
+
});
|
| 16 |
|
| 17 |
+
function renderAppList(manifest) {
|
| 18 |
const listContainer = document.getElementById('app-list-container');
|
| 19 |
listContainer.innerHTML = '';
|
| 20 |
+
manifest.forEach((app, index) => {
|
| 21 |
const item = document.createElement('div');
|
| 22 |
item.className = 'grid-item';
|
| 23 |
+
item.style.setProperty('--gradient', app.gradient);
|
| 24 |
item.innerHTML = `
|
| 25 |
+
<img src="${app.icon}" alt="${app.name}">
|
| 26 |
<h2>${app.name}</h2>
|
| 27 |
`;
|
| 28 |
item.addEventListener('click', () => showAppDetail(app));
|
|
|
|
| 30 |
});
|
| 31 |
}
|
| 32 |
|
| 33 |
+
function showAppDetail(app) {
|
| 34 |
+
const detailView = document.createElement('div');
|
| 35 |
+
detailView.className = 'detail-view';
|
| 36 |
+
detailView.id = 'app-detail';
|
| 37 |
+
detailView.innerHTML = `
|
| 38 |
+
<header>
|
| 39 |
+
<h1>${app.name}</h1>
|
| 40 |
+
</header>
|
| 41 |
+
<main>
|
| 42 |
+
<img src="${app.icon}" alt="${app.name}">
|
| 43 |
<p>${app.description}</p>
|
| 44 |
+
<div class="screenshots">
|
| 45 |
+
<img src="${app.screenshots[0]}" alt="Screenshot 1">
|
| 46 |
+
<img src="${app.screenshots[1]}" alt="Screenshot 2">
|
| 47 |
+
</div>
|
| 48 |
+
<button id="install-button">Install</button>
|
| 49 |
+
</main>
|
| 50 |
`;
|
| 51 |
+
document.getElementById('app').appendChild(detailView);
|
| 52 |
|
| 53 |
+
document.getElementById('install-button').addEventListener('click', () => {
|
| 54 |
+
window.location.href = app.installUrl;
|
| 55 |
+
});
|
| 56 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|