Spaces:
Runtime error
Runtime error
File size: 6,963 Bytes
012148b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | <!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>
|