This commit is contained in:
foxster-mp4
2023-07-17 19:16:44 -07:00
parent 8eef026fa8
commit 8ed7aa4bc1
23 changed files with 546 additions and 357 deletions

View File

@@ -1,4 +1,17 @@
function main(json) {
//
// index.js
// altsource-viewer (https://github.com/therealFoxster/altsource-viewer)
//
// Copyright (c) 2023 Foxster.
// MIT License.
//
import { sourceURL, formatString } from "./utilities.js";
import { NewsItem } from "./components/NewsItem.js";
import { AppHeader } from "./components/AppHeader.js";
import { main } from "./main.js";
main((json) => {
// Set "View All News" link
document.querySelector("#news a").href = `news.html?source=${sourceURL}`;
// Set "View All Apps" link
@@ -17,15 +30,15 @@ function main(json) {
(new Date(b.date)).valueOf() - (new Date(a.date)).valueOf());
if (json.news.length == 1) {
document.getElementById("news-items").insertAdjacentHTML("beforeend", newsItemHTML(json.news[0], true));
document.getElementById("news-items").insertAdjacentHTML("beforeend", NewsItem(json.news[0], true));
document.getElementById("news-items").classList.add("one");
} else for (let i = 0; i < 5 && i < json.news.length; i++)
document.getElementById("news-items").insertAdjacentHTML("beforeend", newsItemHTML(json.news[i], true));
document.getElementById("news-items").insertAdjacentHTML("beforeend", NewsItem(json.news[i], true));
} else document.getElementById("news").remove();
// Sort apps in descending order of version date
json.apps.sort((a, b) => (new Date(b.versionDate)).valueOf() - (new Date(a.versionDate)).valueOf());
//
// Featured apps
let count = 1;
@@ -39,7 +52,7 @@ function main(json) {
// If there are featured apps, ignore non-featured apps
if (json.featuredApps && !json.featuredApps.includes(app.bundleIdentifier)) return;
document.getElementById("apps").insertAdjacentHTML("beforeend", appHeaderHTML(app));
document.getElementById("apps").insertAdjacentHTML("beforeend", AppHeader(app));
count++;
});
@@ -51,6 +64,6 @@ function main(json) {
<div class="item">
<p>${description}</p>
</div>
`);
`);
else document.getElementById("about").remove();
}
});