You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and dots ('.'), can be up to 35 characters long. Letters must be lowercase.
61 lines
1.6 KiB
61 lines
1.6 KiB
import { My } from "../skama_code/api/agent.js"; |
|
import home from "./home.js"; |
|
import login from "./login.js"; |
|
import reg from "./reg.js"; |
|
import systems from "./systems.js"; |
|
|
|
function init_menu(temp_engine) { |
|
temp_engine.add_event("#reg-link", "click", () => { |
|
reg(temp_engine); |
|
}); |
|
temp_engine.add_event("#login-link", "click", () => { |
|
login(temp_engine); |
|
}); |
|
temp_engine.add_event("#systems-link", "click", () => { |
|
systems(temp_engine); |
|
}); |
|
temp_engine.add_event(".nav-brand", "click", () => { |
|
home(temp_engine); |
|
}); |
|
temp_engine.add_event("#logout-link", "click", () => { |
|
My.agent = null; |
|
localStorage.removeItem("token"); |
|
home(temp_engine); |
|
}); |
|
} |
|
|
|
function loged_links() { |
|
$(".nav-links").html(` |
|
<li class="nav-link smooth" id="systems-link">Systems</li> |
|
<li class="nav-link smooth" id="contracts-link">Contracts</li> |
|
<li class="nav-link smooth" id="ships-link">Ships</li> |
|
<li class="nav-link smooth" id="logout-link">logout</li> |
|
`); |
|
} |
|
|
|
function unloged_links() { |
|
$(".nav-links").html(` |
|
<li class="nav-link smooth" id="login-link">Log in</li> |
|
<li class="nav-link smooth" id="reg-link">New Agent</li> |
|
`); |
|
} |
|
|
|
function show_stats() { |
|
$(".stats").html(` |
|
<p>Agent name : ${My.agent.name}</p> |
|
<p>Credits : ${My.agent.credits}</p> |
|
<p>Ships : ${My.agent.ships_cpt}</p> |
|
<p>Faction : ${My.agent.faction}</p> |
|
<p>HQ : ${My.agent.hq}</p> |
|
`); |
|
} |
|
|
|
export default function menu_mod(temp_engine) { |
|
init_menu(temp_engine); |
|
if (My.agent) { |
|
show_stats(); |
|
loged_links(); |
|
} else { |
|
unloged_links(); |
|
} |
|
}
|
|
|