@prosopo/client-bundle-example 2.9.5 → 2.10.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/CHANGELOG.md +134 -0
  2. package/dist/cjs/index.cjs +49 -0
  3. package/dist/index.js +49 -1
  4. package/package.json +5 -9
  5. package/vite.config.ts +1 -0
  6. package/dist/assets/captcha-BaCo3bEP.js +0 -1
  7. package/dist/assets/captcha-DAWM1slf.css +0 -1
  8. package/dist/assets/dummy.txt +0 -0
  9. package/dist/assets/frictionless-explicit-CtnTw8dK.js +0 -1
  10. package/dist/assets/frictionless-implicit-BH7anfOq.js +0 -1
  11. package/dist/assets/image-explicit-Dm_JoW0N.js +0 -4
  12. package/dist/assets/image-implicit-M0Y7U93R.js +0 -1
  13. package/dist/assets/index-Ck5HfpfQ.js +0 -1
  14. package/dist/assets/invisible-frictionless-explicit-CSPYfcNr.js +0 -4
  15. package/dist/assets/invisible-frictionless-implicit-D0saDt4U.js +0 -1
  16. package/dist/assets/invisible-image-explicit-erOMAo-F.js +0 -4
  17. package/dist/assets/invisible-image-implicit-c0sMfk2s.js +0 -1
  18. package/dist/assets/invisible-pow-explicit-BgMt7lhN.js +0 -4
  19. package/dist/assets/invisible-pow-implicit-CnxS8gw2.js +0 -4
  20. package/dist/assets/pow-explicit-BgDWNJK9.js +0 -4
  21. package/dist/assets/pow-implicit-Ck5HfpfQ.js +0 -1
  22. package/dist/frictionless-explicit.html +0 -875
  23. package/dist/frictionless-implicit.html +0 -874
  24. package/dist/image-explicit.html +0 -877
  25. package/dist/index.html +0 -850
  26. package/dist/invisible-frictionless-explicit.html +0 -877
  27. package/dist/invisible-frictionless-implicit.html +0 -884
  28. package/dist/invisible-image-explicit.html +0 -878
  29. package/dist/invisible-image-implicit.html +0 -884
  30. package/dist/invisible-pow-explicit.html +0 -878
  31. package/dist/invisible-pow-implicit.html +0 -878
  32. package/dist/plugins/explanation-injector.ts +0 -250
  33. package/dist/plugins/form-filler-injector.ts +0 -233
  34. package/dist/plugins/navigation-injector.ts +0 -602
  35. package/dist/plugins/status-log-injector.ts +0 -199
  36. package/dist/pow-explicit.html +0 -877
  37. package/dist/pow-implicit.html +0 -881
