-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHumanVerified.html
More file actions
785 lines (723 loc) · 27.1 KB
/
HumanVerified.html
File metadata and controls
785 lines (723 loc) · 27.1 KB
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
<!DOCTYPE html>
<html lang="en" data-bs-theme="dark">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Human-Verified Form - Advanced Bot Protection</title>
<!-- Bootstrap 5.3.8 CSS -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.8/css/bootstrap.min.css" rel="stylesheet">
<style>
.verification-indicator {
position: fixed;
top: 20px;
right: 20px;
z-index: 1050;
min-width: 200px;
}
.verification-level {
padding: 0.5rem 1rem;
border-radius: 20px;
font-weight: 600;
text-align: center;
margin-bottom: 0.5rem;
}
.level-none {
background: linear-gradient(45deg, #6c757d, #495057);
}
.level-basic {
background: linear-gradient(45deg, #ffc107, #fd7e14);
}
.level-enhanced {
background: linear-gradient(45deg, #17a2b8, #20c997);
}
.level-verified {
background: linear-gradient(45deg, #28a745, #20c997);
animation: pulse-success 2s infinite;
}
@keyframes pulse-success {
0%,
100% {
box-shadow: 0 0 10px rgba(40, 167, 69, 0.3);
}
50% {
box-shadow: 0 0 20px rgba(40, 167, 69, 0.6);
}
}
.form-protection-info {
background: rgba(255, 255, 255, 0.05);
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 10px;
}
.interaction-zone {
min-height: 200px;
border: 2px dashed rgba(255, 255, 255, 0.3);
background: rgba(255, 255, 255, 0.02);
border-radius: 10px;
transition: all 0.3s ease;
}
.interaction-zone:hover {
background: rgba(255, 255, 255, 0.05);
border-color: rgba(255, 255, 255, 0.5);
}
.verification-progress {
height: 6px;
border-radius: 3px;
}
.security-badge {
position: absolute;
top: -5px;
right: -5px;
background: #28a745;
color: white;
border-radius: 50%;
width: 20px;
height: 20px;
font-size: 12px;
display: flex;
align-items: center;
justify-content: center;
}
.form-section {
margin-bottom: 2rem;
padding: 1.5rem;
background: rgba(255, 255, 255, 0.03);
border-radius: 10px;
border: 1px solid rgba(255, 255, 255, 0.1);
}
</style>
</head>
<body class="bg-dark text-light">
<!-- Navigation -->
<nav class="navbar navbar-expand-lg navbar-dark sticky-top bg-gradient bg-body-tertiary">
<div class="container-fluid">
<a class="navbar-brand fw-bold" href="/../#overview">
<i class="bi bi-bootstrap-fill me-2"></i> Bootstrap Enhanced Components </a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ms-auto">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Demos </a>
<ul class="dropdown-menu pt-0">
<li>
<h5 class="px-3 py-2 text-nowrap text-primary border-bottom border-primary bg-dark-subtle rounded-top">
Production Ready </h5>
</li>
<li>
<a class="dropdown-item" href="https://yohn.github.io/Bootstrap-Enhanced-Components/JsonTable/Example.html">
JSON Table (like Data Tables) </a>
</li>
<li>
<a class="dropdown-item" href="https://yohn.github.io/Bootstrap-Enhanced-Components/YoBox/Example.html">
YoBox </a>
</li>
<li>
<a class="dropdown-item"
href="https://yohn.github.io/Bootstrap-Enhanced-Components/AutoTextarea/Example.html"> Auto Textarea
</a>
</li>
<li>
<a class="dropdown-item"
href="https://yohn.github.io/Bootstrap-Enhanced-Components/InputMask/Example.html"> Input Mask </a>
</li>
<li>
<a class="dropdown-item"
href="https://yohn.github.io/Bootstrap-Enhanced-Components/MultiSelect/Example.html"> Multi Select
</a>
</li>
<li>
<a class="dropdown-item"
href="https://yohn.github.io/Bootstrap-Enhanced-Components/FileUploadPreview/Example.html"> File
Upload Preview </a>
</li>
<li>
<a class="dropdown-item"
href="https://yohn.github.io/Bootstrap-Enhanced-Components/WysiwygEditor/Example.html"> Wysiwyg Editor
</a>
</li>
<li>
<a class="dropdown-item"
href="https://yohn.github.io/Bootstrap-Enhanced-Components/ToastAlerts/Example.html"> Toast Alerts
</a>
</li>
<li>
<a class="dropdown-item"
href="https://yohn.github.io/Bootstrap-Enhanced-Components/SimpleLightbox/Example.html"> Simple
Lightbox </a>
</li>
<li>
<a class="dropdown-item"
href="https://yohn.github.io/Bootstrap-Enhanced-Components/ContextMenu/Example.html"> Context Menu
</a>
</li>
<li>
<hr class="dropdown-divider">
</li>
<li>
<h5 class="px-3 py-2 text-nowrap text-primary border-bottom border-primary bg-dark-subtle"> Needs
Testing </h5>
</li>
<li>
<a class="dropdown-item"
href="https://yohn.github.io/Bootstrap-Enhanced-Components/BehaviorTracker/HumanVerified.html"> Human
Verified </a>
</li>
<li>
<a class="dropdown-item"
href="https://yohn.github.io/Bootstrap-Enhanced-Components/BehaviorTracker/Example.html"> Behavior
Tracker </a>
</li>
<li>
<a class="dropdown-item"
href="https://yohn.github.io/Bootstrap-Enhanced-Components/MultiLevelDropdown/Example.html"> Multi
Level Dropdown </a>
</li>
<li>
<a class="dropdown-item"
href="https://yohn.github.io/Bootstrap-Enhanced-Components/OnboardingTour/Example.html"> Onboarding
Tour </a>
</li>
<li>
<hr class="dropdown-divider">
</li>
<li>
<h5 class="px-3 py-2 text-nowrap text-primary border-bottom border-primary bg-dark-subtle rounded-top">
Needs Improvements </h5>
</li>
<li>
<a class="dropdown-item"
href="https://yohn.github.io/Bootstrap-Enhanced-Components/RateLimiter/Example.html"> Rate Limiter
</a>
</li>
<li>
<a class="dropdown-item"
href="https://yohn.github.io/Bootstrap-Enhanced-Components/ImageLightbox/Example.html"> Image Lightbox
</a>
</li>
</ul>
</li>
<li class="nav-item">
<a class="nav-link" href="/../#components">Components</a>
</li>
\ <li class="nav-item">
<a class="nav-link" href="https://github.com/Yohn/Bootstrap-Enhanced-Components" target="_blank">
<i class="bi bi-github"></i> GitHub </a>
</li>
</ul>
</div>
</div>
</nav>
<!-- Verification Indicator -->
<div id="verificationIndicator" class="verification-indicator">
<div class="card bg-dark border-secondary">
<div class="card-body p-3">
<div class="d-flex align-items-center mb-2">
<div class="security-badge">🛡️</div>
<h6 class="mb-0">Human Verification</h6>
</div>
<div id="verificationLevel" class="verification-level level-none"> ANALYZING... </div>
<div class="mb-2">
<small class="text-muted">Confidence Score</small>
<div class="progress verification-progress">
<div id="confidenceBar" class="progress-bar bg-info" style="width: 50%"></div>
</div>
<small id="confidenceText" class="text-muted">50%</small>
</div>
<div class="small text-muted">
<div>Session: <span id="sessionTime">0s</span></div>
<div>Interactions: <span id="interactionCount">0</span></div>
</div>
</div>
</div>
</div>
<div class="container py-5">
<div class="row justify-content-center">
<div class="col-lg-8">
<!-- Header -->
<div class="text-center mb-5">
<h1 class="display-5 mb-3">🔒 Secure Contact Form</h1>
<p class="lead text-muted"> Advanced bot protection with behavioral analysis </p>
</div>
<!-- Protection Info -->
<div class="form-protection-info p-4 mb-4">
<h5 class="mb-3">
<i class="bi bi-shield-check"></i> Multi-Layer Protection Active
</h5>
<div class="row">
<div class="col-md-6">
<ul class="list-unstyled small">
<li>✅ Behavioral tracking</li>
<li>✅ Timing analysis</li>
<li>✅ Interaction monitoring</li>
</ul>
</div>
<div class="col-md-6">
<ul class="list-unstyled small">
<li>✅ Mouse pattern analysis</li>
<li>✅ Keyboard rhythm detection</li>
<li>✅ Security checks</li>
</ul>
</div>
</div>
</div>
<!-- Main Form -->
<form id="protectedForm" class="needs-validation" novalidate>
<!-- Personal Information Section -->
<div class="form-section">
<h5 class="mb-4">📝 Personal Information</h5>
<div class="row">
<div class="col-md-6 mb-3">
<label for="firstName" class="form-label">First Name *</label>
<input type="text" id="firstName" name="firstName" class="form-control" required>
<div class="valid-feedback">Looks good!</div>
<div class="invalid-feedback">Please provide your first name.</div>
</div>
<div class="col-md-6 mb-3">
<label for="lastName" class="form-label">Last Name *</label>
<input type="text" id="lastName" name="lastName" class="form-control" required>
<div class="valid-feedback">Looks good!</div>
<div class="invalid-feedback">Please provide your last name.</div>
</div>
</div>
<div class="row">
<div class="col-md-6 mb-3">
<label for="email" class="form-label">Email Address *</label>
<input type="email" id="email" name="email" class="form-control" required>
<div class="valid-feedback">Email looks good!</div>
<div class="invalid-feedback">Please provide a valid email address.</div>
</div>
<div class="col-md-6 mb-3">
<label for="phone" class="form-label">Phone Number</label>
<input type="tel" id="phone" name="phone" class="form-control" data-mask="phone">
<div class="form-text">Format: (555) 123-4567</div>
</div>
</div>
</div>
<!-- Message Section -->
<div class="form-section">
<h5 class="mb-4">💬 Your Message</h5>
<div class="mb-3">
<label for="subject" class="form-label">Subject *</label>
<select id="subject" name="subject" class="form-select" required>
<option value="">Choose a subject...</option>
<option value="general">General Inquiry</option>
<option value="support">Technical Support</option>
<option value="sales">Sales Question</option>
<option value="feedback">Feedback</option>
<option value="other">Other</option>
</select>
<div class="invalid-feedback">Please select a subject.</div>
</div>
<div class="mb-3">
<label for="message" class="form-label">Message *</label>
<textarea id="message" name="message" class="form-control" rows="5" required
placeholder="Please describe your inquiry in detail..."></textarea>
<div class="invalid-feedback">Please provide your message.</div>
</div>
</div>
<!-- Interaction Test Zone -->
<div class="form-section">
<h5 class="mb-4">🎯 Interaction Verification</h5>
<p class="text-muted mb-3"> Please interact with the elements below to verify you're human: </p>
<div class="interaction-zone d-flex flex-column justify-content-center align-items-center p-4">
<div class="mb-3">
<button type="button" class="btn btn-outline-primary me-2">Click Me</button>
<button type="button" class="btn btn-outline-success me-2">Or This</button>
<button type="button" class="btn btn-outline-info">Or This One</button>
</div>
<div class="mb-3 w-75">
<input type="range" class="form-range" min="0" max="100" value="50" id="interactionSlider">
<div class="text-center">
<small class="text-muted">Move the slider: <span id="sliderValue">50</span>%</small>
</div>
</div>
<div class="w-75">
<input type="text" class="form-control" placeholder="Type something here...">
</div>
</div>
</div>
<!-- Preferences Section -->
<div class="form-section">
<h5 class="mb-4">⚙️ Preferences</h5>
<div class="row">
<div class="col-md-6">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="newsletter" name="preferences[]"
value="newsletter">
<label class="form-check-label" for="newsletter"> Subscribe to newsletter </label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="updates" name="preferences[]" value="updates">
<label class="form-check-label" for="updates"> Receive product updates </label>
</div>
</div>
<div class="col-md-6">
<div class="form-check">
<input class="form-check-input" type="radio" name="contact_method" id="email_contact" value="email"
checked>
<label class="form-check-label" for="email_contact"> Contact via email </label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="contact_method" id="phone_contact" value="phone">
<label class="form-check-label" for="phone_contact"> Contact via phone </label>
</div>
</div>
</div>
</div>
<!-- Verification Status -->
<div class="form-section">
<h5 class="mb-4">🛡️ Security Status</h5>
<div class="row">
<div class="col-md-6">
<div class="card bg-dark border-secondary h-100">
<div class="card-body">
<h6 class="card-title">Behavioral Analysis</h6>
<div class="mb-2">
<small class="text-muted">Mouse Activity</small>
<div class="progress verification-progress">
<div id="mouseProgress" class="progress-bar bg-primary" style="width: 0%"></div>
</div>
</div>
<div class="mb-2">
<small class="text-muted">Keyboard Activity</small>
<div class="progress verification-progress">
<div id="keyboardProgress" class="progress-bar bg-success" style="width: 0%"></div>
</div>
</div>
<div>
<small class="text-muted">Form Engagement</small>
<div class="progress verification-progress">
<div id="engagementProgress" class="progress-bar bg-info" style="width: 0%"></div>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="card bg-dark border-secondary h-100">
<div class="card-body">
<h6 class="card-title">Security Checks</h6>
<div class="d-flex justify-content-between align-items-center mb-2">
<small>Timing Analysis</small>
<span id="timingCheck" class="badge bg-secondary">Checking...</span>
</div>
<div class="d-flex justify-content-between align-items-center mb-2">
<small>Interaction Patterns</small>
<span id="patternCheck" class="badge bg-secondary">Checking...</span>
</div>
<div class="d-flex justify-content-between align-items-center">
<small>Human Verification</small>
<span id="humanCheck" class="badge bg-secondary">Pending...</span>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Submit Section -->
<div class="form-section text-center">
<div id="submitStatus" class="mb-3">
<div class="alert alert-info">
<i class="bi bi-clock"></i> Please interact with the form for at least 10 seconds before submitting.
</div>
</div>
<button type="submit" id="submitBtn" class="btn btn-primary btn-lg" disabled>
<span class="spinner-border spinner-border-sm d-none me-2" id="submitSpinner"></span> Submit Form
</button>
<div class="mt-2">
<small class="text-muted"> 🔒 Your submission is protected by advanced anti-bot technology </small>
</div>
</div>
</form>
<!-- Debug Panel (for demonstration) -->
<div class="mt-5">
<div class="card bg-dark border-secondary">
<div class="card-header">
<h6 class="mb-0">🔍 Debug Information (Demo Only)</h6>
</div>
<div class="card-body">
<div class="row">
<div class="col-md-6">
<h6>Verification Data</h6>
<pre id="debugInfo" class="small bg-black p-2 rounded"
style="font-size: 0.7rem; max-height: 200px; overflow-y: auto;"></pre>
</div>
<div class="col-md-6">
<h6>Activity Log</h6>
<div id="activityLog" class="bg-black p-2 rounded small"
style="font-size: 0.7rem; max-height: 200px; overflow-y: auto;">
<div class="text-muted">Waiting for activity...</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Bootstrap JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.8/js/bootstrap.bundle.min.js"></script>
<!-- Include our components -->
<script src="js/BehaviorTracker.js"></script>
<script src="js/HumanVerificationForm.js"></script>
<!-- Demo Script -->
<script>
class FormProtectionDemo {
constructor() {
this.verificationForm = null;
this.updateInterval = null;
this._initializeDemo();
}
_initializeDemo() {
// Initialize the human verification system
this.verificationForm = new HumanVerificationForm('#protectedForm', {
// Custom configuration
behaviorTracking: {
enabled: true,
minTrackingTime: 10000, // 10 seconds for demo
requiredInteractions: 3,
botScoreThreshold: 0.3,
humanScoreThreshold: 0.7
},
timingChecks: {
minFillTime: 5000, // 5 seconds minimum for demo
maxFillTime: 1800000,
suspiciousFastFill: 1000
},
// Callbacks
onVerificationStart: (data) => {
this._logActivity('Verification system started', 'info');
this._startUIUpdates();
},
onVerificationComplete: (verification, data) => {
this._logActivity('Form submitted successfully!', 'success');
this._showSuccess(verification);
},
onSubmissionBlocked: (verification, data) => {
this._logActivity('Form submission blocked', 'danger');
this._showBlocked(verification);
},
onBotDetected: (analysis) => {
this._logActivity('Bot behavior detected!', 'warning');
},
onHumanVerified: (analysis) => {
this._logActivity('Human behavior verified!', 'success');
}
});
this._setupDemoElements();
}
_setupDemoElements() {
// Slider interaction
const slider = document.getElementById('interactionSlider');
const sliderValue = document.getElementById('sliderValue');
slider.addEventListener('input', (e) => {
sliderValue.textContent = e.target.value;
this._logActivity(`Slider moved to ${e.target.value}%`, 'info');
});
// Button interactions
document.querySelectorAll('.interaction-zone button').forEach(btn => {
btn.addEventListener('click', () => {
this._logActivity(`Button clicked: "${btn.textContent}"`, 'info');
btn.classList.add('btn-outline-light');
setTimeout(() => btn.classList.remove('btn-outline-light'), 300);
});
});
// Form validation
document.getElementById('protectedForm').addEventListener('input', () => {
this._updateFormValidation();
});
}
_startUIUpdates() {
this.updateInterval = setInterval(() => {
this._updateUI();
}, 1000);
}
_updateUI() {
const status = this.verificationForm.getVerificationStatus();
// Update verification indicator
this._updateVerificationIndicator(status);
// Update security checks
this._updateSecurityChecks(status);
// Update progress bars
this._updateProgressBars(status);
// Update submit button
this._updateSubmitButton(status);
// Update debug info
this._updateDebugInfo(status);
}
_updateVerificationIndicator(status) {
const levelElement = document.getElementById('verificationLevel');
const confidenceBar = document.getElementById('confidenceBar');
const confidenceText = document.getElementById('confidenceText');
const sessionTime = document.getElementById('sessionTime');
const interactionCount = document.getElementById('interactionCount');
// Update level
levelElement.className = `verification-level level-${status.level}`;
levelElement.textContent = status.level.toUpperCase();
// Update confidence
const confidence = Math.round(status.confidence * 100);
confidenceBar.style.width = `${confidence}%`;
confidenceText.textContent = `${confidence}%`;
// Update session info
sessionTime.textContent = `${Math.round(status.sessionTime / 1000)}s`;
interactionCount.textContent = this.verificationForm.verificationData.fieldInteractions.size;
}
_updateSecurityChecks(status) {
const timingCheck = document.getElementById('timingCheck');
const patternCheck = document.getElementById('patternCheck');
const humanCheck = document.getElementById('humanCheck');
// Timing check
if (status.sessionTime >= 10000) {
timingCheck.className = 'badge bg-success';
timingCheck.textContent = 'Passed';
} else {
timingCheck.className = 'badge bg-warning';
timingCheck.textContent = 'Checking...';
}
// Pattern check
if (status.confidence > 0.6) {
patternCheck.className = 'badge bg-success';
patternCheck.textContent = 'Natural';
} else if (status.confidence > 0.3) {
patternCheck.className = 'badge bg-warning';
patternCheck.textContent = 'Analyzing...';
} else {
patternCheck.className = 'badge bg-danger';
patternCheck.textContent = 'Suspicious';
}
// Human check
if (status.isVerified) {
humanCheck.className = 'badge bg-success';
humanCheck.textContent = 'Verified';
} else if (status.level === 'enhanced') {
humanCheck.className = 'badge bg-info';
humanCheck.textContent = 'Likely Human';
} else {
humanCheck.className = 'badge bg-secondary';
humanCheck.textContent = 'Pending...';
}
}
_updateProgressBars(status) {
const mouseProgress = document.getElementById('mouseProgress');
const keyboardProgress = document.getElementById('keyboardProgress');
const engagementProgress = document.getElementById('engagementProgress');
// Mouse activity (based on movements)
const mouseActivity = Math.min(100, this.verificationForm.verificationData.mouseMovements / 50 * 100);
mouseProgress.style.width = `${mouseActivity}%`;
// Keyboard activity (based on keystrokes)
const keyboardActivity = Math.min(100, this.verificationForm.verificationData.keystrokes / 20 * 100);
keyboardProgress.style.width = `${keyboardActivity}%`;
// Engagement (based on field interactions)
const engagementActivity = Math.min(100, this.verificationForm.verificationData.fieldInteractions.size / 5 * 100);
engagementProgress.style.width = `${engagementActivity}%`;
}
_updateSubmitButton(status) {
const submitBtn = document.getElementById('submitBtn');
const submitStatus = document.getElementById('submitStatus');
if (status.isVerified) {
submitBtn.disabled = false;
submitBtn.className = 'btn btn-success btn-lg';
submitStatus.innerHTML = `
<div class="alert alert-success">
<i class="bi bi-check-circle"></i>
Verification complete! You may now submit the form.
</div>
`;
} else if (status.level === 'enhanced' && status.sessionTime >= 10000) {
submitBtn.disabled = false;
submitBtn.className = 'btn btn-warning btn-lg';
submitStatus.innerHTML = `
<div class="alert alert-warning">
<i class="bi bi-exclamation-triangle"></i>
Enhanced verification required. Additional checks may apply.
</div>
`;
} else if (status.sessionTime < 10000) {
submitBtn.disabled = true;
const remaining = Math.ceil((10000 - status.sessionTime) / 1000);
submitStatus.innerHTML = `
<div class="alert alert-info">
<i class="bi bi-clock"></i>
Please interact with the form for ${remaining} more seconds.
</div>
`;
} else {
submitBtn.disabled = true;
submitStatus.innerHTML = `
<div class="alert alert-warning">
<i class="bi bi-exclamation-triangle"></i>
Please complete the verification requirements above.
</div>
`;
}
}
_updateFormValidation() {
// Basic Bootstrap validation
const form = document.getElementById('protectedForm');
const inputs = form.querySelectorAll('input[required], select[required], textarea[required]');
let validCount = 0;
inputs.forEach(input => {
if (input.checkValidity()) {
validCount++;
input.classList.add('is-valid');
input.classList.remove('is-invalid');
} else if (input.value) {
input.classList.add('is-invalid');
input.classList.remove('is-valid');
}
});
// Update progress if enough fields are valid
if (validCount >= inputs.length * 0.8) {
this._logActivity('Form validation looking good!', 'success');
}
}
_updateDebugInfo(status) {
const debugInfo = document.getElementById('debugInfo');
const data = {
level: status.level,
score: status.score,
confidence: Math.round(status.confidence * 100),
sessionTime: Math.round(status.sessionTime / 1000),
interactions: this.verificationForm.verificationData.fieldInteractions.size,
mouseMovements: this.verificationForm.verificationData.mouseMovements,
keystrokes: this.verificationForm.verificationData.keystrokes,
suspiciousFlags: status.suspiciousFlags,
isVerified: status.isVerified
};
debugInfo.textContent = JSON.stringify(data, null, 2);
}
_logActivity(message, type = 'info') {
const activityLog = document.getElementById('activityLog');
const timestamp = new Date().toLocaleTimeString();
const logEntry = document.createElement('div');
logEntry.className = `text-${type} mb-1`;
logEntry.innerHTML = `<small>[${timestamp}]</small> ${message}`;
if (activityLog.children.length === 1 && activityLog.children[0].textContent.includes('Waiting')) {
activityLog.innerHTML = '';
}
activityLog.appendChild(logEntry);
activityLog.scrollTop = activityLog.scrollHeight;
// Limit entries
while (activityLog.children.length > 20) {
activityLog.removeChild(activityLog.firstChild);
}
}
_showSuccess(verification) {
// Show success modal or message
alert(`Form submitted successfully!\nVerification Score: ${verification.score}\nConfidence: ${Math.round(verification.confidence * 100)}%`);
}
_showBlocked(verification) {
// Show blocked message
alert(`Form submission blocked.\nReason: ${verification.reason}\nRecommendations: ${verification.recommendations.join(', ')}`);
}
}
// Initialize when DOM is ready
document.addEventListener('DOMContentLoaded', () => {
window.formDemo = new FormProtectionDemo();
});
</script>
</body>
</html>