fortnite sauce

This commit is contained in:
st5 committed 2026-04-04 12:28:36 -05:00
1 parent 649574ec11
commit 25dd6281ce
6 files changed
+400 -968

No files matched your search

+25 -37
View File
@@ -1,58 +1,46 @@
const STORAGE_KEY = "levelup-typing-save-v1";
function readSave() {
const raw = localStorage.getItem(STORAGE_KEY);
if (!raw) return null;
const q = (id) => document.getElementById(id);
const set_text = (id, value) => {
const el = q(id);
if (el) el.textContent = value;
};
const read_save = () => {
try {
return JSON.parse(raw);
} catch (error) {
return JSON.parse(localStorage.getItem(STORAGE_KEY) || "null");
} catch {
return null;
}
}
};
function setText(id, value) {
const el = document.getElementById(id);
if (el) el.textContent = value;
}
function renderHistory(recentRounds) {
const list = document.getElementById("historyList");
function render_history(recent_rounds) {
const list = q("historyList");
if (!list) return;
list.innerHTML = "";
if (!recentRounds || recentRounds.length === 0) {
if (!recent_rounds?.length) {
const item = document.createElement("li");
item.className = "history-item";
item.textContent = "no rounds played yet... complete a run to see your history!";
list.appendChild(item);
return;
}
recentRounds.forEach((round) => {
recent_rounds.forEach((round) => {
const item = document.createElement("li");
item.className = "history-item";
const date = new Date(round.stamp || Date.now());
const when = `${date.toLocaleDateString()} ${date.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" })}`;
item.textContent = `${when} | ${round.wpm || 0} wpm / ${round.accuracy || 0}% acc / combo ${round.bestCombo || 0} / +${round.xp || 0} xp / ${(round.difficulty || "normal").toLowerCase()}`;
const best_combo = round.best_combo ?? round.bestCombo ?? 0;
item.className = "history-item";
item.textContent = `${when} | ${round.wpm || 0} wpm / ${round.accuracy || 0}% acc / combo ${best_combo} / +${round.xp || 0} xp / ${(round.difficulty || "normal").toLowerCase()}`;
list.appendChild(item);
});
}
function boot() {
const save = readSave() || {};
(function boot() {
const save = read_save() || {};
const stats = save.stats || {};
setText("sTotalRounds", String(stats.totalRounds || 0));
setText("sBestWpm", String(stats.bestWpm || 0));
setText("sBestAcc", `${Math.round(stats.bestAccuracy || 0)}%`);
setText("sAvgWpm", String(Math.round(stats.averageWpm || 0)));
setText("sAvgAcc", `${Math.round(stats.averageAccuracy || 0)}%`);
renderHistory(Array.isArray(save.recentRounds) ? save.recentRounds : []);
}
boot();
set_text("sTotalRounds", String(stats.total_rounds ?? stats.totalRounds ?? 0));
set_text("sBestWpm", String(stats.best_wpm ?? stats.bestWpm ?? 0));
set_text("sBestAcc", `${Math.round(stats.best_accuracy ?? stats.bestAccuracy ?? 0)}%`);
set_text("sAvgWpm", String(Math.round(stats.average_wpm ?? stats.averageWpm ?? 0)));
set_text("sAvgAcc", `${Math.round(stats.average_accuracy ?? stats.averageAccuracy ?? 0)}%`);
render_history(Array.isArray(save.recent_rounds ?? save.recentRounds) ? save.recent_rounds ?? save.recentRounds : []);
})();