From 964698c6c617e3dc92e23d405534b1a3da3ea44f Mon Sep 17 00:00:00 2001 From: nayakrujul Date: Sun, 30 Jun 2024 19:20:05 +0530 Subject: [PATCH] Rickroll! --- scripts/folders-classic.js | 30 +++++++++++++++++++++++++++++- scripts/misc.js | 20 +++++++++++++++++++- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/scripts/folders-classic.js b/scripts/folders-classic.js index 413812a..d9985b4 100644 --- a/scripts/folders-classic.js +++ b/scripts/folders-classic.js @@ -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); @@ -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(); -} \ No newline at end of file +} diff --git a/scripts/misc.js b/scripts/misc.js index ec79f48..d4ab4dc 100644 --- a/scripts/misc.js +++ b/scripts/misc.js @@ -108,4 +108,22 @@ function title_case(str) { return str.replace(/\w\S*/g, (text) => text.charAt(0).toUpperCase() + text.substring(1).toLowerCase() ); -} \ No newline at end of file +} + +/** + * 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(""); +}