Skip to content

Commit da38920

Browse files
committed
refactor: pin "create custom app" and "request an app" cards
1 parent daf9bc7 commit da38920

7 files changed

Lines changed: 58 additions & 57 deletions

File tree

static/apps.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@
4141
<option value="mail">&#77;&#97;&#105;&#108;</option>
4242
</select>
4343
</div>
44-
<div class="pinned"></div>
45-
<div class="apps"></div>
44+
<div id="apps-container">
45+
<div class="pinned"></div>
46+
<div class="apps"></div>
47+
</div>
4648
<script src="assets/js/launcher.js"></script>
4749
<script src="/assets/js/main.js"></script>
4850
<script async src="https://www.googletagmanager.com/gtag/js?id=G-WKJQ5QHQTJ"></script>

static/assets/js/launcher.js

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ function createCustomApp() {
118118
saveCustomApp(customApp);
119119

120120
const card = renderAppCard(customApp, 0, true);
121-
const nonPinnedContainer = document.querySelector(".apps");
122-
nonPinnedContainer.insertBefore(card, nonPinnedContainer.firstChild);
121+
const pinnedContainer = document.querySelector(".pinned");
122+
pinnedContainer.appendChild(card);
123123
}
124124
}
125125

@@ -214,27 +214,13 @@ function renderAppCard(app, appIndex, isCustom = false) {
214214
link.appendChild(paragraph);
215215
columnDiv.appendChild(link);
216216

217-
if (appIndex !== 0) {
217+
if (appIndex !== 0 && appIndex !== 1) {
218218
columnDiv.appendChild(createPinButton(appIndex));
219219
}
220220

221221
return columnDiv;
222222
}
223223

224-
function loadCustomApps() {
225-
const storedApps = getFromStorage("custom");
226-
227-
if (storedApps) {
228-
const apps = JSON.parse(storedApps);
229-
const nonPinnedContainer = document.querySelector(".apps");
230-
231-
Object.values(apps).forEach(app => {
232-
const card = renderAppCard(app, 0, true);
233-
nonPinnedContainer.insertBefore(card, nonPinnedContainer.firstChild);
234-
});
235-
}
236-
}
237-
238224
function getJsonPath() {
239225
if (isGamesPage) return "/assets/json/games.min.json";
240226
if (isToolsPage) return "/assets/json/t.min.json";
@@ -268,15 +254,25 @@ function loadAppsFromJson() {
268254
fetch(jsonPath)
269255
.then(response => response.json())
270256
.then(appsList => {
257+
const nonPinnedContainer = document.querySelector(".apps");
258+
const pinnedContainer = document.querySelector(".pinned");
259+
const pinnedList = getPinnedApps();
260+
261+
const appsContainer = document.getElementById("apps-container");
262+
if (appsContainer) {
263+
appsContainer.appendChild(pinnedContainer);
264+
appsContainer.appendChild(nonPinnedContainer);
265+
}
266+
267+
const specialCards = appsList.splice(0, 2);
268+
271269
appsList.sort((a, b) => {
272270
if (a.name.startsWith("[Custom]")) return -1;
273271
if (b.name.startsWith("[Custom]")) return 1;
274272
return a.name.localeCompare(b.name);
275273
});
276274

277-
const nonPinnedContainer = document.querySelector(".apps");
278-
const pinnedContainer = document.querySelector(".pinned");
279-
const pinnedList = getPinnedApps();
275+
appsList.unshift(...specialCards);
280276

281277
let appIndex = 0;
282278

@@ -285,7 +281,9 @@ function loadAppsFromJson() {
285281

286282
const card = renderAppCard(app, appIndex);
287283

288-
if (appIndex !== 0 && isAppPinned(appIndex, pinnedList)) {
284+
if (appIndex === 0 || appIndex === 1) {
285+
pinnedContainer.appendChild(card);
286+
} else if (pinnedList != null && isAppPinned(appIndex, pinnedList)) {
289287
pinnedContainer.appendChild(card);
290288
} else {
291289
nonPinnedContainer.appendChild(card);
@@ -294,15 +292,27 @@ function loadAppsFromJson() {
294292
appIndex++;
295293
});
296294

297-
const appsContainer = document.getElementById("apps-container");
298-
appsContainer.appendChild(pinnedContainer);
299-
appsContainer.appendChild(nonPinnedContainer);
295+
loadCustomAppsInline();
300296
})
301297
.catch(error => {
302298
console.error("Error fetching app data:", error);
303299
});
304300
}
305301

302+
function loadCustomAppsInline() {
303+
const storedApps = getFromStorage("custom");
304+
305+
if (storedApps) {
306+
const apps = JSON.parse(storedApps);
307+
308+
const pinnedContainer = document.querySelector(".pinned");
309+
Object.values(apps).forEach(app => {
310+
const card = renderAppCard(app, 0, true);
311+
pinnedContainer.appendChild(card);
312+
});
313+
}
314+
}
315+
306316
function filterByCategory() {
307317
const selectedCategories = Array.from(document.querySelectorAll("#category option:checked")).map(option => option.value);
308318

@@ -331,6 +341,5 @@ window.category = filterByCategory;
331341
window.bar = filterBySearchTerm;
332342

333343
document.addEventListener("DOMContentLoaded", () => {
334-
loadCustomApps();
335344
loadAppsFromJson();
336345
});

static/assets/json/apps.json

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
11
[
2+
{
3+
"name": "Request An App",
4+
"link": "https://forms.gle/vwdHN3iPz5cLaHaMA",
5+
"image": "/assets/media/icons/request.webp",
6+
"categories": ["all"]
7+
},
28
{
3-
"name": "! Create Custom App",
9+
"name": "Create Custom App",
410
"image": "/assets/media/icons/custom.webp",
511
"categories": ["all"],
612
"custom": "true"
713
},
8-
{
9-
"name": "! Interstellar FAQ/Docs",
10-
"image": "/assets/media/icons/help_center_googlefonts.png",
11-
"link": "https://docs.gointerstellar.app",
12-
"categories": ["all"]
13-
},
14-
{
15-
"name": "! [NEW] Request An App",
16-
"link": "https://forms.gle/vwdHN3iPz5cLaHaMA",
17-
"image": "/assets/media/icons/request.webp",
18-
"categories": ["all"]
19-
},
2014
{
2115
"name": "Amazon",
2216
"link": "https://amazon.com/",

static/assets/json/apps.min.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

static/assets/json/games.json

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
11
[
2+
{
3+
"name": "Request A Game",
4+
"link": "https://forms.gle/vwdHN3iPz5cLaHaMA",
5+
"image": "/assets/media/icons/request.webp",
6+
"categories": ["all"]
7+
},
28
{
3-
"name": "! Create Custom App",
9+
"name": "Create Custom Game",
410
"image": "/assets/media/icons/custom.webp",
511
"categories": ["all"],
612
"custom": "true"
713
},
8-
{
9-
"name": "! Interstellar FAQ/Docs",
10-
"image": "/assets/media/icons/help_center_googlefonts.png",
11-
"link": "https://docs.gointerstellar.app",
12-
"categories": ["all"]
13-
},
14-
{
15-
"name": "! [NEW] Request A Game",
16-
"link": "https://forms.gle/vwdHN3iPz5cLaHaMA",
17-
"image": "/assets/media/icons/request.webp",
18-
"categories": ["all"]
19-
},
2014
{
2115
"name": "Fancade",
2216
"link": "https://play.fancade.com",

static/assets/json/games.min.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

static/games.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@
3434
<option value="local">&#76;&#111;&#99;&#97;&#108;</option>
3535
</select>
3636
</div>
37-
<div class="pinned"></div>
38-
<div class="apps"></div>
37+
<div id="apps-container">
38+
<div class="pinned"></div>
39+
<div class="apps"></div>
40+
</div>
3941
<script src="/assets/js/launcher.js"></script>
4042
<script src="./assets/ultraviolet/bundle.js"></script>
4143
<script src="./assets/ultraviolet/config.js"></script>

0 commit comments

Comments
 (0)