Disabled no recruting faction

fusion
Makaci Michael Gabriel ago%!(EXTRA string=1 year)
parent 057f445f26
commit 3b275c8bd4
  1. 84
      js/controllers/reg.js

@ -1,52 +1,58 @@
import { Auth } from "../skama_code/auth/auth.js"; import { Auth } from "../skama_code/auth/auth.js";
import { My } from "../skama_code/api/agent.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 home from "./home.js";
import login from "./login.js"; import login from "./login.js";
import menu_mod from "./menu_mod.js"; import menu_mod from "./menu_mod.js";
export default function reg(temp_engine) { export default function reg(temp_engine) {
let auth = new Auth(); let auth = new Auth();
temp_engine.after_render((temp_engine) => { temp_engine.after_render((temp_engine) => {
menu_mod(temp_engine); menu_mod(temp_engine);
Faction.list_all((factions) => { Faction.list_all((factions) => {
factions.forEach(faction => { factions.forEach((faction) => {
const option = `<option>${faction.symbol}</option>`; let option;
$("#group-faction").append(option); if (faction.isRecruting) {
}); option = `<option>${faction.symbol}</option>`;
}); } else {
option = `<option disabled>${faction.symbol}</option>`;
temp_engine.add_event("#btn-register", "click", () => { }
const is_checked = $("#in-remember").is(":checked");
const symbol = $("#in-name").val(); $("#group-faction").append(option);
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);
})
}); });
auth.done((agent) => { temp_engine.add_event("#btn-register", "click", () => {
My.agent = agent; const is_checked = $("#in-remember").is(":checked");
home(temp_engine); const symbol = $("#in-name").val();
const faction = $("#in-faction").val();
auth.store = is_checked;
auth.register({ name: symbol, faction: faction });
}); });
auth.fail((errors) => { temp_engine.add_event("#btn-cancel", "click", () => {
$(".errors").html(""); $("#in-name").val("");
errors.forEach(error => { $("#in-remember").prop("checked", false);
$(".errors").append(`<p>${error}</p>`); });
});
}) 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(`<p>${error}</p>`);
});
});
temp_engine.render(`templates/auth/reg.html`); temp_engine.render(`templates/auth/reg.html`);
} }
Loading…
Cancel
Save