dataquantals commited on
Commit
7549acf
·
verified ·
1 Parent(s): b50651d

undefined - Initial Deployment

Browse files
Files changed (2) hide show
  1. index.html +446 -302
  2. prompts.txt +0 -1
index.html CHANGED
@@ -793,6 +793,138 @@
793
  </div>
794
  </template>
795
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
796
  <script>
797
  // View Toggle
798
  function toggleView(view) {
@@ -1140,340 +1272,352 @@
1140
  document.documentElement.classList.add('high-contrast');
1141
  }
1142
 
1143
- // Consent Management
1144
- class ConsentManager {
1145
- constructor() {
1146
- this.modal = document.getElementById('consentModal');
1147
- this.signaturePad = null;
1148
- this.identityVerified = false;
1149
- this.setupEventListeners();
1150
- }
1151
-
1152
- setupEventListeners() {
1153
- // ID Upload
1154
- document.getElementById('idUpload').addEventListener('change', (e) => this.handleIdUpload(e));
1155
-
1156
- // Liveness Check
1157
- document.getElementById('startLivenessCheck').addEventListener('click', () => this.startLivenessCheck());
1158
-
1159
- // Language Change
1160
- document.getElementById('consentLanguage').addEventListener('change', () => this.updateConsentForm());
1161
-
1162
- // Signature Type
1163
- document.querySelectorAll('input[name="signatureType"]').forEach(input => {
1164
- input.addEventListener('change', (e) => this.toggleSignatureType(e.target.value));
1165
- });
1166
- }
1167
-
1168
- async openConsentModal(participantId) {
1169
- try {
1170
- const participant = await this.fetchParticipant(participantId);
1171
- this.currentParticipant = participant;
1172
-
1173
- // Load consent forms
1174
- const forms = await this.fetchConsentForms({
1175
- projectId: participant.projectId,
1176
- locale: participant.language
1177
- });
1178
-
1179
- this.populateConsentForm(forms);
1180
- this.modal.classList.remove('hidden');
1181
- this.initializeSignaturePad();
1182
- } catch (error) {
1183
- this.handleError(error);
1184
- }
1185
- }
1186
-
1187
- async handleIdUpload(event) {
1188
- const file = event.target.files[0];
1189
- if (!file) return;
1190
-
1191
- try {
1192
- const result = await this.verifyIdentity(file);
1193
- this.identityVerified = result.isVerified;
1194
- this.updateStatus('Identity verified');
1195
- } catch (error) {
1196
- this.handleError(error);
1197
- }
1198
  }
1199
-
1200
- async startLivenessCheck() {
1201
- try {
1202
- const stream = await navigator.mediaDevices.getUserMedia({ video: true });
1203
- // Implement liveness detection logic
1204
- this.updateStatus('Liveness check completed');
1205
- } catch (error) {
1206
- this.handleError(error);
1207
- }
1208
  }
1209
-
1210
- async updateConsentForm() {
1211
- const language = document.getElementById('consentLanguage').value;
1212
- const version = document.getElementById('consentVersion').value;
1213
-
1214
- try {
1215
- const form = await this.fetchConsentForm(language, version);
1216
- this.displayConsentForm(form);
1217
- } catch (error) {
1218
- this.handleError(error);
1219
- }
1220
  }
 
 
1221
 
1222
- initializeSignaturePad() {
1223
- const canvas = document.getElementById('signatureCanvas');
1224
- this.signaturePad = new SignaturePad(canvas, {
1225
- backgroundColor: 'rgb(255, 255, 255)',
1226
- penColor: 'rgb(0, 0, 0)'
1227
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1228
  }
1229
-
1230
- toggleSignatureType(type) {
1231
- const canvas = document.getElementById('signatureCanvas');
1232
- const typeInput = document.createElement('input');
1233
- typeInput.type = 'text';
1234
- typeInput.className = 'w-full h-48 border rounded p-2';
1235
-
1236
- if (type === 'type') {
1237
- canvas.parentNode.replaceChild(typeInput, canvas);
1238
- } else {
1239
- typeInput.parentNode.replaceChild(canvas, typeInput);
1240
- this.initializeSignaturePad();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1241
  }
1242
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1243
 
1244
- async processConsent() {
1245
- try {
1246
- if (!this.identityVerified) {
1247
- throw new Error('Identity verification required');
1248
- }
1249
 
1250
- const signature = await this.captureSignature();
1251
- const pdfBlob = await this.generateConsentPDF(signature);
1252
-
1253
- await this.saveConsent(pdfBlob);
1254
- this.updateParticipantStatus();
1255
- this.closeModal();
1256
- } catch (error) {
1257
- this.handleError(error);
1258
- }
1259
- }
1260
 
1261
- async captureSignature() {
1262
- if (this.signaturePad) {
1263
- return await this.signaturePad.toDataURL();
1264
- }
1265
- return document.querySelector('input[type="text"]').value;
1266
  }
1267
 
1268
- async generateConsentPDF(signature) {
1269
- // Implement PDF generation
1270
- return new Blob(['PDF content'], { type: 'application/pdf' });
1271
- }
 
 
 
 
 
 
 
 
 
 
 
 
1272
 
1273
- async saveConsent(pdfBlob) {
1274
- try {
1275
- await this.api.post('/consents', {
1276
- participant_id: this.currentParticipant.id,
1277
- pdf: pdfBlob,
1278
- audit_trail: this.createAuditTrail()
1279
- });
1280
- } catch (error) {
1281
- if (error instanceof OfflineError) {
1282
- await this.storeOfflineConsent(pdfBlob);
1283
- }
1284
- throw error;
1285
- }
1286
  }
1287
 
1288
- createAuditTrail() {
1289
- return {
1290
- timestamp: new Date().toISOString(),
1291
- action: 'CONSENT_UPDATE',
1292
- participant: this.currentParticipant.id,
1293
- device: this.getDeviceType(),
1294
- offline: !navigator.onLine
1295
- };
1296
- }
1297
 
1298
- getDeviceType() {
1299
- return /Mobile|Android|iPhone/i.test(navigator.userAgent) ? 'mobile' : 'desktop';
1300
- }
1301
 
1302
- updateStatus(message) {
1303
- document.getElementById('consentStatus').textContent = message;
1304
- }
 
1305
 
1306
- handleError(error) {
1307
- console.error('Consent Error:', error);
1308
- this.updateStatus(`Error: ${error.message}`);
1309
- }
1310
 
1311
- closeModal() {
1312
- this.modal.classList.add('hidden');
1313
- this.identityVerified = false;
1314
- this.updateStatus('Ready to process consent');
1315
- }
1316
  }
1317
 
1318
  // Initialize consent manager
1319
  const consentManager = new ConsentManager();
1320
 
1321
- // Update consent button click handler
1322
- document.querySelectorAll('.action-button[aria-label="Update Consent"]').forEach(button => {
1323
- button.addEventListener('click', () => {
1324
- const participantId = button.closest('.participant-card').querySelector('.text-lg').textContent;
1325
- consentManager.openConsentModal(participantId);
1326
- });
1327
- });
1328
-
1329
- function closeConsentModal() {
1330
- consentManager.closeModal();
1331
- }
1332
-
1333
- function clearSignature() {
1334
- if (consentManager.signaturePad) {
1335
- consentManager.signaturePad.clear();
1336
- }
1337
  }
1338
 
1339
- function processConsent() {
1340
- consentManager.processConsent();
 
 
 
1341
  }
1342
 
1343
- // Add SignaturePad library
1344
- const signaturePadScript = document.createElement('script');
1345
- signaturePadScript.src = 'https://cdn.jsdelivr.net/npm/signature_pad@4.0.0/dist/signature_pad.umd.min.js';
1346
- document.head.appendChild(signaturePadScript);
1347
-
1348
  // New Session Modal
1349
  class SessionManager {
1350
- constructor() {
1351
- this.currentParticipant = null;
1352
- this.currentProject = null;
1353
- this.modal = null;
1354
- this.selectedSessionType = null;
1355
- }
1356
-
1357
- async initializeSession(participantId) {
1358
- try {
1359
- // Check consent status
1360
- const participant = await this.fetchParticipant(participantId);
1361
- if (participant.consentStatus !== 'ACTIVE') {
1362
- this.showConsentRequiredModal(participantId);
1363
- return;
1364
- }
1365
-
1366
- // Check for incomplete sessions
1367
- const incompleteSessions = await this.fetchIncompleteSessions(participantId);
1368
- if (incompleteSessions.length >= 3) {
1369
- this.showWarningModal('TooManyIncompleteSessions', { count: 3 });
1370
- return;
1371
- }
1372
-
1373
- this.currentParticipant = participant;
1374
- this.currentProject = await this.fetchCurrentProject();
1375
- this.showNewSessionModal();
1376
- } catch (error) {
1377
- this.handleError(error);
1378
- }
1379
- }
1380
-
1381
- async fetchParticipant(participantId) {
1382
- // Simulated API call
1383
- return {
1384
- id: participantId,
1385
- consentStatus: 'ACTIVE',
1386
- language: 'bem_ZM'
1387
- };
1388
- }
1389
-
1390
- async fetchCurrentProject() {
1391
- // Simulated API call
1392
- return {
1393
- id: 'urban-sustainability',
1394
- methodology: 'QUALITATIVE'
1395
- };
1396
- }
1397
-
1398
- async fetchIncompleteSessions(participantId) {
1399
- // Simulated API call
1400
- return [];
1401
  }
 
 
 
 
 
 
 
 
 
 
1402
 
1403
- showNewSessionModal() {
1404
- const template = document.getElementById('newSessionModal');
1405
- const modalContent = template.content.cloneNode(true);
1406
- this.modal = document.createElement('div');
1407
- this.modal.appendChild(modalContent);
1408
- document.body.appendChild(this.modal);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1409
 
1410
- // Add event listeners
1411
- this.modal.querySelectorAll('.session-type-btn').forEach(btn => {
1412
- btn.addEventListener('click', () => this.selectSessionType(btn.dataset.type));
1413
- });
1414
- }
 
1415
 
1416
- selectSessionType(type) {
1417
- this.selectedSessionType = type;
1418
- this.modal.querySelectorAll('.session-type-btn').forEach(btn => {
1419
- btn.classList.toggle('border-blue-500', btn.dataset.type === type);
1420
- });
1421
  }
1422
 
1423
- async startNewSession() {
1424
- if (!this.selectedSessionType) {
1425
- this.showError('Please select a session type');
1426
- return;
1427
- }
1428
-
1429
- try {
1430
- const sessionData = {
1431
- participant_id: this.currentParticipant.id,
1432
- project_id: this.currentProject.id,
1433
- default_language: this.modal.querySelector('.session-language').value,
1434
- metadata: {
1435
- preferred_communication: this.modal.querySelector('input[name="communication"]:checked').value,
1436
- accessibility_requirements: Array.from(this.modal.querySelectorAll('input[name="accessibility"]:checked')).map(cb => cb.value)
1437
- }
1438
- };
1439
-
1440
- // Route based on session type
1441
- switch (this.selectedSessionType) {
1442
- case 'interview':
1443
- window.location.href = `/interviews/new?participant=${this.currentParticipant.id}`;
1444
- break;
1445
- case 'survey':
1446
- this.launchSurveyWizard(this.currentParticipant.id);
1447
- break;
1448
- case 'observation':
1449
- window.location.href = `/observations?participant=${this.currentParticipant.id}`;
1450
- break;
1451
- }
1452
- } catch (error) {
1453
- this.handleError(error);
1454
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1455
  }
1456
-
1457
- handleError(error) {
1458
- console.error('Session error:', error);
1459
- // Show appropriate error message to user
1460
- this.showError(error.message);
1461
- }
1462
-
1463
- showError(message) {
1464
- // Implement error display logic
1465
- alert(message);
1466
- }
1467
-
1468
- showConsentRequiredModal(participantId) {
1469
- // Implement consent required modal
1470
- alert('Active consent required to start a new session');
1471
- }
1472
-
1473
- showWarningModal(type, data) {
1474
- // Implement warning modal
1475
- alert(`Warning: ${type} - ${JSON.stringify(data)}`);
1476
- }
 
1477
  }
1478
 
1479
  // Initialize session manager
@@ -1481,14 +1625,14 @@
1481
 
1482
  // Update the existing newSession function
1483
  function newSession(participantId) {
1484
- sessionManager.initializeSession(participantId);
1485
  }
1486
 
1487
  function closeNewSessionModal() {
1488
- const modal = document.querySelector('#newSessionModal').parentElement;
1489
- if (modal) {
1490
- modal.remove();
1491
- }
1492
  }
1493
  </script>
1494
  <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://deepsite.hf.co/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://deepsite.hf.co" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://deepsite.hf.co?remix=dataquantals/quantals-collect" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
 
793
  </div>
794
  </template>
795
 
796
+ <!-- Consent Update Modal Template -->
797
+ <template id="consentUpdateModal">
798
+ <div class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50">
799
+ <div class="bg-white rounded-lg shadow-xl w-full max-w-4xl max-h-[90vh] overflow-y-auto">
800
+ <!-- Header -->
801
+ <div class="p-6 border-b border-gray-200">
802
+ <div class="flex items-center justify-between">
803
+ <h3 class="text-xl font-semibold text-gray-900">Update Consent</h3>
804
+ <button type="button" class="text-gray-400 hover:text-gray-500" onclick="closeConsentModal()">
805
+ <span class="sr-only">Close</span>
806
+ <i class="fas fa-times"></i>
807
+ </button>
808
+ </div>
809
+ </div>
810
+
811
+ <!-- Content -->
812
+ <div class="p-6">
813
+ <!-- Identity Verification -->
814
+ <div class="mb-8">
815
+ <h4 class="text-lg font-medium text-gray-900 mb-4">Identity Verification</h4>
816
+ <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
817
+ <!-- Photo ID Upload -->
818
+ <div class="border-2 border-dashed border-gray-300 rounded-lg p-6 text-center">
819
+ <input type="file" id="photoIdUpload" accept="image/*" class="hidden" onchange="handlePhotoIdUpload(event)">
820
+ <label for="photoIdUpload" class="cursor-pointer">
821
+ <i class="fas fa-id-card text-3xl text-gray-400 mb-2"></i>
822
+ <div class="text-sm text-gray-600">Upload Photo ID</div>
823
+ <div class="text-xs text-gray-500 mt-1">Supported: JPG, PNG</div>
824
+ </label>
825
+ <div id="photoIdPreview" class="mt-4 hidden">
826
+ <img src="" alt="ID Preview" class="max-h-32 mx-auto">
827
+ <div class="mt-2 text-sm text-green-600">Edge detection successful</div>
828
+ </div>
829
+ </div>
830
+
831
+ <!-- Liveness Check -->
832
+ <div class="border-2 border-dashed border-gray-300 rounded-lg p-6 text-center">
833
+ <button type="button" onclick="startLivenessCheck()" class="w-full">
834
+ <i class="fas fa-camera text-3xl text-gray-400 mb-2"></i>
835
+ <div class="text-sm text-gray-600">Start Liveness Check</div>
836
+ <div class="text-xs text-gray-500 mt-1">Required for e-signatures</div>
837
+ </button>
838
+ <div id="livenessStatus" class="mt-4 hidden">
839
+ <div class="text-sm text-green-600">Verification successful</div>
840
+ </div>
841
+ </div>
842
+ </div>
843
+ </div>
844
+
845
+ <!-- Document Selection -->
846
+ <div class="mb-8">
847
+ <h4 class="text-lg font-medium text-gray-900 mb-4">Consent Form</h4>
848
+ <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
849
+ <!-- Language Selection -->
850
+ <div>
851
+ <label class="block text-sm font-medium text-gray-700 mb-2">Language</label>
852
+ <select id="consentLanguage" class="w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500">
853
+ <option value="bem_ZM">Bemba (Zambia)</option>
854
+ <option value="nya_ZM">Nyanja (Zambia)</option>
855
+ <option value="toi_ZM">Tonga (Zambia)</option>
856
+ <option value="en_ZM">English (Zambia)</option>
857
+ </select>
858
+ </div>
859
+
860
+ <!-- Version Selection -->
861
+ <div>
862
+ <label class="block text-sm font-medium text-gray-700 mb-2">Form Version</label>
863
+ <select id="consentVersion" class="w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500">
864
+ <option value="v2.1-2025">Version 2.1 (2025)</option>
865
+ <option value="v2.0-2024">Version 2.0 (2024)</option>
866
+ </select>
867
+ </div>
868
+ </div>
869
+
870
+ <!-- Form Preview -->
871
+ <div class="mt-4 border rounded-lg p-4">
872
+ <iframe id="consentPreview" class="w-full h-64 border-0"></iframe>
873
+ </div>
874
+ </div>
875
+
876
+ <!-- Signature Capture -->
877
+ <div class="mb-8">
878
+ <h4 class="text-lg font-medium text-gray-900 mb-4">Signature</h4>
879
+ <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
880
+ <!-- Signature Type -->
881
+ <div>
882
+ <label class="block text-sm font-medium text-gray-700 mb-2">Signature Type</label>
883
+ <div class="space-y-2">
884
+ <label class="inline-flex items-center">
885
+ <input type="radio" name="signatureType" value="draw" class="form-radio text-blue-600" checked>
886
+ <span class="ml-2">Draw Signature</span>
887
+ </label>
888
+ <label class="inline-flex items-center">
889
+ <input type="radio" name="signatureType" value="type" class="form-radio text-blue-600">
890
+ <span class="ml-2">Type Signature</span>
891
+ </label>
892
+ <label class="inline-flex items-center">
893
+ <input type="radio" name="signatureType" value="witness" class="form-radio text-blue-600">
894
+ <span class="ml-2">Witness Co-sign</span>
895
+ </label>
896
+ </div>
897
+ </div>
898
+
899
+ <!-- Signature Pad -->
900
+ <div>
901
+ <div id="signaturePad" class="border rounded-lg h-32 bg-white"></div>
902
+ <div class="mt-2 flex justify-between">
903
+ <button type="button" onclick="clearSignature()" class="text-sm text-gray-600 hover:text-gray-900">
904
+ Clear
905
+ </button>
906
+ <button type="button" onclick="saveSignature()" class="text-sm text-blue-600 hover:text-blue-900">
907
+ Save
908
+ </button>
909
+ </div>
910
+ </div>
911
+ </div>
912
+ </div>
913
+ </div>
914
+
915
+ <!-- Footer -->
916
+ <div class="px-6 py-4 bg-gray-50 border-t border-gray-200 flex justify-end space-x-3">
917
+ <button type="button" class="px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500" onclick="closeConsentModal()">
918
+ Cancel
919
+ </button>
920
+ <button type="button" class="px-4 py-2 text-sm font-medium text-white bg-blue-600 border border-transparent rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500" onclick="processConsent()">
921
+ Process Consent
922
+ </button>
923
+ </div>
924
+ </div>
925
+ </div>
926
+ </template>
927
+
928
  <script>
929
  // View Toggle
930
  function toggleView(view) {
 
1272
  document.documentElement.classList.add('high-contrast');
1273
  }
1274
 
1275
+ // API Response Types
1276
+ const API_RESPONSES = {
1277
+ USER: {
1278
+ "id": "user-123",
1279
+ "role": "RESEARCHER",
1280
+ "permissions": ["CONSENT_MANAGEMENT", "PARTICIPANT_EDIT"]
1281
+ },
1282
+ PARTICIPANT: {
1283
+ "id": "P-12",
1284
+ "language": "bem_ZM",
1285
+ "consentStatus": "ACTIVE",
1286
+ "metadata": {
1287
+ "preferredLanguage": "bem_ZM",
1288
+ "accessibility": []
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1289
  }
1290
+ },
1291
+ PROJECT: {
1292
+ "id": "urban-sustainability",
1293
+ "methodology": "QUALITATIVE",
1294
+ "consentForms": {
1295
+ "versions": ["v2.1-2025", "v2.0-2024"],
1296
+ "languages": ["bem_ZM", "nya_ZM", "toi_ZM", "en_ZM"]
 
 
1297
  }
1298
+ },
1299
+ CONSENT_FORM: {
1300
+ "id": "form-1",
1301
+ "version": "v2.1-2025",
1302
+ "language": "bem_ZM",
1303
+ "content": "Base64 encoded PDF content",
1304
+ "metadata": {
1305
+ "createdAt": "2024-01-01T00:00:00Z",
1306
+ "updatedAt": "2024-01-01T00:00:00Z"
 
 
1307
  }
1308
+ }
1309
+ };
1310
 
1311
+ class ConsentManager {
1312
+ constructor() {
1313
+ this.currentParticipant = null;
1314
+ this.currentProject = null;
1315
+ this.modal = null;
1316
+ this.signaturePad = null;
1317
+ this.identityVerified = false;
1318
+ }
1319
+
1320
+ async initializeConsent(participantId) {
1321
+ try {
1322
+ const user = await this.fetchCurrentUser();
1323
+ if (user.role !== 'RESEARCHER') {
1324
+ this.auditLog('CONSENT_ACCESS_DENIED', { userId: user.id });
1325
+ return;
1326
+ }
1327
+
1328
+ this.currentParticipant = await this.fetchParticipant(participantId);
1329
+ this.currentProject = await this.fetchCurrentProject();
1330
+ this.showConsentModal();
1331
+ } catch (error) {
1332
+ this.handleError(error);
1333
  }
1334
+ }
1335
+
1336
+ async fetchCurrentUser() {
1337
+ // Simulated API call
1338
+ return API_RESPONSES.USER;
1339
+ }
1340
+
1341
+ async fetchParticipant(participantId) {
1342
+ // Simulated API call
1343
+ return {
1344
+ ...API_RESPONSES.PARTICIPANT,
1345
+ id: participantId
1346
+ };
1347
+ }
1348
+
1349
+ async fetchCurrentProject() {
1350
+ // Simulated API call
1351
+ return API_RESPONSES.PROJECT;
1352
+ }
1353
+
1354
+ async fetchConsentForms(params) {
1355
+ // Simulated API call
1356
+ return [{
1357
+ ...API_RESPONSES.CONSENT_FORM,
1358
+ language: params.locale
1359
+ }];
1360
+ }
1361
+
1362
+ createAuditTrail() {
1363
+ return {
1364
+ "timestamp": new Date().toISOString(),
1365
+ "user": {
1366
+ "id": this.currentUser.id,
1367
+ "role": this.currentUser.role
1368
+ },
1369
+ "action": "CONSENT_UPDATE",
1370
+ "metadata": {
1371
+ "formVersion": this.modal.querySelector('#consentVersion').value,
1372
+ "language": this.modal.querySelector('#consentLanguage').value,
1373
+ "signatureType": this.modal.querySelector('input[name="signatureType"]:checked').value,
1374
+ "deviceInfo": {
1375
+ "type": this.getDeviceType(),
1376
+ "offline": !navigator.onLine
1377
  }
1378
+ }
1379
+ };
1380
+ }
1381
+
1382
+ async processPhotoId(file) {
1383
+ // Simulated photo processing
1384
+ return {
1385
+ "success": true,
1386
+ "edgesDetected": true,
1387
+ "previewUrl": URL.createObjectURL(file),
1388
+ "metadata": {
1389
+ "fileType": file.type,
1390
+ "fileSize": file.size,
1391
+ "timestamp": new Date().toISOString()
1392
+ }
1393
+ };
1394
+ }
1395
+
1396
+ async generateConsentPDF(data) {
1397
+ // Simulated PDF generation
1398
+ return {
1399
+ "participant": {
1400
+ "id": data.participant.id,
1401
+ "language": data.participant.language
1402
+ },
1403
+ "form": {
1404
+ "version": data.formVersion,
1405
+ "language": this.modal.querySelector('#consentLanguage').value
1406
+ },
1407
+ "signature": {
1408
+ "type": data.signature.type,
1409
+ "image": "Base64 encoded signature",
1410
+ "timestamp": new Date().toISOString()
1411
+ },
1412
+ "metadata": {
1413
+ "generatedAt": new Date().toISOString(),
1414
+ "deviceInfo": this.getDeviceType()
1415
+ }
1416
+ };
1417
+ }
1418
 
1419
+ async saveConsent(pdfBlob) {
1420
+ const formData = new FormData();
1421
+ formData.append('participant_id', this.currentParticipant.id);
1422
+ formData.append('pdf', pdfBlob);
1423
+ formData.append('audit_trail', JSON.stringify(this.createAuditTrail()));
1424
 
1425
+ const response = await fetch('/api/consents', {
1426
+ method: 'POST',
1427
+ body: formData
1428
+ });
 
 
 
 
 
 
1429
 
1430
+ if (!response.ok) {
1431
+ throw new Error('Failed to save consent');
 
 
 
1432
  }
1433
 
1434
+ return await response.json();
1435
+ }
1436
+
1437
+ async updateParticipantStatus() {
1438
+ const newStatus = this.currentParticipant.consentStatus === 'WITHDRAWN' ? 'ACTIVE' : 'ACTIVE';
1439
+ const response = await fetch(`/api/participants/${this.currentParticipant.id}`, {
1440
+ method: 'PATCH',
1441
+ headers: {
1442
+ 'Content-Type': 'application/json'
1443
+ },
1444
+ body: JSON.stringify({
1445
+ "consentStatus": newStatus,
1446
+ "updatedAt": new Date().toISOString(),
1447
+ "updatedBy": this.currentUser.id
1448
+ })
1449
+ });
1450
 
1451
+ if (!response.ok) {
1452
+ throw new Error('Failed to update participant status');
 
 
 
 
 
 
 
 
 
 
 
1453
  }
1454
 
1455
+ return await response.json();
1456
+ }
 
 
 
 
 
 
 
1457
 
1458
+ getDeviceType() {
1459
+ return /Mobile|Tablet|iPad|iPhone|Android/.test(navigator.userAgent) ? 'mobile' : 'desktop';
1460
+ }
1461
 
1462
+ handleError(error) {
1463
+ console.error('Consent error:', error);
1464
+ this.showError(error.message);
1465
+ }
1466
 
1467
+ showError(message) {
1468
+ // Implement error display logic
1469
+ alert(message);
1470
+ }
1471
 
1472
+ auditLog(action, data) {
1473
+ console.log('Audit:', action, data);
1474
+ }
 
 
1475
  }
1476
 
1477
  // Initialize consent manager
1478
  const consentManager = new ConsentManager();
1479
 
1480
+ // Update the existing updateConsent function
1481
+ function updateConsent(participantId) {
1482
+ consentManager.initializeConsent(participantId);
 
 
 
 
 
 
 
 
 
 
 
 
 
1483
  }
1484
 
1485
+ function closeConsentModal() {
1486
+ const modal = document.querySelector('#consentUpdateModal').parentElement;
1487
+ if (modal) {
1488
+ modal.remove();
1489
+ }
1490
  }
1491
 
 
 
 
 
 
1492
  // New Session Modal
1493
  class SessionManager {
1494
+ constructor() {
1495
+ this.currentParticipant = null;
1496
+ this.currentProject = null;
1497
+ this.modal = null;
1498
+ this.selectedSessionType = null;
1499
+ }
1500
+
1501
+ async initializeSession(participantId) {
1502
+ try {
1503
+ // Check consent status
1504
+ const participant = await this.fetchParticipant(participantId);
1505
+ if (participant.consentStatus !== 'ACTIVE') {
1506
+ this.showConsentRequiredModal(participantId);
1507
+ return;
1508
+ }
1509
+
1510
+ // Check for incomplete sessions
1511
+ const incompleteSessions = await this.fetchIncompleteSessions(participantId);
1512
+ if (incompleteSessions.length >= 3) {
1513
+ this.showWarningModal('TooManyIncompleteSessions', { count: 3 });
1514
+ return;
1515
+ }
1516
+
1517
+ this.currentParticipant = participant;
1518
+ this.currentProject = await this.fetchCurrentProject();
1519
+ this.showNewSessionModal();
1520
+ } catch (error) {
1521
+ this.handleError(error);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1522
  }
1523
+ }
1524
+
1525
+ async fetchParticipant(participantId) {
1526
+ // Simulated API call
1527
+ return {
1528
+ id: participantId,
1529
+ consentStatus: 'ACTIVE',
1530
+ language: 'bem_ZM'
1531
+ };
1532
+ }
1533
 
1534
+ async fetchCurrentProject() {
1535
+ // Simulated API call
1536
+ return {
1537
+ id: 'urban-sustainability',
1538
+ methodology: 'QUALITATIVE'
1539
+ };
1540
+ }
1541
+
1542
+ async fetchIncompleteSessions(participantId) {
1543
+ // Simulated API call
1544
+ return [];
1545
+ }
1546
+
1547
+ showNewSessionModal() {
1548
+ const template = document.getElementById('newSessionModal');
1549
+ const modalContent = template.content.cloneNode(true);
1550
+ this.modal = document.createElement('div');
1551
+ this.modal.appendChild(modalContent);
1552
+ document.body.appendChild(this.modal);
1553
+
1554
+ // Add event listeners
1555
+ this.modal.querySelectorAll('.session-type-btn').forEach(btn => {
1556
+ btn.addEventListener('click', () => this.selectSessionType(btn.dataset.type));
1557
+ });
1558
+ }
1559
 
1560
+ selectSessionType(type) {
1561
+ this.selectedSessionType = type;
1562
+ this.modal.querySelectorAll('.session-type-btn').forEach(btn => {
1563
+ btn.classList.toggle('border-blue-500', btn.dataset.type === type);
1564
+ });
1565
+ }
1566
 
1567
+ async startNewSession() {
1568
+ if (!this.selectedSessionType) {
1569
+ this.showError('Please select a session type');
1570
+ return;
 
1571
  }
1572
 
1573
+ try {
1574
+ const sessionData = {
1575
+ participant_id: this.currentParticipant.id,
1576
+ project_id: this.currentProject.id,
1577
+ default_language: this.modal.querySelector('.session-language').value,
1578
+ metadata: {
1579
+ preferred_communication: this.modal.querySelector('input[name="communication"]:checked').value,
1580
+ accessibility_requirements: Array.from(this.modal.querySelectorAll('input[name="accessibility"]:checked')).map(cb => cb.value)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1581
  }
1582
+ };
1583
+
1584
+ // Route based on session type
1585
+ switch (this.selectedSessionType) {
1586
+ case 'interview':
1587
+ window.location.href = `/interviews/new?participant=${this.currentParticipant.id}`;
1588
+ break;
1589
+ case 'survey':
1590
+ this.launchSurveyWizard(this.currentParticipant.id);
1591
+ break;
1592
+ case 'observation':
1593
+ window.location.href = `/observations?participant=${this.currentParticipant.id}`;
1594
+ break;
1595
+ }
1596
+ } catch (error) {
1597
+ this.handleError(error);
1598
  }
1599
+ }
1600
+
1601
+ handleError(error) {
1602
+ console.error('Session error:', error);
1603
+ // Show appropriate error message to user
1604
+ this.showError(error.message);
1605
+ }
1606
+
1607
+ showError(message) {
1608
+ // Implement error display logic
1609
+ alert(message);
1610
+ }
1611
+
1612
+ showConsentRequiredModal(participantId) {
1613
+ // Implement consent required modal
1614
+ alert('Active consent required to start a new session');
1615
+ }
1616
+
1617
+ showWarningModal(type, data) {
1618
+ // Implement warning modal
1619
+ alert(`Warning: ${type} - ${JSON.stringify(data)}`);
1620
+ }
1621
  }
1622
 
1623
  // Initialize session manager
 
1625
 
1626
  // Update the existing newSession function
1627
  function newSession(participantId) {
1628
+ sessionManager.initializeSession(participantId);
1629
  }
1630
 
1631
  function closeNewSessionModal() {
1632
+ const modal = document.querySelector('#newSessionModal').parentElement;
1633
+ if (modal) {
1634
+ modal.remove();
1635
+ }
1636
  }
1637
  </script>
1638
  <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://deepsite.hf.co/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://deepsite.hf.co" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://deepsite.hf.co?remix=dataquantals/quantals-collect" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
prompts.txt CHANGED
@@ -1 +0,0 @@
1
- <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Projects - Quantals Collect</title> <script src="https://cdn.tailwindcss.com"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> <style> /* Custom styles */ .project-card { transition: all 0.2s ease; } .project-card:hover { transform: translateY(-2px); box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); } .priority-dot { width: 8px; height: 8px; border-radius: 50%; } .priority-high { background-color: #ef4444; } .priority-medium { background-color: #f59e0b; } .priority-low { background-color: #10b981; } .status-badge { padding: 0.25rem 0.75rem; border-radius: 9999px; font-size: 0.75rem; font-weight: 500; } .status-active { background-color: #dcfce7; color: #166534; } .status-paused { background-color: #fef3c7; color: #92400e; } .status-completed { background-color: #dbeafe; color: #1e40af; } .status-archived { background-color: #f3f4f6; color: #374151; } .create-project-btn { position: fixed; bottom: 2rem; right: 2rem; z-index: 50; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); } .modal { transition: opacity 0.25s ease; } .modal-backdrop { background-color: rgba(0, 0, 0, 0.5); transition: opacity 0.25s ease; } .tag { transition: all 0.2s ease; } .tag:hover { transform: scale(1.05); } .drag-drop-zone { border: 2px dashed #e5e7eb; transition: all 0.2s ease; } .drag-drop-zone.dragover { border-color: #3b82f6; background-color: #eff6ff; } /* Table styles */ .table-container { overflow-x: auto; } .table-view th { position: sticky; top: 0; background-color: #f9fafb; z-index: 10; } .table-view tr:hover { background-color: #f3f4f6; } </style> </head> <body class="bg-gray-50 font-sans"> <div class="flex h-screen overflow-hidden"> <!-- Sidebar --> <div class="sidebar bg-indigo-800 text-white w-64 flex flex-col"> <div class="p-4 flex items-center space-x-3 border-b border-indigo-700"> <div class="bg-white p-2 rounded-lg"> <i class="fas fa-microscope text-indigo-800 text-xl"></i> </div> <h1 class="text-xl font-bold">Quantals Collect</h1> </div> <nav class="flex-1 p-4 space-y-2"> <a href="dashboard.html" class="flex items-center space-x-3 p-2 rounded-lg text-indigo-200 hover:bg-indigo-700 hover:text-white"> <i class="fas fa-home"></i> <span>Dashboard</span> </a> <a href="projects.html" class="flex items-center space-x-3 p-2 rounded-lg bg-indigo-700 text-white"> <i class="fas fa-project-diagram"></i> <span>Projects</span> </a> <a href="participants.html" class="flex items-center space-x-3 p-2 rounded-lg text-indigo-200 hover:bg-indigo-700 hover:text-white"> <i class="fas fa-users"></i> <span>Participants</span> </a> <a href="interviews.html" class="flex items-center space-x-3 p-2 rounded-lg text-indigo-200 hover:bg-indigo-700 hover:text-white"> <i class="fas fa-microphone"></i> <span>Interviews</span> </a> <a href="notes.html" class="flex items-center space-x-3 p-2 rounded-lg text-indigo-200 hover:bg-indigo-700 hover:text-white"> <i class="fas fa-sticky-note"></i> <span>Notes</span> </a> <a href="analysis.html" class="flex items-center space-x-3 p-2 rounded-lg text-indigo-200 hover:bg-indigo-700 hover:text-white"> <i class="fas fa-chart-pie"></i> <span>Analysis</span> </a> </nav> <div class="p-4 border-t border-indigo-700"> <a href="settings.html" class="flex items-center space-x-3 p-2 rounded-lg text-indigo-200 hover:bg-indigo-700 hover:text-white"> <i class="fas fa-cog"></i> <span>Settings</span> </a> </div> </div> <!-- Main Content --> <div class="flex-1 flex flex-col overflow-hidden"> <!-- Header --> <header class="bg-white shadow-sm p-4"> <div class="flex justify-between items-center"> <div class="flex items-center space-x-4"> <nav class="text-sm"> <ol class="list-none p-0 inline-flex"> <li class="flex items-center"> <a href="dashboard.html" class="text-gray-500 hover:text-gray-700">Dashboard</a> <i class="fas fa-chevron-right text-gray-400 mx-2"></i> </li> <li class="text-gray-700">Projects</li> </ol> </nav> </div> <div class="flex items-center space-x-4"> <button id="viewToggle" class="p-2 rounded-lg hover:bg-gray-100"> <i class="fas fa-th-large text-gray-600"></i> </button> <div class="relative"> <input type="text" placeholder="Search projects..." class="pl-10 pr-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500"> <i class="fas fa-search absolute left-3 top-3 text-gray-400"></i> </div> </div> </div> </header> <!-- Main Content Area --> <main class="flex-1 overflow-y-auto p-6"> <div class="max-w-7xl mx-auto"> <!-- Filters --> <div class="mb-6 flex flex-wrap gap-4"> <select class="px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500"> <option value="">All Status</option> <option value="active">Active</option> <option value="paused">Paused</option> <option value="completed">Completed</option> <option value="archived">Archived</option> </select> <select class="px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500"> <option value="">All Methodologies</option> <option value="qualitative">Qualitative</option> <option value="quantitative">Quantitative</option> <option value="mixed">Mixed Methods</option> </select> <select class="px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500"> <option value="">All Team Members</option> <option value="1">John Doe</option> <option value="2">Jane Smith</option> </select> </div> <!-- Grid View --> <div id="gridView" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"> <!-- Project Card --> <div class="project-card bg-white rounded-lg shadow-sm p-6"> <div class="flex justify-between items-start mb-4"> <div class="flex items-center space-x-2"> <div class="priority-dot priority-high"></div> <h3 class="text-lg font-semibold text-gray-800">Urban Sustainability Study</h3> </div> <div class="flex items-center space-x-2"> <span class="status-badge status-active">Active</span> <button class="p-2 hover:bg-gray-100 rounded-lg"> <i class="fas fa-ellipsis-v text-gray-600"></i> </button> </div> </div> <div class="space-y-4"> <div> <p class="text-sm text-gray-600">Research Questions:</p> <p class="text-sm text-gray-800 line-clamp-2">How do urban residents perceive and interact with green spaces? What factors influence their usage patterns?</p> </div> <div class="flex items-center justify-between"> <div class="flex items-center space-x-2"> <span class="px-2 py-1 bg-blue-100 text-blue-800 text-xs rounded-full">Qualitative</span> <span class="px-2 py-1 bg-green-100 text-green-800 text-xs rounded-full">#Sustainability</span> </div> <div class="flex items-center space-x-2"> <i class="fas fa-users text-gray-400"></i> <span class="text-sm text-gray-600">3 members</span> </div> </div> <div> <div class="flex justify-between text-sm text-gray-600 mb-1"> <span>Progress</span> <span>45%</span> </div> <div class="h-2 bg-gray-200 rounded-full"> <div class="h-2 bg-indigo-600 rounded-full" style="width: 45%"></div> </div> </div> </div> </div> <!-- More Project Cards... --> </div> <!-- Table View (Hidden by default) --> <div id="tableView" class="hidden"> <div class="table-container"> <table class="table-view w-full"> <thead> <tr class="text-left"> <th class="p-4">Project</th> <th class="p-4">Status</th> <th class="p-4">Methodology</th> <th class="p-4">Progress</th> <th class="p-4">Team</th> <th class="p-4">Actions</th> </tr> </thead> <tbody> <tr> <td class="p-4"> <div class="flex items-center space-x-2"> <div class="priority-dot priority-high"></div> <span class="font-medium">Urban Sustainability Study</span> </div> </td> <td class="p-4"> <span class="status-badge status-active">Active</span> </td> <td class="p-4"> <span class="px-2 py-1 bg-blue-100 text-blue-800 text-xs rounded-full">Qualitative</span> </td> <td class="p-4"> <div class="w-32"> <div class="h-2 bg-gray-200 rounded-full"> <div class="h-2 bg-indigo-600 rounded-full" style="width: 45%"></div> </div> </div> </td> <td class="p-4"> <div class="flex -space-x-2"> <div class="w-8 h-8 rounded-full bg-indigo-100 flex items-center justify-center"> <span class="text-xs font-medium text-indigo-800">JD</span> </div> <div class="w-8 h-8 rounded-full bg-green-100 flex items-center justify-center"> <span class="text-xs font-medium text-green-800">JS</span> </div> </div> </td> <td class="p-4"> <button class="p-2 hover:bg-gray-100 rounded-lg"> <i class="fas fa-ellipsis-v text-gray-600"></i> </button> </td> </tr> </tbody> </table> </div> </div> </div> </main> </div> </div> <!-- Create Project Button --> <button class="create-project-btn p-4 bg-indigo-600 text-white rounded-full hover:bg-indigo-700 transition-colors"> <i class="fas fa-plus mr-2"></i> Create Project </button> <!-- Create Project Modal --> <div id="createProjectModal" class="modal hidden fixed inset-0 z-50"> <div class="modal-backdrop absolute inset-0"></div> <div class="relative min-h-screen flex items-center justify-center p-4"> <div class="bg-white rounded-lg shadow-xl max-w-4xl w-full max-h-[90vh] overflow-y-auto"> <div class="p-6 border-b border-gray-200"> <div class="flex justify-between items-center"> <h3 class="text-xl font-semibold text-gray-800">Create New Project</h3> <button class="p-2 hover:bg-gray-100 rounded-lg"> <i class="fas fa-times text-gray-600"></i> </button> </div> </div> <div class="p-6"> <form class="space-y-6"> <!-- Basic Info --> <div> <h4 class="text-lg font-medium text-gray-800 mb-4">Basic Information</h4> <div class="space-y-4"> <div> <label class="block text-sm font-medium text-gray-700 mb-1">Project Title</label> <input type="text" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500" required> </div> <div> <label class="block text-sm font-medium text-gray-700 mb-1">Description</label> <textarea class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500" rows="4"></textarea> </div> <div class="grid grid-cols-2 gap-4"> <div> <label class="block text-sm font-medium text-gray-700 mb-1">Start Date</label> <input type="date" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500"> </div> <div> <label class="block text-sm font-medium text-gray-700 mb-1">End Date</label> <input type="date" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500"> </div> </div> </div> </div> <!-- Research Design --> <div> <h4 class="text-lg font-medium text-gray-800 mb-4">Research Design</h4> <div class="space-y-4"> <div> <label class="block text-sm font-medium text-gray-700 mb-1">Methodology</label> <select class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500"> <option value="qualitative">Qualitative</option> <option value="quantitative">Quantitative</option> <option value="mixed">Mixed Methods</option> </select> </div> <div> <label class="block text-sm font-medium text-gray-700 mb-1">Research Questions</label> <div class="space-y-2"> <div class="flex items-center space-x-2"> <input type="text" class="flex-1 px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500" placeholder="Enter research question"> <button class="p-2 text-gray-600 hover:text-gray-800"> <i class="fas fa-plus"></i> </button> </div> </div> </div> <div class="flex items-center"> <input type="checkbox" id="ethicsApproval" class="h-4 w-4 text-indigo-600 focus:ring-indigo-500 border-gray-300 rounded"> <label for="ethicsApproval" class="ml-2 block text-sm text-gray-700">Ethics approval required</label> </div> </div> </div> <!-- Team Assignment --> <div> <h4 class="text-lg font-medium text-gray-800 mb-4">Team Assignment</h4> <div class="space-y-4"> <div> <label class="block text-sm font-medium text-gray-700 mb-1">Search Team Members</label> <input type="text" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500" placeholder="Search by name or email"> </div> <div class="space-y-2"> <div class="flex items-center justify-between p-2 bg-gray-50 rounded-lg"> <div class="flex items-center space-x-2"> <div class="w-8 h-8 rounded-full bg-indigo-100 flex items-center justify-center"> <span class="text-xs font-medium text-indigo-800">JD</span> </div> <span class="text-sm">John Doe</span> </div> <select class="px-3 py-1 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500"> <option value="owner">Owner</option> <option value="editor">Editor</option> <option value="viewer">Viewer</option> </select> </div> </div> </div> </div> <!-- Document Upload --> <div> <h4 class="text-lg font-medium text-gray-800 mb-4">Documents</h4> <div class="drag-drop-zone p-8 text-center rounded-lg"> <i class="fas fa-cloud-upload-alt text-4xl text-gray-400 mb-2"></i> <p class="text-gray-600">Drag and drop files here or click to browse</p> <p class="text-sm text-gray-500 mt-1">Supports PDF, DOCX (max 10MB)</p> </div> </div> </form> </div> <div class="p-6 border-t border-gray-200 flex justify-end space-x-4"> <button class="px-4 py-2 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-50">Cancel</button> <button class="px-4 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700">Create Project</button> </div> </div> </div> </div> <script> // View Toggle const viewToggle = document.getElementById('viewToggle'); const gridView = document.getElementById('gridView'); const tableView = document.getElementById('tableView'); let isGridView = true; viewToggle.addEventListener('click', () => { isGridView = !isGridView; gridView.classList.toggle('hidden'); tableView.classList.toggle('hidden'); viewToggle.querySelector('i').classList.toggle('fa-th-large'); viewToggle.querySelector('i').classList.toggle('fa-list'); }); // Create Project Modal const createProjectBtn = document.querySelector('.create-project-btn'); const createProjectModal = document.getElementById('createProjectModal'); const modalBackdrop = createProjectModal.querySelector('.modal-backdrop'); createProjectBtn.addEventListener('click', () => { createProjectModal.classList.remove('hidden'); document.body.style.overflow = 'hidden'; }); function closeModal() { createProjectModal.classList.add('hidden'); document.body.style.overflow = ''; } modalBackdrop.addEventListener('click', closeModal); createProjectModal.querySelector('.fa-times').closest('button').addEventListener('click', closeModal); // Drag and Drop const dragDropZone = document.querySelector('.drag-drop-zone'); ['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => { dragDropZone.addEventListener(eventName, preventDefaults, false); }); function preventDefaults(e) { e.preventDefault(); e.stopPropagation(); } ['dragenter', 'dragover'].forEach(eventName => { dragDropZone.addEventListener(eventName, highlight, false); }); ['dragleave', 'drop'].forEach(eventName => { dragDropZone.addEventListener(eventName, unhighlight, false); }); function highlight(e) { dragDropZone.classList.add('dragover'); } function unhighlight(e) { dragDropZone.classList.remove('dragover'); } dragDropZone.addEventListener('drop', handleDrop, false); function handleDrop(e) { const dt = e.dataTransfer; const files = dt.files; handleFiles(files); } function handleFiles(files) { // Handle file upload logic here console.log('Files to upload:', files); } // Auto-save functionality let saveTimeout; const form = document.querySelector('form'); form.addEventListener('input', () => { clearTimeout(saveTimeout); saveTimeout = setTimeout(() => { // Simulate auto-save console.log('Auto-saving...'); }, 1500); }); // Initialize tooltips and other UI components document.addEventListener('DOMContentLoaded', () => { // Add any initialization code here }); </script> </body> </html>