Skip to content

Commit

Permalink
Add "More info" link to numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
ArhanChaudhary committed Aug 23, 2024
1 parent 8c33875 commit f0b2bdd
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 38 deletions.
12 changes: 12 additions & 0 deletions src/lib/Modal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { fly } from 'svelte/transition';
export let value: number;
export let message: string;
export let link: string | undefined = undefined;
export let guessType: GuessType;
let visible = false;
Expand Down Expand Up @@ -36,6 +37,17 @@
class:bg-gray-200={guessType === GuessType.technicallyIncorrect}
>
{value}
{#if link}
•
<a
href={link}
target="_blank"
rel="noopener noreferrer"
class="text-blue-600 underline"
>
More info</a
>
{/if}
</div>
<div
class="p-4"
Expand Down
4 changes: 2 additions & 2 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
<div class="flex justify-center absolute bottom-0 h-10 items-center left-0 right-0">
<a
href="https://github.com/ArhanChaudhary/iconic-computing-numbers"
class="text-blue-600 dark:text-blue-500 underline mx-1">Source</a
class="text-blue-600 underline mx-1">Source</a
>
&#x2022;
<a href="https://arhan.sh" class="text-blue-600 dark:text-blue-500 underline mx-1"
<a href="https://arhan.sh" class="text-blue-600 underline mx-1"
>My website</a
>
</div>
Expand Down
16 changes: 9 additions & 7 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
export let data;
let guesses = 0;
let modals = new Array<{ value: number; message: string; guessType: GuessType }>();
let modals = new Array<{ value: number; message: string; link?: string; guessType: GuessType }>();
let numbersEl: HTMLDivElement;
let numbersCount = Object.keys(data.numbers).length;
let startTime = performance.now();
Expand Down Expand Up @@ -65,14 +65,14 @@
let guess = (e.target as HTMLInputElement).valueAsNumber;
(e.target as HTMLInputElement).value = '';
let alreadyGuessedNumber = data.numbers
.concat(data.technicallyIncorrectNumbers)
.find(({ value, guessed }) => value === guess && guessed);
if (alreadyGuessedNumber) {
if (
data.numbers.some(({ value, guessed }) => value === guess && guessed) ||
data.technicallyIncorrectNumbers.some(({ value, guessed }) => value === guess && guessed)
) {
modals = [
...modals,
{
value: alreadyGuessedNumber.value,
value: guess,
message: 'You have already guessed this number.',
guessType: GuessType.technicallyIncorrect
}
Expand All @@ -87,7 +87,8 @@
modals = [
...modals,
{
...technicallyIncorrectNumber,
value: technicallyIncorrectNumber.value,
message: technicallyIncorrectNumber.message,
guessType: GuessType.technicallyIncorrect
}
];
Expand All @@ -101,6 +102,7 @@
{
value: number.value,
message: number.message,
link: number.link,
guessType: GuessType.correct
}
];
Expand Down
124 changes: 95 additions & 29 deletions src/routes/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,91 +2,157 @@ const numbers = [
{
value: 1970,
message:
'The UNIX epoch year and universal computer time representation. One of the first magic numbers you learn in computer science.',
guessed: false
'The UNIX epoch year for universal computer time representation. One of the first magic numbers you learn in computer science.',
guessed: false,
link: 'https://en.wikipedia.org/wiki/Unix_time'
},
{
value: 192168,
message: 'The most commonly used private IPv4 address range, formally 192.168.0.0/16.',
guessed: false
guessed: false,
link: 'https://en.wikipedia.org/wiki/Private_network#Private_IPv4_addresses'
},
{
value: 1337,
message: '"Leet", in hacker speech.',
guessed: false,
link: 'https://en.wikipedia.org/wiki/Leet'
},
{ value: 1337, message: '"Leet", in hacker speech.', guessed: false },
{
value: 754,
message: 'The IEEE standard for floating-point arithmetic used by every modern computer.',
guessed: false
guessed: false,
link: 'https://en.wikipedia.org/wiki/IEEE_754'
},
{
value: 8086,
message: 'The Intel 8086, the first microprocessor with the now-widespread x86 architecture.',
guessed: false
guessed: false,
link: 'https://en.wikipedia.org/wiki/Intel_8086'
},
{
value: 214748,
message:
'2^31 - 1 truncated, or the maximum value for a 32-bit signed binary integer. Also a common hard limit in video games.',
guessed: false
guessed: false,
link: 'https://en.wikipedia.org/wiki/2147483647'
},
{
value: 418,
message: 'The HTTP status code for "I\'m a teapot", an April Fools\' joke by the IETF.',
guessed: false
guessed: false,
link: 'https://en.wikipedia.org/wiki/Hyper_Text_Coffee_Pot_Control_Protocol'
},
{
value: 443,
message: 'The default port for HTTPS.',
guessed: false,
link: 'https://en.wikipedia.org/wiki/HTTPS#Difference_from_HTTP'
},
{ value: 443, message: 'The default port for HTTPS.', guessed: false },
{
value: 414141,
message:
'"AAA" in hexadecimal, a string often used in buffer overflow attacks or other security exploits.',
guessed: false
'"AAA ..." in hexadecimal, a string often used in buffer overflow attacks or other security exploits.',
guessed: false,
link: 'https://en.wikipedia.org/wiki/Buffer_overflow'
},
{
value: 44100,
message: 'The standard sampling rate for digital and analog audio.',
guessed: false,
link: 'https://en.wikipedia.org/wiki/44,100_Hz'
},
{ value: 44100, message: 'The standard sample rate for analog audio CDs.', guessed: false },
{
value: 3301,
message: 'The Cicada 3301 internet mystery, popularized by LEMMiNO.',
guessed: false
guessed: false,
link: 'https://en.wikipedia.org/wiki/Cicada_3301'
},
{
value: 9600,
message: 'A common baud rate for serial communication.',
guessed: false,
link: 'https://en.wikipedia.org/wiki/Baud'
},
{
value: 80211,
message: 'The IEEE standard for wireless networking, or Wi-Fi.',
guessed: false,
link: 'https://en.wikipedia.org/wiki/IEEE_802.11'
},
{ value: 9600, message: 'A common baud rate for serial communication.', guessed: false },
{ value: 80211, message: 'The IEEE standard for wireless networking, or Wi-Fi.', guessed: false },
{
value: 400000,
message: 'The base memory address for Linux executables in hexadecimal.',
guessed: false
message: 'The base virtual memory address for Linux executables in hexadecimal.',
guessed: false,
link: 'https://en.wikipedia.org/wiki/Virtual_memory'
},
{
value: 25519,
message: 'Curve25519, a widely used elliptic curve in cryptography and key exchange.',
guessed: false
guessed: false,
link: 'https://en.wikipedia.org/wiki/Curve25519'
},
{
value: 264,
message: 'H.264 or Advanced Video Coding, a common video compression standard.',
guessed: false
guessed: false,
link: 'https://en.wikipedia.org/wiki/Advanced_Video_Coding'
},
{
value: 509,
message: 'The X.509 ITU certificate standard, used in TLS and SSL.',
guessed: false
guessed: false,
link: 'https://en.wikipedia.org/wiki/X.509'
},
{
value: 7400,
message: 'A popular series of digital logic integrated circuits.',
guessed: false
guessed: false,
link: 'https://en.wikipedia.org/wiki/7400_series'
},
{
value: 65537,
message: 'The most commonly chosen exponent in the RSA cryptosystem.',
guessed: false,
link: 'https://en.wikipedia.org/wiki/65537#Applications'
},
{
value: 777,
message: 'The chmod octal permission mode for full access.',
guessed: false,
link: 'https://en.wikipedia.org/wiki/Chmod'
},
{
value: 8601,
message: 'The ISO standard for human-readable universal date and time representation.',
guessed: false,
link: 'https://en.wikipedia.org/wiki/ISO_8601'
},
{ value: 65537, message: 'The de facto exponent used in RSA encryption.', guessed: false },
{ value: 777, message: 'The chmod octal permission mode for full access.', guessed: false },
{ value: 8601, message: 'The ISO standard for date and time representation.', guessed: false },
{
value: 2600,
message: '2600: The Hacker Quarterly, a popular technical magazine for hackers.',
guessed: false
message:
'2600: The Hacker Quarterly, a popular technical magazine, referencing the 2600Hz phreaking tone.',
guessed: false,
link: 'https://en.wikipedia.org/wiki/2600:_The_Hacker_Quarterly'
},
{
value: 5994,
message: 'The field refresh frequency for NTSC color.',
guessed: false,
link: 'https://en.wikipedia.org/wiki/NTSC#Resolution_and_refresh_rate'
},
{
value: 437,
message: 'The original IBM PC code page.',
guessed: false,
link: 'https://en.wikipedia.org/wiki/Code_page_437'
},
{ value: 5994, message: 'The NTSC vertical scan rate.', guessed: false },
{ value: 437, message: 'The original IBM PC code page.', guessed: false },
{
value: 471768,
message:
'The truncated solution to the 25-year-long Busy Beaver Challenge for 5-state 2-symbol Turing machines.',
guessed: false
guessed: false,
link: 'https://en.wikipedia.org/wiki/Busy_Beaver'
}
];

Expand Down

0 comments on commit f0b2bdd

Please sign in to comment.