Skip to content
Merged

Dev #80

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .weblate
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[weblate]
url = https://hosted.weblate.org/api/
translation = multiplayerpiano/frontend
2 changes: 1 addition & 1 deletion client/locales/sv/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"Ask bots not to index this room": "Ingen index",
"Inner color:": "Inre färg:",
"Outer color:": "Yttre färg:",
"Player limit:": "Spelargräns lol",
"Player limit:": "Spelargräns:",
"APPLY": "TILLÄMPA",
"My Fancy New Name": "Mitt Fina Nya Namn",
"USER SET": "ANGE",
Expand Down
2 changes: 1 addition & 1 deletion client/screen.css
Original file line number Diff line number Diff line change
Expand Up @@ -1407,7 +1407,7 @@ input[type="range"]:hover {
z-index: 900;
}

.participant-menu {
.participant-menu, .top {
z-index: 1000;
}

Expand Down
68 changes: 50 additions & 18 deletions client/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -1264,7 +1264,7 @@ $(function() {
"This site makes a lot of sound! You may want to adjust the volume before continuing.";
document.getElementById("motd-text").innerHTML = msg.motd;
openModal("#motd");
$(document).off("keydown", modalHandleEsc);
$(document).on("keydown", modalHandleEsc);
var user_interact = function(evt) {
if (
(evt.path || (evt.composedPath && evt.composedPath())).includes(
Expand Down Expand Up @@ -1835,6 +1835,7 @@ $(function() {
var gHideChat = localStorage.hideChat == "true";
var gNoPreventDefault = localStorage.noPreventDefault == "true";
var gHideBotUsers = localStorage.hideBotUsers == "true";
var gCancelDMs = localStorage.cancelDMs == "true";
var gSnowflakes =
new Date().getMonth() === 11 && localStorage.snowflakes !== "false";

Expand Down Expand Up @@ -2247,20 +2248,39 @@ $(function() {
gClient.on("participant removed", (part) => {
if (gIsDming && part._id === gDmParticipant._id) {
chat.endDM();
chat.endDM();
}
if (!gCancelDMs) {
new Notification({title: 'DM Cancelled',
html: gHasSeenDMWarning ?
`Your message is still in the chat input field, but will send as a public message.<br/>
You can disable this in Client Settings.`
: `Your message is still in the chatbox, but it will send as a public message.<br/>
You can disable this in Client Settings.<br/>
Enabling "Cancel DMs when recipient leaves" will clear your message from the text input<br/>
and unfocus the textbox when the person you're typing to leaves the channel.`,
target: "#room",
duration: 20000,
class: "top"
});
if (!localStorage.hasSeenDMWarning) gHasSeenDMWarning = true; localStorage.hasSeenDMWarning = true;
$("#chat-input").blur();
}
if (gCancelDMs) {
chat.blur();
$("#chat input").value = "";
new Notification({title: "DM Cancelled",
text: `${part.name} left the room.`,
target: "#room",
duration: 10000
});
}
}
});

//Replies

var gReplyParticipant;
var gIsReplying = false;
var gMessageId;
gClient.on(`participant removed`, (part) => {
if (gIsReplying && part._id === gReplyParticipant._id) {
MPP.chat.cancelReply();
}
});

// click participant names
(function() {
Expand Down Expand Up @@ -2805,7 +2825,8 @@ $(function() {
$("#room .more").fadeOut(250);
var selected_name = $(evt.target).attr("roomname");
if (typeof selected_name != "undefined") {
changeRoom(selected_name, "right");
if (!evt.ctrlKey) changeRoom(selected_name, "right");
else window.open(`?c=${selected_name}`)
}
return false;
}
Expand Down Expand Up @@ -2861,7 +2882,7 @@ $(function() {
if (gClient.accountInfo.type === "discord") {
$("#account #avatar-image").prop("src", gClient.accountInfo.avatar);
$("#account #logged-in-user-text").text(
"@" + gClient.accountInfo.username
`@${gClient.accountInfo.username}`
);
}
} else {
Expand All @@ -2872,7 +2893,7 @@ $(function() {
var gModal;

function modalHandleEsc(evt) {
if (evt.keyCode == 27) {
if (evt.keyCode == 27 || (evt.keyCode == 32 || evt.keyCode == 13) && document.activeElement.type !== "text") {
closeModal();
if (!gNoPreventDefault) evt.preventDefault();
evt.stopPropagation();
Expand Down Expand Up @@ -3258,7 +3279,7 @@ $(function() {
chat.endDM();
}
if (gIsReplying) {
chat.cancelReply();
chat.cancelReply(part);
}
setTimeout(function() {
chat.blur();
Expand Down Expand Up @@ -3344,15 +3365,14 @@ $(function() {
$("#chat-input")[0].placeholder = `Replying to ${part.name} in a DM.`;
},

cancelReply: function() {
if (gIsDming) gIsDming = false;
cancelReply: function(part) {
gIsReplying = false;
$(`#msg-${gMessageId}`).css({
"background-color": "unset",
border: "1px solid #00000000",
});
$("#chat-input")[0].placeholder = window.i18nextify.i18next.t(
`You can chat with this thing.`,
(gIsDming ? `Direct messaging ${part.name}` : `You can chat with this thing.`),
);
},

Expand Down Expand Up @@ -3394,7 +3414,7 @@ $(function() {
},
]);
setTimeout(() => {
MPP.chat.cancelReply();
MPP.chat.cancelReply(gReplyParticipant);
}, 100);
} else {
gClient.sendArray([
Expand All @@ -3406,7 +3426,7 @@ $(function() {
},
]);
setTimeout(() => {
MPP.chat.cancelReply();
MPP.chat.cancelReply(gReplyParticipant);
}, 100);
}
} else {
Expand Down Expand Up @@ -4782,7 +4802,7 @@ $(function() {
"hide-chat",
"Hide chat",
gHideChat,
false,
true,
html,
() => {
gHideChat = !gHideChat;
Expand All @@ -4796,6 +4816,18 @@ $(function() {
},
);

createSetting(
"cancel-dms",
"Cancel DMs when recipient leaves",
gCancelDMs,
false,
html,
() => {
gCancelDMs = !gCancelDMs;
localStorage.cancelDMs = gCancelDMs;
},
);

content.appendChild(html);
break;

Expand Down
9 changes: 8 additions & 1 deletion docs/protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,7 @@ This is sent when a client sends a [custom](#custom-server-bound) message.
#### Properties
- `"data"`: The data sent in this custom message. Can be any valid JSON.
- `"p"`: The user id of the client who sent this custom message.
- `"u"`: The full user info of the client who sent this custom message.
#### Example
```json
{
Expand All @@ -823,7 +824,13 @@ This is sent when a client sends a [custom](#custom-server-bound) message.
"hello",
"how are you"
],
"p":"1dbe9eb24f0f4668cc72ac79"
"p":"e597eb458dd0da2b05edb1b1",
"u":{
"afk": false,
"color": "#4ac0e8",
"name": "cheezburger0",
"_id": "e597eb458dd0da2b05edb1b1"
}
}
```

Expand Down