Skip to content

Commit

Permalink
bad idea to merge this but gonna anyway because i need that spinning xof
Browse files Browse the repository at this point in the history
  • Loading branch information
DexrnZacAttack authored May 11, 2024
2 parents 0768644 + 85e9d88 commit 150aec7
Show file tree
Hide file tree
Showing 8 changed files with 133 additions and 115 deletions.
52 changes: 3 additions & 49 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ <h1 class="loadingText hidden" id="loadingText"></h1>
<div class="mainCardsContainer" id="mainCardsContainer" style="display:flex;flex-direction: column;">
<div id="tabs" style="display:flex;flex-direction: row;">
<button class="tabbuttonclicked" id="dcbutton" onclick="changeMainCard('Discord');">Discord</button>
<button class="tabbutton" id="abbutton" onclick="changeMainCard('About');" style="margin-left:10px;">My
stuff</button>
<button class="tabbutton" id="bbutton" onclick="changeMainCard('Blog');" style="margin-left:10px;">Blog</button>
<!-- <button class="tabbutton" id="steambutton" style="align-self: baseline; margin-left:2%;" onclick="changeMainCard('Steam');">Steam</button> -->
<button class="tabbutton" id="settingsbtn" style="margin-right:0;margin-left:auto;"></button>
</div>
Expand Down Expand Up @@ -96,54 +95,9 @@ <h1 class="loadingText hidden" id="loadingText"></h1>
</div>
</div>
</div>
<!-- "STUFF" CARD -->
<div class="card" id="stuffTab"
<!-- BLOG CARD -->
<div class="card" id="blogCard"
style="width: 100%; border-top-left-radius: 0%; border-top-right-radius: 0%; display:none;">
<div class="expandcard" style="text-align: center;">
<h2>PC Specs</h2>
<div class="details" style="text-align: center;">
<h3>Components</h3>
<p><b>CPU</b></p>
<p><a href="https://www.amd.com/en/product/8456">Ryzen
5 3600</a></p>
<p><b>GPU</b></p>
<p><a
href="https://www.amazon.com/EVGA-GeForce-08G-P5-3553-KR-Dual-Fan-Backplate/dp/B09QLCFNRV">Nvidia
GeForce RTX 3050 (EVGA)</a></p>
<p><b>Motherboard</b></p>
<p><a href="https://www.asrock.com/mb/AMD/B550M%20Phantom%20Gaming%204/">ASRock
B550M Phantom Gaming 4</a></p>
<p><b>Memory</b></p>
<p><a
href="https://www.amazon.com/G-SKILL-Ripjaws-PC4-25600-3200MHz-F4-3200C16D-16GVKB/dp/B015FXXBW0">16GB
GSkill RipJaws</a> @ 3200MHz</p>
<p><a href="https://www.amazon.com/CORSAIR-Vengeance-2x8GB-2400MHz-Memory/dp/B00S51XHUQ">16GB
Corsair Vengeance LPX</a> @
3200MHz</p>
<p>The Corsair RAM is meant to be 2400MHz
but my motherboard let me XMP it to
3200MHz anyways lmao</p>
<h3>Accessories</h3>
<p><b>Monitor(s)</b></p>
<p><a href="https://www.amazon.com/MSI-Non-Glare-FreeSync-Optix-MAG241C/dp/B07FB6SY6Z?th=1">MSI
Optix MAG241C</a> (1920x1080
144hz)</p>
<p><a href="https://www.amazon.com/HP-W2072a-20-Inch-LED-lit-Monitor/dp/B0085H66NU">HP
W2072a</a> (1600x900 60hz)</p>
<p><b>Audio</b></p>
<p><a
href="https://www.amazon.com/Blue-Microphone-Streaming-Podcasting-Play-Silver/dp/B002VA464S">Blue
Yeti</a> Microphone</p>
<p><a href="https://www.amazon.com/Razer-Kraken-7-1-Retractable-Noise-Cancelling/dp/B072DRCM1Q">Razer
Kraken 7.1 V2</a> Headphones</p>
<p><b>Input</b></p>
<p><a href="https://www.amazon.com/Logitech-G502-Performance-Gaming-Mouse/dp/B07GBZ4Q68">Logitech
G502</a> Mouse</p>
<p><a href="https://www.amazon.com/Razer-Huntsman-Tournament-Tenkeyless-Keyboard/dp/B082J1961J">Razer
Huntsman Tournament Edition</a>
Keyboard</p>
</div>
</div>
</div>
</div>
<!-- DISCORD ACTIVITY CARD -->
Expand Down
6 changes: 5 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ import "./js/modules/msgbox.js"; // unused? not used yet, at least
import "./js/background.js"; // this sets an 'onload' handler
import "./js/fadeout.js"; // this sets a 'DOMContentLoaded' handler
import "./js/expandable.js"; // component setup
import "./js/blog.js";

import { fadeBG } from "./js/background.js";
import { actuallySetLanguage } from "./js/lanyard.js";
import { type Theme, checkLang, getLang, getThemeCookie, setTheme } from "./js/settings.js"
import { curTab, setCurTab } from "./js/tabs.js";
import { setVer } from "./js/ver.js";
import { loadBlog } from "./js/blog.js";

document.addEventListener("DOMContentLoaded", function () {
// thx actuallyaridan
Expand Down Expand Up @@ -125,4 +127,6 @@ document.addEventListener('DOMContentLoaded', function () {
});


setVer("default");
setVer("default");

document.querySelector('#bbutton').addEventListener('click', loadBlog);
13 changes: 13 additions & 0 deletions js/blog.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
interface posts {
name: {
timestamp: number,
title: string,
filename: string,
postURL: string
}
}

export async function loadBlog() {
const res: Promise<posts> = (await fetch("http://dexrn.duckdns.org/posts")).json();
const blog = (await fetch(`http://dexrn.duckdns.org/${res.postURL}`)).json();
}
137 changes: 83 additions & 54 deletions js/lanyard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

import validator from 'validator';
import langEN from "../assets/lang/en-US.json?url";
import langCN from "../assets/lang/zh-CN.json?url";

Expand Down Expand Up @@ -52,8 +53,11 @@ async function lanyardGetLang(): Promise<string | null> {
return null;
}

async function createActivity(id: string) {
// TODO: Allow multiple activities to show on website.
async function createActivity() {
const {
data: { activities },
} = await fetchResponse(USERID);
console.log(activities.length);
}

async function lanyardCheckLang(lang: string | null): Promise<string> {
Expand Down Expand Up @@ -99,7 +103,7 @@ export async function actuallySetLanguage(): Promise<void> {
const langFilePath = await lanyardCheckLang(lang);
try {
localizedText = await lanyardSetLang(langFilePath);
} catch {}
} catch { }
}

async function fetchResponse(userId: string): Promise<LanyardAPI> {
Expand Down Expand Up @@ -133,39 +137,50 @@ async function setAvatarFrame(): Promise<void> {
// Dexrn: Jank incoming!
switch (discord_status) {
case "online":
onlineState.innerText = localizedText!.lyonline;
pfp.style.border = "2px solid #3ba45d";
pfp.style.boxShadow = "0 0 20px #3ba45d";
onlineState.style.cssText = "color: #3ba45d; opacity: 1;";
platforms.style.cssText = "color: #3ba45d; opacity: 1;";
if (onlineState.innerText !== localizedText!.lyonline) {
onlineState.innerText = localizedText!.lyonline;
pfp.style.border = "2px solid #3ba45d";
pfp.style.boxShadow = "0 0 20px #3ba45d";
onlineState.style.cssText = "color: #3ba45d; opacity: 1;";
platforms.style.cssText = "color: #3ba45d; opacity: 1;";
}
break;
case "dnd":
pfp.style.border = "2px solid #ed4245";
pfp.style.boxShadow = "0 0 20px #ed4245";
onlineState.innerText = localizedText!.lydnd;
onlineState.style.cssText = "color: #ed4245; opacity: 1;";
platforms.style.cssText = "color: #ed4245; opacity: 1;";
if (onlineState.innerText !== localizedText!.lydnd) {
pfp.style.border = "2px solid #ed4245";
pfp.style.boxShadow = "0 0 20px #ed4245";
onlineState.innerText = localizedText!.lydnd;
onlineState.style.cssText = "color: #ed4245; opacity: 1;";
platforms.style.cssText = "color: #ed4245; opacity: 1;";
}
break;
case "idle":
onlineState.innerText = localizedText!.lyidle;
pfp.style.border = "2px solid #faa81a";
pfp.style.boxShadow = "0 0 20px #faa81a";
onlineState.style.cssText = "color: #faa81a; opacity: 1;";
platforms.style.cssText = "color: #faa81a; opacity: 1;";
if (onlineState.innerText !== localizedText!.lyidle) {
onlineState.innerText = localizedText!.lyidle;
pfp.style.border = "2px solid #faa81a";
pfp.style.boxShadow = "0 0 20px #faa81a";
onlineState.style.cssText = "color: #faa81a; opacity: 1;";
platforms.style.cssText = "color: #faa81a; opacity: 1;";
}
break;
case "offline":
onlineState.innerText = localizedText!.lyoffline;
pfp.style.border = "2px solid #747e8c";
pfp.style.boxShadow = "0 0 20px #747e8c";
onlineState.style.cssText = "color: unset; opacity: 0.5;";
if (onlineState.innerText !== localizedText!.lyoffline) {
onlineState.innerText = localizedText!.lyoffline;
pfp.style.border = "2px solid #747e8c";
pfp.style.boxShadow = "0 0 20px #747e8c";
onlineState.style.cssText = "color: unset; opacity: 0.5;";
}
disc_isOffline = true;
break;
default:
onlineState.innerText = localizedText!.lyunknown;
pfp.style.border = "2px solid #747e8c";
pfp.style.boxShadow = "0 0 20px #747e8c";
onlineState.style.cssText = "color: unset; opacity: 0.5;";
if (onlineState.innerText !== localizedText!.lyunknown) {
onlineState.innerText = localizedText!.lyunknown;
pfp.style.border = "2px solid #747e8c";
pfp.style.boxShadow = "0 0 20px #747e8c";
onlineState.style.cssText = "color: unset; opacity: 0.5;";
}
disc_isOffline = true;
break;
}

const platformarray: string[] = [];
Expand All @@ -187,7 +202,8 @@ async function setAvatarFrame(): Promise<void> {

if (disc_isOffline != true)
// Dexrn: Best way I could think of doing it.
platforms.innerText = `${localizedText!.lypin}${disc_platform}`;
if (platforms.innerText !== `${localizedText!.lypin}${disc_platform}`)
platforms.innerText = `${localizedText!.lypin}${disc_platform}`;
}


Expand All @@ -205,7 +221,8 @@ async function setStatus(): Promise<void> {
if (activityOfType4) {
const { state } = activityOfType4;
if (state) {
customStatus.innerHTML = `${state}`;
if (customStatus.innerHTML !== validator.escape(state))
customStatus.innerHTML = validator.escape(state);
}
}
}
Expand All @@ -217,27 +234,30 @@ async function setActivityBigImage(): Promise<void> {
} = await fetchResponse(USERID);
const mostRecent = activities.filter((m: { type: number; }) => m.type !== 4).shift();
if (mostRecent?.emoji && !mostRecent?.assets?.large_image) {
var ext = "webp";
mostRecent?.emoji?.animated === true ? ext = "gif" : ext = "webp";
bigImage.style.display = "block";
bigImage.src = `https://cdn.discordapp.com/emojis/${mostRecent.emoji.id}.webp?quality=lossless`;
bigImage.title = mostRecent.emoji.name;
if (bigImage.src !== `https://cdn.discordapp.com/emojis/${validator.escape(mostRecent.emoji.id)}.${ext}?quality=lossless`)
bigImage.src = `https://cdn.discordapp.com/emojis/${validator.escape(mostRecent.emoji.id)}.${ext}?quality=lossless`;
bigImage.title = validator.escape(mostRecent.emoji.name);
} else if (!mostRecent?.assets?.large_image) {
bigImage.style.display = "none";
return;
} else {
const imageLink = mostRecent.assets.large_image.includes("external")
? `https://media.discordapp.net/external/${
mostRecent.assets.large_image.split("mp:external/")[1]
}`
: `https://cdn.discordapp.com/app-assets/${mostRecent.application_id}/${mostRecent.assets.large_image}.png?size=256`;
? `https://media.discordapp.net/external/${mostRecent.assets.large_image.split("mp:external/")[1]
}`
: `https://cdn.discordapp.com/app-assets/${validator.escape(mostRecent.application_id)}/${validator.escape(mostRecent.assets.large_image)}.png?quality=lossless`;
if (mostRecent.assets.large_image.includes("spotify")) {
bigImage.style.display = "block";
bigImage.src = spotify!.album_art_url;
bigImage.title = spotify!.album;
bigImage.src = validator.escape(spotify!.album_art_url);
bigImage.title = validator.escape(spotify!.album);
return;
}
bigImage.style.display = "block";
bigImage.src = imageLink;
bigImage.title = mostRecent.assets.large_text;
if (bigImage.src !== imageLink)
bigImage.src = imageLink;
bigImage.title = validator.escape(mostRecent.assets.large_text);
}
}

Expand All @@ -254,27 +274,36 @@ async function setActivitySmallImage(): Promise<void> {
!mostRecent?.assets?.small_image ||
mostRecent.assets.small_image.includes("spotify")
) {
smallImage.style.display = "none";
smallImageAlt.style.display = "none";
if (smallImage.style.display !== "none")
smallImage.style.display = "none";
if (smallImageAlt.style.display !== "none")
smallImageAlt.style.display = "none";
return;
}

const imageLink = mostRecent.assets.small_image.includes("external")
? `https://media.discordapp.net/external/${
mostRecent.assets.small_image.split("mp:external/")[1]
}`
? `https://media.discordapp.net/external/${mostRecent.assets.small_image.split("mp:external/")[1]
}`
: `https://cdn.discordapp.com/app-assets/${mostRecent.application_id}/${mostRecent.assets.small_image}.png?size=256`;

if (!mostRecent.assets.large_image && mostRecent.assets.small_image) {
smallImageAlt.style.display = "block";
smallImageAlt.src = imageLink;
smallImageAlt.title = mostRecent.assets.small_text;
smallImage.style.display = "none";
if (smallImageAlt.style.display !== "block")
smallImageAlt.style.display = "block";
if (smallImageAlt.src !== imageLink)
smallImageAlt.src = imageLink;
if (smallImageAlt.title !== validator.escape(mostRecent.assets.small_text))
smallImageAlt.title = validator.escape(mostRecent.assets.small_text);
if (smallImage.style.display !== "none")
smallImage.style.display = "none";
} else {
smallImageAlt.style.display = "none";
smallImage.style.display = "block";
smallImage.src = imageLink;
smallImage.title = mostRecent.assets.small_text;
if (smallImageAlt.style.display !== "none")
smallImageAlt.style.display = "none";
if (smallImage.style.display !== "block")
smallImage.style.display = "block";
if (smallImage.src !== imageLink)
smallImage.src = imageLink;
if (smallImage.title !== validator.escape(mostRecent.assets.small_text))
smallImage.title = validator.escape(mostRecent.assets.small_text);
}
}

Expand All @@ -288,7 +317,7 @@ async function setActivityName(): Promise<void> {
return;
}
activityName.style.display = "block";
activityName.innerText = mostRecent.name;
activityName.innerText = validator.escape(mostRecent.name);
}
async function setActivityState(): Promise<void> {
const response = await fetchResponse(USERID);
Expand All @@ -304,7 +333,7 @@ async function setActivityState(): Promise<void> {
}

activityState.style.display = "block";
activityState.innerText = mostRecent!.state ?? "";
activityState.innerText = validator.escape(mostRecent!.state) ?? "";
}

async function setTimestamp(): Promise<void> {
Expand Down Expand Up @@ -354,7 +383,7 @@ async function setActivityDetails(): Promise<void> {
return;
}
activityDetail.style.display = "block";
activityDetail.innerText = mostRecent!.details ?? "";
activityDetail.innerText = validator.escape(mostRecent!.details) ?? "";
}

function presenceInvoke(): void {
Expand Down
2 changes: 1 addition & 1 deletion js/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ function setLang(langFilePath: string): void {
checkIfExists("themetxt", data.ThemeText);
checkIfExists("ftlThemeTxt", data.FirstTimeLoadThemeText);
checkIfExists("blogbtntxt", data.BlogButtonText);
checkIfExists("abbutton", data.StuffText);
checkIfExists("bbutton", data.StuffText);
checkIfExists("stuff2-path", data.MyStuffPath);
checkIfExists("darkopt", data.InitialSetupDarkThemeOption);
checkIfExists("lightopt", data.InitialSetupLightThemeOption);
Expand Down
Loading

0 comments on commit 150aec7

Please sign in to comment.