├── .gitignore ├── README.md ├── package.json └── dist ├── index.html ├── words.txt └── js └── main.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # IT Acronym Beater 2 | 3 | > Simple speed typing app built with JavaScript 4 | 5 | ## Use 6 | 7 | Run index.html in a browser 8 | 9 | 10 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "wordbeater", 3 | "version": "1.0.0", 4 | "description": "Speed typing game written in vanilla JS", 5 | "main": "index.js", 6 | "scripts": { 7 | "deploy": "gh-pages -d dist" 8 | }, 9 | "author": "Brad Traversy", 10 | "license": "MIT", 11 | "homepage": "https://bradtraversy.github.io/wordbeater", 12 | "dependencies": { 13 | "gh-pages": "^4.0.0" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /dist/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | WordBeater 9 | 11 | 12 | 13 | 14 |
15 |

IT Acronyms Beater

16 |
17 |
18 | 19 | 20 |
21 |
22 |

Type The Given Acronym Within 23 | 5 Seconds:

24 |

hello

25 | 26 |

27 | 28 | 29 |
30 |
31 |

Time Left: 32 | 0 33 |

34 |
35 |
36 |

Score: 37 | 0 38 |

39 |
40 |

41 |
42 |

High Score: 43 | 0 44 |

45 |
46 |
47 | 48 | 49 |
50 |
51 |
52 |
Instructions
53 |

Type each acronyms in the given amount of seconds to score. To play again, just type the current acronym. Your 54 | score 55 | will reset.

