mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-11-07 11:30:24 +08:00
Merge branch 'master' of https://github.com/Miodec/monkeytype into mongo
This commit is contained in:
commit
2632a38251
3 changed files with 128 additions and 115 deletions
3
.github/pull_request_template.md
vendored
3
.github/pull_request_template.md
vendored
|
|
@ -8,8 +8,7 @@ If your change is visual (mainly themes) it would be extra awesome if you could
|
|||
|
||||
### Checklist <!-- please check the items you have completed -->
|
||||
|
||||
- [] I have read the [`Code Of Conduct`](/CODE_OF_CONDUCT.md)
|
||||
- [] I viewed the [`Contributing file`](/CONTRIBUTING.md)
|
||||
- [] I have read the [`CODE_OF_CONDUCT.md`](https://github.com/Miodec/monkeytype/blob/master/CODE_OF_CONDUCT.md) and the [`CONTRIBUTING.md`](https://github.com/Miodec/monkeytype/blob/master/CONTRIBUTING.md)
|
||||
- [] If my PR is a new language or theme I modified the appropriate files to incorporate the language or theme
|
||||
- [] I checked if my PR has any bugs or other issues that could reduce the stability of the project
|
||||
- [] I understand that the maintainer has the right to reject my PR and it may not get accepted.
|
||||
|
|
|
|||
|
|
@ -335,5 +335,15 @@ const layouts = {
|
|||
" "
|
||||
],
|
||||
},
|
||||
engram: {
|
||||
keymapShowTopRow: true,
|
||||
keys: [
|
||||
"[{", "1|", "2=", "3~", "4+", "5<", "6>", "7^", "8&", "9%", "0*", "]}", "/\\",
|
||||
"bB", "yY", "oO", "uU", "'(", "\")", "lL", "dD", "wW", "vV", "zZ", "#$", "@`",
|
||||
"cC", "iI", "eE", "aA", ",;", ".:", "hH", "tT", "sS", "nN", "qQ",
|
||||
"\\|", "gG", "xX", "jJ", "kK", "-_", "?!", "rR", "mM", "fF", "pP",
|
||||
" "
|
||||
]
|
||||
}
|
||||
}
|
||||
export default layouts;
|
||||
|
|
|
|||
|
|
@ -1561,121 +1561,125 @@ export function finish(difficultyFailed = false) {
|
|||
`checking <i class="fas fa-spin fa-fw fa-circle-notch"></i>`
|
||||
);
|
||||
}
|
||||
axiosInstance
|
||||
.post("/api/testCompleted", {
|
||||
obj: completedEvent,
|
||||
})
|
||||
.then((e) => {
|
||||
e = e.data;
|
||||
//return a result message that will be shown if there was an error
|
||||
AccountButton.loading(false);
|
||||
if (e.data == null) {
|
||||
Notifications.add(
|
||||
"Unexpected response from the server: " + e.data,
|
||||
-1
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (e.data.resultCode === -1) {
|
||||
Notifications.add("Could not save result", -1);
|
||||
} else if (e.data.resultCode === -2) {
|
||||
Notifications.add(
|
||||
"Possible bot detected. Result not saved.",
|
||||
-1
|
||||
);
|
||||
} else if (e.data.resultCode === -3) {
|
||||
Notifications.add(
|
||||
"Could not verify keypress stats. Result not saved.",
|
||||
-1
|
||||
);
|
||||
} else if (e.data.resultCode === -4) {
|
||||
Notifications.add(
|
||||
"Result data does not make sense. Result not saved.",
|
||||
-1
|
||||
);
|
||||
} else if (e.data.resultCode === -5) {
|
||||
Notifications.add("Test too short. Result not saved.", -1);
|
||||
} else if (e.data.resultCode === -999) {
|
||||
console.error("internal error: " + e.data.message);
|
||||
Notifications.add(
|
||||
"Internal error. Result might not be saved. " +
|
||||
e.data.message,
|
||||
-1
|
||||
);
|
||||
} else if (e.data.resultCode === 1 || e.data.resultCode === 2) {
|
||||
completedEvent.id = e.data.createdId;
|
||||
TestLeaderboards.check(completedEvent);
|
||||
if (e.data.resultCode === 2) {
|
||||
completedEvent.isPb = true;
|
||||
}
|
||||
if (
|
||||
DB.getSnapshot() !== null &&
|
||||
DB.getSnapshot().results !== undefined
|
||||
) {
|
||||
DB.getSnapshot().results.unshift(completedEvent);
|
||||
if (DB.getSnapshot().globalStats.time == undefined) {
|
||||
DB.getSnapshot().globalStats.time =
|
||||
testtime +
|
||||
completedEvent.incompleteTestSeconds -
|
||||
afkseconds;
|
||||
} else {
|
||||
DB.getSnapshot().globalStats.time +=
|
||||
testtime +
|
||||
completedEvent.incompleteTestSeconds -
|
||||
afkseconds;
|
||||
}
|
||||
if (DB.getSnapshot().globalStats.started == undefined) {
|
||||
DB.getSnapshot().globalStats.started =
|
||||
TestStats.restartCount + 1;
|
||||
} else {
|
||||
DB.getSnapshot().globalStats.started +=
|
||||
TestStats.restartCount + 1;
|
||||
}
|
||||
if (DB.getSnapshot().globalStats.completed == undefined) {
|
||||
DB.getSnapshot().globalStats.completed = 1;
|
||||
} else {
|
||||
DB.getSnapshot().globalStats.completed += 1;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
firebase
|
||||
.analytics()
|
||||
.logEvent("testCompleted", completedEvent);
|
||||
} catch (e) {
|
||||
console.log("Analytics unavailable");
|
||||
}
|
||||
|
||||
if (e.data.resultCode === 2) {
|
||||
//new pb
|
||||
PbCrown.show();
|
||||
DB.saveLocalPB(
|
||||
Config.mode,
|
||||
mode2,
|
||||
Config.punctuation,
|
||||
Config.language,
|
||||
Config.difficulty,
|
||||
stats.wpm,
|
||||
stats.acc,
|
||||
stats.wpmRaw,
|
||||
consistency
|
||||
if (!window.navigator.onLine) {
|
||||
Notifications.add("You are offline. Result not saved.", -1);
|
||||
} else {
|
||||
axiosInstance
|
||||
.post("/api/testCompleted", {
|
||||
obj: completedEvent,
|
||||
})
|
||||
.then((e) => {
|
||||
AccountButton.loading(false);
|
||||
if (e.data == null) {
|
||||
Notifications.add(
|
||||
"Unexpected response from the server: " + e.data,
|
||||
-1
|
||||
);
|
||||
} else if (e.data.resultCode === 1) {
|
||||
PbCrown.hide();
|
||||
// if (localPb) {
|
||||
// Notifications.add(
|
||||
// "Local PB data is out of sync! Refresh the page to resync it or contact Miodec on Discord.",
|
||||
// 15000
|
||||
// );
|
||||
// }
|
||||
return;
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
AccountButton.loading(false);
|
||||
console.error(e);
|
||||
Notifications.add("Could not save result. " + e, -1);
|
||||
});
|
||||
if (e.data.resultCode === -1) {
|
||||
Notifications.add("Could not save result", -1);
|
||||
} else if (e.data.resultCode === -2) {
|
||||
Notifications.add(
|
||||
"Possible bot detected. Result not saved.",
|
||||
-1
|
||||
);
|
||||
} else if (e.data.resultCode === -3) {
|
||||
Notifications.add(
|
||||
"Could not verify keypress stats. Result not saved.",
|
||||
-1
|
||||
);
|
||||
} else if (e.data.resultCode === -4) {
|
||||
Notifications.add(
|
||||
"Result data does not make sense. Result not saved.",
|
||||
-1
|
||||
);
|
||||
} else if (e.data.resultCode === -5) {
|
||||
Notifications.add("Test too short. Result not saved.", -1);
|
||||
} else if (e.data.resultCode === -999) {
|
||||
console.error("internal error: " + e.data.message);
|
||||
Notifications.add(
|
||||
"Internal error. Result might not be saved. " +
|
||||
e.data.message,
|
||||
-1
|
||||
);
|
||||
} else if (
|
||||
e.data.resultCode === 1 ||
|
||||
e.data.resultCode === 2
|
||||
) {
|
||||
completedEvent.id = e.data.createdId;
|
||||
TestLeaderboards.check(completedEvent);
|
||||
if (e.data.resultCode === 2) {
|
||||
completedEvent.isPb = true;
|
||||
}
|
||||
if (
|
||||
DB.getSnapshot() !== null &&
|
||||
DB.getSnapshot().results !== undefined
|
||||
) {
|
||||
DB.getSnapshot().results.unshift(completedEvent);
|
||||
if (DB.getSnapshot().globalStats.time == undefined) {
|
||||
DB.getSnapshot().globalStats.time =
|
||||
testtime +
|
||||
completedEvent.incompleteTestSeconds -
|
||||
afkseconds;
|
||||
} else {
|
||||
DB.getSnapshot().globalStats.time +=
|
||||
testtime +
|
||||
completedEvent.incompleteTestSeconds -
|
||||
afkseconds;
|
||||
}
|
||||
if (DB.getSnapshot().globalStats.started == undefined) {
|
||||
DB.getSnapshot().globalStats.started =
|
||||
TestStats.restartCount + 1;
|
||||
} else {
|
||||
DB.getSnapshot().globalStats.started +=
|
||||
TestStats.restartCount + 1;
|
||||
}
|
||||
if (DB.getSnapshot().globalStats.completed == undefined) {
|
||||
DB.getSnapshot().globalStats.completed = 1;
|
||||
} else {
|
||||
DB.getSnapshot().globalStats.completed += 1;
|
||||
}
|
||||
}
|
||||
try {
|
||||
firebase
|
||||
.analytics()
|
||||
.logEvent("testCompleted", completedEvent);
|
||||
} catch (e) {
|
||||
console.log("Analytics unavailable");
|
||||
}
|
||||
|
||||
if (e.data.resultCode === 2) {
|
||||
//new pb
|
||||
PbCrown.show();
|
||||
DB.saveLocalPB(
|
||||
Config.mode,
|
||||
mode2,
|
||||
Config.punctuation,
|
||||
Config.language,
|
||||
Config.difficulty,
|
||||
stats.wpm,
|
||||
stats.acc,
|
||||
stats.wpmRaw,
|
||||
consistency
|
||||
);
|
||||
} else if (e.data.resultCode === 1) {
|
||||
PbCrown.hide();
|
||||
// if (localPb) {
|
||||
// Notifications.add(
|
||||
// "Local PB data is out of sync! Refresh the page to resync it or contact Miodec on Discord.",
|
||||
// 15000
|
||||
// );
|
||||
// }
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
AccountButton.loading(false);
|
||||
console.error(e);
|
||||
Notifications.add("Could not save result. " + e, -1);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue