-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
120 lines (112 loc) · 5.19 KB
/
index.html
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<!doctype html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<link href="https://fonts.googleapis.com/css?family=Press+Start+2P" rel="stylesheet">
<link href="https://unpkg.com/nes.css@2.2.1/css/nes.min.css" rel="stylesheet" />
<link rel="icon" type="image/png" href="jean.png" />
<title>Jean Nerator</title>
<meta name="description" content="Jean Nerator, le générateur de Jean !">
</head>
<body style="text-align: center;">
<h1 style="margin-top: 50px;">Jean Nerator</h1>
<section class="nes-container with-title" style="width: 600px; margin: auto; margin-top: 30px;">
<div class="title"><h3 style="display: inline-block" id="jean"></h3>
<a>
<img id="speak" src="./speak.png" alt="" style="margin-left: .5rem;margin-bottom: .5rem; width: 32px; display: none"></div>
</a>
<img id="img" src="" style="margin-top: 50px;"/>
</section>
<br>
<button style="margin-top: 70px" id="generate" type="button" class="nes-btn is-success">Generate</button>
<br>
<button style="margin-top: 70px" id="experimentalJean" type="button" class="nes-btn is-primary">Experimental ♂️</button>
<button style="margin-top: 70px" id="experimentalJeanne" type="button" class="nes-btn is-error">Experimental ♀️</button>
<a href="https://github.com/real-goatoo/Jean-Nerator" target="_blank">
<i class="nes-icon github" style="position: absolute;
bottom: 5px;
right: 5px;
"></i>
</a>
<script>
var jean = [
"Nétéou",
"Globe",
"Neymar",
"Sérien",
"Kete",
"Pauche",
"Fouy",
"Bon"
];
var vowels = ["a","e","i","o","u","y", "n", "é", "è"];
var specialLetters = ["m", "p", "b"];
var experimentalJean = [];
fetch('./verb.json')
.then(response => response.json())
.then(function(data) {
experimentalJean = data.filter(
function(verb) {
if (typeof verb.Indicatif === 'undefined') {
return false;
}
if (verb.Indicatif.Présent[0].startsWith("en")) {
return true;
}
if (verb.Indicatif.Présent[0].startsWith("an") && !vowels.includes(verb.Indicatif.Présent[0][2])) {
return true;
}
if (verb.Indicatif.Présent[0].startsWith("em") && specialLetters.includes(verb.Indicatif.Présent[0][2])) {
return true;
}
if (verb.Indicatif.Présent[0].startsWith("am") && specialLetters.includes(verb.Indicatif.Présent[0][2])) {
return true;
}
return false;
}).map(function(verb) {
var name = verb.Indicatif.Présent[0].substring(2);
return "Jean "+name.charAt(0).toUpperCase() + name.slice(1);
})
});
var experimentalJeanne = [];
fetch('./verb.json')
.then(response => response.json())
.then(function(data) {
experimentalJeanne = data.filter(
function(verb) {
if (typeof verb.Indicatif === 'undefined') {
return false;
}
return verb.Indicatif.Présent[0].startsWith("an") && vowels.includes(verb.Indicatif.Présent[0][2]);
}).map(function(verb) {
var subLetters = verb.Indicatif.Présent[0][2] === "n" ? 3 : 2;
var name = verb.Indicatif.Présent[0].substring(subLetters);
return "Jeanne "+name.charAt(0).toUpperCase() + name.slice(1);
})
});
document.getElementById("generate").addEventListener("click", function (e) {
document.getElementById("jean").innerHTML = "Jean " + jean[Math.floor(Math.random() * jean.length)];
document.getElementById("img").src = "https://loremflickr.com/320/240/man?" + new Date().getTime();
document.getElementById("speak").style.display = "inline-block";
});
document.getElementById("experimentalJean").addEventListener("click", function (e) {
document.getElementById("jean").innerHTML = experimentalJean[Math.floor(Math.random() * experimentalJean.length)];
document.getElementById("img").src = "https://loremflickr.com/320/240/man,old?" + new Date().getTime();
document.getElementById("speak").style.display = "inline-block";
});
document.getElementById("experimentalJeanne").addEventListener("click", function (e) {
document.getElementById("jean").innerHTML = experimentalJeanne[Math.floor(Math.random() * experimentalJeanne.length)];
document.getElementById("img").src = "https://loremflickr.com/320/240/women,old?" + new Date().getTime();
document.getElementById("speak").style.display = "inline-block";
});
var synth = window.speechSynthesis;
document.getElementById("speak").addEventListener("click", function (e) {
var utterThis = new SpeechSynthesisUtterance(document.getElementById("jean").innerHTML);
utterThis.lang = "fr-FR";
utterThis.pitch = 1.2;
utterThis.rate = 0.6;
synth.speak(utterThis);
});
</script>
</body>
</html>