Spaces:
Running
Running
undefined - Initial Deployment
Browse files- index.html +147 -17
index.html
CHANGED
|
@@ -162,7 +162,60 @@
|
|
| 162 |
padding-right: max(0.75rem, env(safe-area-inset-right));
|
| 163 |
}
|
| 164 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
</style>
|
|
|
|
|
|
|
| 166 |
</head>
|
| 167 |
<body class="bg-gray-50 font-sans">
|
| 168 |
<div class="flex h-screen overflow-hidden">
|
|
@@ -640,7 +693,7 @@
|
|
| 640 |
<!-- Signature Capture -->
|
| 641 |
<div class="space-y-4">
|
| 642 |
<h3 class="font-medium text-gray-900">Signature</h3>
|
| 643 |
-
<div class="grid grid-cols-2 gap-4">
|
| 644 |
<div>
|
| 645 |
<label class="block text-sm font-medium text-gray-700">Signature Type</label>
|
| 646 |
<div class="mt-2 space-y-2">
|
|
@@ -898,8 +951,10 @@
|
|
| 898 |
|
| 899 |
<!-- Signature Pad -->
|
| 900 |
<div>
|
| 901 |
-
<div
|
| 902 |
-
|
|
|
|
|
|
|
| 903 |
<button type="button" onclick="clearSignature()" class="text-sm text-gray-600 hover:text-gray-900">
|
| 904 |
Clear
|
| 905 |
</button>
|
|
@@ -1308,6 +1363,65 @@
|
|
| 1308 |
}
|
| 1309 |
};
|
| 1310 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1311 |
// Consent Management
|
| 1312 |
const ConsentManager = {
|
| 1313 |
currentParticipant: null,
|
|
@@ -1315,6 +1429,7 @@
|
|
| 1315 |
modal: null,
|
| 1316 |
signaturePad: null,
|
| 1317 |
identityVerified: false,
|
|
|
|
| 1318 |
|
| 1319 |
async initialize(participantId) {
|
| 1320 |
try {
|
|
@@ -1375,10 +1490,20 @@
|
|
| 1375 |
|
| 1376 |
initializeSignaturePad() {
|
| 1377 |
const canvas = this.modal.querySelector('#signaturePad');
|
| 1378 |
-
this.
|
| 1379 |
-
|
| 1380 |
-
|
| 1381 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1382 |
},
|
| 1383 |
|
| 1384 |
addEventListeners() {
|
|
@@ -1450,30 +1575,35 @@
|
|
| 1450 |
|
| 1451 |
switch (signatureType) {
|
| 1452 |
case 'draw':
|
| 1453 |
-
|
| 1454 |
-
|
| 1455 |
-
|
| 1456 |
-
|
| 1457 |
-
|
| 1458 |
|
| 1459 |
case 'type':
|
| 1460 |
const typedName = this.modal.querySelector('#typeSignature').value;
|
| 1461 |
-
if (!typedName)
|
|
|
|
|
|
|
| 1462 |
return {
|
| 1463 |
type: 'TYPED',
|
| 1464 |
-
text: typedName
|
|
|
|
| 1465 |
};
|
| 1466 |
|
| 1467 |
case 'witness':
|
| 1468 |
-
const witnessData = await this.getWitnessSignature();
|
| 1469 |
-
if (!witnessData)
|
|
|
|
|
|
|
| 1470 |
return {
|
| 1471 |
type: 'WITNESS',
|
| 1472 |
...witnessData
|
| 1473 |
};
|
| 1474 |
|
| 1475 |
default:
|
| 1476 |
-
|
| 1477 |
}
|
| 1478 |
},
|
| 1479 |
|
|
|
|
| 162 |
padding-right: max(0.75rem, env(safe-area-inset-right));
|
| 163 |
}
|
| 164 |
}
|
| 165 |
+
|
| 166 |
+
.signature-pad-container {
|
| 167 |
+
position: relative;
|
| 168 |
+
width: 100%;
|
| 169 |
+
height: 200px;
|
| 170 |
+
border: 1px solid #e5e7eb;
|
| 171 |
+
border-radius: 0.375rem;
|
| 172 |
+
background-color: white;
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
.signature-pad-container canvas {
|
| 176 |
+
position: absolute;
|
| 177 |
+
left: 0;
|
| 178 |
+
top: 0;
|
| 179 |
+
width: 100%;
|
| 180 |
+
height: 100%;
|
| 181 |
+
border-radius: 0.375rem;
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
.signature-pad-actions {
|
| 185 |
+
display: flex;
|
| 186 |
+
justify-content: space-between;
|
| 187 |
+
margin-top: 0.5rem;
|
| 188 |
+
}
|
| 189 |
+
|
| 190 |
+
.signature-pad-actions button {
|
| 191 |
+
padding: 0.5rem 1rem;
|
| 192 |
+
font-size: 0.875rem;
|
| 193 |
+
border-radius: 0.375rem;
|
| 194 |
+
transition: all 0.2s;
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
.signature-pad-actions button:hover {
|
| 198 |
+
opacity: 0.9;
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
.signature-pad-actions button:focus {
|
| 202 |
+
outline: none;
|
| 203 |
+
box-shadow: 0 0 0 2px #3b82f6, 0 0 0 4px white;
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
/* High contrast mode support */
|
| 207 |
+
@media (forced-colors: active) {
|
| 208 |
+
.signature-pad-container {
|
| 209 |
+
border: 2px solid CanvasText;
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
.signature-pad-actions button {
|
| 213 |
+
border: 2px solid CanvasText;
|
| 214 |
+
}
|
| 215 |
+
}
|
| 216 |
</style>
|
| 217 |
+
<!-- Add this in the head section -->
|
| 218 |
+
<script src="https://cdn.jsdelivr.net/npm/signature_pad@4.0.0/dist/signature_pad.umd.min.js"></script>
|
| 219 |
</head>
|
| 220 |
<body class="bg-gray-50 font-sans">
|
| 221 |
<div class="flex h-screen overflow-hidden">
|
|
|
|
| 693 |
<!-- Signature Capture -->
|
| 694 |
<div class="space-y-4">
|
| 695 |
<h3 class="font-medium text-gray-900">Signature</h3>
|
| 696 |
+
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
| 697 |
<div>
|
| 698 |
<label class="block text-sm font-medium text-gray-700">Signature Type</label>
|
| 699 |
<div class="mt-2 space-y-2">
|
|
|
|
| 951 |
|
| 952 |
<!-- Signature Pad -->
|
| 953 |
<div>
|
| 954 |
+
<div class="signature-pad-container">
|
| 955 |
+
<canvas id="signaturePad"></canvas>
|
| 956 |
+
</div>
|
| 957 |
+
<div class="signature-pad-actions">
|
| 958 |
<button type="button" onclick="clearSignature()" class="text-sm text-gray-600 hover:text-gray-900">
|
| 959 |
Clear
|
| 960 |
</button>
|
|
|
|
| 1363 |
}
|
| 1364 |
};
|
| 1365 |
|
| 1366 |
+
// Signature Pad Implementation
|
| 1367 |
+
let signaturePad = null;
|
| 1368 |
+
|
| 1369 |
+
function initializeSignaturePad() {
|
| 1370 |
+
const canvas = document.getElementById('signaturePad');
|
| 1371 |
+
const ratio = Math.max(window.devicePixelRatio || 1, 1);
|
| 1372 |
+
|
| 1373 |
+
// Set canvas size
|
| 1374 |
+
canvas.width = canvas.offsetWidth * ratio;
|
| 1375 |
+
canvas.height = canvas.offsetHeight * ratio;
|
| 1376 |
+
canvas.getContext('2d').scale(ratio, ratio);
|
| 1377 |
+
|
| 1378 |
+
// Initialize signature pad
|
| 1379 |
+
signaturePad = new SignaturePad(canvas, {
|
| 1380 |
+
backgroundColor: 'rgb(255, 255, 255)',
|
| 1381 |
+
penColor: 'rgb(0, 0, 0)',
|
| 1382 |
+
velocityFilterWeight: 0.7,
|
| 1383 |
+
minWidth: 0.5,
|
| 1384 |
+
maxWidth: 2.5,
|
| 1385 |
+
throttle: 16,
|
| 1386 |
+
minDistance: 1
|
| 1387 |
+
});
|
| 1388 |
+
|
| 1389 |
+
// Handle window resize
|
| 1390 |
+
window.addEventListener('resize', () => {
|
| 1391 |
+
const ratio = Math.max(window.devicePixelRatio || 1, 1);
|
| 1392 |
+
canvas.width = canvas.offsetWidth * ratio;
|
| 1393 |
+
canvas.height = canvas.offsetHeight * ratio;
|
| 1394 |
+
canvas.getContext('2d').scale(ratio, ratio);
|
| 1395 |
+
signaturePad.clear();
|
| 1396 |
+
});
|
| 1397 |
+
}
|
| 1398 |
+
|
| 1399 |
+
function clearSignature() {
|
| 1400 |
+
if (signaturePad) {
|
| 1401 |
+
signaturePad.clear();
|
| 1402 |
+
}
|
| 1403 |
+
}
|
| 1404 |
+
|
| 1405 |
+
async function saveSignature() {
|
| 1406 |
+
if (!signaturePad || signaturePad.isEmpty()) {
|
| 1407 |
+
alert('Please provide a signature');
|
| 1408 |
+
return null;
|
| 1409 |
+
}
|
| 1410 |
+
|
| 1411 |
+
try {
|
| 1412 |
+
const signatureData = await signaturePad.toDataURL('image/png');
|
| 1413 |
+
return {
|
| 1414 |
+
type: 'DIGITAL',
|
| 1415 |
+
image: signatureData,
|
| 1416 |
+
timestamp: new Date().toISOString()
|
| 1417 |
+
};
|
| 1418 |
+
} catch (error) {
|
| 1419 |
+
console.error('Error saving signature:', error);
|
| 1420 |
+
alert('Failed to save signature');
|
| 1421 |
+
return null;
|
| 1422 |
+
}
|
| 1423 |
+
}
|
| 1424 |
+
|
| 1425 |
// Consent Management
|
| 1426 |
const ConsentManager = {
|
| 1427 |
currentParticipant: null,
|
|
|
|
| 1429 |
modal: null,
|
| 1430 |
signaturePad: null,
|
| 1431 |
identityVerified: false,
|
| 1432 |
+
signatureManager: null,
|
| 1433 |
|
| 1434 |
async initialize(participantId) {
|
| 1435 |
try {
|
|
|
|
| 1490 |
|
| 1491 |
initializeSignaturePad() {
|
| 1492 |
const canvas = this.modal.querySelector('#signaturePad');
|
| 1493 |
+
this.signatureManager = new SignatureManager();
|
| 1494 |
+
this.signatureManager.initialize(canvas);
|
| 1495 |
+
|
| 1496 |
+
// Setup type input if exists
|
| 1497 |
+
const typeInput = this.modal.querySelector('#typeSignature');
|
| 1498 |
+
if (typeInput) {
|
| 1499 |
+
this.signatureManager.setupTypeInput(typeInput);
|
| 1500 |
+
}
|
| 1501 |
+
|
| 1502 |
+
// Setup witness form if exists
|
| 1503 |
+
const witnessForm = this.modal.querySelector('#witnessForm');
|
| 1504 |
+
if (witnessForm) {
|
| 1505 |
+
this.signatureManager.setupWitnessForm(witnessForm);
|
| 1506 |
+
}
|
| 1507 |
},
|
| 1508 |
|
| 1509 |
addEventListeners() {
|
|
|
|
| 1575 |
|
| 1576 |
switch (signatureType) {
|
| 1577 |
case 'draw':
|
| 1578 |
+
const signatureData = await saveSignature();
|
| 1579 |
+
if (!signatureData) {
|
| 1580 |
+
throw new Error('Please provide a signature');
|
| 1581 |
+
}
|
| 1582 |
+
return signatureData;
|
| 1583 |
|
| 1584 |
case 'type':
|
| 1585 |
const typedName = this.modal.querySelector('#typeSignature').value;
|
| 1586 |
+
if (!typedName) {
|
| 1587 |
+
throw new Error('Please type your name');
|
| 1588 |
+
}
|
| 1589 |
return {
|
| 1590 |
type: 'TYPED',
|
| 1591 |
+
text: typedName,
|
| 1592 |
+
timestamp: new Date().toISOString()
|
| 1593 |
};
|
| 1594 |
|
| 1595 |
case 'witness':
|
| 1596 |
+
const witnessData = await this.signatureManager.getWitnessSignature();
|
| 1597 |
+
if (!witnessData) {
|
| 1598 |
+
throw new Error('Please complete witness information');
|
| 1599 |
+
}
|
| 1600 |
return {
|
| 1601 |
type: 'WITNESS',
|
| 1602 |
...witnessData
|
| 1603 |
};
|
| 1604 |
|
| 1605 |
default:
|
| 1606 |
+
throw new Error('Invalid signature type');
|
| 1607 |
}
|
| 1608 |
},
|
| 1609 |
|