TIMBOVILL commited on
Commit
230ce00
1 Parent(s): c1434c9

Update scripts.js

Browse files
Files changed (1) hide show
  1. scripts.js +40 -38
scripts.js CHANGED
@@ -1,17 +1,28 @@
1
- async function fetchManifest() {
2
- const response = await fetch('manifest.json');
3
- return await response.json();
4
- }
 
 
 
 
 
 
 
 
 
 
 
5
 
6
- function renderAppList(apps) {
7
  const listContainer = document.getElementById('app-list-container');
8
  listContainer.innerHTML = '';
9
- apps.forEach((app, index) => {
10
  const item = document.createElement('div');
11
  item.className = 'grid-item';
12
- item.style.background = `linear-gradient(135deg, ${app.gradient[0]}, ${app.gradient[1]})`;
13
  item.innerHTML = `
14
- <img src="${app.iconUrl}" alt="${app.name}">
15
  <h2>${app.name}</h2>
16
  `;
17
  item.addEventListener('click', () => showAppDetail(app));
@@ -19,36 +30,27 @@ function renderAppList(apps) {
19
  });
20
  }
21
 
22
- function renderAppDetail(app) {
23
- const detailContainer = document.getElementById('app-detail-container');
24
- detailContainer.innerHTML = `
25
- <div class="detail-view">
26
- <h2>${app.name}</h2>
 
 
 
 
 
27
  <p>${app.description}</p>
28
- ${app.screenshots.map(src => `<img src="${src}" alt="${app.name} Screenshot">`).join('')}
29
- <button onclick="backToList()">Back to List</button>
30
- </div>
 
 
 
31
  `;
32
- }
33
 
34
- function showAppDetail(app) {
35
- const listContainer = document.getElementById('app-list-container');
36
- const detailContainer = document.getElementById('app-detail-container');
37
- listContainer.classList.add('hidden');
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
+ }