Further cleanup, mostly with svelte 5 migration placeholder cleanup

This commit is contained in:
Mawoka
2025-10-26 11:53:53 +01:00
parent 0c23d9b9c1
commit 41fe3e3ad5
74 changed files with 309 additions and 1154 deletions
+12 -28
View File
@@ -5,10 +5,6 @@ SPDX-License-Identifier: MPL-2.0
-->
<script lang="ts">
import { run } from 'svelte/legacy';
function sortObjectbyValue(obj) {
const ret = {};
Object.keys(obj)
@@ -20,12 +16,12 @@ SPDX-License-Identifier: MPL-2.0
interface Props {
scores: any;
question_results: Array<{
username: string;
answer: string;
right: boolean;
time_taken: number;
score: number;
}>;
username: string;
answer: string;
right: boolean;
time_taken: number;
score: number;
}>;
username: any;
}
@@ -37,26 +33,14 @@ SPDX-License-Identifier: MPL-2.0
scores[i.username] = 0;
}
}
run(() => {
console.log(score_by_username, scores, 'dieter');
});
for (const i of question_results) {
score_by_username[i.username] = i.score;
}
run(() => {
scores = sortObjectbyValue(scores);
});
const do_sth = () => {
for (const i of Object.keys(score_by_username)) {
scores[i] = (score_by_username[i] ?? 0) + (scores[i] ?? 0);
}
scores = scores;
};
do_sth();
for (const username of Object.keys(score_by_username)) {
scores[username] = (score_by_username[username] ?? 0) + (scores[username] ?? 0);
}
scores = scores;
let sorted_scores = $derived(sortObjectbyValue(scores));
</script>
<div>
@@ -65,7 +49,7 @@ SPDX-License-Identifier: MPL-2.0
<p class="p-4 bg-black/40 rounded-lg text-2xl">
+{score_by_username[username] ?? '0'}
</p>
<p>Total score: {scores[username] ?? '0'}</p>
<p>Total score: {sorted_scores[username] ?? '0'}</p>
</div>
</div>
</div>