Add clang-format config
This commit is contained in:
parent
fd529835a4
commit
5c85e09ad5
3 changed files with 143 additions and 128 deletions
7
.clang-format
Normal file
7
.clang-format
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
Language: JavaScript
|
||||||
|
UseTab: Always
|
||||||
|
IndentWidth: 4
|
||||||
|
TabWidth: 4
|
||||||
|
LineEnding: LF
|
||||||
|
---
|
4
Justfile
4
Justfile
|
@ -1,5 +1,9 @@
|
||||||
check:
|
check:
|
||||||
markdownlint-cli2
|
markdownlint-cli2
|
||||||
|
clang-format --dry-run assets/js/*.js
|
||||||
|
|
||||||
|
format:
|
||||||
|
clang-format -i assets/js/*.js
|
||||||
|
|
||||||
serve:
|
serve:
|
||||||
hugo serve
|
hugo serve
|
||||||
|
|
260
assets/js/its.js
260
assets/js/its.js
|
@ -16,8 +16,8 @@ function randomRange(min, max) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function delay(millis) {
|
async function delay(millis) {
|
||||||
await new Promise((resolve) =>
|
await new Promise(
|
||||||
setTimeout(resolve, millis),
|
(resolve) => setTimeout(resolve, millis),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ function setNixieColor(color) {
|
||||||
function nixieRainbow() {
|
function nixieRainbow() {
|
||||||
const tubeSpans = document.querySelectorAll('.tube>span');
|
const tubeSpans = document.querySelectorAll('.tube>span');
|
||||||
const numberOfSpans = tubeSpans.length;
|
const numberOfSpans = tubeSpans.length;
|
||||||
|
|
||||||
tubeSpans.forEach((span, index) => {
|
tubeSpans.forEach((span, index) => {
|
||||||
const hue = Math.floor((360 / numberOfSpans) * index);
|
const hue = Math.floor((360 / numberOfSpans) * index);
|
||||||
const color = `hsl(${hue}, 100%, 50%)`;
|
const color = `hsl(${hue}, 100%, 50%)`;
|
||||||
|
@ -126,13 +126,13 @@ function nixieRainbow() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetNixieRainbow() {
|
function resetNixieRainbow() {
|
||||||
const tubeSpans = document.querySelectorAll('.tube>span');
|
const tubeSpans = document.querySelectorAll('.tube>span');
|
||||||
|
|
||||||
tubeSpans.forEach((span) => {
|
tubeSpans.forEach((span) => {
|
||||||
span.style.color = '';
|
span.style.color = '';
|
||||||
span.style.textShadow = '';
|
span.style.textShadow = '';
|
||||||
span.style.animation = '';
|
span.style.animation = '';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleInput(event) {
|
function handleInput(event) {
|
||||||
|
@ -143,36 +143,39 @@ function handleInput(event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function inputCodeCheck(typedText) {
|
function inputCodeCheck(typedText) {
|
||||||
switch(typedText.toLowerCase()) {
|
switch (typedText.toLowerCase()) {
|
||||||
case "(){:;}":
|
case "(){:;}":
|
||||||
shellShock();
|
shellShock();
|
||||||
break;
|
break;
|
||||||
case "matrix":
|
case "matrix":
|
||||||
matrix();
|
matrix();
|
||||||
break;
|
break;
|
||||||
case "barrel":
|
case "barrel":
|
||||||
barrel();
|
barrel();
|
||||||
break;
|
break;
|
||||||
case "astley":
|
case "astley":
|
||||||
astley();
|
astley();
|
||||||
break;
|
break;
|
||||||
case "kawaii":
|
case "kawaii":
|
||||||
nyan_cat();
|
nyan_cat();
|
||||||
break;
|
break;
|
||||||
case "pacman":
|
case "pacman":
|
||||||
pacman();
|
pacman();
|
||||||
break;
|
break;
|
||||||
case "gamble":
|
case "gamble":
|
||||||
gamble();
|
gamble();
|
||||||
break;
|
break;
|
||||||
case "drkhsh":
|
case "drkhsh":
|
||||||
drkhsh();
|
drkhsh();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const code = [38, 38, 40, 40, 37, 39, 37, 39, 66, 65];
|
const code = [ 38, 38, 40, 40, 37, 39, 37, 39, 66, 65 ];
|
||||||
const code_two = [48, 49, 49, 56, 57, 57, 57, 56, 56, 49, 57, 57, 57, 49, 49, 57, 55, 50, 53, 51];
|
const code_two = [
|
||||||
|
48, 49, 49, 56, 57, 57, 57, 56, 56, 49,
|
||||||
|
57, 57, 57, 49, 49, 57, 55, 50, 53, 51
|
||||||
|
];
|
||||||
|
|
||||||
let currentStepOne = 0;
|
let currentStepOne = 0;
|
||||||
let currentStepTwo = 0;
|
let currentStepTwo = 0;
|
||||||
|
@ -188,7 +191,8 @@ function checkSequence(e) {
|
||||||
currentStepOne = 0;
|
currentStepOne = 0;
|
||||||
setNixieColor('var(--nixie-green)');
|
setNixieColor('var(--nixie-green)');
|
||||||
setNixieContent("ITCRWD");
|
setNixieContent("ITCRWD");
|
||||||
let search_field = document.getElementsByClassName("widget-search__field")[0];
|
let search_field =
|
||||||
|
document.getElementsByClassName("widget-search__field")[0];
|
||||||
search_field.placeholder = 'Emergency Services';
|
search_field.placeholder = 'Emergency Services';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -199,7 +203,8 @@ function checkSequence(e) {
|
||||||
currentStepTwo++;
|
currentStepTwo++;
|
||||||
if (currentStepTwo === code_two.length) {
|
if (currentStepTwo === code_two.length) {
|
||||||
nixieRainbow();
|
nixieRainbow();
|
||||||
let search_field = document.getElementsByClassName("widget-search__field")[0];
|
let search_field =
|
||||||
|
document.getElementsByClassName("widget-search__field")[0];
|
||||||
search_field.placeholder = 'user@it-syndikat:~$';
|
search_field.placeholder = 'user@it-syndikat:~$';
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
search_field.value = '';
|
search_field.value = '';
|
||||||
|
@ -222,24 +227,27 @@ window.addEventListener('keydown', checkSequence);
|
||||||
function shuffleArray(array) {
|
function shuffleArray(array) {
|
||||||
for (let i = array.length - 1; i > 0; i--) {
|
for (let i = array.length - 1; i > 0; i--) {
|
||||||
const j = Math.floor(Math.random() * (i + 1));
|
const j = Math.floor(Math.random() * (i + 1));
|
||||||
[array[i], array[j]] = [array[j], array[i]];
|
[array[i], array[j]] = [ array[j], array[i] ];
|
||||||
}
|
}
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
function shuffleString(inputString, charSet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+[]{}|;:,.<>?') {
|
function shuffleString(
|
||||||
let characters = inputString.split('');
|
inputString,
|
||||||
|
charSet =
|
||||||
|
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+[]{}|;:,.<>?') {
|
||||||
|
let characters = inputString.split('');
|
||||||
|
|
||||||
for (let i = 0; i < inputString.length; i++) {
|
for (let i = 0; i < inputString.length; i++) {
|
||||||
characters.push(charSet[Math.floor(Math.random() * charSet.length)]);
|
characters.push(charSet[Math.floor(Math.random() * charSet.length)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = characters.length - 1; i > 0; i--) {
|
for (let i = characters.length - 1; i > 0; i--) {
|
||||||
const j = Math.floor(Math.random() * (i + 1));
|
const j = Math.floor(Math.random() * (i + 1));
|
||||||
[characters[i], characters[j]] = [characters[j], characters[i]];
|
[characters[i], characters[j]] = [ characters[j], characters[i] ];
|
||||||
}
|
}
|
||||||
|
|
||||||
return characters.join('');
|
return characters.join('');
|
||||||
}
|
}
|
||||||
|
|
||||||
function shellShock() {
|
function shellShock() {
|
||||||
|
@ -252,9 +260,9 @@ function shellShock() {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
element.style.display = 'none';
|
element.style.display = 'none';
|
||||||
if (index === shuffledElements.length - 1) {
|
if (index === shuffledElements.length - 1) {
|
||||||
setTimeout(() => {
|
setTimeout(
|
||||||
document.body.innerText = "But nobody came.";
|
() => { document.body.innerText = "But nobody came."; },
|
||||||
}, 100);
|
100);
|
||||||
}
|
}
|
||||||
}, index * 100);
|
}, index * 100);
|
||||||
});
|
});
|
||||||
|
@ -263,18 +271,16 @@ function shellShock() {
|
||||||
function matrix() {
|
function matrix() {
|
||||||
resetNixieRainbow();
|
resetNixieRainbow();
|
||||||
setNixieColor('var(--nixie-green)');
|
setNixieColor('var(--nixie-green)');
|
||||||
setInterval(() => {
|
setInterval(() => { setNixieContent(shuffleString('matrix')); }, 100);
|
||||||
setNixieContent(shuffleString('matrix'));
|
|
||||||
}, 100);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function barrel() {
|
function barrel() {
|
||||||
document.body.style.transition = 'transform 5s';
|
document.body.style.transition = 'transform 5s';
|
||||||
document.body.style.transform = 'rotate(360deg)';
|
document.body.style.transform = 'rotate(360deg)';
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
document.body.style.transition = '';
|
document.body.style.transition = '';
|
||||||
document.body.style.transform = '';
|
document.body.style.transform = '';
|
||||||
}, 5000);
|
}, 5000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -285,61 +291,60 @@ function astley() {
|
||||||
sidebar.style.display = 'none';
|
sidebar.style.display = 'none';
|
||||||
let wrapper = document.querySelector('.wrapper.flex');
|
let wrapper = document.querySelector('.wrapper.flex');
|
||||||
const div = document.createElement('div');
|
const div = document.createElement('div');
|
||||||
div.innerHTML = `
|
div.innerHTML = `
|
||||||
<video width="560" height="315" autoplay><source src="/videos/eastereggs/guesswhat.mp4" type="video/mp4"></video>`;
|
<video width="560" height="315" autoplay><source src="/videos/eastereggs/guesswhat.mp4" type="video/mp4"></video>`;
|
||||||
wrapper.appendChild(div);
|
wrapper.appendChild(div);
|
||||||
}
|
}
|
||||||
|
|
||||||
function nyan_cat() {
|
function nyan_cat() {
|
||||||
const nyanCatDiv = document.createElement('div');
|
const nyanCatDiv = document.createElement('div');
|
||||||
nyanCatDiv.id = 'nyan-cat';
|
nyanCatDiv.id = 'nyan-cat';
|
||||||
|
|
||||||
const nyanCatImg = document.createElement('img');
|
const nyanCatImg = document.createElement('img');
|
||||||
nyanCatImg.src = '/images/eastereggs/nyancat.gif';
|
nyanCatImg.src = '/images/eastereggs/nyancat.gif';
|
||||||
nyanCatImg.alt = 'Nyan Cat';
|
nyanCatImg.alt = 'Nyan Cat';
|
||||||
|
|
||||||
nyanCatDiv.appendChild(nyanCatImg);
|
nyanCatDiv.appendChild(nyanCatImg);
|
||||||
|
|
||||||
document.body.appendChild(nyanCatDiv);
|
document.body.appendChild(nyanCatDiv);
|
||||||
}
|
}
|
||||||
|
|
||||||
function pacman() {
|
function pacman() {
|
||||||
resetNixieRainbow();
|
resetNixieRainbow();
|
||||||
setNixieColor('yellow');
|
setNixieColor('yellow');
|
||||||
const pacManDiv = document.createElement('div');
|
const pacManDiv = document.createElement('div');
|
||||||
pacManDiv.id = 'pac-man';
|
pacManDiv.id = 'pac-man';
|
||||||
pacManDiv.innerHTML = `
|
pacManDiv.innerHTML = `
|
||||||
<img src="/images/eastereggs/pacman.gif" alt="Pac-Man">
|
<img src="/images/eastereggs/pacman.gif" alt="Pac-Man">
|
||||||
`;
|
`;
|
||||||
|
|
||||||
document.body.appendChild(pacManDiv);
|
document.body.appendChild(pacManDiv);
|
||||||
|
|
||||||
const elements = document.querySelectorAll('.menu__item, .tube, .tube>span');
|
const elements =
|
||||||
|
document.querySelectorAll('.menu__item, .tube, .tube>span');
|
||||||
|
|
||||||
function checkCollision() {
|
function checkCollision() {
|
||||||
const rect1 = pacManDiv.getBoundingClientRect();
|
const rect1 = pacManDiv.getBoundingClientRect();
|
||||||
|
|
||||||
elements.forEach((element) => {
|
elements.forEach((element) => {
|
||||||
const rect2 = element.getBoundingClientRect();
|
const rect2 = element.getBoundingClientRect();
|
||||||
|
|
||||||
if (
|
if (rect1.left < rect2.left + rect2.width &&
|
||||||
rect1.left < rect2.left + rect2.width &&
|
rect1.left + rect1.width > rect2.left &&
|
||||||
rect1.left + rect1.width > rect2.left &&
|
rect1.top < rect2.top + rect2.height &&
|
||||||
rect1.top < rect2.top + rect2.height &&
|
rect1.top + rect1.height > rect2.top) {
|
||||||
rect1.top + rect1.height > rect2.top
|
|
||||||
) {
|
|
||||||
if (element.nodeName === "LI") {
|
if (element.nodeName === "LI") {
|
||||||
element.style.visibility = 'hidden';
|
element.style.visibility = 'hidden';
|
||||||
} else {
|
} else {
|
||||||
element.style.display = 'none';
|
element.style.display = 'none';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Continue checking for collisions
|
||||||
|
requestAnimationFrame(checkCollision);
|
||||||
|
}
|
||||||
|
|
||||||
// Continue checking for collisions
|
|
||||||
requestAnimationFrame(checkCollision);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Continue checking for collisions
|
// Continue checking for collisions
|
||||||
requestAnimationFrame(checkCollision);
|
requestAnimationFrame(checkCollision);
|
||||||
}
|
}
|
||||||
|
@ -347,26 +352,25 @@ function pacman() {
|
||||||
function gamble() {
|
function gamble() {
|
||||||
// make lever
|
// make lever
|
||||||
let tubeBoxes = document.querySelectorAll('.tube-box');
|
let tubeBoxes = document.querySelectorAll('.tube-box');
|
||||||
tubeBoxes.forEach(tubeBox => {
|
tubeBoxes.forEach(tubeBox => {
|
||||||
let lever = document.createElement('button');
|
let lever = document.createElement('button');
|
||||||
lever.textContent = 'Go';
|
lever.textContent = 'Go';
|
||||||
lever.classList.add('btn');
|
lever.classList.add('btn');
|
||||||
lever.addEventListener('click', startSlotMachine);
|
lever.addEventListener('click', startSlotMachine);
|
||||||
tubeBox.prepend(lever);
|
tubeBox.prepend(lever);
|
||||||
// amount display
|
// amount display
|
||||||
let amountSpan = document.createElement('span');
|
let amountSpan = document.createElement('span');
|
||||||
amountSpan.textContent = "1337€";
|
amountSpan.textContent = "1337€";
|
||||||
amountSpan.id = "score";
|
amountSpan.id = "score";
|
||||||
tubeBox.insertBefore(amountSpan, lever);
|
tubeBox.insertBefore(amountSpan, lever);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let intervalId;
|
let intervalId;
|
||||||
|
|
||||||
function startSlotMachine() {
|
function startSlotMachine() {
|
||||||
intervalId = setInterval(() => {
|
intervalId =
|
||||||
setNixieContent(shuffleString('gamble'));
|
setInterval(() => { setNixieContent(shuffleString('gamble')); }, 100);
|
||||||
}, 100);
|
|
||||||
|
|
||||||
setTimeout(stopSlotMachine, 2000);
|
setTimeout(stopSlotMachine, 2000);
|
||||||
}
|
}
|
||||||
|
@ -386,8 +390,8 @@ function countMatches() {
|
||||||
symbols.splice(-6);
|
symbols.splice(-6);
|
||||||
|
|
||||||
const symbolCounts = symbols.reduce((acc, symbol) => {
|
const symbolCounts = symbols.reduce((acc, symbol) => {
|
||||||
acc[symbol] = (acc[symbol] || 0) + 1;
|
acc[symbol] = (acc[symbol] || 0) + 1;
|
||||||
return acc;
|
return acc;
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
return Math.max(...Object.values(symbolCounts));
|
return Math.max(...Object.values(symbolCounts));
|
||||||
|
@ -396,24 +400,24 @@ function countMatches() {
|
||||||
function evaluateScore(matches) {
|
function evaluateScore(matches) {
|
||||||
let score;
|
let score;
|
||||||
switch (matches) {
|
switch (matches) {
|
||||||
case 6:
|
case 6:
|
||||||
score = 1337;
|
score = 1337;
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
score = 420;
|
score = 420;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
score = 69;
|
score = 69;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
score = 13;
|
score = 13;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
score = 5;
|
score = 5;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
score = -25; // No matches or only 1 match
|
score = -25; // No matches or only 1 match
|
||||||
}
|
}
|
||||||
return score;
|
return score;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -423,7 +427,7 @@ function applyScore(score) {
|
||||||
let scoreNum = parseFloat(scoreSpan.textContent);
|
let scoreNum = parseFloat(scoreSpan.textContent);
|
||||||
scoreNum += score;
|
scoreNum += score;
|
||||||
scoreSpan.textContent = `${scoreNum}€`;
|
scoreSpan.textContent = `${scoreNum}€`;
|
||||||
if(scoreNum <= 0) {
|
if (scoreNum <= 0) {
|
||||||
setNixieColor('red');
|
setNixieColor('red');
|
||||||
setNixieContent('DEATH💀')
|
setNixieContent('DEATH💀')
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue