-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
41 lines (37 loc) · 1.6 KB
/
main.js
File metadata and controls
41 lines (37 loc) · 1.6 KB
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
$(document).ready(function(){
var content = document.getElementById('results');
//search for masculine name
$(".male").on("click", function() {
$.getJSON('https://www.behindthename.com/api/random.json?usage=eng&gender=m&key=ba498830053',function(data){
var name = data.names[0];
$(content).replaceWith("<div id='results'>"+ name +"</div>")
//Speaks name
if(responsiveVoice.voiceSupport()) {
responsiveVoice.speak(name, "UK English Male");
}
$("#results").on("click", function(){
responsiveVoice.speak(name, "UK English Male");
});
//Sets variable name content again
content = document.getElementById('results');
//$(content).append(data.names[0]);
});
});
//search for feminine name
$(".female").on("click", function() {
$.getJSON('https://www.behindthename.com/api/random.json?usage=eng&gender=f&key=ba498830053',function(data){
var name = data.names[0];
$(content).replaceWith("<div id='results'>"+ name +"</div>")
//Speaks name
if(responsiveVoice.voiceSupport()) {
responsiveVoice.speak(name, "UK English Female");
$("#results").on("click", function(){
responsiveVoice.speak(name, "UK English Female");
});
}
//Sets variable name content again
content = document.getElementById('results');
//$(content).append(data.names[0]);
});
});
});