@@ -1,874 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
- <head>
4
- <link href="https://cdn.muicss.com/mui-0.10.3/css/mui.min.css" rel="stylesheet" type="text/css"/>
5
- <title>Procaptcha demo: Frictionless CAPTCHA</title>
6
- <script type="text/javascript">
7
- window.onCaptchaFailed = function () {
8
- console.log('Challenge failed');
9
- updateCaptchaStatus('Challenge failed - CAPTCHA verification could not be completed', 'error');
10
- }
11
- </script>
12
-
13
- <style>
14
- .nav-topbar {
15
- background-color: #2196F3;
16
- padding: 0;
17
- margin-bottom: 20px;
18
- transition: all 0.3s ease;
19
- overflow: hidden;
20
- max-height: 500px;
21
- box-shadow: 0 2px 5px rgba(0,0,0,0.2);
22
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
23
- }
24
- .nav-topbar.collapsed {
25
- max-height: 60px;
26
- }
27
- .nav-container {
28
- max-width: 1200px;
29
- margin: 0 auto;
30
- padding: 0 20px;
31
- position: relative;
32
- }
33
- .nav-header {
34
- display: flex;
35
- justify-content: space-between;
36
- align-items: center;
37
- padding: 12px 0;
38
- position: relative;
39
- z-index: 20;
40
- }
41
- .nav-title {
42
- color: white;
43
- font-size: 1.25rem;
44
- font-weight: 600;
45
- margin: 0;
46
- display: flex;
47
- align-items: center;
48
- gap: 8px;
49
- }
50
- .nav-title-text {
51
- margin-right: 8px;
52
- }
53
- .nav-title-hint {
54
- font-size: 0.875rem;
55
- font-weight: normal;
56
- opacity: 0;
57
- transition: opacity 0.3s ease;
58
- color: rgba(255,255,255,0.8);
59
- }
60
- .collapsed .nav-title-hint {
61
- opacity: 0.8;
62
- }
63
- .nav-toggle {
64
- background-color: rgba(255,255,255,0.1);
65
- color: white;
66
- border: none;
67
- padding: 8px 12px;
68
- cursor: pointer;
69
- border-radius: 6px;
70
- z-index: 10;
71
- display: flex;
72
- align-items: center;
73
- justify-content: center;
74
- transition: background-color 0.2s ease;
75
- }
76
- .nav-toggle:hover {
77
- background-color: rgba(255,255,255,0.2);
78
- }
79
- .nav-toggle-icon {
80
- width: 24px;
81
- height: 24px;
82
- display: inline-block;
83
- position: relative;
84
- }
85
- .nav-toggle-icon svg {
86
- position: absolute;
87
- top: 0;
88
- left: 0;
89
- transition: opacity 0.3s ease;
90
- }
91
- .nav-toggle-icon .icon-collapse {
92
- opacity: 1;
93
- }
94
- .nav-toggle-icon .icon-expand {
95
- opacity: 0;
96
- }
97
- .collapsed .nav-toggle-icon .icon-collapse {
98
- opacity: 0;
99
- }
100
- .collapsed .nav-toggle-icon .icon-expand {
101
- opacity: 1;
102
- }
103
- .nav-content {
104
- padding: 0 0 20px 0;
105
- transition: opacity 0.3s ease;
106
- }
107
- .collapsed .nav-content {
108
- opacity: 0;
109
- }
110
- .nav-sections {
111
- display: flex;
112
- flex-wrap: wrap;
113
- gap: 20px;
114
- }
115
- .nav-section {
116
- flex: 1;
117
- min-width: 280px;
118
- }
119
- .nav-section h3 {
120
- color: white;
121
- font-size: 1rem;
122
- font-weight: 600;
123
- margin: 0 0 12px 0;
124
- padding-bottom: 8px;
125
- border-bottom: 1px solid rgba(255,255,255,0.2);
126
- }
127
- .nav-group {
128
- background: rgba(255,255,255,0.1);
129
- border-radius: 8px;
130
- padding: 12px;
131
- margin-bottom: 12px;
132
- }
133
- .nav-group-title {
134
- color: rgba(255,255,255,0.9);
135
- font-size: 0.875rem;
136
- font-weight: 500;
137
- margin: 0 0 8px 0;
138
- text-transform: uppercase;
139
- letter-spacing: 0.5px;
140
- }
141
- .nav-group-links {
142
- list-style: none;
143
- margin: 0;
144
- padding: 0;
145
- }
146
- .nav-group-links li {
147
- margin: 6px 0;
148
- }
149
- .nav-group-links a {
150
- color: white;
151
- text-decoration: none;
152
- font-weight: 500;
153
- padding: 6px 8px;
154
- display: inline-block;
155
- border-radius: 4px;
156
- transition: background-color 0.2s ease;
157
- }
158
- .nav-group-links a:hover {
159
- background-color: rgba(255,255,255,0.2);
160
- }
161
- .nav-group-links .active {
162
- background-color: rgba(255,255,255,0.2);
163
- font-weight: 600;
164
- }
165
- .nav-group-links .disabled {
166
- color: rgba(255,255,255,0.5);
167
- cursor: not-allowed;
168
- opacity: 0.7;
169
- }
170
-
171
- @media (max-width: 768px) {
172
- .nav-container {
173
- padding: 0 16px;
174
- }
175
- .nav-title {
176
- font-size: 1.125rem;
177
- }
178
- .nav-title-hint {
179
- display: none;
180
- }
181
- .nav-sections {
182
- flex-direction: column;
183
- gap: 16px;
184
- }
185
- .nav-section {
186
- min-width: 100%;
187
- }
188
- .nav-section h3 {
189
- font-size: 0.875rem;
190
- }
191
- .nav-group {
192
- padding: 10px;
193
- }
194
- .nav-group-title {
195
- font-size: 0.8125rem;
196
- }
197
- .nav-group-links a {
198
- padding: 8px 10px;
199
- width: 100%;
200
- }
201
- }
202
-
203
- @media (max-width: 480px) {
204
- .nav-topbar {
205
- max-height: 60px;
206
- }
207
- .nav-topbar.collapsed {
208
- max-height: 60px;
209
- }
210
- .nav-title {
211
- font-size: 1rem;
212
- }
213
- .nav-toggle {
214
- padding: 6px 10px;
215
- }
216
- }
217
-
218
- .nav-group-dropdown {
219
- position: relative;
220
- display: inline-block;
221
- }
222
-
223
- .nav-group-dropdown-btn {
224
- background: none;
225
- border: none;
226
- color: white;
227
- font-weight: 500;
228
- padding: 6px 8px;
229
- cursor: pointer;
230
- display: flex;
231
- align-items: center;
232
- gap: 4px;
233
- border-radius: 4px;
234
- transition: background-color 0.2s ease;
235
- }
236
-
237
- .nav-group-dropdown-btn:hover {
238
- background-color: rgba(255,255,255,0.2);
239
- }
240
-
241
- .nav-group-dropdown-btn svg {
242
- width: 16px;
243
- height: 16px;
244
- transition: transform 0.2s ease;
245
- }
246
-
247
- .nav-group-dropdown-btn.open svg {
248
- transform: rotate(180deg);
249
- }
250
-
251
- .nav-group-dropdown-content {
252
- display: none;
253
- position: absolute;
254
- background-color: rgba(33, 150, 243, 0.95);
255
- min-width: 160px;
256
- box-shadow: 0 8px 16px rgba(0,0,0,0.2);
257
- z-index: 1;
258
- border-radius: 4px;
259
- padding: 8px 0;
260
- margin-top: 4px;
261
- }
262
-
263
- .nav-group-dropdown-btn.open + .nav-group-dropdown-content {
264
- display: block;
265
- }
266
-
267
- .nav-group-dropdown-content a {
268
- color: white;
269
- padding: 8px 16px;
270
- text-decoration: none;
271
- display: block;
272
- transition: background-color 0.2s ease;
273
- }
274
-
275
- .nav-group-dropdown-content a:hover {
276
- background-color: rgba(255,255,255,0.2);
277
- }
278
-
279
- .nav-group-dropdown-content a.active {
280
- background-color: rgba(255,255,255,0.2);
281
- font-weight: 600;
282
- }
283
-
284
- @media (max-width: 768px) {
285
- .nav-group-dropdown-content {
286
- position: static;
287
- box-shadow: none;
288
- background-color: rgba(255,255,255,0.1);
289
- margin-top: 8px;
290
- }
291
- }
292
- </style>
293
- <script type="module" crossorigin src="/assets/frictionless-implicit-BH7anfOq.js"></script>
294
- <link rel="modulepreload" crossorigin href="/assets/captcha-BaCo3bEP.js">
295
- <link rel="stylesheet" crossorigin href="/assets/captcha-DAWM1slf.css">
296
-
297
- <style>
298
- .form-filler-button {
299
- position: fixed;
300
- bottom: 20px;
301
- right: 20px;
302
- background-color: #2196F3;
303
- color: white;
304
- border: none;
305
- border-radius: 30px;
306
- padding: 12px 20px;
307
- font-size: 14px;
308
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
309
- cursor: pointer;
310
- box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
311
- z-index: 9999;
312
- display: flex;
313
- align-items: center;
314
- gap: 8px;
315
- transition: all 0.2s ease;
316
- outline: none;
317
- }
318
-
319
- .form-filler-button:hover {
320
- background-color: #1976D2;
321
- box-shadow: 0 6px 12px rgba(0, 0, 0, 0.25);
322
- transform: translateY(-2px);
323
- }
324
-
325
- .form-filler-button:active {
326
- transform: translateY(1px);
327
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
328
- }
329
-
330
- .form-filler-button svg {
331
- width: 18px;
332
- height: 18px;
333
- fill: white;
334
- }
335
-
336
- .form-filler-button span {
337
- font-weight: 500;
338
- }
339
-
340
- @media (max-width: 768px) {
341
- .form-filler-button {
342
- bottom: 15px;
343
- right: 15px;
344
- padding: 10px 15px;
345
- font-size: 12px;
346
- }
347
-
348
- .form-filler-button svg {
349
- width: 14px;
350
- height: 14px;
351
- }
352
- }
353
- </style>
354
-
355
- <style>
356
- .captcha-status {
357
- margin-top: 20px;
358
- padding: 15px;
359
- background-color: #f0f8ff;
360
- border: 2px solid #2196F3;
361
- border-radius: 5px;
362
- font-family: monospace;
363
- font-size: 14px;
364
- }
365
- .status-item {
366
- margin: 5px 0;
367
- padding: 5px;
368
- }
369
- .status-success {
370
- color: #4CAF50;
371
- font-weight: bold;
372
- }
373
- .status-error {
374
- color: #F44336;
375
- font-weight: bold;
376
- }
377
- .status-info {
378
- color: #2196F3;
379
- }
380
- .status-warning {
381
- color: #FF9800;
382
- }
383
- .status-title {
384
- font-weight: bold;
385
- margin-bottom: 10px;
386
- border-bottom: 1px solid #2196F3;
387
- padding-bottom: 5px;
388
- }
389
- .console-output {
390
- margin-top: 20px;
391
- padding: 10px;
392
- background-color: #f5f5f5;
393
- border: 1px solid #ddd;
394
- border-radius: 4px;
395
- font-family: monospace;
396
- white-space: pre-wrap;
397
- max-height: 200px;
398
- overflow-y: auto;
399
- }
400
- </style>
401
-
402
- <script type="module">
403
- // Function to update CAPTCHA status display
404
- function updateCaptchaStatus(message, type = 'info') {
405
- const statusContainer = document.getElementById('captcha-status');
406
- if (!statusContainer) return;
407
-
408
- const timestamp = new Date().toLocaleTimeString();
409
- const statusItem = document.createElement('div');
410
- statusItem.className = `status-item status-${type}`;
411
- statusItem.innerHTML = `[${timestamp}] ${message}`;
412
- statusContainer.appendChild(statusItem);
413
-
414
- // Also log to console
415
- console.log(`CAPTCHA Status: ${message}`);
416
- }
417
-
418
- // Make updateCaptchaStatus available globally
419
- window.updateCaptchaStatus = updateCaptchaStatus;
420
-
421
- // Override the original callbacks with enhanced versions that use status logging
422
- const originalOnCaptchaFailed = window.onCaptchaFailed;
423
- window.onCaptchaFailed = function() {
424
- updateCaptchaStatus('Challenge failed - CAPTCHA verification could not be completed', 'error');
425
- if (originalOnCaptchaFailed) originalOnCaptchaFailed();
426
- };
427
-
428
- const originalOnCaptchaVerified = window.onCaptchaVerified;
429
- window.onCaptchaVerified = function(output) {
430
- updateCaptchaStatus('Challenge passed successfully!', 'success');
431
- updateCaptchaStatus(`Token generated: ${output.substring(0, 15)}...`, 'success');
432
- if (originalOnCaptchaVerified) originalOnCaptchaVerified(output);
433
- };
434
-
435
- const originalOnActionHandler = window.onActionHandler;
436
- window.onActionHandler = function() {
437
- const procaptchaElements = document.getElementsByName('procaptcha-response');
438
-
439
- if (!procaptchaElements.length) {
440
- updateCaptchaStatus('Error: No CAPTCHA response token found', 'error');
441
- alert("Must complete captcha");
442
- return;
443
- }
444
-
445
- updateCaptchaStatus('Form submission initiated with valid CAPTCHA token', 'info');
446
- if (originalOnActionHandler) originalOnActionHandler();
447
- };
448
-
449
- document.addEventListener('DOMContentLoaded', function() {
450
- updateCaptchaStatus('Page loaded - Initializing CAPTCHA system', 'info');
451
-
452
- // Monitor DOM for CAPTCHA initialization
453
- const observer = new MutationObserver((mutations) => {
454
- mutations.forEach((mutation) => {
455
- if (mutation.addedNodes.length) {
456
- for (let i = 0; i < mutation.addedNodes.length; i++) {
457
- const node = mutation.addedNodes[i];
458
- if (node.classList && (node.classList.contains('procaptcha') ||
459
- node.querySelector && node.querySelector('.procaptcha'))) {
460
- updateCaptchaStatus('CAPTCHA DOM elements initialized', 'info');
461
- observer.disconnect();
462
- break;
463
- }
464
- }
465
- }
466
- });
467
- });
468
-
469
- observer.observe(document.body, { childList: true, subtree: true });
470
- });
471
-
472
- // Create a method to show CAPTCHA execution events
473
- document.addEventListener('procaptcha:execute', function(e) {
474
- // Determine captcha type from the page URL
475
- const url = window.location.pathname;
476
- const isFrictionless = url.includes('frictionless');
477
- const isImage = url.includes('image');
478
- const isPow = url.includes('pow');
479
-
480
- let captchaType = 'unknown';
481
- if (isFrictionless) captchaType = 'frictionless';
482
- else if (isImage) captchaType = 'image';
483
- else if (isPow) captchaType = 'pow';
484
-
485
- updateCaptchaStatus(`CAPTCHA execution started: type=${captchaType}`, 'info');
486
- updateCaptchaStatus(`Container: ${e.detail.containerId}, timestamp: ${new Date(e.detail.timestamp).toLocaleTimeString()}`, 'info');
487
- });
488
- </script>
489
- </head>
490
- <body>
491
-
492
- <div id="nav-topbar" class="nav-topbar">
493
- <div class="nav-container">
494
- <div id="nav-header" class="nav-header">
495
- <h1 class="nav-title">
496
- <span class="nav-title-text">Procaptcha Demo Playground</span>
497
- <span class="nav-title-hint">(Click anywhere to see more examples)</span>
498
- </h1>
499
- <button id="nav-toggle" class="nav-toggle" aria-label="Toggle navigation">
500
- <span class="nav-toggle-icon">
501
- <svg class="icon-collapse" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
502
- <polyline points="18 15 12 9 6 15"></polyline>
503
- </svg>
504
- <svg class="icon-expand" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
505
- <polyline points="6 9 12 15 18 9"></polyline>
506
- </svg>
507
- </span>
508
- </button>
509
- </div>
510
- <div class="nav-content">
511
- <div class="nav-sections">
512
-
513
- <div class="nav-section">
514
- <h3>Standard Captchas</h3>
515
- <div class="nav-row">
516
-
517
- <div class="nav-group">
518
- <div class="nav-group-title">Image</div>
519
- <div class="nav-group-links">
520
- <a href="index.html">Implicit</a>
521
- <a href="image-explicit.html">Explicit</a>
522
- </div>
523
- </div>
524
-
525
-
526
- <div class="nav-group">
527
- <div class="nav-group-title">Pow</div>
528
- <div class="nav-group-links">
529
- <a href="pow-implicit.html">Implicit</a>
530
- <a href="pow-explicit.html">Explicit</a>
531
- </div>
532
- </div>
533
-
534
-
535
- <div class="nav-group">
536
- <div class="nav-group-title">Frictionless</div>
537
- <div class="nav-group-links">
538
- <a href="frictionless-implicit.html" class="active">Implicit</a>
539
- <a href="frictionless-explicit.html">Explicit</a>
540
- </div>
541
- </div>
542
-
543
- </div>
544
- </div>
545
-
546
-
547
- <div class="nav-section">
548
- <h3>Invisible Captchas</h3>
549
- <div class="nav-row">
550
-
551
- <div class="nav-group">
552
- <div class="nav-group-title">Image</div>
553
- <div class="nav-group-links">
554
- <a href="invisible-image-implicit.html">Implicit</a>
555
- <a href="invisible-image-explicit.html">Explicit</a>
556
- </div>
557
- </div>
558
-
559
-
560
- <div class="nav-group">
561
- <div class="nav-group-title">Pow</div>
562
- <div class="nav-group-links">
563
- <a href="invisible-pow-implicit.html">Implicit</a>
564
- <a href="invisible-pow-explicit.html">Explicit</a>
565
- </div>
566
- </div>
567
-
568
-
569
- <div class="nav-group">
570
- <div class="nav-group-title">Frictionless</div>
571
- <div class="nav-group-links">
572
- <a href="invisible-frictionless-implicit.html">Implicit</a>
573
- <a href="invisible-frictionless-explicit.html">Explicit</a>
574
- </div>
575
- </div>
576
-
577
- </div>
578
- </div>
579
-
580
- </div>
581
- </div>
582
- </div>
583
- </div>
584
-
585
-
586
- <div class="mui-container">
587
- <h1>Frictionless CAPTCHA - Explicit Rendering</h1>
588
- <p>This example demonstrates how to use Procaptcha in frictionless mode with explicit rendering.</p>
589
-
590
- <!-- CAPTCHA Status Display will be injected by the status-log-injector plugin -->
591
-
592
- <form action="undefined/signup" method="POST" class="mui-form">
593
- <h2>Example Login Form</h2>
594
- <div class="mui-textfield mui-textfield--float-label">
595
- <label for="name">Name</label>
596
- <input id="name" type="text" name="name" required/>
597
- </div>
598
- <div class="mui-textfield mui-textfield--float-label">
599
- <label for="email">Email Address</label>
600
- <input id="email" type="email" name="email" required/>
601
- </div>
602
- <div class="mui-textfield mui-textfield--float-label">
603
- <label for="password">Password</label>
604
- <input id="password" type="password" name="password" required/>
605
- </div>
606
- <div class="mui-textfield mui-textfield--float-label">
607
- <div id="procaptcha-container"></div>
608
- </div>
609
- <div id="messageContainer" style="display: none; color: black;"><span id="message"></span></div>
610
- <button type="button" class="mui-btn mui-btn--raised" onclick="onActionHandler()" data-cy="submit-button">Submit</button>
611
- </form>
612
- <!-- CAPTCHA Status Display -->
613
- <div id="captcha-status" class="captcha-status">
614
- <div class="status-title">CAPTCHA Status Log</div>
615
- </div>
616
-
617
- <!-- Console output display area -->
618
- <div id="console-output" class="console-output" style="display: none;"></div>
619
-
620
-
621
- </div>
622
-
623
- <script>
624
- document.addEventListener('DOMContentLoaded', function() {
625
- const toggleBtn = document.getElementById('nav-toggle');
626
- const navBar = document.getElementById('nav-topbar');
627
- const navHeader = document.getElementById('nav-header');
628
- const isMobile = window.innerWidth <= 768;
629
-
630
- // Check if navigation was previously collapsed
631
- const navCollapsed = localStorage.getItem('navCollapsed') === 'true';
632
- if (navCollapsed) {
633
- navBar.classList.add('collapsed');
634
- }
635
-
636
- // Function to expand the navigation
637
- function expandNav() {
638
- if (navBar.classList.contains('collapsed')) {
639
- navBar.classList.remove('collapsed');
640
- localStorage.setItem('navCollapsed', 'false');
641
- }
642
- }
643
-
644
- // Function to collapse the navigation
645
- function collapseNav() {
646
- if (!navBar.classList.contains('collapsed')) {
647
- navBar.classList.add('collapsed');
648
- localStorage.setItem('navCollapsed', 'true');
649
- }
650
- }
651
-
652
- // Function to toggle the navigation
653
- function toggleNav() {
654
- navBar.classList.toggle('collapsed');
655
- localStorage.setItem('navCollapsed', navBar.classList.contains('collapsed'));
656
- }
657
-
658
- // Toggle on button click
659
- toggleBtn.addEventListener('click', function(e) {
660
- e.stopPropagation();
661
- toggleNav();
662
- });
663
-
664
- // Expand on toggle button hover when collapsed (desktop only)
665
- if (!isMobile) {
666
- toggleBtn.addEventListener('mouseenter', function() {
667
- if (navBar.classList.contains('collapsed')) {
668
- expandNav();
669
- }
670
- });
671
- }
672
-
673
- // Toggle on header click
674
- navHeader.addEventListener('click', function(e) {
675
- if (e.target.tagName === 'A') {
676
- return;
677
- }
678
- toggleNav();
679
- });
680
-
681
- // Make the header appear clickable with cursor style
682
- navHeader.style.cursor = 'pointer';
683
-
684
- // Handle window resize
685
- window.addEventListener('resize', function() {
686
- const newIsMobile = window.innerWidth <= 768;
687
- if (newIsMobile !== isMobile) {
688
- if (newIsMobile) {
689
- // On mobile, collapse the nav by default
690
- collapseNav();
691
- } else {
692
- // On desktop, expand the nav by default
693
- expandNav();
694
- }
695
- }
696
- });
697
-
698
- // Handle dropdown toggles
699
- document.querySelectorAll('.nav-group-dropdown-btn').forEach(button => {
700
- button.addEventListener('click', function(e) {
701
- e.stopPropagation();
702
- this.classList.toggle('open');
703
- });
704
- });
705
-
706
- // Close dropdowns when clicking outside
707
- document.addEventListener('click', function(e) {
708
- if (!e.target.closest('.nav-group-dropdown')) {
709
- document.querySelectorAll('.nav-group-dropdown-btn').forEach(button => {
710
- button.classList.remove('open');
711
- });
712
- }
713
- });
714
- });
715
- </script>
716
-
717
-
718
- <button id="form-filler-button" class="form-filler-button" title="Fill all form fields with default values">
719
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
720
- <path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"/>
721
- </svg>
722
- <span>Fill Form</span>
723
- </button>
724
-
725
- <script>
726
- document.addEventListener('DOMContentLoaded', function() {
727
- // Create a function to fill the form with sensible default values
728
- function fillFormWithDefaults() {
729
- // Get all input elements
730
- const inputs = document.querySelectorAll('input, select, textarea');
731
-
732
- // Record which elements were filled for status feedback
733
- const filledElements = [];
734
-
735
- // Process each input
736
- inputs.forEach(input => {
737
- let filled = true;
738
-
739
- // Skip hidden inputs and those with existing values
740
- if (input.type === 'hidden' || (input.value && input.value.trim() !== '')) {
741
- filled = false;
742
- }
743
- // Handle different input types
744
- else if (input.type === 'text') {
745
- if (input.id.toLowerCase().includes('name') || input.name.toLowerCase().includes('name')) {
746
- input.value = 'John Doe';
747
- } else {
748
- input.value = 'Default Text';
749
- }
750
- }
751
- else if (input.type === 'email') {
752
- input.value = 'test@example.com';
753
- }
754
- else if (input.type === 'password') {
755
- input.value = 'Password123!';
756
- }
757
- else if (input.type === 'tel') {
758
- input.value = '+1234567890';
759
- }
760
- else if (input.type === 'number') {
761
- input.value = '42';
762
- }
763
- else if (input.type === 'url') {
764
- input.value = 'https://example.com';
765
- }
766
- else if (input.type === 'date') {
767
- const today = new Date();
768
- const yyyy = today.getFullYear();
769
- const mm = String(today.getMonth() + 1).padStart(2, '0');
770
- const dd = String(today.getDate()).padStart(2, '0');
771
- input.value = `${yyyy}-${mm}-${dd}`;
772
- }
773
- else if (input.type === 'time') {
774
- input.value = '12:00';
775
- }
776
- else if (input.type === 'checkbox' || input.type === 'radio') {
777
- input.checked = true;
778
- }
779
- else if (input.tagName === 'SELECT') {
780
- if (input.options.length > 0) {
781
- input.selectedIndex = 1 >= input.options.length ? 0 : 1; // Select second option if available, first otherwise
782
- }
783
- }
784
- else if (input.tagName === 'TEXTAREA') {
785
- input.value = 'This is a sample text for the textarea field.';
786
- }
787
- else {
788
- // For any other input types
789
- input.value = 'Default Value';
790
- }
791
-
792
- // Add to filled elements if we actually filled it
793
- if (filled) {
794
- filledElements.push(input);
795
-
796
- // Dispatch input event to trigger any listeners
797
- const event = new Event('input', { bubbles: true });
798
- input.dispatchEvent(event);
799
-
800
- // For select elements, also dispatch change event
801
- if (input.tagName === 'SELECT') {
802
- const changeEvent = new Event('change', { bubbles: true });
803
- input.dispatchEvent(changeEvent);
804
- }
805
- }
806
- });
807
-
808
- // Show a notification about what was filled
809
- if (filledElements.length > 0) {
810
- // If an updateCaptchaStatus function exists (from our other demos), use it
811
- if (typeof window.updateCaptchaStatus === 'function') {
812
- window.updateCaptchaStatus(`Filled ${filledElements.length} form fields with default values`, 'info');
813
- } else {
814
- console.log(`Filled ${filledElements.length} form fields with default values`);
815
- }
816
-
817
- // Highlight the filled fields briefly
818
- filledElements.forEach(el => {
819
- const originalBackground = el.style.backgroundColor;
820
- const originalTransition = el.style.transition;
821
-
822
- el.style.transition = 'background-color 1.5s ease';
823
- el.style.backgroundColor = '#e3f2fd';
824
-
825
- setTimeout(() => {
826
- el.style.backgroundColor = originalBackground;
827
- setTimeout(() => {
828
- el.style.transition = originalTransition;
829
- }, 1500);
830
- }, 500);
831
- });
832
- }
833
- }
834
-
835
- // Add the click event listener to the form filler button
836
- const formFillerButton = document.getElementById('form-filler-button');
837
- if (formFillerButton) {
838
- formFillerButton.addEventListener('click', fillFormWithDefaults);
839
- }
840
- });
841
- </script>
842
-
843
- <div class="explanation">
844
- <h2>How Frictionless CAPTCHA Works (Implicit Rendering)</h2>
845
-
846
- <h3>Implementation Details</h3>
847
- <p>This example demonstrates how to use Procaptcha in frictionless mode with implicit rendering:</p>
848
- <ol>
849
- <li>Import the Procaptcha script</li>
850
- <li>Add a div with the procaptcha class</li>
851
- <li>Set data-* attributes to configure the CAPTCHA</li>
852
- <li>Handle the verification result in the callback function</li>
853
- </ol>
854
-
855
- <h3>Key Code Example</h3>
856
- <pre>&lt;div
857
- class=&quot;procaptcha&quot;
858
- data-theme=&quot;light&quot;
859
- data-sitekey=&quot;%PROSOPO_SITE_KEY_FRICTIONLESS%&quot;
860
- data-failed-callback=&quot;onCaptchaFailed&quot;
861
- data-callback=&quot;onCaptchaVerified&quot;
862
- data-captcha-type=&quot;frictionless&quot;
863
- &gt;&lt;/div&gt;</pre>
864
-
865
- <h3>Execution Flow</h3>
866
- <ol>
867
- <li>On page load, Procaptcha scans for elements with the procaptcha class</li>
868
- <li>The CAPTCHA verification happens when the user interacts with it</li>
869
- <li>When verification is complete, the callback function is called with the token</li>
870
- <li>On successful verification, the form can be submitted with the token</li>
871
- </ol>
872
- </div>
873
- </body>
874
- </html>