Skip to content

Commit

Permalink
Rickroll!
Browse files Browse the repository at this point in the history
  • Loading branch information
nayakrujul committed Jun 30, 2024
1 parent b025198 commit 964698c
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
30 changes: 29 additions & 1 deletion scripts/folders-classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,28 @@ function new_question() {
document.getElementById("classic-question-text").innerHTML = sanitise(question);
}

function check_input_classic() {
let value = textbox.value;
let unpunctuated = remove_punctuation(value);
textbox.value = "";
let rickroll = [ // Hey there!
"thonnu", //
"thunno", // You're looking at the code
"rujul", // behind rickrolls on VTP6.
"rujulnayak", //
"vtp", // Enter any of these keywords
"vtp6", // into the input box on VTP6,
"rick", // and you will be redirected
"rickroll", // to a rickroll (link below).
"rickrollme", //
"nevergonnagiveyouup", // Try it out at your own risk.
];
if (rickroll.includes(unpunctuated))
return window.open(
"https://youtu.be/xvFZjo5PgG0", // This is the link.
"_blank").focus();
}

function folders_start_classic(terms) {
full_terms_list = [...terms];
randomised_terms = random_shuffle(terms);
Expand All @@ -38,5 +60,11 @@ function folders_start_classic(terms) {
textbox = document.getElementById("classic-input");
textbox.focus();

textbox.addEventListener("keyup", ({ key }) => {
if (key === "Enter") {
check_input_classic();
}
});

new_question();
}
}
20 changes: 19 additions & 1 deletion scripts/misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,22 @@ function title_case(str) {
return str.replace(/\w\S*/g, (text) =>
text.charAt(0).toUpperCase() + text.substring(1).toLowerCase()
);
}
}

/**
* Keeps only alphanumeric characters in a given string
* @param {String} str The string to remove punctuation from.
* @returns {String} The alphanumeric string.
*/
function remove_punctuation(string) {
return [...string]
.map((c) => {
let ord = c.charCodeAt(0);
return (
(47 < ord && ord < 58) ||
(64 < ord && ord < 91) ||
(96 < ord && ord < 123)
|| (ord > 127)) ? c : "";
}
).join("");
}

0 comments on commit 964698c

Please sign in to comment.