-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphonatick.html
104 lines (90 loc) · 2.91 KB
/
phonatick.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
<!DOCTYPE html>
<html lang="en">
<head>
<style>
body {
max-width: 800px;
margin: 0 auto;
padding: 20px;
font-family: Arial, sans-serif;
}
.loading {
text-align: center;
font-size: 1.2em;
color: #666;
padding: 20px;
}
.word-pair {
margin: 10px 0;
padding: 10px;
border-bottom: 1px solid #eee;
}
.word {
font-weight: bold;
color: #333;
display: inline-block;
}
.pronunciation {
color: #666;
margin-left: 20px;
display: inline-block;
}
@media (max-width: 600px) {
body {
padding: 10px;
font-size: 18px;
}
h1 {
font-size: 2em;
}
.word, .pronunciation {
display: block;
margin: 5px 0;
font-size: 1.1em;
}
.pronunciation {
margin-left: 0;
}
.loading {
font-size: 1.3em;
}
}
</style>
</head>
<body>
<h1>PhonaTick</h1>
<p><i>Helps you master tricky English pronunciations by turning confusing spellings into easy-to-understand sounds</i></p>
<div id="loadingMessage" class="loading">Loading...</div>
<div id="wordList"></div>
<script>
async function fetchWords() {
try {
const wordList = document.getElementById('wordList');
const loadingMessage = document.getElementById('loadingMessage');
const response = await fetch('https://rightful-veiled-lyre.glitch.me/data.json?sql=select+word%2C+pronunciation+from+aphonetic');
const data = await response.json();
// Hide loading message once data is loaded
loadingMessage.style.display = 'none';
// Check if data is an object and has rows property
const items = data.rows || [];
items.forEach(item => {
const div = document.createElement('div');
div.className = 'word-pair';
div.innerHTML = `
<span class="word">${item[0]}</span>
<span class="pronunciation">${item[1]}</span>
`;
wordList.appendChild(div);
});
} catch (error) {
const loadingMessage = document.getElementById('loadingMessage');
loadingMessage.textContent = 'Error loading data. Please try again later.';
loadingMessage.style.color = '#ff0000';
//console.error('Error fetching data:', error);
}
}
// Call the function when the page loads
fetchWords();
</script>
</body>
</html>