Skip to content

Commit

Permalink
rescrambled kwargs link on leave, always keep dot
Browse files Browse the repository at this point in the history
  • Loading branch information
bweithers committed Oct 25, 2023
1 parent 578f62f commit 4df3348
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 2 deletions.
25 changes: 25 additions & 0 deletions assets/js/blogpost.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ document.getElementById("kwargs-link").onmouseover = event => {
event.target.innerText = event.target.innerText
.split("")
.map((letter, index) => {
if (letter == '.'){return '.'}
if(index+1 < iteration) {
return event.target.dataset.value[index];
}
Expand All @@ -24,6 +25,30 @@ document.getElementById("kwargs-link").onmouseover = event => {
clearInterval(interval);
}

iteration += 1 / 3;
}, 30);
}
document.getElementById("kwargs-link").onmouseleave = event => {
let iteration = 0;
clearInterval(interval);

interval = setInterval(() => {
event.target.innerText = event.target.innerText.split("").map(
(letter, index) => {
if (letter == '.'){return '.'}
if(event.target.innerText.length - index + 1 < iteration) {
return letters[Math.floor(Math.random() * letters.length)]

}

return event.target.dataset.value[index];
})
.join("");

if(iteration > event.target.dataset.value.length + 1){
clearInterval(interval);
}

iteration += 1 / 3;
}, 30);
}
30 changes: 28 additions & 2 deletions assets/js/main.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var left = null;
var centerPane = null;
var lock = 0;
const letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*|";

const handleOnClick = e => {
if (e.target.id != 'right-side' && e.target.id != 'left-side'){
Expand Down Expand Up @@ -74,18 +74,44 @@ document.getElementById("kwargs-link").onmouseover = event => {
event.target.innerText = event.target.innerText
.split("")
.map((letter, index) => {
if (letter == '.'){return '.'}
if(index+1 < iteration) {
return event.target.dataset.value[index];
}

return letters[Math.floor(Math.random() * 26)]
return letters[Math.floor(Math.random() * letters.length)]
})
.join("");

if(iteration >= event.target.dataset.value.length){
clearInterval(interval);
}

iteration += 1 / 3;
}, 30);
}

document.getElementById("kwargs-link").onmouseleave = event => {
let iteration = 0;
clearInterval(interval);

interval = setInterval(() => {
event.target.innerText = event.target.innerText.split("").map(
(letter, index) => {
if (letter == '.'){return '.'}
if(event.target.innerText.length - index + 1 < iteration) {
return letters[Math.floor(Math.random() * letters.length)]

}

return event.target.dataset.value[index];
})
.join("");

if(iteration > event.target.dataset.value.length + 1){
clearInterval(interval);
}

iteration += 1 / 3;
}, 30);
}

0 comments on commit 4df3348

Please sign in to comment.