Files
alfieking.dev/static/js/base.js
Alfie King 9700a5dc7f
All checks were successful
Build and push container image / build-and-push-image (push) Successful in 4m39s
music update
2026-02-02 01:24:14 +00:00

130 lines
3.3 KiB
JavaScript

const values = [
"Web developer",
"Pc games enjoyer",
"Server backend survivor",
"python programmer",
"Javascript disliker",
"I use Arch btw",
"Owo, what's this?",
"Ultimate procrastinator",
"Ultrakill gaming",
"00111010 00110011",
"fistful of dollar",
"Thy end is now!!!",
"Possibly a furry",
"Prepare thyself!!!",
"Spegatti code master",
"Ethernet cable untangler",
"Caffeine addict",
"I'm not a robot ☑",
"Loud Music enjoyer",
"part time femboy :<",
];
let typing_direction = 1;
let text = "";
let speed = 100;
let selectedValue = 0;
let currentValueIndex = 0;
let pause = false;
function randomValue() {
selectedValue = Math.floor(Math.random() * values.length);
currentValueIndex = 0;
}
function type() {
if (typing_direction == 1) {
if (currentValueIndex < values[selectedValue].length) {
text += values[selectedValue][currentValueIndex];
currentValueIndex++;
} else {
typing_direction = -1;
pause = true;
}
} else {
if (currentValueIndex > 0) {
text = text.slice(0, -1);
currentValueIndex--;
} else {
typing_direction = 1;
randomValue();
}
}
}
function typing() {
type();
document.getElementById("typing").innerHTML = "$ " + text;
if (typing_direction == 1) {
speed = 80 + Math.random() * 100;
} else {
speed = 60 + (Math.random() * 100) / 2;
}
if (!pause) {
setTimeout(typing, speed);
} else {
setTimeout(typing, 500);
pause = false;
}
}
typing();
// HIDDEN STUFF (shh don't tell anyone >:3)
let last5Chars = "";
document.addEventListener('keydown', function(event) {
last5Chars += event.key;
if (last5Chars == "furry") {
console.log("owo, whats this?");
document.getElementById('furry').style.display = 'block';
}
if (last5Chars == "irken") {
console.log("doom doom doom!");
document.querySelector(":root").style.setProperty('--font-family', 'Irken');
document.querySelector(":root").style.setProperty('--title-font', '1.5em');
}
while (last5Chars.length >= 5) {
last5Chars = last5Chars.slice(1);
}
});
// Spotify API (now lastfm)
function getSpotify() {
fetch('/lastfm/info').then(response => {
return response.json();
}).then(data => {
document.getElementById('spotify').style.backgroundImage = "url(" + data.image + ")";
document.getElementById('spotify-title').innerHTML = data.track;
document.getElementById('spotify-artist').innerHTML = data.artist;
});
}
if (document.getElementById('spotify')) {
getSpotify();
setInterval(getSpotify, 60000);
}
// load buttons
function loadButtons() {
fetch('/static/content/buttons/non_link_buttons.txt').then(response => {
return response.text();
}).then(data => {
container = document.getElementById('button-collection');
for (let line of data.split('\n')) {
if (line == "") {
continue;
}
let img = document.createElement('img');
img.src = line;
container.appendChild(img);
}
});
}
if (document.getElementById('button-collection')) {
loadButtons();
}