== -> === in account.ts

This commit is contained in:
Evan 2023-02-26 10:34:16 -06:00
parent 1cf1cdb70d
commit 55198831f9

View file

@ -32,7 +32,7 @@ let filteredResults: MonkeyTypes.Result<MonkeyTypes.Mode>[] = [];
let visibleTableLines = 0;
function loadMoreLines(lineIndex?: number): void {
if (!filteredResults || filteredResults.length == 0) return;
if (!filteredResults || filteredResults.length === 0) return;
let newVisibleLines;
if (lineIndex && lineIndex > visibleTableLines) {
newVisibleLines = Math.ceil(lineIndex / 10) * 10;
@ -42,22 +42,11 @@ function loadMoreLines(lineIndex?: number): void {
for (let i = visibleTableLines; i < newVisibleLines; i++) {
const result = filteredResults[i];
if (!result) continue;
let diff = result.difficulty;
if (diff == undefined) {
diff = "normal";
}
const diff = result.difficulty ?? "normal";
let raw;
try {
raw = Config.alwaysShowCPM
? (result.rawWpm * 5).toFixed(2)
: result.rawWpm.toFixed(2);
if (raw == undefined) {
raw = "-";
}
} catch (e) {
raw = "-";
}
const raw = Config.alwaysShowCPM
? (result.rawWpm * 5).toFixed(2)
: result.rawWpm.toFixed(2);
let icons = `<span aria-label="${result.language?.replace(
"_",
@ -325,10 +314,7 @@ function fillContent(): void {
return;
}
let resdiff = result.difficulty;
if (resdiff == undefined) {
resdiff = "normal";
}
const resdiff = result.difficulty ?? "normal";
if (!ResultFilters.getFilter("difficulty", resdiff)) {
if (filterDebug) {
console.log(`skipping result due to difficulty filter`, result);
@ -342,7 +328,7 @@ function fillContent(): void {
return;
}
if (result.mode == "time") {
if (result.mode === "time") {
let timefilter: MonkeyTypes.Mode2Custom<"time"> = "custom";
if ([15, 30, 60, 120].includes(parseInt(result.mode2 as string))) {
timefilter = result.mode2;
@ -353,7 +339,7 @@ function fillContent(): void {
}
return;
}
} else if (result.mode == "words") {
} else if (result.mode === "words") {
let wordfilter: MonkeyTypes.Mode2Custom<"words"> = "custom";
if (
[10, 25, 50, 100, 200].includes(parseInt(result.mode2 as string))
@ -368,7 +354,7 @@ function fillContent(): void {
}
}
if (result.quoteLength != null) {
if (result.quoteLength !== null) {
let filter: MonkeyTypes.QuoteModes | undefined = undefined;
if (result.quoteLength === 0) {
filter = "short";
@ -445,7 +431,7 @@ function fillContent(): void {
break;
}
}
if (counter == 0) {
if (counter === 0) {
if (filterDebug) {
console.log(`skipping result due to funbox filter`, result);
}
@ -567,28 +553,28 @@ function fillContent(): void {
let tt = 0;
if (
result.testDuration == undefined &&
result.testDuration === undefined &&
result.mode2 !== "custom" &&
result.mode2 !== "zen"
) {
//test finished before testDuration field was introduced - estimate
if (result.mode == "time") {
if (result.mode === "time") {
tt = result.mode2;
} else if (result.mode == "words") {
} else if (result.mode === "words") {
tt = (result.mode2 / result.wpm) * 60;
}
} else {
tt = parseFloat(result.testDuration as unknown as string); //legacy results could have a string here
}
if (result.incompleteTestSeconds != undefined) {
if (result.incompleteTestSeconds !== undefined) {
tt += result.incompleteTestSeconds;
} else if (result.restartCount != undefined && result.restartCount > 0) {
} else if (result.restartCount !== undefined && result.restartCount > 0) {
tt += (tt / 4) * result.restartCount;
}
// if (result.incompleteTestSeconds != undefined) {
// if (result.incompleteTestSeconds !== undefined) {
// tt += result.incompleteTestSeconds;
// } else if (result.restartCount != undefined && result.restartCount > 0) {
// } else if (result.restartCount !== undefined && result.restartCount > 0) {
// tt += (tt / 4) * result.restartCount;
// }
totalSecondsFiltered += tt;
@ -611,7 +597,7 @@ function fillContent(): void {
}
}
if (result.rawWpm != null) {
if (result.rawWpm !== null) {
if (rawWpm.last10Count < 10) {
rawWpm.last10Count++;
rawWpm.last10Total += result.rawWpm;
@ -629,7 +615,7 @@ function fillContent(): void {
totalAcc += result.acc;
if (result.restartCount != undefined) {
if (result.restartCount !== undefined) {
testRestarts += result.restartCount;
}
@ -664,7 +650,7 @@ function fillContent(): void {
? ",<br> " + (result.punctuation ? "&" : "") + "with numbers"
: "";
topWpm = result.wpm;
if (result.mode == "custom") topMode = result.mode;
if (result.mode === "custom") topMode = result.mode;
else {
topMode =
result.mode + " " + result.mode2 + puncsctring + numbsctring;
@ -737,7 +723,7 @@ function fillContent(): void {
x: bucket,
y: histogramChartData[bucket],
});
if (bucket + 10 != parseInt(keys[i + 1])) {
if (bucket + 10 !== parseInt(keys[i + 1])) {
for (let j = bucket + 10; j < parseInt(keys[i + 1]); j += 10) {
histogramChartDataBucketed.push({ x: j, y: 0 });
labels.push(`${j} - ${j + 9}`);
@ -776,7 +762,7 @@ function fillContent(): void {
accountHistoryScaleOptions["wpm"].min = 0;
}
if (!chartData || chartData.length == 0) {
if (!chartData || chartData.length === 0) {
$(".pageAccount .group.noDataError").removeClass("hidden");
$(".pageAccount .group.chart").addClass("hidden");
$(".pageAccount .group.dailyActivityChart").addClass("hidden");
@ -918,7 +904,7 @@ function fillContent(): void {
$(".pageAccount .avgAcc10 .val").text(averageAccLast10 + "%");
if (totalCons == 0 || totalCons == undefined) {
if (totalCons === 0 || totalCons === undefined) {
$(".pageAccount .avgCons .val").text("-");
$(".pageAccount .avgCons10 .val").text("-");
} else {
@ -1054,7 +1040,7 @@ function sortAndRefreshHistory(
// This allows to reverse the sorting order when clicking multiple times on the table header
let descending = true;
if (forceDescending !== null) {
if (forceDescending == true) {
if (forceDescending) {
$(headerClass).append(
'<i class="fas fa-sort-down" aria-hidden="true"></i>'
);
@ -1121,7 +1107,7 @@ $(".pageAccount .toggleAccuracyOnChart").on("click", () => {
});
$(".pageAccount .toggleChartStyle").on("click", () => {
if (Config.chartStyle == "line") {
if (Config.chartStyle === "line") {
UpdateConfig.setChartStyle("scatter");
} else {
UpdateConfig.setChartStyle("line");
@ -1273,7 +1259,7 @@ export const page = new Page(
await ResultFilters.appendButtons();
ResultFilters.updateActive();
await Misc.sleep(0);
if (DB.getSnapshot()?.results == undefined) {
if (DB.getSnapshot()?.results === undefined) {
$(".pageLoading .fill, .pageAccount .fill").css("width", "0%");
$(".pageAccount .content").addClass("hidden");
$(".pageAccount .preloader").removeClass("hidden");