Skip to content
This repository has been archived by the owner on Apr 7, 2023. It is now read-only.

Commit

Permalink
rename formatters more sanely, adding mass formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
Colin McLeod committed Apr 17, 2015
1 parent 11e5c13 commit acffdd1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 deletions.
7 changes: 4 additions & 3 deletions app/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ angular.module('app', ['ngRoute','shipyard','ngLodash','app.templates'])
$rootScope.ships = DB.ships;

// Formatters
$rootScope.credits = d3.format(',.0f');
$rootScope.power = d3.format(',.2f');
$rootScope.percent = d3.format(',.2%');
$rootScope.fCrd = d3.format(',.0f');
$rootScope.fPwr = d3.format(',.2f');
$rootScope.fMass = d3.format(',.2r');
$rootScope.fPct = d3.format(',.2%');

$rootScope.calcJumpRange = function(mass, fsd, fuel) {
return Math.pow( (fuel || fsd.maxfuel) / fds.fuelmul, 1 / fsd.fuelpower ) * fsd.optmass / mass;
Expand Down
12 changes: 6 additions & 6 deletions app/views/costs.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<div class="list-item" ng-class="{enabled:ship.incCost}" ng-click="toggle(ship)">
<div class="lbl">{{ship.name}}</div><div class="val">{{$r.credits(ship.cost)}}</div>
<div class="lbl">{{ship.name}}</div><div class="val">{{$r.fCrd(ship.cost)}}</div>
</div>
<div class="list-item" ng-class="{enabled:ship.bulkheads.incCost}" ng-click="toggle(ship.bulkheads)" ng-if="ship.bulkheads.c.cost">
<div class="lbl">{{ship.bulkheads.c.name}}</div><div class="val">{{$r.credits(ship.bulkheads.c.cost)}}</div>
<div class="lbl">{{ship.bulkheads.c.name}}</div><div class="val">{{$r.fCrd(ship.bulkheads.c.cost)}}</div>
</div>
<div ng-repeat="c in ship.common" ng-if="c.c.cost" class="list-item common" ng-class="{enabled:c.incCost}" ng-click="toggle(c)">
<div class="lbl">{{c.c.class}}{{c.c.rating}} {{$r.CArr[$index]}}</div><div class="val">{{$r.credits(c.c.cost)}}</div>
<div class="lbl">{{c.c.class}}{{c.c.rating}} {{$r.CArr[$index]}}</div><div class="val">{{$r.fCrd(c.c.cost)}}</div>
</div>
<div ng-repeat="c in ship.hardpoints" ng-if="c.c.cost" class="list-item hardpoints" ng-class="{enabled:c.incCost}" ng-click="toggle(c)">
<div class="lbl">{{c.c.class}}{{c.c.rating}} {{c.c.name}}</div><div class="val">{{$r.credits(c.c.cost)}}</div>
<div class="lbl">{{c.c.class}}{{c.c.rating}} {{c.c.name}}</div><div class="val">{{$r.fCrd(c.c.cost)}}</div>
</div>
<div ng-repeat="c in ship.internal" ng-if="c.c.cost" class="list-item internal" ng-class="{enabled:c.incCost}" ng-click="toggle(c)">
<div class="lbl">{{c.c.class}}{{c.c.rating}} {{c.c.name || $r.igMap[c.c.group]}}</div><div class="val">{{$r.credits(c.c.cost)}}</div>
<div class="lbl">{{c.c.class}}{{c.c.rating}} {{c.c.name || $r.igMap[c.c.group]}}</div><div class="val">{{$r.fCrd(c.c.cost)}}</div>
</div>
<div class="list-item">
<div class="lbl">Total</div><div class="val">{{$r.credits(ship.totalCost)}}</div>
<div class="lbl">Total</div><div class="val">{{$r.fCrd(ship.totalCost)}}</div>
</div>
14 changes: 7 additions & 7 deletions app/views/power.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<div ng-if="ship.common[0].c.pGen" class="list-item common enabled">
<div class="lbl">{{ship.common[0].c.class}}{{ship.common[0].c.rating}} {{$r.CArr[0]}}</div><div class="val">{{$r.power(ship.common[0].c.pGen)}}</div>
<div class="lbl">{{ship.common[0].c.class}}{{ship.common[0].c.rating}} {{$r.CArr[0]}}</div><div class="val">{{$r.fPwr(ship.common[0].c.pGen)}}</div>
</div>
<div ng-repeat="c in ship.common" ng-if="c.c.power" class="list-item common" ng-class="{enabled:c.enabled, consumer:c.c.power}" ng-click="toggle(c)">
<div class="lbl">{{c.c.class}}{{c.c.rating}} {{$r.CArr[$index]}}</div><div class="val">{{$r.power(c.c.power)}}</div>
<div class="lbl">{{c.c.class}}{{c.c.rating}} {{$r.CArr[$index]}}</div><div class="val">{{$r.fPwr(c.c.power)}}</div>
</div>
<div class="list-item common consumer" ng-class="{enabled:ship.cargoScoop.enabled}" ng-click="toggle(ship.cargoScoop)">
<div class="lbl">1H Cargo Scoop</div><div class="val">{{$r.power(ship.cargoScoop.c.power)}}</div>
<div class="lbl">1H Cargo Scoop</div><div class="val">{{$r.fPwr(ship.cargoScoop.c.power)}}</div>
</div>

<div ng-repeat="c in ship.hardpoints" ng-if="c.c.power" class="list-item hardpoints" ng-class="{enabled:c.enabled, consumer:c.c.power}" ng-click="toggle(c)">
<div class="lbl">{{c.c.class}}{{c.c.rating}} {{c.c.name}}</div><div class="val">{{$r.power(c.c.power)}}</div>
<div class="lbl">{{c.c.class}}{{c.c.rating}} {{c.c.name}}</div><div class="val">{{$r.fPwr(c.c.power)}}</div>
</div>

<div ng-repeat="c in ship.internal" ng-if="c.c.power" class="list-item internal" ng-class="{enabled:c.enabled, consumer:c.c.power}" ng-click="toggle(c)">
<div class="lbl">{{c.c.class}}{{c.c.rating}} {{c.c.name || $r.igMap[c.c.group]}}</div><div class="val">{{$r.power(c.c.power)}}</div>
<div class="lbl">{{c.c.class}}{{c.c.rating}} {{c.c.name || $r.igMap[c.c.group]}}</div><div class="val">{{$r.fPwr(c.c.power)}}</div>
</div>

<div>Retracted: {{$r.power(ship.powerRetracted)}} ({{$r.percent(ship.powerRetracted/ship.powerAvailable)}})</div>
<div>Deployed: {{$r.power(ship.powerDeployed)}} ({{$r.percent(ship.powerDeployed/ship.powerAvailable)}})</div>
<div>Retracted: {{$r.fPwr(ship.powerRetracted)}} ({{$r.percent(ship.powerRetracted/ship.powerAvailable)}})</div>
<div>Deployed: {{$r.fPwr(ship.powerDeployed)}} ({{$r.percent(ship.powerDeployed/ship.powerAvailable)}})</div>
4 changes: 2 additions & 2 deletions app/views/ship.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

<fieldset id="overview">
<legend>{{ship.name}}</legend>
<div>Class: {{ship.class}}</div>
<div>Mass: {{ship.unladenMass}} - {{ship.ladenMass}} [{{ship.mass}}]T</div>
<div>Class: {{ship.class)}</div>
<div>Mass: {{fMass(ship.unladenMass)}} - {{fMass(ship.ladenMass)}} [{{ship.mass}}]T</div>
<div>Speed: {{ship.speed}} <span class="boost">[{{ship.boost}}] M/s</span></div>
<div>Agility: {{ship.agility}}</div>
<div>Shields: {{ship.shields}}</div>
Expand Down

0 comments on commit acffdd1

Please sign in to comment.