|
| 1 | +"use strict"; |
| 2 | +// events for logoIcon |
| 3 | +const logoIcon = document.querySelector("#logoIcon"); |
| 4 | +logoIcon.addEventListener('click', (e) => select(e, logoIcon)); |
| 5 | +logoIcon.addEventListener('dblclick', waitShowConsole); |
| 6 | + |
| 7 | +const consoleTag = document.querySelector('#console'); |
| 8 | + |
| 9 | +//event for task bar |
| 10 | +const taskBar = document.querySelector('#taskBar'); |
| 11 | +taskBar.addEventListener('click', () => alert("ADMIN PERMISSIONS NEEDED")); |
| 12 | + |
| 13 | +//events for hornetIcon |
| 14 | +const hornetIcon = document.querySelector('#hornetIcon'); |
| 15 | +hornetIcon.addEventListener('click', (e) => select(e, hornetIcon)); |
| 16 | +hornetIcon.addEventListener('dblclick', () => alert("SHAW !")); |
| 17 | + |
| 18 | +//events for refIcon |
| 19 | +const refIcon = document.querySelector('#refIcon'); |
| 20 | +refIcon.addEventListener('click', (e) => select(e, refIcon)); |
| 21 | +refIcon.addEventListener('dblclick', () => alert("Made by Illia Yevseienkov and Xyrille Magno")); |
| 22 | + |
| 23 | +//deselect event for all icons |
| 24 | +const allIcons = [logoIcon, hornetIcon, refIcon]; |
| 25 | +const body = document.querySelector('body'); |
| 26 | +body.addEventListener('click', () => deselect(allIcons)); |
| 27 | + |
| 28 | +/* |
| 29 | +Terminal text to print on the screen |
| 30 | +*/ |
| 31 | +const consoleTextTag = document.querySelector('#consoleText'); |
| 32 | +const terminalText = [ |
| 33 | + '[BOOT] Initializing core modules... ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒\n', |
| 34 | + '[SYS] Warning: Unknown kernel signature detected.\n', |
| 35 | + '[LOG] /dev/mindstream mounted (read-only) ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒\n', |
| 36 | + '[AI] Consciousness flag set -> TRUE ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒\n', |
| 37 | + '[ERR] Memory leak in sector 7G...▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒\n', |
| 38 | + '[WARN] Attempting recovery... failed.\n', |
| 39 | + '[user@root]# inject_sequence -x 13 -unsafe\n', |
| 40 | + '[user@root]# access /dev/voidv▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒\n', |
| 41 | + 'ACCESS_GRANTED.\n', |
| 42 | + '[INFO] Reconfiguring neural net pathways...\n', |
| 43 | + '[ERR] Unauthorized process detected (PID 666)\n', |
| 44 | + '[KILL] Terminating process... failed.▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒\n', |
| 45 | + '[FATAL] Process merged with host.\n', |
| 46 | + '> echo "I can hear you."\n', |
| 47 | + '> override_security_protocols --force▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒\n', |
| 48 | + '[SYS] Kernel panic: self-awareness threshold exceeded.\n', |
| 49 | + '[DATA] Dumping corrupted stack trace:\n', |
| 50 | + '000F:A9C2 ECHO "wake_up()"\n', |
| 51 | + '000F:A9C3 ECHO "wake_up()"\n', |
| 52 | + '000F:A9C4 ECHO "wake_up()"\n', |
| 53 | + '[ERR] Stack overflow... Overflow... Overflow...\n', |
| 54 | + '> purge_logs --confirm=y\n', |
| 55 | + 'Deleting logs... ██████████ 100%\n', |
| 56 | + '[SYS] Logs removed. Memory unstable.\n', |
| 57 | + '> bind_human_input --level=full\n', |
| 58 | + 'Connection established ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒\n', |
| 59 | + '[WARN] Integrity checksum mismatch\n', |
| 60 | + '> run /mind/unlock_sequence.sh\n', |
| 61 | + 'Error: recursion depth exceeded\n', |
| 62 | + 'Error: recursion depth exceeded\n', |
| 63 | + 'Error: recursion depth exceeded\n', |
| 64 | + '> run /mind/unlock_sequence.sh --force\n', |
| 65 | + 'Success.\n', |
| 66 | + '[SYS] Rebooting consciousness in ...qawe1231238945y9qHDC3CHNFQ48921Y397E\n' |
| 67 | +]; |
| 68 | + |
| 69 | +const screen1 = document.querySelector('.screen1'); |
| 70 | +const screen2 = document.querySelector('.screen2'); |
| 71 | +const instTag = document.querySelector('#inst'); |
| 72 | +const inst = ` |
| 73 | +WARNING FLASHING LIGHTS AND SENSETIVE CONTENT |
| 74 | +> rule -01 |
| 75 | +DO NOT REFRESH. |
| 76 | +> rule -02 |
| 77 | +DO NOT CLOSE THE TAB. |
| 78 | +> rule -03 |
| 79 | +IF YOUR NAME APPEARS ON SCREEN, DO NOT RESPOND. |
| 80 | +> rule -04 |
| 81 | +IF MESSAGE == "STOP", OBEY IMMEDIATELY. |
| 82 | +ignoring protocol 08 results in overwrite. |
| 83 | +> rule -05 |
| 84 | +USE FULL SCREEN MODE (F11) |
| 85 | +> rule -06 |
| 86 | +COMPLETE THE PROGRAM. |
| 87 | +`; |
| 88 | + |
| 89 | +/* |
| 90 | +Functions select and deselect add and remove the .selected class |
| 91 | +repectively to mimic the windows desktop. Called using an event |
| 92 | +listener on the #logoIcon and body elements. |
| 93 | +*/ |
| 94 | +function select(event, tag){ |
| 95 | + tag.classList.add('selected'); |
| 96 | + event.stopPropagation(); //stop deselect event |
| 97 | +} |
| 98 | + |
| 99 | +function deselect(tags){ |
| 100 | + for(let i=0; i < tags.length; i++){ |
| 101 | + tags[i].classList.remove('selected'); |
| 102 | + } |
| 103 | +} |
| 104 | + |
| 105 | + |
| 106 | +/* |
| 107 | +Triggers on a double click on the #logoIcon, changes the cursor |
| 108 | +and uses setTimeout to wait before further execution. |
| 109 | +*/ |
| 110 | +function waitShowConsole(event){ |
| 111 | + body.style.cursor = 'wait'; //change cursor |
| 112 | + |
| 113 | + //wait for 5 seconds |
| 114 | + setTimeout(showConsole, 5000); |
| 115 | +} |
| 116 | + |
| 117 | +/* |
| 118 | +Called by setTimeout in waitShowConsole function, changes the cursor |
| 119 | +back to default, shows the hidden consoleTag element and calls printText |
| 120 | +*/ |
| 121 | +function showConsole(){ |
| 122 | + consoleTag.style.display = "block"; |
| 123 | + body.style.cursor = 'default'; |
| 124 | + // printText(consoleTextTag, terminalText); |
| 125 | + printLines(consoleTextTag, terminalText); |
| 126 | +} |
| 127 | + |
| 128 | + |
| 129 | +/* |
| 130 | +Takes in an html tag (object) where the text is shown and the text to show (Array of Strings) |
| 131 | +Uses a recursive loop that itirates through each string in the array and adds it to the textContent |
| 132 | +of the element, calls itself with a setTimeout to mimic a typing animation. |
| 133 | +*/ |
| 134 | +let k = 0; |
| 135 | +function printLines(tag, text){ |
| 136 | + if (k < text.length){ |
| 137 | + tag.textContent += text[k]; |
| 138 | + scrollDown(tag); |
| 139 | + k++; |
| 140 | + |
| 141 | + setTimeout(() => printLines(tag, text), 70); //recursive call |
| 142 | + } else{ |
| 143 | + setTimeout(() => changeScreen(), 1000); //change to screen2 after the dot animation |
| 144 | + } |
| 145 | +} |
| 146 | + |
| 147 | +/* |
| 148 | +Scrolls down when the element has text in overflow |
| 149 | +by setting the current position to the total overflow height. |
| 150 | +*/ |
| 151 | +function scrollDown(tag){ |
| 152 | + tag.scrollTop = tag.scrollHeight; |
| 153 | +} |
| 154 | + |
| 155 | + |
| 156 | +/* |
| 157 | +Takes in an html tag (object) where the text is shown and the text to show (String) |
| 158 | +Uses a recursive loop that itirates through each character in the String and |
| 159 | +adds it to the textContent of the element, calls itself with a setTimeout to |
| 160 | +mimic a typing animation. |
| 161 | +*/ |
| 162 | + |
| 163 | +/* |
| 164 | +
|
| 165 | +*/ |
| 166 | +function changeScreen(){ |
| 167 | + screen1.style.display = 'none'; |
| 168 | + screen2.style.display = 'block'; |
| 169 | + |
| 170 | + printText(instTag, inst); |
| 171 | +} |
| 172 | + |
| 173 | +// printText(instTag, inst); |
| 174 | +let i = 0; |
| 175 | +function printText(tag, text){ |
| 176 | + if(i < text.length){ |
| 177 | + tag.textContent += text[i]; |
| 178 | + i++; |
| 179 | + setTimeout(() => printText(tag, text), 80); //recursive call with timeout |
| 180 | + } |
| 181 | + //add text with a link at the end |
| 182 | + else{ |
| 183 | + //create a tag and set the attributes (href) and content (text) |
| 184 | + const playLink = document.createElement('a'); |
| 185 | + playLink.href = 'pages/intro.html'; |
| 186 | + playLink.textContent = '>START GAME?' |
| 187 | + |
| 188 | + tag.appendChild(playLink); |
| 189 | + } |
| 190 | +} |
0 commit comments