From 3b275c8bd47d985c3fc5400be64746ab5c686a7a Mon Sep 17 00:00:00 2001 From: Makaci Michael Gabriel Date: Fri, 26 Apr 2024 10:32:33 +0200 Subject: [PATCH] Disabled no recruting faction --- js/controllers/reg.js | 86 +++++++++++++++++++++++-------------------- 1 file changed, 46 insertions(+), 40 deletions(-) diff --git a/js/controllers/reg.js b/js/controllers/reg.js index 57b5543..0d15014 100644 --- a/js/controllers/reg.js +++ b/js/controllers/reg.js @@ -1,52 +1,58 @@ import { Auth } from "../skama_code/auth/auth.js"; import { My } from "../skama_code/api/agent.js"; -import { Faction } from "../skama_code/api/faction.js" +import { Faction } from "../skama_code/api/faction.js"; import home from "./home.js"; import login from "./login.js"; import menu_mod from "./menu_mod.js"; export default function reg(temp_engine) { - let auth = new Auth(); - - temp_engine.after_render((temp_engine) => { - menu_mod(temp_engine); - - Faction.list_all((factions) => { - factions.forEach(faction => { - const option = ``; - $("#group-faction").append(option); - }); - }); - - temp_engine.add_event("#btn-register", "click", () => { - const is_checked = $("#in-remember").is(":checked"); - const symbol = $("#in-name").val(); - const faction = $("#in-faction").val(); - auth.store = is_checked; - auth.register({name: symbol, faction: faction}); - }); - - temp_engine.add_event("#btn-cancel", "click", () => { - $("#in-name").val(""); - $("#in-remember").prop("checked", false); - }); - - temp_engine.add_event("#btn-log", "click", () => { - login(temp_engine); - }) + let auth = new Auth(); + + temp_engine.after_render((temp_engine) => { + menu_mod(temp_engine); + + Faction.list_all((factions) => { + factions.forEach((faction) => { + let option; + if (faction.isRecruting) { + option = ``; + } else { + option = ``; + } + + $("#group-faction").append(option); + }); }); - auth.done((agent) => { - My.agent = agent; - home(temp_engine); + temp_engine.add_event("#btn-register", "click", () => { + const is_checked = $("#in-remember").is(":checked"); + const symbol = $("#in-name").val(); + const faction = $("#in-faction").val(); + auth.store = is_checked; + auth.register({ name: symbol, faction: faction }); }); - auth.fail((errors) => { - $(".errors").html(""); - errors.forEach(error => { - $(".errors").append(`

${error}

`); - }); - }) + temp_engine.add_event("#btn-cancel", "click", () => { + $("#in-name").val(""); + $("#in-remember").prop("checked", false); + }); + + temp_engine.add_event("#btn-log", "click", () => { + login(temp_engine); + }); + }); + + auth.done((agent) => { + My.agent = agent; + home(temp_engine); + }); + + auth.fail((errors) => { + $(".errors").html(""); + errors.forEach((error) => { + $(".errors").append(`

${error}

`); + }); + }); - temp_engine.render(`templates/auth/reg.html`); -} \ No newline at end of file + temp_engine.render(`templates/auth/reg.html`); +}