mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-12-28 19:08:32 +08:00
moved tribe files to a new directory
renamed mm status to matchmaking moved some code into a function
This commit is contained in:
parent
0963a46917
commit
da626a4ea0
5 changed files with 60 additions and 46 deletions
|
|
@ -92,9 +92,6 @@ const refactoredSrc = [
|
|||
"./src/js/misc.js",
|
||||
"./src/js/layouts.js",
|
||||
"./src/js/input-suggestions.js",
|
||||
"./src/js/tribe-mm-status.js",
|
||||
"./src/js/tribe-default-configs.js",
|
||||
"./src/js/tribe.js",
|
||||
"./src/js/sound.js",
|
||||
"./src/js/theme-colors.js",
|
||||
"./src/js/chart-controller.js",
|
||||
|
|
@ -114,6 +111,10 @@ const refactoredSrc = [
|
|||
"./src/js/route-controller.js",
|
||||
"./src/js/ready.js",
|
||||
|
||||
"./src/js/tribe/matchmaking.js",
|
||||
"./src/js/tribe/tribe-default-configs.js",
|
||||
"./src/js/tribe/tribe.js",
|
||||
|
||||
"./src/js/account/all-time-stats.js",
|
||||
"./src/js/account/pb-tables.js",
|
||||
"./src/js/account/result-filters.js",
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
let el = $("#tribeMatchmakingStatus");
|
||||
|
||||
export function show() {
|
||||
el.removeClass("hidden");
|
||||
}
|
||||
|
||||
export function hide() {
|
||||
el.addClass("hidden");
|
||||
}
|
||||
|
||||
export function setText(text) {
|
||||
el.find(".text").text(text);
|
||||
}
|
||||
|
||||
export function setIcon(html) {
|
||||
el.find(".icon").html(html);
|
||||
}
|
||||
|
||||
export function reset() {
|
||||
this.setText("Tribe mm status");
|
||||
this.setIcon('<i class="fas fa-spin fa-circle-notch"></i>');
|
||||
this.hide();
|
||||
}
|
||||
41
src/js/tribe/matchmaking.js
Normal file
41
src/js/tribe/matchmaking.js
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
let banner = $("#tribeMatchmakingStatus");
|
||||
|
||||
export function showBanner() {
|
||||
banner.removeClass("hidden");
|
||||
}
|
||||
|
||||
export function hideBanner() {
|
||||
banner.addClass("hidden");
|
||||
}
|
||||
|
||||
export function setBannerText(text) {
|
||||
banner.find(".text").text(text);
|
||||
}
|
||||
|
||||
export function setBannerIcon(html) {
|
||||
banner.find(".icon").html(html);
|
||||
}
|
||||
|
||||
export function resetBanner() {
|
||||
this.setText("Tribe mm status");
|
||||
this.setIcon('<i class="fas fa-spin fa-circle-notch"></i>');
|
||||
this.hide();
|
||||
}
|
||||
|
||||
export function disableLobbyButtons() {
|
||||
$(".pageTribe .prelobby .matchmaking .buttons .button").addClass("disabled");
|
||||
$(".pageTribe .prelobby .privateRooms .button").addClass("disabled");
|
||||
$(".pageTribe .prelobby .matchmaking .leaveMatchmakingButton").removeClass(
|
||||
"hidden"
|
||||
);
|
||||
}
|
||||
|
||||
export function enableLobbyButtons() {
|
||||
$(".pageTribe .prelobby .matchmaking .buttons .button").removeClass(
|
||||
"disabled"
|
||||
);
|
||||
$(".pageTribe .prelobby .privateRooms .button").removeClass("disabled");
|
||||
$(".pageTribe .prelobby .matchmaking .leaveMatchmakingButton").addClass(
|
||||
"hidden"
|
||||
);
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import InputSuggestions from "./input-suggestions";
|
||||
import * as MatchmakingStatus from "./tribe-mm-status";
|
||||
import * as Matchmaking from "./matchmaking";
|
||||
import TribeDefaultConfigs from "./tribe-default-configs";
|
||||
import * as Misc from "./misc";
|
||||
import * as UI from "./ui";
|
||||
|
|
@ -1035,7 +1035,7 @@ socket.on("disconnect", (f) => {
|
|||
resetResult();
|
||||
changeActiveSubpage("preloader");
|
||||
showHideTribeDiff(false);
|
||||
MatchmakingStatus.reset();
|
||||
Matchmaking.resetBanner();
|
||||
// $(".pageTribe .preloader div").removeClass("hidden");
|
||||
// $(".pageTribe .preloader").removeClass("hidden").css("opacity", 1);
|
||||
// $(".pageTribe .preloader .icon").html(`<i class="fas fa-fw fa-times"></i>`);
|
||||
|
|
@ -1124,7 +1124,7 @@ socket.on("mp_room_joined", (data) => {
|
|||
}
|
||||
} else {
|
||||
state = 7;
|
||||
MatchmakingStatus.setText(
|
||||
Matchmaking.setBannerText(
|
||||
`Waiting for more players to join (${
|
||||
Object.keys(room.users).length
|
||||
}/2)...`
|
||||
|
|
@ -1141,14 +1141,8 @@ socket.on("mp_room_leave", () => {
|
|||
changeActiveSubpage("prelobby");
|
||||
resetLobby();
|
||||
resetRace();
|
||||
$(".pageTribe .prelobby .matchmaking .leaveMatchmakingButton").addClass(
|
||||
"hidden"
|
||||
);
|
||||
$(".pageTribe .prelobby .matchmaking .buttons .button").removeClass(
|
||||
"disabled"
|
||||
);
|
||||
$(".pageTribe .prelobby .privateRooms .button").removeClass("disabled");
|
||||
MatchmakingStatus.hide();
|
||||
Matchmaking.enableLobbyButtons();
|
||||
Matchmaking.hideBanner();
|
||||
// swapElements($(".pageTribe .lobby"), $(".pageTribe .prelobby"), 250);
|
||||
});
|
||||
|
||||
|
|
@ -1171,7 +1165,7 @@ socket.on("mp_room_user_left", (data) => {
|
|||
} else {
|
||||
delete room.users[data.sid];
|
||||
if (state <= 8) {
|
||||
MatchmakingStatus.setText(
|
||||
Matchmaking.setBannerText(
|
||||
`Waiting for more players to join (${
|
||||
Object.keys(room.users).length
|
||||
}/2)...`
|
||||
|
|
@ -1267,11 +1261,11 @@ socket.on("mp_chat_message", async (data) => {
|
|||
|
||||
socket.on("mp_update_mm_status", (data) => {
|
||||
if (data.visible) {
|
||||
MatchmakingStatus.show();
|
||||
Matchmaking.showBanner();
|
||||
} else {
|
||||
MatchmakingStatus.hide();
|
||||
Matchmaking.hideBanner();
|
||||
}
|
||||
if (data.text !== undefined) MatchmakingStatus.setText(data.text);
|
||||
if (data.text !== undefined) Matchmaking.setBannerText(data.text);
|
||||
if (data.raceStarting === true) {
|
||||
playSound("join");
|
||||
}
|
||||
|
|
@ -1495,7 +1489,7 @@ socket.on("mp_room_test_init", (data) => {
|
|||
$(".pageTest #result .tribeResultChat .chat .input input").val("");
|
||||
lobbySuggestions.hide();
|
||||
resultSuggestions.hide();
|
||||
MatchmakingStatus.reset();
|
||||
Matchmaking.resetBanner();
|
||||
sendIsTypingUpdate(false);
|
||||
hideResultCountdown();
|
||||
$(".pageTest #restartTestButton").addClass("hidden");
|
||||
|
|
@ -1981,8 +1975,8 @@ $(".pageTribe .prelobby .matchmaking .button").click((e) => {
|
|||
if (state >= 6 && state <= 8) return;
|
||||
if ($(e.currentTarget).hasClass("disabled")) return;
|
||||
let queue = $(e.currentTarget).attr("queue");
|
||||
MatchmakingStatus.setText("Searching for a room...");
|
||||
MatchmakingStatus.show();
|
||||
Matchmaking.setBannerText("Searching for a room...");
|
||||
Matchmaking.showBanner();
|
||||
state = 6;
|
||||
lastQueue = queue;
|
||||
applyRoomConfig(TribeDefaultConfigs[queue]);
|
||||
|
|
@ -1999,8 +1993,9 @@ $(".pageTribe .prelobby .matchmaking .button").click((e) => {
|
|||
$(".pageTest #result #queueAgainButton").click((e) => {
|
||||
if (state >= 6 && state <= 8) return;
|
||||
if ($(e.currentTarget).hasClass("disabled")) return;
|
||||
MatchmakingStatus.setText("Searching for a room...");
|
||||
MatchmakingStatus.show();
|
||||
Matchmaking.setBannerText("Searching for a room...");
|
||||
Matchmaking.showBanner();
|
||||
showHideTribeDiff(false);
|
||||
state = 6;
|
||||
applyRoomConfig(TribeDefaultConfigs[lastQueue]);
|
||||
TestLogic.restart();
|
||||
Loading…
Add table
Reference in a new issue