Skip to content

Commit 9bff02c

Browse files
committed
Adding loading text update
1 parent 3251312 commit 9bff02c

File tree

2 files changed

+48
-9
lines changed

2 files changed

+48
-9
lines changed

wiktionary_pron/index.html

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,14 @@
121121
font-family: "EB Garamond";
122122
}
123123

124-
span.ipa{
124+
span.ipa {
125125
margin-right: 5px;
126126
}
127-
span.input_text{
127+
128+
span.input_text {
128129
margin-left: 5px;
129130
}
131+
130132
.error {
131133
color: red;
132134
}
@@ -192,7 +194,7 @@
192194
}
193195

194196
body.dark_mode i.fa-sun-o {
195-
color: yellow;
197+
color: #fefeac;
196198
}
197199

198200
body i.fa-moon-o {
@@ -237,6 +239,23 @@
237239
position: relative
238240
}
239241

242+
#lang_container {
243+
244+
position: relative;
245+
text-align: center;
246+
}
247+
248+
#loading_text {
249+
position: absolute;
250+
top: 0;
251+
right: 0;
252+
font-size: 12px;
253+
font-family: monospace;
254+
max-width: 250px;
255+
margin: 0px;
256+
padding: 0px;
257+
}
258+
240259
</style>
241260

242261

@@ -264,11 +283,14 @@ <h1 style="flex: 1;">Online IPA Converter</h1>
264283
<div>
265284
Language:
266285
</div>
267-
<select autocomplete="off" class="dropdown" disabled="true" id="lang">
268-
<option disabled selected value> -- select an option --</option>
286+
<div id="lang_container">
287+
<select autocomplete="off" class="dropdown" disabled="true" id="lang">
288+
<option disabled selected value> -- select an option --</option>
269289

270290

271-
</select>
291+
</select>
292+
<p id="loading_text">...</p>
293+
</div>
272294
<div>
273295
Additional options:
274296
</div>

wiktionary_pron/scripts/lua_init.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,26 @@ const lua = await factory.createEngine();
55
lua.global.set("fetch", (url) => fetch(url));
66

77
async function mountFile(file_path, lua_path) {
8-
const x = await fetch(file_path).then((data) => data.text());
9-
await factory.mountFile(lua_path, x);
8+
const content = await fetch(file_path).then((data) => data.text());
9+
await factory.mountFile(lua_path, content);
1010
}
1111

12+
function updateLoadingText(filePath, fileExtension) {
13+
const loadingBar = document.getElementById("loading_text");
14+
15+
if (!filePath && !fileExtension) {
16+
loadingBar.innerHTML = "";
17+
loadingBar.style.display = "none";
18+
} else {
19+
loadingBar.innerHTML = `Loading ${filePath}.${fileExtension}...`;
20+
loadingBar.style.display = "block";
21+
}
22+
}
23+
24+
lua.global.set("updateLoadingText", (file_path, extension) =>
25+
updateLoadingText(file_path, extension),
26+
);
27+
1228
await mountFile("../wiktionary_pron/lua_modules/memoize.lua", "memoize.lua");
1329

1430
await lua.doString(`
@@ -27,8 +43,9 @@ await lua.doString(`
2743
2844
--local resp = fetch(string.format('https://cdn.statically.io/gh/hellpanderrr/hellpanderrr.github.io/master/wiktionary_pron/lua_modules/%s.%s',path,extension) ):await()
2945
--local resp = fetch(string.format('https://cdn.jsdelivr.net/gh/hellpanderrr/hellpanderrr.github.io/wiktionary_pron/lua_modules/%s.%s',path,extension) ):await()
46+
updateLoadingText(path, extension)
3047
local resp = fetch(string.format('../wiktionary_pron/lua_modules/%s.%s',path,extension) ):await()
31-
48+
updateLoadingText("", "")
3249
local text = resp:text():await()
3350
local module = load(text)()
3451
print('loaded '..path)

0 commit comments

Comments
 (0)