format: run prettify

This commit is contained in:
SethBurkart123
2025-05-05 18:04:10 +10:00
parent 771169348f
commit 0f9f618164
142 changed files with 28768 additions and 20790 deletions
+49 -49
View File
@@ -1,93 +1,93 @@
import { AppendLoadingSymbol } from "@/seqta/ui/Loading"
import stringToHTML from "./stringToHTML"
import { delay } from "./delay"
import { settingsState } from "./listeners/SettingsState"
import browser from "webextension-polyfill"
import LogoLightOutline from "@/resources/icons/betterseqta-light-outline.png"
import { animate, stagger } from "motion"
import { AppendLoadingSymbol } from "@/seqta/ui/Loading";
import stringToHTML from "./stringToHTML";
import { delay } from "./delay";
import { settingsState } from "./listeners/SettingsState";
import browser from "webextension-polyfill";
import LogoLightOutline from "@/resources/icons/betterseqta-light-outline.png";
import { animate, stagger } from "motion";
export async function SendNewsPage() {
console.info("[BetterSEQTA+] Started Loading News Page")
document.title = "News ― SEQTA Learn"
await delay(100)
console.info("[BetterSEQTA+] Started Loading News Page");
document.title = "News ― SEQTA Learn";
await delay(100);
const element = document.querySelector("[data-key=news]")
element!.classList.add("active")
const element = document.querySelector("[data-key=news]");
element!.classList.add("active");
// Remove all current elements in the main div to add new elements
const main = document.getElementById("main")
main!.innerHTML = ""
const main = document.getElementById("main");
main!.innerHTML = "";
const html = stringToHTML(/* html */ `
<div class="home-root">
<div class="home-container" id="news-container">
<h1 class="border">Latest Headlines in ${settingsState.newsSource ? settingsState.newsSource.charAt(0).toUpperCase() + settingsState.newsSource.slice(1) : "Australia"}</h1>
</div>
</div>`)
</div>`);
main!.append(html.firstChild!)
main!.append(html.firstChild!);
const titlediv = document.getElementById("title")!.firstChild
;(titlediv! as HTMLElement).innerText = "News"
AppendLoadingSymbol("newsloading", "#news-container")
const titlediv = document.getElementById("title")!.firstChild;
(titlediv! as HTMLElement).innerText = "News";
AppendLoadingSymbol("newsloading", "#news-container");
const response = (await browser.runtime.sendMessage({
type: "sendNews",
source: settingsState.newsSource,
})) as any
const newscontainer = document.querySelector("#news-container")
document.getElementById("newsloading")?.remove()
})) as any;
const newscontainer = document.querySelector("#news-container");
document.getElementById("newsloading")?.remove();
// Create a document fragment to batch DOM operations
const fragment = document.createDocumentFragment()
const fragment = document.createDocumentFragment();
// Map over articles to create elements
response.news.articles.forEach((article: any) => {
const newsarticle = document.createElement("a")
newsarticle.classList.add("NewsArticle")
newsarticle.href = article.url
newsarticle.target = "_blank"
const newsarticle = document.createElement("a");
newsarticle.classList.add("NewsArticle");
newsarticle.href = article.url;
newsarticle.target = "_blank";
const articleimage = document.createElement("div")
articleimage.classList.add("articleimage")
const articleimage = document.createElement("div");
articleimage.classList.add("articleimage");
if (article.urlToImage == "null" || article.urlToImage == null) {
articleimage.style.cssText = `
background-image: url(${browser.runtime.getURL(LogoLightOutline)});
width: 20%;
margin: 0 7.5%;
`
`;
} else {
articleimage.style.backgroundImage = `url(${article.urlToImage})`
articleimage.style.backgroundImage = `url(${article.urlToImage})`;
}
const articletext = document.createElement("div")
articletext.classList.add("ArticleText")
const articletext = document.createElement("div");
articletext.classList.add("ArticleText");
const title = document.createElement("a")
title.innerText = article.title
title.href = article.url
title.target = "_blank"
const title = document.createElement("a");
title.innerText = article.title;
title.href = article.url;
title.target = "_blank";
const description = document.createElement("p")
const description = document.createElement("p");
article.description =
article.description.length > 400
? article.description.substring(0, 400) + "..."
: article.description
description.innerHTML = article.description
: article.description;
description.innerHTML = article.description;
articletext.append(title, description)
newsarticle.append(articleimage, articletext)
fragment.append(newsarticle)
})
articletext.append(title, description);
newsarticle.append(articleimage, articletext);
fragment.append(newsarticle);
});
// Single DOM update to append all articles
newscontainer?.append(fragment)
newscontainer?.append(fragment);
if (!settingsState.animations) return
if (!settingsState.animations) return;
const articles = Array.from(document.querySelectorAll(".NewsArticle"))
const articles = Array.from(document.querySelectorAll(".NewsArticle"));
animate(
articles.slice(0, 20),
@@ -99,5 +99,5 @@ export async function SendNewsPage() {
damping: 20,
mass: 1,
},
)
}
);
}