<!DOCTYPE html>
<html lang=”en”>
<head>
<meta charset=”UTF-8″>
<meta name=”viewport” content=”width=device-width, initial-scale=1.0″>
<title></title>
<style>
table, th, td {
border: 2px solid rgb(219, 39, 39);
border-collapse: collapse;
padding: 8px;
text-align: center;
background-color: beige;
font-family: Verdana, Geneva, Tahoma, sans-serif;
}
input[type=”number”] {
width: 80px;
text-align: center;
}
.cLeft{
text-align: left;
}
</style>
</head>
<body>
<h1></h1>
<table>
<tr>
<th>OY-PHD</th>
<th>Lbs in Left wing</th>
<th>Lbs in Right wing</th>
</tr>
<tr>
<td class=”cLeft”>Fuel On-board</td>
<td><input type=”number” id=”leftFuel” value=”0″ oninput=”calculateFuel()”></td>
<td><input type=”number” id=”rightFuel” value=”0″ oninput=”calculateFuel()”></td>
</tr>
<tr>
<td class=”cLeft”>Total fuel On-board (Lbs)</td>
<td colspan=”2″ id=”totalFuel”>0</td>
</tr>
<tr>
<td class=”cLeft”>Required fuel (Lbs)</td>
<td colspan=”2″><input type=”number” id=”requiredFuel” value=”0″ oninput=”calculateFuel()”></td>
</tr>
<tr>
<td class=”cLeft”>Required Up-lift (Lbs)</td>
<td colspan=”2″ id=”fuelDifference”>0</td>
</tr>
<tr>
<th>DISTRIBUTION</th>
<th>Left wing</th>
<th>Right wing</th>
</tr>
<tr>
<td class=”cLeft”>Pounds</td>
<td id=”leftBox”>0</td>
<td id=”rightBox”>0</td>
</tr>
<tr>
<td class=”cLeft”>Gallons</td>
<td id=”calcLeft”>0</td>
<td id=”calcRight”>0</td>
</tr>
<tr>
<td class=”cLeft”>Liter</td>
<td id=”ltrLeft”>0</td>
<td id=”ltrRight”>0</td>
</tr>
<tr>
<td class=”cLeft”>Liter Priest</td>
<td id=”priestLeft”>0.0</td>
<td id=”priestRight”>0.0</td>
</tr>
</table>

<script>
function calculateFuel() {
const leftFuel = parseFloat(document.getElementById(‘leftFuel’).value) || 0;
const rightFuel = parseFloat(document.getElementById(‘rightFuel’).value) || 0;
const requiredFuel = parseFloat(document.getElementById(‘requiredFuel’).value) || 0;

const totalFuel = Math.round(leftFuel + rightFuel);
const fuelDifference = Math.round(requiredFuel – leftFuel – rightFuel);

const leftBox = Math.round((requiredFuel * 0.5) – leftFuel);
const rightBox = Math.round((requiredFuel * 0.5) – rightFuel);

const calcLeft = Math.round(leftBox / 6.7);
const calcRight = Math.round(rightBox / 6.7);

const ltrLeft = Math.round(calcLeft * 3.785);
const ltrRight = Math.round(calcRight * 3.785);

const priestLeft = (ltrLeft / 100 * 0.15).toFixed(1);
const priestRight = (ltrRight / 100 * 0.15).toFixed(1);

document.getElementById(‘totalFuel’).innerText = totalFuel;
document.getElementById(‘fuelDifference’).innerText = fuelDifference;
document.getElementById(‘leftBox’).innerText = leftBox;
document.getElementById(‘rightBox’).innerText = rightBox;
document.getElementById(‘calcLeft’).innerText = calcLeft;
document.getElementById(‘calcRight’).innerText = calcRight;
document.getElementById(‘ltrLeft’).innerText = ltrLeft;
document.getElementById(‘ltrRight’).innerText = ltrRight;
document.getElementById(‘priestLeft’).innerText = priestLeft;
document.getElementById(‘priestRight’).innerText = priestRight;
}
</script>
</body>
</html>