-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcastlenamia.js
90 lines (79 loc) · 1.64 KB
/
castlenamia.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
'use strict';
var isLegible = false;
var prefix = [
"Rondo",
"Symphony",
"Legacy",
"Aria",
"Lament",
"Dawn",
"Portrait",
"Order",
"Lords",
"Encore",
"Harmony",
"Concert",
"Mirror",
"Sonata",
"Waltz",
"Nocturne",
"Litany",
"Requiem",
"Dirge",
"Chorus",
"Prelude",
"Ritual",
"Melody",
"Minuet",
"Overture",
"Circle",
"Ballade",
"Veil",
"Dusk",
"Crescent",
];
var suffix = [
"Blood",
"the Night",
"Darkness",
"Dissonance",
"Sorrow",
"Darkness",
"Ruin",
"Shadows",
"Fate",
"Regret",
"Virtue",
"Despair",
"the Condemned",
"Moonlight",
"Piety",
"Tranquility",
"Devotion",
"Perdition",
"Blasphemy",
"Desire",
"Death",
"the Dark",
"Agony",
"the Moon",
];
function randomItem(array) {
return array[Math.floor(Math.random() * array.length)];
}
function toggleLegibility() {
isLegible = !isLegible;
var root = document.documentElement;
var fontFamily = isLegible ? "roboto, sans-serif" : "fette-unz-fraktur, serif";
root.style.setProperty("--font-family", fontFamily);
}
function generateName() {
document.querySelector("h2").innerText = randomItem(prefix) + " of " + randomItem(suffix);
}
document.addEventListener("DOMContentLoaded", function () {
generateName();
var toggleLegibilityButton = document.querySelector("#toggle-legibility");
toggleLegibilityButton.addEventListener("click", toggleLegibility);
var reRollButton = document.querySelector("#reroll");
reRollButton.addEventListener("click", generateName);
});