56 |
57 |
58 |
59 |
60 |
61 |
62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /dist/words.txt: -------------------------------------------------------------------------------- 1 | CPU - Central Processing Unit 2 | RAM - Random Access Memory 3 | ROM - Read-Only Memory 4 | GPU - Graphics Processing Unit 5 | HDD - Hard Disk Drive 6 | SSD - Solid State Drive 7 | LAN - Local Area Network 8 | WAN - Wide Area Network 9 | VPN - Virtual Private Network 10 | OS - Operating System 11 | API - Application Programming Interface 12 | SQL - Structured Query Language 13 | DNS - Domain Name System 14 | FTP - File Transfer Protocol 15 | HTTP - Hypertext Transfer Protocol 16 | HTTPS - Hypertext Transfer Protocol Secure 17 | IP - Internet Protocol 18 | DNS - Domain Name System 19 | USB - Universal Serial Bus 20 | DHCP - Dynamic Host Configuration Protocol 21 | AD - Active Directory 22 | AI - Artificial Intelligence 23 | AJAX - Asynchronous JavaScript and XML 24 | ALU - Arithmetic Logic Unit 25 | ARP - Address Resolution Protocol 26 | BGP - Border Gateway Protocol 27 | BIOS - Basic Input/Output System 28 | CDN - Content Delivery Network 29 | CLI - Command Line Interface 30 | CMS - Content Management System 31 | CRM - Customer Relationship Management 32 | CSS - Cascading Style Sheets 33 | DDoS - Distributed Denial of Service 34 | DHCP - Dynamic Host Configuration Protocol 35 | DNS - Domain Name System 36 | ECC - Error Correction Code 37 | EDI - Electronic Data Interchange 38 | EDP - Electronic Data Processing 39 | EDR - Endpoint Detection and Response 40 | EPROM - Erasable Programmable Read-Only Memory 41 | ERP - Enterprise Resource Planning 42 | ESXi - VMware ESXi 43 | EULA - End User License Agreement 44 | FIFO - First In, First Out 45 | firmware - software that controls the basic functions of a device 46 | GPT-3 - Generative Pre-trained Transformer 3 47 | GUI - Graphical User Interface 48 | HDFS - Hadoop Distributed File System 49 | HTML - Hypertext Markup Language 50 | IaaS - Infrastructure as a Service 51 | ICMP - Internet Control Message Protocol 52 | IDS - Intrusion Detection System 53 | IIS - Internet Information Services 54 | IOPS - Input/Output Operations Per Second 55 | IP - Internet Protocol 56 | IPS - Intrusion Prevention System 57 | ISDN - Integrated Services Digital Network 58 | ISP - Internet Service Provider 59 | IT - Information Technology 60 | JVM - Java Virtual Machine 61 | LIFO - Last In, First Out 62 | LMS - Learning Management System 63 | LOIC - Low Orbit Ion Cannon 64 | LUN - Logical Unit Number 65 | MAC - Media Access Control 66 | MBR - Master Boot Record 67 | MFA - Multi-Factor Authentication 68 | MIMO - Multiple Input, Multiple Output 69 | MITM - Man-in-the-Middle 70 | MPLS - Multiprotocol Label Switching 71 | NAT - Network Address Translation 72 | NFS - Network File System 73 | NTP - Network Time Protocol 74 | OAuth - Open Authorization 75 | OOP - Object-Oriented Programming 76 | OSI - Open Systems Interconnection 77 | PaaS - Platform as a Service 78 | PBX - Private Branch Exchange 79 | PC - Personal Computer 80 | PCI - Peripheral Component Interconnect -------------------------------------------------------------------------------- /dist/js/main.js: -------------------------------------------------------------------------------- 1 | window.addEventListener('load', init); 2 | 3 | var words = []; 4 | 5 | //Load words 6 | async function load_words() 7 | { 8 | return new Promise(resolve => { 9 | var xmlhttp; 10 | if (window.XMLHttpRequest) 11 | { 12 | // IE7+, Firefox, Chrome, Opera, Safari 13 | xmlhttp=new XMLHttpRequest(); 14 | } 15 | else 16 | { 17 | // IE6, IE5 18 | xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 19 | } 20 | xmlhttp.onreadystatechange=function() 21 | { 22 | if (xmlhttp.readyState==4 && xmlhttp.status==200) 23 | { 24 | 25 | if (navigator.userAgentData.platform === "Windows") 26 | words=xmlhttp.responseText.split("\r\n"); 27 | else 28 | words=xmlhttp.responseText.split("\n"); 29 | 30 | words = words.map(string => { 31 | const parts = string.split(" - "); 32 | return { acronym: parts[0], terms: parts[1] }; 33 | }); 34 | 35 | resolve('resolved'); 36 | } 37 | } 38 | xmlhttp.open("GET","words.txt",true); 39 | xmlhttp.send(); 40 | }); 41 | } 42 | 43 | // Available Levels 44 | const levels = { 45 | supereasy: 10, 46 | easy: 5, 47 | medium: 3, 48 | hard: 1 49 | }; 50 | 51 | // To change level 52 | const currentLevel = levels.supereasy; 53 | 54 | let time = currentLevel; 55 | let score = 0; 56 | let isPlaying; 57 | 58 | // DOM Elements 59 | const wordInput = document.querySelector('#word-input'); 60 | const currentWord = document.querySelector('#current-word'); 61 | const scoreDisplay = document.querySelector('#score'); 62 | const timeDisplay = document.querySelector('#time'); 63 | const message = document.querySelector('#message'); 64 | const seconds = document.querySelector('#seconds'); 65 | const highscoreDisplay = document.querySelector('#highscore'); 66 | 67 | // Initialize Game 68 | async function init() { 69 | let result = await load_words(); 70 | // Show number of seconds in UI 71 | seconds.innerHTML = currentLevel; 72 | // Load word from array 73 | showWord(words); 74 | // Start matching on word input 75 | wordInput.addEventListener('input', startMatch); 76 | // Call countdown every second 77 | setInterval(countdown, 1000); 78 | // Check game status 79 | setInterval(checkStatus, 50); 80 | 81 | } 82 | 83 | // Start match 84 | function startMatch() { 85 | if (matchWords()) { 86 | isPlaying = true; 87 | time = currentLevel + 1; 88 | showWord(words); 89 | wordInput.value = ''; 90 | score++; 91 | } 92 | 93 | // Highscore based on score value for Session Storage 94 | if (typeof sessionStorage['highscore'] === 'undefined' || score > sessionStorage['highscore']) { 95 | sessionStorage['highscore'] = score; 96 | } else { 97 | sessionStorage['highscore'] = sessionStorage['highscore']; 98 | } 99 | 100 | // Prevent display of High Score: -1 101 | if (sessionStorage['highscore'] >= 0) { 102 | highscoreDisplay.innerHTML = sessionStorage['highscore']; 103 | } 104 | 105 | // If score is -1, display 0 106 | if (score === -1) { 107 | scoreDisplay.innerHTML = 0; 108 | } else { 109 | scoreDisplay.innerHTML = score; 110 | } 111 | } 112 | 113 | // Match currentWord to wordInput 114 | function matchWords() { 115 | 116 | let find = words.find(o => o.acronym === currentWord.innerHTML); 117 | 118 | if (wordInput.value === find.terms) { 119 | message.innerHTML = 'Correct!!!'; 120 | return true; 121 | } else { 122 | message.innerHTML = ''; 123 | return false; 124 | } 125 | } 126 | 127 | // Pick & show random word 128 | function showWord(words) { 129 | // Generate random array index 130 | const randIndex = Math.floor(Math.random() * words.length); 131 | // Output random word 132 | currentWord.innerHTML = words[randIndex].acronym; 133 | } 134 | 135 | // Countdown timer 136 | function countdown() { 137 | // Make sure time is not run out 138 | if (time > 0) { 139 | // Decrement 140 | time--; 141 | } else if (time === 0) { 142 | // Game is over 143 | isPlaying = false; 144 | } 145 | // Show time 146 | timeDisplay.innerHTML = time; 147 | } 148 | 149 | // Check game status 150 | function checkStatus() { 151 | let find = words.find(o => o.acronym === currentWord.innerHTML); 152 | if (!isPlaying && time === 0) { 153 | message.innerHTML = 'Game Over!!! ' + find.terms; 154 | score = -1; 155 | } 156 | } 157 | --------------------------------------------------------------------------------