mean-pap-api / index.html
jcharton's picture
Adding files
012148b verified
Raw History Blame Contribute Delete
6.96 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=0.8">
<title>Mean PAP Calculator</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">
<style>
body { background-color: #f8f9fa; padding: 20px; }
.container { max-width: 900px; background: white; padding: 20px; border-radius: 8px; box-shadow: 0px 0px 10px rgba(0,0,0,0.1); }
img { width: 100%; margin-top: 10px; border: 1px solid #ddd; border-radius: 5px; }
body {
transform: scale(0.75); /* Scale down to 90% */
transform-origin: top center; /* Set the origin for the scaling */
width: 100%; /* Prevent horizontal scrolling */
}
</style>
</head>
<body>
<div class="container">
<h2 class="text-center">Mean PAP Calculator</h2>
<form id="calculatorForm">
<table>
<tr>
<td width="500px">
<div class="mb-3">
<p><h5 class="mt-3">Age
<input type="number" id="age" class="form-control" value="60" required></h5></p>
<p><h5 class="mt-3">Upload Chest X-ray:
<input type="file" id="xrayUpload" class="form-control" accept="image/*" onchange="uploadXray()"></h5></p>
<h5 class="mt-3">Upload Lead 1:
<input type="file" id="lead1Upload" class="form-control" accept="image/*" onchange="uploadLead(1)"></h5>
<h5 class="mt-3">Upload Lead 2:
<input type="file" id="lead2Upload" class="form-control" accept="image/*" onchange="uploadLead(2)"></h5>
<h5 class="mt-3">Upload Lead 3:
<input type="file" id="lead3Upload" class="form-control" accept="image/*" onchange="uploadLead(3)"></h5>
<h5 class="mt-3">Upload Lead 4:
<input type="file" id="lead4Upload" class="form-control" accept="image/*" onchange="uploadLead(4)"></h5>
<h5 class="mt-3">Upload Lead 5:
<input type="file" id="lead5Upload" class="form-control" accept="image/*" onchange="uploadLead(5)"></h5>
<h5 class="mt-3">Upload Lead 6:
<input type="file" id="lead6Upload" class="form-control" accept="image/*" onchange="uploadLead(6)"></h5>
<h5 class="mt-3">Upload Lead 7:
<input type="file" id="lead7Upload" class="form-control" accept="image/*" onchange="uploadLead(7)"></h5>
<h5 class="mt-3">Upload Lead 8:
<input type="file" id="lead8Upload" class="form-control" accept="image/*" onchange="uploadLead(8)"></h5>
<h5 class="mt-3">Upload Lead 9:
<input type="file" id="lead9Upload" class="form-control" accept="image/*" onchange="uploadLead(9)"></h5>
<h5 class="mt-3">Upload Lead 10:
<input type="file" id="lead10Upload" class="form-control" accept="image/*" onchange="uploadLead(10)"></h5>
<h5 class="mt-3">Upload Lead 11:
<input type="file" id="lead11Upload" class="form-control" accept="image/*" onchange="uploadLead(11)"></h5>
<h5 class="mt-3">Upload Lead 12:
<input type="file" id="lead12Upload" class="form-control" accept="image/*" onchange="uploadLead(12)"></h5>
</div>
<input type="hidden" id="cxr" value="">
<input type="hidden" id="lead1" value="">
<input type="hidden" id="lead2" value="">
<input type="hidden" id="lead3" value="">
<input type="hidden" id="lead4" value="">
<input type="hidden" id="lead5" value="">
<input type="hidden" id="lead6" value="">
<input type="hidden" id="lead7" value="">
<input type="hidden" id="lead8" value="">
<input type="hidden" id="lead9" value="">
<input type="hidden" id="lead10" value="">
<input type="hidden" id="lead11" value="">
<input type="hidden" id="lead12" value="">
<button type="button" class="btn btn-success w-100" onclick="calculatePAP()">Calculate</button>
<h5 class="mt-3">Calculated Mean PAP: <span id="result" class="fw-bold">-</span></h5>
</td>
<td width="300px">
<img id="xrayPreview" src="" alt="X-ray Preview">
<img id="lead1Preview" src="" alt="Lead 1 Preview">
<img id="lead2Preview" src="" alt="Lead 2 Preview">
<img id="lead3Preview" src="" alt="Lead 3 Preview">
<img id="lead4Preview" src="" alt="Lead 4 Preview">
<img id="lead5Preview" src="" alt="Lead 5 Preview">
<img id="lead6Preview" src="" alt="Lead 6 Preview">
<img id="lead7Preview" src="" alt="Lead 7 Preview">
<img id="lead8Preview" src="" alt="Lead 8 Preview">
<img id="lead9Preview" src="" alt="Lead 9 Preview">
<img id="lead10Preview" src="" alt="Lead 10 Preview">
<img id="lead11Preview" src="" alt="Lead 11 Preview">
<img id="lead12Preview" src="" alt="Lead 12 Preview">
</td>
</tr>
</table>
</form>
</div>
<script>
const API_URL = window.location.href;
function calculatePAP() {
const data = {
age: document.getElementById("age").value,
cxr: document.getElementById("cxr").value,
lead1: document.getElementById("lead1").value,
lead2: document.getElementById("lead2").value,
lead3: document.getElementById("lead3").value,
lead4: document.getElementById("lead4").value,
lead5: document.getElementById("lead5").value,
lead6: document.getElementById("lead6").value,
lead7: document.getElementById("lead7").value,
lead8: document.getElementById("lead8").value,
lead9: document.getElementById("lead9").value,
lead10: document.getElementById("lead10").value,
lead11: document.getElementById("lead11").value,
lead12: document.getElementById("lead12").value
};
fetch(API_URL + "/calculate", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(data)
})
.then(response => response.json())
.then(data => {
document.getElementById("result").innerText = data.mean_pap + " mmHg";
});
}
function uploadXray() {
const fileInput = document.getElementById("xrayUpload");
const file = fileInput.files[0];
const formData = new FormData();
formData.append("file", file);
fetch(API_URL + "/upload_image", {
method: "POST",
body: formData
})
.then(response => response.json())
.then(data => {
if (data.image_url) {
document.getElementById("xrayPreview").src = API_URL + data.image_url;
document.getElementById("cxr").value = '.' + data.image_url;
}
});
}
function uploadLead(idx) {
const fileInput = document.getElementById("lead"+idx+"Upload");
const file = fileInput.files[0];
const formData = new FormData();
formData.append("file", file);
fetch(API_URL + "/upload_image", {
method: "POST",
body: formData
})
.then(response => response.json())
.then(data => {
if (data.image_url) {
document.getElementById("lead"+idx+"Preview").src = API_URL + data.image_url;
document.getElementById("lead"+idx).value = '.' + data.image_url;
}
});
}
</script>
</body>
</html>