mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-11-09 13:44:29 +08:00
prettier
This commit is contained in:
parent
f4d10c1afa
commit
a34d676f08
6 changed files with 300 additions and 259 deletions
|
|
@ -1803,9 +1803,9 @@ key {
|
|||
border-bottom: 2px solid var(--error-color);
|
||||
text-shadow: 1px 0px 0px var(--bg-color),
|
||||
// 2px 0px 0px var(--bg-color),
|
||||
-1px 0px 0px var(--bg-color),
|
||||
-1px 0px 0px var(--bg-color),
|
||||
// -2px 0px 0px var(--bg-color),
|
||||
0px 1px 0px var(--bg-color),
|
||||
0px 1px 0px var(--bg-color),
|
||||
1px 1px 0px var(--bg-color), -1px 1px 0px var(--bg-color);
|
||||
}
|
||||
|
||||
|
|
@ -3103,7 +3103,7 @@ key {
|
|||
:nth-child(13) {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
|
||||
:nth-child(14) {
|
||||
opacity: 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@
|
|||
</head>
|
||||
|
||||
<body>
|
||||
<div id="backgroundLoader" style="display: none"></div>
|
||||
<div id="backgroundLoader" style="display: none;"></div>
|
||||
<div
|
||||
class="nameChangeMessage"
|
||||
style="
|
||||
|
|
@ -840,7 +840,7 @@
|
|||
</div>
|
||||
|
||||
<div class="config">
|
||||
<div style="display: grid; grid-auto-flow: column">
|
||||
<div style="display: grid; grid-auto-flow: column;">
|
||||
<div class="group punctuationMode">
|
||||
<!-- <div class="title">time</div> -->
|
||||
<div class="buttons">
|
||||
|
|
@ -916,7 +916,7 @@
|
|||
</div>
|
||||
<div
|
||||
class="signOut hidden"
|
||||
style="grid-column: 3/4; grid-row: 1/2"
|
||||
style="grid-column: 3/4; grid-row: 1/2;"
|
||||
tabindex="0"
|
||||
>
|
||||
<i class="fas fa-sign-out-alt"></i>
|
||||
|
|
@ -1171,7 +1171,7 @@
|
|||
<div class="group testType">
|
||||
<div class="top">test type</div>
|
||||
<div class="bottom">-</div>
|
||||
<div class="tags" style="margin-top: 0.5rem">
|
||||
<div class="tags" style="margin-top: 0.5rem;">
|
||||
<div class="top">tags</div>
|
||||
<div class="bottom">-</div>
|
||||
</div>
|
||||
|
|
@ -1238,7 +1238,7 @@
|
|||
class="icon-button"
|
||||
aria-label="Copy words list"
|
||||
data-balloon-pos="up"
|
||||
style="display: inline-block"
|
||||
style="display: inline-block;"
|
||||
>
|
||||
<i class="fas fa-copy"></i>
|
||||
</span>
|
||||
|
|
@ -1464,14 +1464,16 @@
|
|||
When you connect your monkeytype account to your Discord
|
||||
account, you will be automatically assigned a new role every
|
||||
time you achieve a new personal best in a 60 second test.
|
||||
<br><br>
|
||||
Don't pair your account before joining the Discord server, as it might result in the bot not being able to give you a role.
|
||||
<br />
|
||||
<br />
|
||||
Don't pair your account before joining the Discord server, as it
|
||||
might result in the bot not being able to give you a role.
|
||||
</div>
|
||||
<div class="buttons">
|
||||
<a
|
||||
class="button"
|
||||
href="https://discord.com/api/oauth2/authorize?client_id=757704816532258856&redirect_uri=https%3A%2F%2Fmonkeytype.com%2Fverify&response_type=token&scope=identify"
|
||||
style="text-decoration: none"
|
||||
style="text-decoration: none;"
|
||||
>
|
||||
Verify with Discord
|
||||
</a>
|
||||
|
|
@ -2565,7 +2567,7 @@
|
|||
<div
|
||||
class="button"
|
||||
id="loadCustomColorsFromPreset"
|
||||
style="grid-column: 1/3"
|
||||
style="grid-column: 1/3;"
|
||||
>
|
||||
load from preset
|
||||
</div>
|
||||
|
|
@ -2746,7 +2748,7 @@
|
|||
|
||||
I've contacted Google to get this sorted out - don't worry, the site is safe."
|
||||
data-balloon-length="xlarge"
|
||||
style="text-align: center; margin-top: 1rem; grid-column: 1/3"
|
||||
style="text-align: center; margin-top: 1rem; grid-column: 1/3;"
|
||||
>
|
||||
Returning Chrome Users
|
||||
<br />
|
||||
|
|
@ -2783,7 +2785,7 @@
|
|||
</div>
|
||||
<div class="group">
|
||||
<div class="title">personal bests</div>
|
||||
<div style="display: grid; grid-auto-flow: column; gap: 1rem">
|
||||
<div style="display: grid; grid-auto-flow: column; gap: 1rem;">
|
||||
<div class="titleAndTable timePbTable">
|
||||
<table width="100%">
|
||||
<thead>
|
||||
|
|
@ -2872,7 +2874,7 @@
|
|||
>
|
||||
set filters to current settings
|
||||
</div> -->
|
||||
<div class="buttonsAndTitle" style="grid-column: 1/3">
|
||||
<div class="buttonsAndTitle" style="grid-column: 1/3;">
|
||||
<div class="title">filters</div>
|
||||
<div class="buttons">
|
||||
<div class="button allFilters">all</div>
|
||||
|
|
@ -2882,7 +2884,7 @@
|
|||
</div>
|
||||
<div
|
||||
class="buttonsAndTitle testDate"
|
||||
style="grid-column: 1/3; margin-top: 1rem"
|
||||
style="grid-column: 1/3; margin-top: 1rem;"
|
||||
>
|
||||
<!-- <div class="title">date</div> -->
|
||||
<div class="buttons filterGroup" group="date">
|
||||
|
|
@ -2893,8 +2895,8 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="group filterButtons" style="display: none">
|
||||
<div class="buttonsAndTitle" style="grid-column: 1/3">
|
||||
<div class="group filterButtons" style="display: none;">
|
||||
<div class="buttonsAndTitle" style="grid-column: 1/3;">
|
||||
<div class="title">advanced filters</div>
|
||||
<div class="buttons">
|
||||
<div class="button noFilters">clear filters</div>
|
||||
|
|
@ -2951,15 +2953,15 @@
|
|||
<div class="button" filter="off">off</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="buttonsAndTitle tags" style="grid-column: 1/3">
|
||||
<div class="buttonsAndTitle tags" style="grid-column: 1/3;">
|
||||
<div class="title">tags</div>
|
||||
<div class="buttons filterGroup" group="tags"></div>
|
||||
</div>
|
||||
<div class="buttonsAndTitle languages" style="grid-column: 1/3">
|
||||
<div class="buttonsAndTitle languages" style="grid-column: 1/3;">
|
||||
<div class="title">language</div>
|
||||
<div class="buttons filterGroup" group="language"></div>
|
||||
</div>
|
||||
<div class="buttonsAndTitle funbox" style="grid-column: 1/3">
|
||||
<div class="buttonsAndTitle funbox" style="grid-column: 1/3;">
|
||||
<div class="title">funbox</div>
|
||||
<div class="buttons filterGroup" group="funbox"></div>
|
||||
</div>
|
||||
|
|
@ -2972,7 +2974,7 @@
|
|||
<i class="fas fa-fw fa-spin fa-circle-notch"></i>
|
||||
</div> -->
|
||||
<div class="above"></div>
|
||||
<div class="chart" style="height: 400px">
|
||||
<div class="chart" style="height: 400px;">
|
||||
<canvas id="resultHistoryChart"></canvas>
|
||||
</div>
|
||||
<div class="below">
|
||||
|
|
@ -2990,7 +2992,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="group dailyActivityChart">
|
||||
<div class="chart" style="height: 200px">
|
||||
<div class="chart" style="height: 200px;">
|
||||
<canvas id="activityChart"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -143,7 +143,6 @@ function signUp() {
|
|||
displayName: nname,
|
||||
})
|
||||
.then(async function () {
|
||||
|
||||
// Update successful.
|
||||
await firebase
|
||||
.firestore()
|
||||
|
|
@ -267,15 +266,15 @@ firebase.auth().onAuthStateChanged(function (user) {
|
|||
$(".pageLogin .preloader").addClass("hidden");
|
||||
$("#menu .icon-button.account .text").text(displayName);
|
||||
if (verifyUserWhenLoggedIn !== null) {
|
||||
showNotification('Verifying', 1000);
|
||||
showNotification("Verifying", 1000);
|
||||
verifyUserWhenLoggedIn.uid = user.uid;
|
||||
verifyUser(verifyUserWhenLoggedIn).then(data => {
|
||||
verifyUser(verifyUserWhenLoggedIn).then((data) => {
|
||||
showNotification(data.data.message, 3000);
|
||||
if (data.data.status === 1) {
|
||||
dbSnapshot.discordId = data.data.did;
|
||||
updateDiscordSettingsSection()
|
||||
updateDiscordSettingsSection();
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -284,94 +283,101 @@ function getAccountDataAndInit() {
|
|||
db_getUserSnapshot()
|
||||
.then((e) => {
|
||||
if (dbSnapshot === null) {
|
||||
throw ("Missing db snapshot. Client likely could not connect to the backend.");
|
||||
throw "Missing db snapshot. Client likely could not connect to the backend.";
|
||||
}
|
||||
initPaceCaret(true);
|
||||
if (!configChangedBeforeDb) {
|
||||
if (cookieConfig === null) {
|
||||
accountIconLoading(false);
|
||||
applyConfig(dbSnapshot.config);
|
||||
// showNotification('Applying db config',3000);
|
||||
updateSettingsPage();
|
||||
saveConfigToCookie(true);
|
||||
restartTest(false, true);
|
||||
} else if (dbSnapshot.config !== undefined) {
|
||||
let configsDifferent = false;
|
||||
Object.keys(config).forEach((key) => {
|
||||
if (!configsDifferent) {
|
||||
try {
|
||||
if (key !== "resultFilters") {
|
||||
if (Array.isArray(config[key])) {
|
||||
config[key].forEach((arrval, index) => {
|
||||
if (arrval != dbSnapshot.config[key][index]) {
|
||||
configsDifferent = true;
|
||||
console.log(`.config is different: ${arrval} != ${dbSnapshot.config[key][index]}`);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (config[key] != dbSnapshot.config[key]) {
|
||||
configsDifferent = true;
|
||||
console.log(`..config is different ${key}: ${config[key]} != ${dbSnapshot.config[key]}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
configsDifferent = true;
|
||||
console.log(`...config is different: ${e.message}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
if (configsDifferent) {
|
||||
console.log('applying config from db');
|
||||
initPaceCaret(true);
|
||||
if (!configChangedBeforeDb) {
|
||||
if (cookieConfig === null) {
|
||||
accountIconLoading(false);
|
||||
config = dbSnapshot.config;
|
||||
applyConfig(config);
|
||||
applyConfig(dbSnapshot.config);
|
||||
// showNotification('Applying db config',3000);
|
||||
updateSettingsPage();
|
||||
saveConfigToCookie(true);
|
||||
restartTest(false, true);
|
||||
} else if (dbSnapshot.config !== undefined) {
|
||||
let configsDifferent = false;
|
||||
Object.keys(config).forEach((key) => {
|
||||
if (!configsDifferent) {
|
||||
try {
|
||||
if (key !== "resultFilters") {
|
||||
if (Array.isArray(config[key])) {
|
||||
config[key].forEach((arrval, index) => {
|
||||
if (arrval != dbSnapshot.config[key][index]) {
|
||||
configsDifferent = true;
|
||||
console.log(
|
||||
`.config is different: ${arrval} != ${dbSnapshot.config[key][index]}`
|
||||
);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (config[key] != dbSnapshot.config[key]) {
|
||||
configsDifferent = true;
|
||||
console.log(
|
||||
`..config is different ${key}: ${config[key]} != ${dbSnapshot.config[key]}`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
configsDifferent = true;
|
||||
console.log(`...config is different: ${e.message}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
if (configsDifferent) {
|
||||
console.log("applying config from db");
|
||||
accountIconLoading(false);
|
||||
config = dbSnapshot.config;
|
||||
applyConfig(config);
|
||||
updateSettingsPage();
|
||||
saveConfigToCookie(true);
|
||||
restartTest(false, true);
|
||||
}
|
||||
}
|
||||
dbConfigLoaded = true;
|
||||
} else {
|
||||
accountIconLoading(false);
|
||||
}
|
||||
dbConfigLoaded = true;
|
||||
} else {
|
||||
accountIconLoading(false);
|
||||
}
|
||||
try {
|
||||
if (
|
||||
config.resultFilters === undefined ||
|
||||
config.resultFilters === null ||
|
||||
config.resultFilters.difficulty === undefined
|
||||
) {
|
||||
try {
|
||||
if (
|
||||
dbSnapshot.config.resultFilters == null ||
|
||||
dbSnapshot.config.resultFilters.difficulty === undefined
|
||||
config.resultFilters === undefined ||
|
||||
config.resultFilters === null ||
|
||||
config.resultFilters.difficulty === undefined
|
||||
) {
|
||||
config.resultFilters = defaultAccountFilters;
|
||||
} else {
|
||||
config.resultFilters = dbSnapshot.config.resultFilters;
|
||||
if (
|
||||
dbSnapshot.config.resultFilters == null ||
|
||||
dbSnapshot.config.resultFilters.difficulty === undefined
|
||||
) {
|
||||
config.resultFilters = defaultAccountFilters;
|
||||
} else {
|
||||
config.resultFilters = dbSnapshot.config.resultFilters;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
config.resultFilters = defaultAccountFilters;
|
||||
}
|
||||
} catch (e) {
|
||||
config.resultFilters = defaultAccountFilters;
|
||||
}
|
||||
if ($(".pageLogin").hasClass("active")) {
|
||||
changePage("account");
|
||||
}
|
||||
refreshThemeButtons();
|
||||
accountIconLoading(false);
|
||||
updateFilterTags();
|
||||
updateCommandsTagsList();
|
||||
loadActiveTagsFromCookie();
|
||||
updateResultEditTagsPanelButtons();
|
||||
showAccountSettingsSection();
|
||||
})
|
||||
.catch((e) => {
|
||||
accountIconLoading(false);
|
||||
console.error(e);
|
||||
showNotification("Error downloading user data. Refresh to try again. If error persists contact Miodec.", 5000);
|
||||
$("#top #menu .account .icon").html('<i class="fas fa-fw fa-times"></i>');
|
||||
$("#top #menu .account").css('opacity', 1);
|
||||
});
|
||||
if ($(".pageLogin").hasClass("active")) {
|
||||
changePage("account");
|
||||
}
|
||||
refreshThemeButtons();
|
||||
accountIconLoading(false);
|
||||
updateFilterTags();
|
||||
updateCommandsTagsList();
|
||||
loadActiveTagsFromCookie();
|
||||
updateResultEditTagsPanelButtons();
|
||||
showAccountSettingsSection();
|
||||
})
|
||||
.catch((e) => {
|
||||
accountIconLoading(false);
|
||||
console.error(e);
|
||||
showNotification(
|
||||
"Error downloading user data. Refresh to try again. If error persists contact Miodec.",
|
||||
5000
|
||||
);
|
||||
$("#top #menu .account .icon").html('<i class="fas fa-fw fa-times"></i>');
|
||||
$("#top #menu .account").css("opacity", 1);
|
||||
});
|
||||
}
|
||||
|
||||
var resultHistoryChart = new Chart($(".pageAccount #resultHistoryChart"), {
|
||||
|
|
@ -561,7 +567,7 @@ let activityChart = new Chart($(".pageAccount #activityChart"), {
|
|||
lineStyle: "dotted",
|
||||
width: 2,
|
||||
},
|
||||
order: 3
|
||||
order: 3,
|
||||
},
|
||||
{
|
||||
yAxisID: "avgWpm",
|
||||
|
|
@ -998,7 +1004,7 @@ let defaultAccountFilters = {
|
|||
},
|
||||
};
|
||||
|
||||
getLanguageList().then(languages => {
|
||||
getLanguageList().then((languages) => {
|
||||
languages.forEach((language) => {
|
||||
$(
|
||||
".pageAccount .content .filterButtons .buttonsAndTitle.languages .buttons"
|
||||
|
|
@ -1010,7 +1016,7 @@ getLanguageList().then(languages => {
|
|||
);
|
||||
defaultAccountFilters.language[language] = true;
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
$(
|
||||
".pageAccount .content .filterButtons .buttonsAndTitle.funbox .buttons"
|
||||
|
|
@ -1460,46 +1466,47 @@ $(".pageAccount .topFilters .button.currentConfigFilter").click((e) => {
|
|||
|
||||
$(".pageAccount .topFilters .button.toggleAdvancedFilters").click((e) => {
|
||||
$(".pageAccount .filterButtons").slideToggle(250);
|
||||
$(".pageAccount .topFilters .button.toggleAdvancedFilters").toggleClass('active');
|
||||
$(".pageAccount .topFilters .button.toggleAdvancedFilters").toggleClass(
|
||||
"active"
|
||||
);
|
||||
});
|
||||
|
||||
$(".pageAccount .filterButtons .buttonsAndTitle .buttons, .pageAccount .group.topFilters .buttonsAndTitle.testDate .buttons").click(
|
||||
".button",
|
||||
(e) => {
|
||||
const filter = $(e.target).attr("filter");
|
||||
const group = $(e.target).parents(".buttons").attr("group");
|
||||
// toggleFilterButton(filter);
|
||||
if ($(e.target).hasClass("allFilters")) {
|
||||
Object.keys(config.resultFilters).forEach((group) => {
|
||||
Object.keys(config.resultFilters[group]).forEach((filter) => {
|
||||
if (group === "date") {
|
||||
config.resultFilters[group][filter] = false;
|
||||
} else {
|
||||
config.resultFilters[group][filter] = true;
|
||||
}
|
||||
});
|
||||
});
|
||||
config.resultFilters.date.all = true;
|
||||
} else if ($(e.target).hasClass("noFilters")) {
|
||||
Object.keys(config.resultFilters).forEach((group) => {
|
||||
Object.keys(config.resultFilters[group]).forEach((filter) => {
|
||||
$(
|
||||
".pageAccount .filterButtons .buttonsAndTitle .buttons, .pageAccount .group.topFilters .buttonsAndTitle.testDate .buttons"
|
||||
).click(".button", (e) => {
|
||||
const filter = $(e.target).attr("filter");
|
||||
const group = $(e.target).parents(".buttons").attr("group");
|
||||
// toggleFilterButton(filter);
|
||||
if ($(e.target).hasClass("allFilters")) {
|
||||
Object.keys(config.resultFilters).forEach((group) => {
|
||||
Object.keys(config.resultFilters[group]).forEach((filter) => {
|
||||
if (group === "date") {
|
||||
config.resultFilters[group][filter] = false;
|
||||
});
|
||||
} else {
|
||||
config.resultFilters[group][filter] = true;
|
||||
}
|
||||
});
|
||||
});
|
||||
config.resultFilters.date.all = true;
|
||||
} else if ($(e.target).hasClass("noFilters")) {
|
||||
Object.keys(config.resultFilters).forEach((group) => {
|
||||
Object.keys(config.resultFilters[group]).forEach((filter) => {
|
||||
config.resultFilters[group][filter] = false;
|
||||
});
|
||||
});
|
||||
} else {
|
||||
if (e.shiftKey) {
|
||||
Object.keys(config.resultFilters[group]).forEach((filter) => {
|
||||
config.resultFilters[group][filter] = false;
|
||||
});
|
||||
setFilter(group, filter, true);
|
||||
} else {
|
||||
if (e.shiftKey) {
|
||||
Object.keys(config.resultFilters[group]).forEach((filter) => {
|
||||
config.resultFilters[group][filter] = false;
|
||||
});
|
||||
setFilter(group, filter, true);
|
||||
} else {
|
||||
toggleFilter(group, filter);
|
||||
}
|
||||
toggleFilter(group, filter);
|
||||
}
|
||||
showActiveFilters();
|
||||
saveConfigToCookie();
|
||||
}
|
||||
);
|
||||
showActiveFilters();
|
||||
saveConfigToCookie();
|
||||
});
|
||||
|
||||
function fillPbTables() {
|
||||
$(".pageAccount .timePbTable tbody").html(`
|
||||
|
|
@ -1755,7 +1762,7 @@ function loadMoreLines() {
|
|||
}
|
||||
|
||||
let raw;
|
||||
try{
|
||||
try {
|
||||
raw = result.rawWpm.toFixed(2);
|
||||
if (raw == undefined) {
|
||||
raw = "-";
|
||||
|
|
@ -1801,9 +1808,7 @@ function loadMoreLines() {
|
|||
} else if (result.chartData === "toolong") {
|
||||
icons += `<span class="hoverChartButton" aria-label="Chart history is not available for long tests" data-balloon-pos="up"><i class="fas fa-chart-line"></i></span>`;
|
||||
} else {
|
||||
icons += `<span class="hoverChartButton" filteredResultsId="${
|
||||
i
|
||||
}" style="opacity: 1"><i class="fas fa-chart-line"></i></span>`;
|
||||
icons += `<span class="hoverChartButton" filteredResultsId="${i}" style="opacity: 1"><i class="fas fa-chart-line"></i></span>`;
|
||||
}
|
||||
|
||||
let tagNames = "";
|
||||
|
|
@ -1850,9 +1855,9 @@ function loadMoreLines() {
|
|||
|
||||
let pb = result.isPb;
|
||||
if (pb) {
|
||||
pb = '<i class="fas fa-fw fa-crown"></i>'
|
||||
pb = '<i class="fas fa-fw fa-crown"></i>';
|
||||
} else {
|
||||
pb = '';
|
||||
pb = "";
|
||||
}
|
||||
|
||||
$(".pageAccount .history table tbody").append(`
|
||||
|
|
@ -2005,7 +2010,10 @@ function refreshAccountPage() {
|
|||
|
||||
let langFilter = config.resultFilters.language[result.language];
|
||||
|
||||
if (result.language === "english_expanded" && config.resultFilters.language.english_1k) {
|
||||
if (
|
||||
result.language === "english_expanded" &&
|
||||
config.resultFilters.language.english_1k
|
||||
) {
|
||||
langFilter = true;
|
||||
}
|
||||
if (!langFilter) return;
|
||||
|
|
@ -2112,7 +2120,7 @@ function refreshAccountPage() {
|
|||
activityChartData[resultDate] = {
|
||||
amount: 1,
|
||||
totalWpm: result.wpm,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
tt = 0;
|
||||
|
|
@ -2242,7 +2250,9 @@ function refreshAccountPage() {
|
|||
});
|
||||
activityChartData_avgWpm.push({
|
||||
x: parseInt(date),
|
||||
y: roundTo2(activityChartData[date].totalWpm / activityChartData[date].amount),
|
||||
y: roundTo2(
|
||||
activityChartData[date].totalWpm / activityChartData[date].amount
|
||||
),
|
||||
});
|
||||
lastTimestamp = date;
|
||||
});
|
||||
|
|
@ -2264,14 +2274,13 @@ function refreshAccountPage() {
|
|||
activityChart.data.datasets[0].data = activityChartData_amount;
|
||||
|
||||
activityChart.options.scales.yAxes[1].ticks.minor.fontColor =
|
||||
themeColors.sub;
|
||||
themeColors.sub;
|
||||
activityChart.options.scales.yAxes[1].scaleLabel.fontColor =
|
||||
themeColors.sub;
|
||||
activityChart.data.datasets[1].borderColor = themeColors.sub;
|
||||
// activityChart.data.datasets[1].backgroundColor = themeColors.main;
|
||||
activityChart.data.datasets[1].data = activityChartData_avgWpm;
|
||||
|
||||
|
||||
activityChart.options.legend.labels.fontColor = themeColors.sub;
|
||||
|
||||
resultHistoryChart.options.scales.xAxes[0].ticks.minor.fontColor =
|
||||
|
|
@ -2468,8 +2477,8 @@ function refreshAccountPage() {
|
|||
}
|
||||
if (dbSnapshot === null) {
|
||||
showNotification(`Missing account data. Please refresh.`, 5000);
|
||||
$('.pageAccount .preloader').html('Missing account data. Please refresh.');
|
||||
}else if (dbSnapshot.results === undefined) {
|
||||
$(".pageAccount .preloader").html("Missing account data. Please refresh.");
|
||||
} else if (dbSnapshot.results === undefined) {
|
||||
db_getUserResults().then((d) => {
|
||||
if (d) {
|
||||
// cont();
|
||||
|
|
@ -2657,4 +2666,3 @@ $("#resultEditTagsPanel .confirmButton").click((f) => {
|
|||
function updateLbMemory(mode, mode2, type, value) {
|
||||
dbSnapshot.lbMemory[mode + mode2][type] = value;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,20 +2,26 @@ function capitalizeFirstLetter(str) {
|
|||
return str.charAt(0).toUpperCase() + str.slice(1);
|
||||
}
|
||||
|
||||
function addChildCommands(unifiedCommands, commandItem, parentCommandDisplay = '') {
|
||||
let commandItemDisplay = commandItem.display.replace(/\s?\.\.\.$/g,'');
|
||||
if (parentCommandDisplay) commandItemDisplay = parentCommandDisplay + " > " + commandItemDisplay;
|
||||
function addChildCommands(
|
||||
unifiedCommands,
|
||||
commandItem,
|
||||
parentCommandDisplay = ""
|
||||
) {
|
||||
let commandItemDisplay = commandItem.display.replace(/\s?\.\.\.$/g, "");
|
||||
if (parentCommandDisplay)
|
||||
commandItemDisplay = parentCommandDisplay + " > " + commandItemDisplay;
|
||||
if (commandItem.subgroup) {
|
||||
try {
|
||||
commandItem.exec();
|
||||
currentCommandsIndex = currentCommands.length-1;
|
||||
currentCommands[currentCommandsIndex].list.forEach( cmd => addChildCommands(unifiedCommands, cmd, commandItemDisplay));
|
||||
currentCommandsIndex = currentCommands.length - 1;
|
||||
currentCommands[currentCommandsIndex].list.forEach((cmd) =>
|
||||
addChildCommands(unifiedCommands, cmd, commandItemDisplay)
|
||||
);
|
||||
currentCommands.pop();
|
||||
} catch(e) {}
|
||||
} catch (e) {}
|
||||
} else {
|
||||
let tempCommandItem = {...commandItem};
|
||||
if (parentCommandDisplay)
|
||||
tempCommandItem.display = commandItemDisplay;
|
||||
let tempCommandItem = { ...commandItem };
|
||||
if (parentCommandDisplay) tempCommandItem.display = commandItemDisplay;
|
||||
unifiedCommands.push(tempCommandItem);
|
||||
}
|
||||
}
|
||||
|
|
@ -24,11 +30,12 @@ function generateSingleListOfCommands() {
|
|||
allCommands = [];
|
||||
oldShowCommandLine = showCommandLine;
|
||||
showCommandLine = () => {};
|
||||
commands.list.forEach(c => addChildCommands(allCommands, c));
|
||||
commands.list.forEach((c) => addChildCommands(allCommands, c));
|
||||
showCommandLine = oldShowCommandLine;
|
||||
return {
|
||||
title: "All Commands",
|
||||
list: allCommands};
|
||||
list: allCommands,
|
||||
};
|
||||
}
|
||||
|
||||
function isSingleListCommandLineActive() {
|
||||
|
|
@ -37,17 +44,20 @@ function isSingleListCommandLineActive() {
|
|||
|
||||
function useSingleListCommandLine(show = true) {
|
||||
let allCommands = generateSingleListOfCommands();
|
||||
if (config.singleListCommandLine == "manual") currentCommands.push(allCommands);
|
||||
else if (config.singleListCommandLine == "on") currentCommands = [allCommands];
|
||||
if (config.singleListCommandLine == "manual")
|
||||
currentCommands.push(allCommands);
|
||||
else if (config.singleListCommandLine == "on")
|
||||
currentCommands = [allCommands];
|
||||
|
||||
if (config.singleListCommandLine != "off") $("#commandLine").addClass("allCommands");
|
||||
if (config.singleListCommandLine != "off")
|
||||
$("#commandLine").addClass("allCommands");
|
||||
if (show) showCommandLine();
|
||||
}
|
||||
|
||||
function restoreOldCommandLine(show = true) {
|
||||
if (isSingleListCommandLineActive()) {
|
||||
$("#commandLine").removeClass("allCommands");
|
||||
currentCommands = currentCommands.filter( l => l.title != "All Commands");
|
||||
currentCommands = currentCommands.filter((l) => l.title != "All Commands");
|
||||
if (currentCommands.length < 1) currentCommands = [commands];
|
||||
}
|
||||
if (show) showCommandLine();
|
||||
|
|
@ -471,35 +481,35 @@ let commands = {
|
|||
{
|
||||
id: "randomiseTheme",
|
||||
display: "Next random theme",
|
||||
exec: () => randomiseTheme()
|
||||
exec: () => randomiseTheme(),
|
||||
},
|
||||
{
|
||||
id: "viewTypingPage",
|
||||
display: "View Typing Page",
|
||||
exec: () => $('#top #menu .icon-button.view-start').click()
|
||||
exec: () => $("#top #menu .icon-button.view-start").click(),
|
||||
},
|
||||
{
|
||||
id: "viewLeaderboards",
|
||||
display: "View Leaderboards Page",
|
||||
exec: () => $('#top #menu .icon-button.view-leaderboards').click()
|
||||
exec: () => $("#top #menu .icon-button.view-leaderboards").click(),
|
||||
},
|
||||
{
|
||||
id: "viewAbout",
|
||||
display: "View About Page",
|
||||
exec: () => $('#top #menu .icon-button.view-about').click()
|
||||
exec: () => $("#top #menu .icon-button.view-about").click(),
|
||||
},
|
||||
{
|
||||
id: "viewSettings",
|
||||
display: "View Settings Page",
|
||||
exec: () => $('#top #menu .icon-button.view-settings').click()
|
||||
exec: () => $("#top #menu .icon-button.view-settings").click(),
|
||||
},
|
||||
{
|
||||
id: "viewAccount",
|
||||
display: "View Account Page",
|
||||
exec: () =>
|
||||
$('#top #menu .icon-button.view-account').hasClass('hidden') ?
|
||||
$('#top #menu .icon-button.view-login').click() :
|
||||
$('#top #menu .icon-button.view-account').click()
|
||||
exec: () =>
|
||||
$("#top #menu .icon-button.view-account").hasClass("hidden")
|
||||
? $("#top #menu .icon-button.view-login").click()
|
||||
: $("#top #menu .icon-button.view-account").click(),
|
||||
},
|
||||
{
|
||||
id: "toggleFullscreen",
|
||||
|
|
@ -535,8 +545,10 @@ let commands = {
|
|||
(config.mode === "custom" &&
|
||||
!customTextIsRandom &&
|
||||
customText.length >= 5000) ||
|
||||
(config.mode === "words" && config.words >= 5000 || config.words === 0) ||
|
||||
(config.mode === "time" && (config.time >= 3600 || config.time === 0))
|
||||
(config.mode === "words" && config.words >= 5000) ||
|
||||
config.words === 0 ||
|
||||
(config.mode === "time" &&
|
||||
(config.time >= 3600 || config.time === 0))
|
||||
) {
|
||||
bailout = true;
|
||||
showResult();
|
||||
|
|
@ -647,7 +659,7 @@ let commandsSoundOnClick = {
|
|||
exec: () => {
|
||||
setPlaySoundOnClick("1");
|
||||
playClickSound();
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "setSoundOnClick2",
|
||||
|
|
@ -655,7 +667,7 @@ let commandsSoundOnClick = {
|
|||
exec: () => {
|
||||
setPlaySoundOnClick("2");
|
||||
playClickSound();
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "setSoundOnClick3",
|
||||
|
|
@ -663,7 +675,7 @@ let commandsSoundOnClick = {
|
|||
exec: () => {
|
||||
setPlaySoundOnClick("3");
|
||||
playClickSound();
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "setSoundOnClick4",
|
||||
|
|
@ -671,7 +683,7 @@ let commandsSoundOnClick = {
|
|||
exec: () => {
|
||||
setPlaySoundOnClick("4");
|
||||
playClickSound();
|
||||
}
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
|
@ -879,8 +891,6 @@ let commandsMinWpm = {
|
|||
],
|
||||
};
|
||||
|
||||
|
||||
|
||||
let commandsKeymapStyle = {
|
||||
title: "Change keymap style...",
|
||||
list: [
|
||||
|
|
@ -992,7 +1002,7 @@ let commandsSingleListCommandLine = {
|
|||
exec: () => {
|
||||
setSingleListCommandLine("on");
|
||||
},
|
||||
}
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
|
|
@ -1085,7 +1095,6 @@ let commandsWordCount = {
|
|||
],
|
||||
};
|
||||
|
||||
|
||||
let commandsQuoteLengthConfig = {
|
||||
title: "Change quote length...",
|
||||
list: [
|
||||
|
|
@ -1327,7 +1336,7 @@ function updateCommandsTagsList() {
|
|||
|
||||
commandsTags.list.push({
|
||||
id: "clearTags",
|
||||
display: 'Clear tags',
|
||||
display: "Clear tags",
|
||||
exec: () => {
|
||||
dbSnapshot.tags.forEach((tag) => {
|
||||
tag.active = false;
|
||||
|
|
@ -1363,13 +1372,12 @@ function updateCommandsTagsList() {
|
|||
if (isSingleListCommandLineActive()) {
|
||||
$(
|
||||
`#commandLine .suggestions .entry[command='toggleTag${tag.id}']`
|
||||
).html('Change tags > ' + txt);
|
||||
).html("Change tags > " + txt);
|
||||
} else {
|
||||
$(
|
||||
`#commandLine .suggestions .entry[command='toggleTag${tag.id}']`
|
||||
).html(txt);
|
||||
}
|
||||
|
||||
},
|
||||
});
|
||||
});
|
||||
|
|
@ -1457,32 +1465,32 @@ let commandsLanguages = {
|
|||
};
|
||||
|
||||
// if (getLanguageList().length > 0) {
|
||||
commandsLanguages.list = [];
|
||||
getLanguageList().then(languages => {
|
||||
languages.forEach((language) => {
|
||||
// if (language === "english_10k") return;
|
||||
commandsLanguages.list.push({
|
||||
id: "changeLanguage" + capitalizeFirstLetter(language),
|
||||
display: language.replace(/_/g, " "),
|
||||
exec: () => {
|
||||
changeLanguage(language);
|
||||
restartTest();
|
||||
saveConfigToCookie();
|
||||
},
|
||||
})
|
||||
commandsLanguages.list = [];
|
||||
getLanguageList().then((languages) => {
|
||||
languages.forEach((language) => {
|
||||
// if (language === "english_10k") return;
|
||||
commandsLanguages.list.push({
|
||||
id: "changeLanguage" + capitalizeFirstLetter(language),
|
||||
display: language.replace(/_/g, " "),
|
||||
exec: () => {
|
||||
changeLanguage(language);
|
||||
restartTest();
|
||||
saveConfigToCookie();
|
||||
},
|
||||
});
|
||||
// if (language === "english_expanded") {
|
||||
// commandsLanguages.list.push({
|
||||
// id: "changeLanguageEnglish10k",
|
||||
// display: "english 10k",
|
||||
// exec: () => {
|
||||
// changeLanguage("english_10k");
|
||||
// restartTest();
|
||||
// saveConfigToCookie();
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
});
|
||||
// if (language === "english_expanded") {
|
||||
// commandsLanguages.list.push({
|
||||
// id: "changeLanguageEnglish10k",
|
||||
// display: "english 10k",
|
||||
// exec: () => {
|
||||
// changeLanguage("english_10k");
|
||||
// restartTest();
|
||||
// saveConfigToCookie();
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
});
|
||||
// }
|
||||
|
||||
let commandsLayouts = {
|
||||
|
|
@ -1538,24 +1546,28 @@ if (Object.keys(layouts).length > 0) {
|
|||
}
|
||||
|
||||
$("#commandLine input").keyup((e) => {
|
||||
if (e.keyCode == 38 || e.keyCode == 40 || e.keyCode == 13 || e.code == "Tab") return;
|
||||
if (e.keyCode == 38 || e.keyCode == 40 || e.keyCode == 13 || e.code == "Tab")
|
||||
return;
|
||||
updateSuggestedCommands();
|
||||
});
|
||||
|
||||
$(document).ready((e) => {
|
||||
$(document).keydown((event) => {
|
||||
//escape
|
||||
if ((event.keyCode == 27 && !config.swapEscAndTab) || (event["keyCode"] == 9 && config.swapEscAndTab)) {
|
||||
if (
|
||||
(event.keyCode == 27 && !config.swapEscAndTab) ||
|
||||
(event["keyCode"] == 9 && config.swapEscAndTab)
|
||||
) {
|
||||
event.preventDefault();
|
||||
if (!$("#leaderboardsWrapper").hasClass("hidden")) { //maybe add more condition for closing other dialogs in the future as well
|
||||
if (!$("#leaderboardsWrapper").hasClass("hidden")) {
|
||||
//maybe add more condition for closing other dialogs in the future as well
|
||||
event.preventDefault();
|
||||
hideLeaderboards();
|
||||
return;
|
||||
} else if ($("#commandLineWrapper").hasClass("hidden")) {
|
||||
if (config.singleListCommandLine == "on")
|
||||
if (config.singleListCommandLine == "on")
|
||||
useSingleListCommandLine(false);
|
||||
else
|
||||
currentCommands = [commands];
|
||||
else currentCommands = [commands];
|
||||
showCommandLine();
|
||||
} else {
|
||||
if (currentCommands.length > 1) {
|
||||
|
|
@ -1570,7 +1582,6 @@ $(document).ready((e) => {
|
|||
applyCustomThemeColors();
|
||||
} else {
|
||||
setTheme(config.theme);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1620,7 +1631,7 @@ $("#commandLineWrapper #commandLine .suggestions").on("mouseover", (e) => {
|
|||
});
|
||||
|
||||
$("#commandLineWrapper #commandLine .suggestions").click((e) => {
|
||||
$(".suggestions .entry").removeClass('activeKeyboard');
|
||||
$(".suggestions .entry").removeClass("activeKeyboard");
|
||||
triggerCommand($(e.target).attr("command"));
|
||||
});
|
||||
|
||||
|
|
@ -1646,12 +1657,18 @@ $(document).keydown((e) => {
|
|||
if (!isSingleListCommandLineActive()) {
|
||||
useSingleListCommandLine();
|
||||
return;
|
||||
} else if ($("#commandLine input").val() == ">") { //so that it will ignore succeeding ">" when input is already ">"
|
||||
} else if ($("#commandLine input").val() == ">") {
|
||||
//so that it will ignore succeeding ">" when input is already ">"
|
||||
e.preventDefault();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (e.keyCode == 8 && $("#commandLine input").val().length == 1 && config.singleListCommandLine == "manual" && isSingleListCommandLineActive())
|
||||
if (
|
||||
e.keyCode == 8 &&
|
||||
$("#commandLine input").val().length == 1 &&
|
||||
config.singleListCommandLine == "manual" &&
|
||||
isSingleListCommandLineActive()
|
||||
)
|
||||
restoreOldCommandLine();
|
||||
if (e.keyCode == 13) {
|
||||
//enter
|
||||
|
|
@ -1695,14 +1712,14 @@ $(document).keydown((e) => {
|
|||
let scroll =
|
||||
Math.abs(
|
||||
$(".suggestions").offset().top -
|
||||
$(".entry.activeKeyboard").offset().top -
|
||||
$(".suggestions").scrollTop()
|
||||
$(".entry.activeKeyboard").offset().top -
|
||||
$(".suggestions").scrollTop()
|
||||
) -
|
||||
$(".suggestions").outerHeight() / 2 +
|
||||
$($(".entry")[0]).outerHeight();
|
||||
$(".suggestions").scrollTop(scroll);
|
||||
} catch (e) {
|
||||
console.log('could not scroll suggestions: ' + e.message);
|
||||
console.log("could not scroll suggestions: " + e.message);
|
||||
}
|
||||
// console.log(`scrolling to ${scroll}`);
|
||||
try {
|
||||
|
|
@ -1805,11 +1822,17 @@ function showCommandInput(command, placeholder) {
|
|||
}
|
||||
|
||||
function updateSuggestedCommands() {
|
||||
let inputVal = $("#commandLine input").val().toLowerCase().split(" ").filter((s, i) => s || i == 0); //remove empty entries after first
|
||||
let inputVal = $("#commandLine input")
|
||||
.val()
|
||||
.toLowerCase()
|
||||
.split(" ")
|
||||
.filter((s, i) => s || i == 0); //remove empty entries after first
|
||||
let list = currentCommands[currentCommands.length - 1];
|
||||
if (inputVal[0] === ""
|
||||
&& config.singleListCommandLine === "on"
|
||||
&& currentCommands.length === 1) {
|
||||
if (
|
||||
inputVal[0] === "" &&
|
||||
config.singleListCommandLine === "on" &&
|
||||
currentCommands.length === 1
|
||||
) {
|
||||
$.each(list.list, (index, obj) => {
|
||||
obj.found = false;
|
||||
});
|
||||
|
|
@ -1817,7 +1840,8 @@ function updateSuggestedCommands() {
|
|||
return;
|
||||
}
|
||||
//ignore the preceeding ">"s in the command line input
|
||||
if (inputVal[0] && inputVal[0][0] == ">") inputVal[0] = inputVal[0].replace(/^>+/,'');
|
||||
if (inputVal[0] && inputVal[0][0] == ">")
|
||||
inputVal[0] = inputVal[0].replace(/^>+/, "");
|
||||
if (inputVal[0] == "" && inputVal.length == 1) {
|
||||
$.each(list.list, (index, obj) => {
|
||||
if (obj.visible !== false) obj.found = true;
|
||||
|
|
|
|||
|
|
@ -13,13 +13,13 @@ async function db_getUserSnapshot() {
|
|||
lbMemory: {
|
||||
time15: {
|
||||
global: null,
|
||||
daily: null
|
||||
daily: null,
|
||||
},
|
||||
time60: {
|
||||
global: null,
|
||||
daily: null
|
||||
}
|
||||
}
|
||||
daily: null,
|
||||
},
|
||||
},
|
||||
};
|
||||
// await db.collection('results')
|
||||
// .orderBy('timestamp', 'desc')
|
||||
|
|
@ -74,15 +74,18 @@ async function db_getUserSnapshot() {
|
|||
snap.personalBests = data.personalBests;
|
||||
}
|
||||
snap.discordId = data.discordId;
|
||||
snap.pairingCode = data.discordPairingCode == null ? undefined : data.discordPairingCode;
|
||||
snap.pairingCode =
|
||||
data.discordPairingCode == null
|
||||
? undefined
|
||||
: data.discordPairingCode;
|
||||
snap.config = data.config;
|
||||
snap.favouriteThemes =
|
||||
data.favouriteThemes === undefined ? [] : data.favouriteThemes;
|
||||
snap.globalStats = {
|
||||
time: data.timeTyping,
|
||||
started: data.startedTests,
|
||||
completed: data.completedTests
|
||||
}
|
||||
completed: data.completedTests,
|
||||
};
|
||||
if (data.lbMemory !== undefined) {
|
||||
snap.lbMemory = data.lbMemory;
|
||||
}
|
||||
|
|
@ -241,7 +244,7 @@ async function db_saveLocalPB(
|
|||
acc: acc,
|
||||
raw: raw,
|
||||
timestamp: Date.now(),
|
||||
consistency: consistency
|
||||
consistency: consistency,
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
|
|
@ -256,7 +259,7 @@ async function db_saveLocalPB(
|
|||
acc: acc,
|
||||
raw: raw,
|
||||
timestamp: Date.now(),
|
||||
consistency: consistency
|
||||
consistency: consistency,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,20 +85,20 @@ let currentLanguage = null;
|
|||
async function getLanguage(lang) {
|
||||
try {
|
||||
if (currentLanguage == null || currentLanguage.name !== lang) {
|
||||
console.log('getting language json');
|
||||
console.log("getting language json");
|
||||
await $.getJSON(`languages/${lang}.json`, function (data) {
|
||||
currentLanguage = data;
|
||||
})
|
||||
});
|
||||
}
|
||||
return currentLanguage;
|
||||
} catch (e) {
|
||||
console.error(`error getting language`)
|
||||
console.error(`error getting language`);
|
||||
console.error(e);
|
||||
config.language = "english";
|
||||
showNotification(`Error getting language: ${e.message}`,4000);
|
||||
showNotification(`Error getting language: ${e.message}`, 4000);
|
||||
await $.getJSON(`languages/english.json`, function (data) {
|
||||
currentLanguage = data;
|
||||
})
|
||||
});
|
||||
return currentLanguage;
|
||||
}
|
||||
}
|
||||
|
|
@ -435,14 +435,14 @@ function getPositionString(number) {
|
|||
|
||||
function findGetParameter(parameterName) {
|
||||
var result = null,
|
||||
tmp = [];
|
||||
tmp = [];
|
||||
location.search
|
||||
.substr(1)
|
||||
.split("&")
|
||||
.forEach(function (item) {
|
||||
tmp = item.split("=");
|
||||
if (tmp[0] === parameterName) result = decodeURIComponent(tmp[1]);
|
||||
});
|
||||
.substr(1)
|
||||
.split("&")
|
||||
.forEach(function (item) {
|
||||
tmp = item.split("=");
|
||||
if (tmp[0] === parameterName) result = decodeURIComponent(tmp[1]);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -458,8 +458,12 @@ function objectToQueryString(obj) {
|
|||
function toggleFullscreen(elem) {
|
||||
elem = elem || document.documentElement;
|
||||
|
||||
if (!document.fullscreenElement && !document.mozFullScreenElement &&
|
||||
!document.webkitFullscreenElement && !document.msFullscreenElement) {
|
||||
if (
|
||||
!document.fullscreenElement &&
|
||||
!document.mozFullScreenElement &&
|
||||
!document.webkitFullscreenElement &&
|
||||
!document.msFullscreenElement
|
||||
) {
|
||||
if (elem.requestFullscreen) {
|
||||
elem.requestFullscreen();
|
||||
} else if (elem.msRequestFullscreen) {
|
||||
|
|
@ -480,4 +484,4 @@ function toggleFullscreen(elem) {
|
|||
document.webkitExitFullscreen();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue