mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2026-01-02 21:44:06 +08:00
escaping messages, updated triberesult header,
fixed graphs
This commit is contained in:
parent
3578177c65
commit
50c8835617
4 changed files with 68 additions and 23 deletions
|
|
@ -346,6 +346,10 @@ export function roundTo2(num) {
|
|||
return Math.round((num + Number.EPSILON) * 100) / 100;
|
||||
}
|
||||
|
||||
export function encodeHTML(s) {
|
||||
return s.replace(/&/g, "&").replace(/</g, "<").replace(/"/g, """);
|
||||
}
|
||||
|
||||
export function getNumberSuffix(num) {
|
||||
var j = num % 10,
|
||||
k = num % 100;
|
||||
|
|
|
|||
|
|
@ -531,15 +531,16 @@ function drawMinigraph(sid, result) {
|
|||
|
||||
fillGraphDataAndUpdate(graph, result, sid);
|
||||
|
||||
graphs.push(graph);
|
||||
return graph;
|
||||
}
|
||||
|
||||
function destroyAllGraphs(graphs) {
|
||||
while (graphs.length > 0) {
|
||||
let g = graphs.pop();
|
||||
g.clear();
|
||||
g.destroy();
|
||||
}
|
||||
function destroyAllGraphs() {
|
||||
Object.keys(MP.room.userGraphs).forEach((sid) => {
|
||||
let userGraph = MP.room.userGraphs[sid];
|
||||
userGraph.graph.clear();
|
||||
userGraph.graph.destroy();
|
||||
delete MP.room.userGraphs[sid];
|
||||
});
|
||||
}
|
||||
|
||||
MP.socket.on("connect", (f) => {
|
||||
|
|
@ -775,8 +776,9 @@ MP.socket.on("mp_room_finishTimer_over", (data) => {
|
|||
|
||||
MP.socket.on("mp_room_test_init", (data) => {
|
||||
mp_playSound("start");
|
||||
MP.room.testStats = {};
|
||||
destroyAllGraphs(graphs);
|
||||
MP.room.userGraphs = {};
|
||||
MP.room.userFinished = false;
|
||||
destroyAllGraphs();
|
||||
seedrandom(data.seed, { global: true });
|
||||
mp_refreshTestUserList();
|
||||
changePage("");
|
||||
|
|
@ -873,16 +875,43 @@ MP.socket.on("mp_room_user_finished", (data) => {
|
|||
$(`.tribePlayers .player[socketId=${data.socketId}]`).addClass("failed");
|
||||
$(`.tribeResult .player[socketId=${data.socketId}]`).addClass("failed");
|
||||
}
|
||||
$(`.tribeResult table .player[socketId=${data.socketId}] .progress`),
|
||||
swapElements(
|
||||
$(`.tribeResult table .player[socketId=${data.socketId}] .progress`),
|
||||
$(`.tribeResult table .player[socketId=${data.socketId}] .graph`),
|
||||
125,
|
||||
() => {
|
||||
drawMinigraph(data.socketId, data.result);
|
||||
// $(`.tribeResult table .player[socketId=${data.socketId}] .graph`).css('opacity',0).animate({opacity:1},125);
|
||||
}
|
||||
);
|
||||
|
||||
MP.room.userGraphs[data.socketId] = {
|
||||
data: data.result,
|
||||
};
|
||||
|
||||
swapElements(
|
||||
$(`.tribeResult table .player[socketId=${data.socketId}] .progress`),
|
||||
$(`.tribeResult table .player[socketId=${data.socketId}] .graph`),
|
||||
125
|
||||
);
|
||||
|
||||
setTimeout(() => {
|
||||
if (data.socketId === MP.socket.id) {
|
||||
MP.room.userFinished = true;
|
||||
|
||||
Object.keys(MP.room.userGraphs).forEach((sid) => {
|
||||
let userGraph = MP.room.userGraphs[sid];
|
||||
userGraph.graph = drawMinigraph(sid, userGraph.data);
|
||||
});
|
||||
} else if (MP.room.userFinished) {
|
||||
MP.room.userGraphs[data.socketId].graph = drawMinigraph(
|
||||
data.socketId,
|
||||
data.result
|
||||
);
|
||||
}
|
||||
}, 250);
|
||||
|
||||
// $(`.tribeResult table .player[socketId=${data.socketId}] .progress`),
|
||||
// swapElements(
|
||||
// $(`.tribeResult table .player[socketId=${data.socketId}] .progress`),
|
||||
// $(`.tribeResult table .player[socketId=${data.socketId}] .graph`),
|
||||
// 125,
|
||||
// () => {
|
||||
// drawMinigraph(data.socketId, data.result);
|
||||
// // $(`.tribeResult table .player[socketId=${data.socketId}] .graph`).css('opacity',0).animate({opacity:1},125);
|
||||
// }
|
||||
// );
|
||||
|
||||
if (config.mode !== "time" && !data.result.failed && !data.result.afk) {
|
||||
$(`.tribePlayers .player[socketId=${data.socketId}] .bar`)
|
||||
|
|
@ -997,6 +1026,7 @@ $(".pageTribe #createPrivateRoom").click((f) => {
|
|||
$(".pageTest #result .tribeResultChat .chat .input input").keyup((e) => {
|
||||
if (e.keyCode === 13) {
|
||||
let msg = $(".pageTest #result .tribeResultChat .chat .input input").val();
|
||||
msg = Misc.encodeHTML(msg);
|
||||
if (msg === "") return;
|
||||
if (msg.length > 512) {
|
||||
Notifications.add("Message cannot be longer than 512 characters.", 0);
|
||||
|
|
@ -1018,6 +1048,7 @@ $(".pageTest #result .tribeResultChat .chat .input input").keyup((e) => {
|
|||
$(".pageTribe .lobby .chat .input input").keyup((e) => {
|
||||
if (e.keyCode === 13) {
|
||||
let msg = $(".pageTribe .lobby .chat .input input").val();
|
||||
msg = Misc.encodeHTML(msg);
|
||||
if (msg === "") return;
|
||||
MP.socket.emit("mp_chat_message", {
|
||||
isSystem: false,
|
||||
|
|
|
|||
|
|
@ -1577,6 +1577,9 @@ key {
|
|||
thead {
|
||||
color: var(--sub-color);
|
||||
font-size: 0.75rem;
|
||||
span {
|
||||
opacity: 0.5;
|
||||
}
|
||||
}
|
||||
td {
|
||||
text-align: right;
|
||||
|
|
@ -1626,7 +1629,10 @@ key {
|
|||
width: 4rem;
|
||||
.num {
|
||||
// margin-right: 0.5rem;
|
||||
font-size: 1.4rem;
|
||||
display: block;
|
||||
line-height: 1.4rem;
|
||||
margin-top: 0.4rem;
|
||||
}
|
||||
.points {
|
||||
opacity: 0.5;
|
||||
|
|
|
|||
|
|
@ -1254,22 +1254,26 @@
|
|||
<thead>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>pos</td>
|
||||
<td>
|
||||
pos
|
||||
<br />
|
||||
<span>points</span>
|
||||
</td>
|
||||
<td></td>
|
||||
<td>
|
||||
wpm
|
||||
<br />
|
||||
acc
|
||||
<span>accuracy</span>
|
||||
</td>
|
||||
<td>
|
||||
raw
|
||||
<br />
|
||||
consistency
|
||||
<span>consistency</span>
|
||||
</td>
|
||||
<td>
|
||||
characters
|
||||
<br />
|
||||
other
|
||||
<span>other</span>
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue