-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwordbank.js
61 lines (50 loc) · 1008 Bytes
/
wordbank.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
const GENERATED_NAME_SELECTOR = '#generated-name';
const PREFIXES = [
'Emerald',
'Rust',
'Topaz',
'Halcyon',
'Velvet',
'Stories',
'October',
'Autumn',
'Harvest',
'Amber',
'Moss',
'Mustard',
'Nostalgia',
'Gold',
];
const SUFFIXES = [
'House',
'Haus',
'Maison',
'Place',
'Chateau',
'Home',
'Atelier',
'Co',
'Studio',
'Salon',
];
function onGenerateClick(event) {
event.preventDefault();
const prefix = selectWord(PREFIXES);
const suffix = selectWord(SUFFIXES);
const phrase = `${prefix} ${suffix}`
const value = document.createElement('div')
value.innerHTML = phrase;
document.querySelector(GENERATED_NAME_SELECTOR).replaceChildren(value);
navigator.clipboard.writeText(phrase)
}
function selectWord(list) {
const index = Math.floor(Math.random() * list.length);
return list[index];
}
function main() {
init();
}
function init() {
document.querySelector('#generate-button').addEventListener('click', onGenerateClick)
}
main();