From ae85242fefeadc5d6581e6f8c6fdacb3049c2131 Mon Sep 17 00:00:00 2001 From: Melro Serdoura Daniel Date: Fri, 26 Jan 2024 11:15:32 +0100 Subject: [PATCH] controllers ships fini --- html/templates/ship/ship_modal.html | 16 +--- js/controllers/ships.js | 136 +++++++++++++++++++++++----- 2 files changed, 114 insertions(+), 38 deletions(-) diff --git a/html/templates/ship/ship_modal.html b/html/templates/ship/ship_modal.html index 447f60c..858c6db 100644 --- a/html/templates/ship/ship_modal.html +++ b/html/templates/ship/ship_modal.html @@ -1,18 +1,8 @@
- -

-

-

-

-

-

-

-

-

-

-

-

+
+ +
diff --git a/js/controllers/ships.js b/js/controllers/ships.js index 954653c..7ec8f02 100644 --- a/js/controllers/ships.js +++ b/js/controllers/ships.js @@ -10,45 +10,131 @@ export default (temp_engine) => { modal.load("templates/ship/ship_modal.html"); Ship.list((ships) => { + console.log(ships) ships.forEach(ship => { $(".ships").append( `
${ship.symbol}

fuel capacity: ${ship.fuel.capacity}

- + + + + +
` ) - temp_engine.add_event("#FT", "click", (e) => { - const id_ship = $(e.target).attr("data-symbol"); - if(ship.symbol=id_ship) - { - $(".Ship-id").text("ID : " + ship.symbol); - $(".Ship-registration").text("Registration : " + ship.registration); - $(".Ship-nav").text("Nav : " + ship.nav); - $(".Ship-crew").text("Crew : " + ship.crew); - $(".Ship-frame").text("Frame : " + ship.frame ); - $(".Ship-reactor").text("Reactor : " + ship.reactor ); - $(".Ship-engine").text("Engine : " + ship.engine); - $(".Ship-cooldown").text("Cooldown : " + ship.cooldown); - $(".Ship-modules").text("Modules : " + ship.modules ); - $(".Ship-mounts").text("Mounts : " + ship.mounts ); - $(".Ship-cargo").text("Cargo : " + ship.cargo); - $(".Ship-fuel").text("Fuel : " + ship.fuel); - } - modal.show(); - }); - }); - + }); + temp_engine.add_event(".reg", "click", (e) => { + const id_ship = $(e.target).attr("data-symbol"); + ships.forEach(ship =>{ + if(ship.symbol==id_ship) + { + $(".infos").html(""); + $(".infos").append(`

Name : ${ship.registration.name}

`); + $(".infos").append(`

Faction : ${ship.registration.factionSymbol}

`); + $(".infos").append(`

Role : ${ship.registration.role}

`); + } + }) + modal.show(); + }); + temp_engine.add_event(".nav", "click", (e) => { + const id_ship = $(e.target).attr("data-symbol"); + ships.forEach(ship =>{ + if(ship.symbol==id_ship) + { + $(".infos").html(""); + $(".infos").append(`

Current system : ${ship.nav.systemSymbol}

`); + $(".infos").append(`

Current waypoint : ${ship.nav.waypointSymbol}

`); + $(".infos").append(`

Current status : ${ship.nav.status}

`); + $(".infos").append(`

Flight mode : ${ship.nav.flightMode}

`); + } + }) + modal.show(); + }); + temp_engine.add_event(".crew", "click", (e) => { + const id_ship = $(e.target).attr("data-symbol"); + ships.forEach(ship =>{ + if(ship.symbol==id_ship) + { + $(".infos").html(""); + $(".infos").append(`

Current member : ${ship.crew.current}

`); + $(".infos").append(`

Capacity : ${ship.crew.capacity}

`); + $(".infos").append(`

required member : ${ship.crew.required}

`); + $(".infos").append(`

Moral : ${ship.crew.morale}

`); + } + }) + modal.show(); + }); + temp_engine.add_event(".frame", "click", (e) => { + const id_ship = $(e.target).attr("data-symbol"); + ships.forEach(ship =>{ + if(ship.symbol==id_ship) + { + $(".infos").html(""); + $(".infos").append(`

Name : ${ship.frame.name}

`); + $(".infos").append(`

Description : ${ship.frame.description}

`); + $(".infos").append(`

Fuel capacity : ${ship.frame.fuelCapacity}

`); + $(".infos").append(`

Condition : ${ship.frame.condition}

`); + $(".infos").append(`

Power : ${ship.frame.requirements.power}

`); + $(".infos").append(`

Crew : ${ship.frame.requirements.crew}

`); + + } + }) + modal.show(); + }); + temp_engine.add_event(".react", "click", (e) => { + const id_ship = $(e.target).attr("data-symbol"); + ships.forEach(ship =>{ + if(ship.symbol==id_ship) + { + $(".infos").html(""); + $(".infos").append(`

Name : ${ship.reactor.name}

`); + $(".infos").append(`

Description : ${ship.reactor.description}

`); + $(".infos").append(`

Condition : ${ship.reactor.condition}

`); + $(".infos").append(`

Power : ${ship.reactor.powerOutput}

`); + $(".infos").append(`

Crew : ${ship.reactor.requirements.crew}

`); + } + }) + modal.show(); + }); + temp_engine.add_event(".engine", "click", (e) => { + const id_ship = $(e.target).attr("data-symbol"); + ships.forEach(ship =>{ + if(ship.symbol==id_ship) + { + $(".infos").html(""); + $(".infos").append(`

Name : ${ship.engine.name}

`); + $(".infos").append(`

Description : ${ship.engine.description}

`); + $(".infos").append(`

Condition : ${ship.engine.condition}

`); + $(".infos").append(`

Speed : ${ship.engine.speed}

`); + $(".infos").append(`

Crew : ${ship.engine.requirements.crew}

`); + $(".infos").append(`

Power : ${ship.engine.requirements.power}

`); + } + }) + modal.show(); + }); + temp_engine.add_event(".fuel", "click", (e) => { + const id_ship = $(e.target).attr("data-symbol"); + ships.forEach(ship =>{ + if(ship.symbol==id_ship) + { + $(".infos").html(""); + $(".infos").append(`

current fuel : ${ship.fuel.current}

`); + $(".infos").append(`

Description : ${ship.fuel.capacity}

`); + $(".infos").append(`

Condition : ${ship.fuel.consumed.amount}

`); + $(".infos").append(`

Speed : ${ship.fuel.consumed.timestamp}

`); + } + }) + modal.show(); + }); }); temp_engine.add_event(".btn-close", "click", () => { modal.close(); }); - - - }); temp_engine.render("templates/ship/ship.html");