Skip to content
Merged
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
19 changes: 17 additions & 2 deletions chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,9 @@ function updateGameChatMessageVisibility() {
}
}

function chatInputActionFired() {
async function chatInputActionFired() {
if (!await ensurePlayerConfirmedChatAgeWarning()) return;

const chatInput = document.getElementById("chatInput");
if (!chatInput?.value.trim().length)
return;
Expand Down Expand Up @@ -563,7 +565,7 @@ function initChat() {
document.getSelection().collapseToEnd();
};
gameChatInput.onblur = () => gameChatContainer.classList.remove('focused');
gameChatInput.onkeydown = function (e) {
gameChatInput.onkeydown = async function (e) {
if (e.key === 'Tab') {
e.preventDefault();
cycleGameChatMode();
Expand All @@ -576,6 +578,7 @@ function initChat() {
e.preventDefault();
if (!playerName)
return;
if (!await ensurePlayerConfirmedChatAgeWarning()) return;
switch (gameChatModeIndex) {
case 0:
if (!trySendMapMessage(chatMessageContent))
Expand Down Expand Up @@ -654,6 +657,18 @@ function trySendGlobalMessage(content) {
return false;
}

async function ensurePlayerConfirmedChatAgeWarning() {
if (globalConfig.chatAgeWarningConfirmed) return true;

return new Promise(resolve => {
showConfirmLikeModal('chatAgeWarningModal', () => {
resolve(true);
globalConfig.chatAgeWarningConfirmed = true;
updateConfig(globalConfig, true);
}, () => resolve(false));
})
}

function addChatTip() {
const tips = localizedMessages.chatTips.tips;
if (++globalConfig.chatTipIndex >= Object.keys(tips).length)
Expand Down
29 changes: 27 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -1755,6 +1755,7 @@ class="joystickBase" />
<a href="javascript:void(0);" class="modalClose">✖</a>
<div class="modalHeader">
<h1 class="modalTitle" data-i18n="[html]modal.report.title">Report</h1>
<h3 class="modalSubtitle" data-i18n="[html]modal.report.subtitle">Please create reports responsibly. Repeated frivolous reports will be penalized.</h3>
</div>
<div class="modalContent">
<ul class="formControls" style="width:100%">
Expand Down Expand Up @@ -2201,6 +2202,30 @@ class="joystickBase" />
<div class="modalOverlay"></div>
</div>
<div id="modalFadeOutContainer" class="modalContainer"></div>
<div class="modalContainer hidden">
<div id="chatAgeWarningModal" class="modal hidden">
<a href="javascript:void(0);" class="modalClose">✖</a>
<div class="modalHeader">
<h1 class="modalTitle" data-i18n="[html]modal.chatAgeWarning.title">Before you chat...</h1>
</div>
<div class="modalContent chatRulesInfo">
<p data-i18n="[html]modal.chatAgeWarning.1">
Game chat is reserved for players of ages 16 and older.
</p>
<p data-i18n="[html]modal.chatAgeWarning.2">
By participating in the chat, you confirm that you are 16 or older.
</p>
<p data-i18n="[html]modal.chatAgeWarning.3">
Players found to be in violation of this rule are subject to moderation actions, up to and including permanent bans from multiplayer interactions.
</p>
</div>
<div class="modalFooter">
<button class="jsConfirm unselectable" type="button" data-i18n="[html]modal.chatAgeWarning.ok">Confirm</button>
<button class="jsCancel unselectable" type="button" data-i18n="[html]modal.chatAgeWarning.cancel">Do not participate in chat</button>
</div>
</div>
<div class="modalOverlay"></div>
</div>
<div id="confirmModalContainer" class="confirmModalContainer modalContainer hidden">
<div id="confirmModal" class="confirmModal modal hidden">
<a href="javascript:void(0);" class="modalClose">✖</a>
Expand All @@ -2210,8 +2235,8 @@ class="joystickBase" />
</div>
</div>
<div class="modalFooter">
<button class="confirmOkButton unselectable" type="button" data-i18n="[html]modal.confirm.ok">Ok</button>
<button class="confirmCancelButton unselectable" type="button" data-i18n="[html]modal.confirm.cancel">Cancel</button>
<button class="jsConfirm confirmOkButton unselectable" type="button" data-i18n="[html]modal.confirm.ok">Ok</button>
<button class="jsCancel confirmCancelButton unselectable" type="button" data-i18n="[html]modal.confirm.cancel">Cancel</button>
</div>
</div>
<div class="modalOverlay"></div>
Expand Down
11 changes: 10 additions & 1 deletion lang/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,8 @@
"placeholder": "Custom reason (max 50 characters)",
"other": "Other (specify)"
}
}
},
"subtitle": "Please create reports responsibly. Repeated frivolous reports will be penalized."
},
"rules": {
"title": "القواعد",
Expand Down Expand Up @@ -619,6 +620,14 @@
}
}
}
},
"chatAgeWarning": {
"1": "Game chat is reserved for players of ages 16 and older.",
"2": "By participating in the chat, you confirm that you are 16 or older.",
"3": "Players found to be in violation of this rule are subject to moderation actions, up to and including permanent bans from multiplayer interactions.",
"title": "Before you chat...",
"ok": "Confirm",
"cancel": "Do not participate in chat"
}
},
"tooltips": {
Expand Down
11 changes: 10 additions & 1 deletion lang/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,8 @@
"placeholder": "Sonstiger Grund (maximal 50 Zeichen)",
"other": "Sonstiges (begründen)"
}
}
},
"subtitle": "Please create reports responsibly. Repeated frivolous reports will be penalized."
},
"rules": {
"title": "Regeln",
Expand Down Expand Up @@ -619,6 +620,14 @@
}
}
}
},
"chatAgeWarning": {
"1": "Game chat is reserved for players of ages 16 and older.",
"2": "By participating in the chat, you confirm that you are 16 or older.",
"3": "Players found to be in violation of this rule are subject to moderation actions, up to and including permanent bans from multiplayer interactions.",
"title": "Before you chat...",
"ok": "Confirm",
"cancel": "Do not participate in chat"
}
},
"tooltips": {
Expand Down
9 changes: 9 additions & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,7 @@
},
"report": {
"title": "Report",
"subtitle": "Please create reports responsibly. Repeated frivolous reports will be penalized.",
"submit": "Submit",
"fields": {
"reason": {
Expand Down Expand Up @@ -619,6 +620,14 @@
}
}
}
},
"chatAgeWarning": {
"1": "Game chat is reserved for players of ages 16 and older.",
"2": "By participating in the chat, you confirm that you are 16 or older.",
"3": "Players found to be in violation of this rule are subject to moderation actions, up to and including permanent bans from multiplayer interactions.",
"title": "Before you chat...",
"ok": "Confirm",
"cancel": "Do not participate in chat"
}
},
"tooltips": {
Expand Down
11 changes: 10 additions & 1 deletion lang/eo.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,8 @@
"placeholder": "Custom reason (max 50 characters)",
"other": "Other (specify)"
}
}
},
"subtitle": "Please create reports responsibly. Repeated frivolous reports will be penalized."
},
"rules": {
"title": "Reguloj",
Expand Down Expand Up @@ -619,6 +620,14 @@
}
}
}
},
"chatAgeWarning": {
"1": "Game chat is reserved for players of ages 16 and older.",
"2": "By participating in the chat, you confirm that you are 16 or older.",
"3": "Players found to be in violation of this rule are subject to moderation actions, up to and including permanent bans from multiplayer interactions.",
"title": "Before you chat...",
"ok": "Confirm",
"cancel": "Do not participate in chat"
}
},
"tooltips": {
Expand Down
11 changes: 10 additions & 1 deletion lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,8 @@
"placeholder": "Razón Personalizada (máximo 50 caracteres)",
"other": "Otra (especificar)"
}
}
},
"subtitle": "Please create reports responsibly. Repeated frivolous reports will be penalized."
},
"rules": {
"title": "Reglas",
Expand Down Expand Up @@ -619,6 +620,14 @@
}
}
}
},
"chatAgeWarning": {
"1": "Game chat is reserved for players of ages 16 and older.",
"2": "By participating in the chat, you confirm that you are 16 or older.",
"3": "Players found to be in violation of this rule are subject to moderation actions, up to and including permanent bans from multiplayer interactions.",
"title": "Before you chat...",
"ok": "Confirm",
"cancel": "Do not participate in chat"
}
},
"tooltips": {
Expand Down
11 changes: 10 additions & 1 deletion lang/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,8 @@
"placeholder": "Raison personnalisée (maximum 50 caractères)",
"other": "Autre (spécifier)"
}
}
},
"subtitle": "Please create reports responsibly. Repeated frivolous reports will be penalized."
},
"rules": {
"title": "Règles",
Expand Down Expand Up @@ -619,6 +620,14 @@
}
}
}
},
"chatAgeWarning": {
"1": "Game chat is reserved for players of ages 16 and older.",
"2": "By participating in the chat, you confirm that you are 16 or older.",
"3": "Players found to be in violation of this rule are subject to moderation actions, up to and including permanent bans from multiplayer interactions.",
"title": "Before you chat...",
"ok": "Confirm",
"cancel": "Do not participate in chat"
}
},
"tooltips": {
Expand Down
11 changes: 10 additions & 1 deletion lang/id.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,8 @@
"placeholder": "Custom reason (max 50 characters)",
"other": "Other (specify)"
}
}
},
"subtitle": "Please create reports responsibly. Repeated frivolous reports will be penalized."
},
"rules": {
"title": "Rules",
Expand Down Expand Up @@ -619,6 +620,14 @@
}
}
}
},
"chatAgeWarning": {
"1": "Game chat is reserved for players of ages 16 and older.",
"2": "By participating in the chat, you confirm that you are 16 or older.",
"3": "Players found to be in violation of this rule are subject to moderation actions, up to and including permanent bans from multiplayer interactions.",
"title": "Before you chat...",
"ok": "Confirm",
"cancel": "Do not participate in chat"
}
},
"tooltips": {
Expand Down
11 changes: 10 additions & 1 deletion lang/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,8 @@
"placeholder": "Custom reason (max 50 characters)",
"other": "Other (specify)"
}
}
},
"subtitle": "Please create reports responsibly. Repeated frivolous reports will be penalized."
},
"rules": {
"title": "Regole",
Expand Down Expand Up @@ -619,6 +620,14 @@
}
}
}
},
"chatAgeWarning": {
"1": "Game chat is reserved for players of ages 16 and older.",
"2": "By participating in the chat, you confirm that you are 16 or older.",
"3": "Players found to be in violation of this rule are subject to moderation actions, up to and including permanent bans from multiplayer interactions.",
"title": "Before you chat...",
"ok": "Confirm",
"cancel": "Do not participate in chat"
}
},
"tooltips": {
Expand Down
13 changes: 11 additions & 2 deletions lang/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,8 @@
"placeholder": "任意の理由を記入してください",
"other": "その他 (任意記入)"
}
}
},
"subtitle": "Please create reports responsibly. Repeated frivolous reports will be penalized."
},
"rules": {
"title": "ルール",
Expand Down Expand Up @@ -619,6 +620,14 @@
}
}
}
},
"chatAgeWarning": {
"1": "Game chat is reserved for players of ages 16 and older.",
"2": "By participating in the chat, you confirm that you are 16 or older.",
"3": "Players found to be in violation of this rule are subject to moderation actions, up to and including permanent bans from multiplayer interactions.",
"title": "Before you chat...",
"ok": "Confirm",
"cancel": "Do not participate in chat"
}
},
"tooltips": {
Expand Down Expand Up @@ -1251,4 +1260,4 @@
}
}
}
}
}
11 changes: 10 additions & 1 deletion lang/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,8 @@
"placeholder": "50자 한도 내로 상세히 서술하여 주십시오.",
"other": "기타 (직접 작성)"
}
}
},
"subtitle": "Please create reports responsibly. Repeated frivolous reports will be penalized."
},
"rules": {
"title": "규칙",
Expand Down Expand Up @@ -619,6 +620,14 @@
}
}
}
},
"chatAgeWarning": {
"1": "Game chat is reserved for players of ages 16 and older.",
"2": "By participating in the chat, you confirm that you are 16 or older.",
"3": "Players found to be in violation of this rule are subject to moderation actions, up to and including permanent bans from multiplayer interactions.",
"title": "Before you chat...",
"ok": "Confirm",
"cancel": "Do not participate in chat"
}
},
"tooltips": {
Expand Down
11 changes: 10 additions & 1 deletion lang/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,8 @@
"placeholder": "Custom reason (max 50 characters)",
"other": "Other (specify)"
}
}
},
"subtitle": "Please create reports responsibly. Repeated frivolous reports will be penalized."
},
"rules": {
"title": "Zasady",
Expand Down Expand Up @@ -619,6 +620,14 @@
}
}
}
},
"chatAgeWarning": {
"1": "Game chat is reserved for players of ages 16 and older.",
"2": "By participating in the chat, you confirm that you are 16 or older.",
"3": "Players found to be in violation of this rule are subject to moderation actions, up to and including permanent bans from multiplayer interactions.",
"title": "Before you chat...",
"ok": "Confirm",
"cancel": "Do not participate in chat"
}
},
"tooltips": {
Expand Down
Loading
Loading