@arcade-v/arcade_v 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitlab-ci.yml +14 -0
- package/README.md +105 -0
- package/navigation/customization.js +218 -0
- package/navigation/games/apps.html +63 -0
- package/navigation/games/apps.json +125 -0
- package/navigation/games/games.html +57 -0
- package/navigation/games/games.js +177 -0
- package/navigation/games/games.json +3462 -0
- package/navigation/home.html +163 -0
- package/navigation/home.js +90 -0
- package/navigation/search.js +13 -0
- package/navigation/settings.html +91 -0
- package/navigation/style.css +317 -0
- package/package.json +10 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
let appsData = [];
|
|
2
|
+
let currentPage = 1;
|
|
3
|
+
const itemsPerPage = 24;
|
|
4
|
+
let filteredGames = [];
|
|
5
|
+
let favorites = JSON.parse(localStorage.getItem("favorites")) || [];
|
|
6
|
+
|
|
7
|
+
async function fetchGames(jsonUrl) {
|
|
8
|
+
try {
|
|
9
|
+
const response = await fetch(`${jsonUrl}?_=${Date.now()}`, { cache: "no-store" });
|
|
10
|
+
|
|
11
|
+
if (!response.ok) throw new Error(`HTTP error! Status: ${response.status}`);
|
|
12
|
+
|
|
13
|
+
appsData = await response.json();
|
|
14
|
+
filteredGames = [...appsData];
|
|
15
|
+
renderPage();
|
|
16
|
+
} catch (error) {
|
|
17
|
+
console.error("❌ Failed to load games data:", error);
|
|
18
|
+
const container = document.getElementById("gameButtons");
|
|
19
|
+
if (container)
|
|
20
|
+
container.innerHTML = "<p>Failed to load games. Please try again.</p>";
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function renderPage() {
|
|
25
|
+
const container = document.getElementById("gameButtons");
|
|
26
|
+
container.innerHTML = "";
|
|
27
|
+
|
|
28
|
+
const start = (currentPage - 1) * itemsPerPage;
|
|
29
|
+
const end = start + itemsPerPage;
|
|
30
|
+
const gamesToDisplay = filteredGames.slice(start, end);
|
|
31
|
+
|
|
32
|
+
// ✅ If no games found, reset page count to 1 and stop rendering pagination
|
|
33
|
+
if (gamesToDisplay.length === 0) {
|
|
34
|
+
currentPage = 1; // <-- Reset page count
|
|
35
|
+
const freshGames = filteredGames.slice(0, itemsPerPage);
|
|
36
|
+
|
|
37
|
+
if (freshGames.length === 0) {
|
|
38
|
+
// ✅ Still no games at all → show message
|
|
39
|
+
container.innerHTML = "<p>No games found.</p>";
|
|
40
|
+
document.getElementById("paginationControls").innerHTML = "";
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// ✅ If there ARE games on the first page, render them
|
|
45
|
+
freshGames.forEach((game) => {
|
|
46
|
+
const gameItem = document.createElement("div");
|
|
47
|
+
gameItem.className = "game-button";
|
|
48
|
+
|
|
49
|
+
const isFavorite = favorites.includes(game.title);
|
|
50
|
+
const star = isFavorite ? "⭐" : "☆";
|
|
51
|
+
|
|
52
|
+
let onclickCall = "";
|
|
53
|
+
if (Array.isArray(game.functions)) {
|
|
54
|
+
onclickCall = game.functions
|
|
55
|
+
.map((fn) => {
|
|
56
|
+
const params = fn.params.map((p) => `'${p}'`).join(",");
|
|
57
|
+
return `${fn.name}(${params})`;
|
|
58
|
+
})
|
|
59
|
+
.join(";");
|
|
60
|
+
} else {
|
|
61
|
+
onclickCall = `handleGameClick('${game.url}', '${game.mode}')`;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
gameItem.innerHTML = `
|
|
65
|
+
<button onclick="${onclickCall}" aria-label="${game.title}">
|
|
66
|
+
<img src="${game.image}" alt="${game.title}" loading="lazy">
|
|
67
|
+
</button>
|
|
68
|
+
<p class="game-title">
|
|
69
|
+
${game.title}
|
|
70
|
+
<span class="favorite-icon" onclick="toggleFavorite('${game.title}')">${star}</span>
|
|
71
|
+
</p>
|
|
72
|
+
`;
|
|
73
|
+
|
|
74
|
+
container.appendChild(gameItem);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
renderPaginationControls();
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// ✅ Normal rendering if games exist on the current page
|
|
82
|
+
gamesToDisplay.forEach((game) => {
|
|
83
|
+
const gameItem = document.createElement("div");
|
|
84
|
+
gameItem.className = "game-button";
|
|
85
|
+
|
|
86
|
+
const isFavorite = favorites.includes(game.title);
|
|
87
|
+
const star = isFavorite ? "⭐" : "☆";
|
|
88
|
+
|
|
89
|
+
let onclickCall = "";
|
|
90
|
+
if (Array.isArray(game.functions)) {
|
|
91
|
+
onclickCall = game.functions
|
|
92
|
+
.map((fn) => {
|
|
93
|
+
const params = fn.params.map((p) => `'${p}'`).join(",");
|
|
94
|
+
return `${fn.name}(${params})`;
|
|
95
|
+
})
|
|
96
|
+
.join(";");
|
|
97
|
+
} else {
|
|
98
|
+
onclickCall = `handleGameClick('${game.url}', '${game.mode}')`;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
gameItem.innerHTML = `
|
|
102
|
+
<button onclick="${onclickCall}" aria-label="${game.title}">
|
|
103
|
+
<img src="${game.image}" alt="${game.title}" loading="lazy">
|
|
104
|
+
</button>
|
|
105
|
+
<p class="game-title">
|
|
106
|
+
${game.title}
|
|
107
|
+
<span class="favorite-icon" onclick="toggleFavorite('${game.title}')">${star}</span>
|
|
108
|
+
</p>
|
|
109
|
+
`;
|
|
110
|
+
|
|
111
|
+
container.appendChild(gameItem);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
renderPaginationControls();
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function applyFilters() {
|
|
118
|
+
const searchTerm = document.getElementById("searchBar").value.toLowerCase();
|
|
119
|
+
const selectedCategory = document.getElementById("categorySelect").value;
|
|
120
|
+
const showFavorites = document.getElementById("showFavorites").checked;
|
|
121
|
+
|
|
122
|
+
filteredGames = appsData.filter((game) => {
|
|
123
|
+
const matchSearch = game.title.toLowerCase().includes(searchTerm);
|
|
124
|
+
const matchCategory =
|
|
125
|
+
selectedCategory === "All" ||
|
|
126
|
+
(Array.isArray(game.category) && game.category.includes(selectedCategory)) ||
|
|
127
|
+
game.category === selectedCategory;
|
|
128
|
+
const matchFavorite = !showFavorites || favorites.includes(game.title);
|
|
129
|
+
return matchSearch && matchCategory && matchFavorite;
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
currentPage = 1;
|
|
133
|
+
renderPage();
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function renderPaginationControls() {
|
|
137
|
+
const totalPages = Math.ceil(filteredGames.length / itemsPerPage);
|
|
138
|
+
const pagination = document.getElementById("paginationControls");
|
|
139
|
+
pagination.innerHTML = "";
|
|
140
|
+
|
|
141
|
+
for (let i = 1; i <= totalPages; i++) {
|
|
142
|
+
const btn = document.createElement("button");
|
|
143
|
+
btn.textContent = i;
|
|
144
|
+
if (i === currentPage) {
|
|
145
|
+
btn.classList.add("active-page");
|
|
146
|
+
}
|
|
147
|
+
btn.onclick = () => {
|
|
148
|
+
currentPage = i;
|
|
149
|
+
renderPage();
|
|
150
|
+
};
|
|
151
|
+
pagination.appendChild(btn);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
window.scrollTo({ top: 0, behavior: "smooth" });
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function toggleFavorite(title) {
|
|
158
|
+
if (favorites.includes(title)) {
|
|
159
|
+
favorites = favorites.filter((fav) => fav !== title);
|
|
160
|
+
} else {
|
|
161
|
+
favorites.push(title);
|
|
162
|
+
}
|
|
163
|
+
localStorage.setItem("favorites", JSON.stringify(favorites));
|
|
164
|
+
renderPage();
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function handleGameClick(url, mode) {
|
|
168
|
+
console.log(`🎮 Opening ${url} in mode ${mode}`);
|
|
169
|
+
if (mode === "A") {
|
|
170
|
+
loadBlobContent(url);
|
|
171
|
+
} else if (mode === "B") {
|
|
172
|
+
changePageContent(url);
|
|
173
|
+
} else {
|
|
174
|
+
console.warn("Unknown mode, defaulting to Blob");
|
|
175
|
+
loadBlobContent(url);
|
|
176
|
+
}
|
|
177
|
+
}
|