-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
46 lines (38 loc) · 1.73 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
<!DOCTYPE html>
<html>
<head>
<title>Blahaj Name Chooser! 🦈</title>
</head>
<body>
<h1>Blahaj Name Chooser! 🦈</title>
<div id="nameDisplay">Loading... (if it hangs on this page for a while, refresh or check internet)</div>
<script>
// Function to fetch and display a random name
function chooseRandomName() {
// Create a new XMLHttpRequest object
var xhr = new XMLHttpRequest();
// Open the request to the text file
xhr.open('GET', 'https://raw.githubusercontent.com/WalkTheEarth/Blahaj/main/names.txt', true);
// Handle the response once it's loaded
xhr.onload = function() {
if (xhr.status === 200) {
// Parse the response text into an array of lines
var lines = xhr.responseText.split('\n');
// Choose a random line
var randomIndex = Math.floor(Math.random() * lines.length);
var chosenName = lines[randomIndex].trim();
// Update the name display
document.getElementById('nameDisplay').textContent = chosenName;
} else {
document.getElementById('nameDisplay').textContent = "Error loading names.";
}
};
// Send the request
xhr.send();
}
// Call the function to choose and display a random name
chooseRandomName();
</script>
<a href="https://github.com/WalkTheEarth/Blahaj?tab=readme-ov-file#how-do-i-addsuggest-names">Click here to see how to suggest names.</a>
</body>
</html>