-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
69 lines (58 loc) · 1.47 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
let brand = document.querySelector("#brand")
let generate = document.querySelector("#generate")
let display = document.querySelector("#display")
let reset = document.querySelector("#reset")
let clipboard = document.querySelector(".clipboard")
let brandName;
/**
* Brand Suffixes
*/
const BRANDSUFFIXES = [
"Hub",
"Forge",
"HQ",
"Zone",
"Gen",
"Works",
"Creative",
"Solutions",
"Legacy",
"Zilla",
"Serve",
"Ant",
"Land",
"Scape",
"Labs",
"Age",
]
/**
* Random number generator
*/
function getRandomNumber() {
return Math.floor(Math.random() * 15) + 1;
}
/**
* Event Listener
*/
generate.addEventListener("click", ()=>{
let brandTitle = brand.value
let randomNumber = getRandomNumber()
display.style.padding = "5px 10px"
if(brandTitle == ""){
display.innerHTML = "Kindly enter brand title"
}
else{
brandName = BRANDSUFFIXES[randomNumber + 1] != undefined
? `${brandTitle} ${BRANDSUFFIXES[randomNumber + 1]}`
: `${brandTitle} Gen`
display.innerHTML = brandName + `<div class="clipboard"><i class="fa-solid fa-clipboard"></i></div>`
}
})
reset.addEventListener("click", ()=> {
brand.value = ""
})
display.addEventListener("click", ()=> {
navigator.clipboard.writeText(display.innerText)
display.innerHTML = brandName + `<div class="clipboard"><i class="fa-solid fa-check"></i></div>`
alert("Copied!")
})