Skip to content

Commit

Permalink
remove loading bar because wiso is a whining about load times
Browse files Browse the repository at this point in the history
  • Loading branch information
stonedDiscord committed Sep 8, 2023
1 parent 246181c commit cd82779
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 41 deletions.
1 change: 0 additions & 1 deletion public/client.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
<noscript><p style="color: red;">webAO requires JavaScript to work</p></noscript>
<div id="client_loading">
<h1 id="client_loadingtext">Loading</h1>
<progress id="client_loadingbar" value="0"></progress>
</div>
<div id="client_secondfactor" style="display: none">
<center>
Expand Down
12 changes: 4 additions & 8 deletions webAO/packets/handlers/handleCI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,13 @@ import { handleCharacterInfo } from '../../client/handleCharacterInfo'
*/
export const handleCI = (args: string[]) => {
// Loop through the 10 characters that were sent

document.getElementById(
"client_loadingtext"
)!.innerHTML = `Loading Character ${args[1]}/${client.char_list_length}`;
for (let i = 2; i <= args.length - 2; i++) {
if (i % 2 === 0) {
document.getElementById(
"client_loadingtext"
)!.innerHTML = `Loading Character ${args[1]}/${client.char_list_length}`;
if (i % 2 === 0) {
const chargs = args[i].split("&");
const charid = Number(args[i - 1]);
(<HTMLProgressElement>(
document.getElementById("client_loadingbar")
)).value = charid;
setTimeout(() => handleCharacterInfo(chargs, charid), 500);
}
}
Expand Down
3 changes: 0 additions & 3 deletions webAO/packets/handlers/handleEI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ export const handleEI = (args: string[]) => {
"client_loadingtext"
)!.innerHTML = `Loading Evidence ${args[1]}/${client.evidence_list_length}`;
const evidenceID = Number(args[1]);
(<HTMLProgressElement>document.getElementById("client_loadingbar")).value =
client.char_list_length + evidenceID;

const arg = args[2].split("&");
client.evidences[evidenceID] = {
name: prepChat(arg[0]),
Expand Down
5 changes: 0 additions & 5 deletions webAO/packets/handlers/handleEM.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ export const handleEM = (args: string[]) => {
if (i % 2 === 0) {
const trackname = args[i];
const trackindex = Number(args[i - 1]);
(<HTMLProgressElement>(
document.getElementById("client_loadingbar")
)).value =
client.char_list_length + client.evidence_list_length + trackindex;
if (client.musics_time) {
addTrack(trackname);
} else if (isAudio(trackname)) {
Expand All @@ -37,7 +33,6 @@ export const handleEM = (args: string[]) => {
}
}
}

// get the next batch of tracks
client.sender.sendServer(`AM#${Number(args[1]) / 10 + 1}#%`);
}
3 changes: 0 additions & 3 deletions webAO/packets/handlers/handleLE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ import { prepChat, safeTags } from '../../encoding';
export const handleLE = (args: string[]) => {
client.evidences = [];
for (let i = 1; i < args.length - 1; i++) {
(<HTMLProgressElement>(
document.getElementById("client_loadingbar")
)).value = client.char_list_length + i;
const arg = args[i].split("&");
client.evidences[i - 1] = {
name: prepChat(arg[0]),
Expand Down
12 changes: 2 additions & 10 deletions webAO/packets/handlers/handleSC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ let { mode } = queryParser();
* @param {Array} args packet arguments
*/
export const handleSC = async (args: string[]) => {
const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));

if (mode === "watch") {
// Spectators don't need to pick a character
document.getElementById("client_charselect")!.style.display = "none";
Expand All @@ -22,16 +20,10 @@ export const handleSC = async (args: string[]) => {
document.getElementById("client_loadingtext")!.innerHTML =
"Loading Characters";
for (let i = 1; i < args.length - 1; i++) {
document.getElementById(
"client_loadingtext"
)!.innerHTML = `Loading Character ${i}/${client.char_list_length}`;
const chargs = args[i].split("&");
const charid = i - 1;
(<HTMLProgressElement>(
document.getElementById("client_loadingbar")
)).value = charid;
await sleep(0.1); // TODO: Too many network calls without this. net::ERR_INSUFFICIENT_RESOURCES
handleCharacterInfo(chargs, charid);

setTimeout(() => handleCharacterInfo(chargs, charid), charid*2);
}
// We're done with the characters, request the music
client.sender.sendServer("RM#%");
Expand Down
5 changes: 0 additions & 5 deletions webAO/packets/handlers/handleSI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ export const handleSI = (args: string[]) => {
client.evidence_list_length = Number(args[2]);
client.music_list_length = Number(args[3]);

(<HTMLProgressElement>document.getElementById("client_loadingbar")).max =
client.char_list_length +
client.evidence_list_length +
client.music_list_length;

// create the charselect grid, to be filled by the character loader
document.getElementById("client_chartable")!.innerHTML = "";

Expand Down
11 changes: 5 additions & 6 deletions webAO/packets/handlers/handleSM.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@ export const handleSM = (args: string[]) => {

client.musics_time = false;

document.getElementById(
"client_loadingtext"
)!.innerHTML = `Loading Music`;

for (let i = 1; i < args.length - 1; i++) {
// Check when found the song for the first time
const trackname = args[i];
const trackindex = i - 1;
document.getElementById(
"client_loadingtext"
)!.innerHTML = `Loading Music ${i}/${client.music_list_length}`;
(<HTMLProgressElement>(
document.getElementById("client_loadingbar")
)).value = client.char_list_length + client.evidence_list_length + i;

if (client.musics_time) {
addTrack(trackname);
} else if (isAudio(trackname)) {
Expand Down

0 comments on commit cd82779

Please sign in to comment.