|
| 1 | +@model IconCaptcha.Demo.ViewModels.SubmissionViewModel |
| 2 | +@inject IconCaptcha.IconCaptchaService IconCaptcha |
| 3 | + |
| 4 | +<!DOCTYPE HTML> |
| 5 | +<html lang="en"> |
| 6 | + <head> |
| 7 | + <title>@ViewBag.Title</title> |
| 8 | + <meta charset="UTF-8" /> |
| 9 | + <meta http-equiv="X-UA-Compatible" content="IE=10" /> |
| 10 | + <meta name="author" content="Fabian Wennink © @DateTime.Now.Year" /> |
| 11 | + <meta name="viewport" content="width=device-width, initial-scale=1"> |
| 12 | + <link href="/favicon.ico" rel="shortcut icon" type="image/x-icon" /> |
| 13 | + |
| 14 | + <!-- JUST FOR THE DEMO PAGE --> |
| 15 | + <link href="/demo.css" rel="stylesheet" type="text/css"> |
| 16 | + <script src="/demo.js" type="text/javascript"></script> |
| 17 | + <link href="https://fonts.googleapis.com/css?family=Poppins:400,700" rel="stylesheet"> |
| 18 | + |
| 19 | + <!-- Include IconCaptcha stylesheet - REQUIRED --> |
| 20 | + <link href="/css/icon-captcha.min.css" rel="stylesheet" type="text/css"> |
| 21 | + </head> |
| 22 | + <body> |
| 23 | + <div class="container"> |
| 24 | + |
| 25 | + <div class="logo-text"> |
| 26 | + <a href="https://github.com/fabianwennink/IconCaptcha-ASP.NET/" target="_blank" rel="noopener"> |
| 27 | + Ic<span>o</span>nCaptcha |
| 28 | + </a> |
| 29 | + </div> |
| 30 | + |
| 31 | + <div class="shields"> |
| 32 | + <div class="shields-row"> |
| 33 | + <a href="https://github.com/fabianwennink/IconCaptcha-ASP.NET/releases" target="_blank" rel="noopener"> |
| 34 | + <img src="https://img.shields.io/badge/Version-3.0.0-orange.svg?style=flat-square" alt="Version 3.0.0 Badge"/> |
| 35 | + </a> |
| 36 | + <a href="https://github.com/fabianwennink/IconCaptcha-ASP.NET/blob/master/LICENSE" target="_blank" rel="noopener"> |
| 37 | + <img src="https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square" alt="License-MIT Badge" /> |
| 38 | + </a> |
| 39 | + <a href="https://github.com/fabianwennink/IconCaptcha-ASP.NET/issues" target="_blank" rel="noopener"> |
| 40 | + <img src="https://img.shields.io/github/issues/fabianwennink/IconCaptcha-ASP.NET?style=flat-square" alt="Git Issues Badge" /> |
| 41 | + </a> |
| 42 | + <a href="https://github.com/fabianwennink/IconCaptcha-ASP.NET" target="_blank" rel="noopener"> |
| 43 | + <img src="https://img.shields.io/github/stars/fabianwennink/IconCaptcha-ASP.NET?color=%23ffff&logo=github&style=flat-square" alt="Git Stars Badge" /> |
| 44 | + </a> |
| 45 | + </div> |
| 46 | + </div> |
| 47 | + |
| 48 | + <div class="section"> |
| 49 | + |
| 50 | + <!-- Captcha message placeholder --> |
| 51 | + <p class="message"></p> |
| 52 | + |
| 53 | + <!-- The IconCaptcha holder should ALWAYS be placed WITHIN the <form> element --> |
| 54 | + <form method="post" asp-action="AjaxFormSubmit"> |
| 55 | + |
| 56 | + <!-- Additional security token to prevent CSRF. Optional but highly recommended - disable via IconCaptcha options. --> |
| 57 | + <input type="hidden" name="_iconcaptcha-token" value="@IconCaptcha.Token()"/> |
| 58 | + |
| 59 | + <!-- The IconCaptcha will be rendered in this element - REQUIRED --> |
| 60 | + <div class="iconcaptcha-holder" data-theme="light"></div> |
| 61 | + |
| 62 | + <!-- Submit button to test your IconCaptcha input --> |
| 63 | + <input type="submit" value="Submit demo captcha" class="btn" > |
| 64 | + </form> |
| 65 | + |
| 66 | + <!-- Theme selector - JUST FOR THE DEMO PAGE --> |
| 67 | + <div class="themes"> |
| 68 | + <div class="theme theme--light"><span data-theme="light"></span><span>Light</span></div> |
| 69 | + <div class="theme theme--legacy-light"><span data-theme="legacy-light"></span><span>Legacy Light</span></div> |
| 70 | + <div class="theme theme--dark"><span data-theme="dark"></span><span>Dark</span></div> |
| 71 | + <div class="theme theme--legacy-dark"><span data-theme="legacy-dark"></span><span>Legacy Dark</span></div> |
| 72 | + </div> |
| 73 | + <small>(theme selector only works when the challenge has not been requested yet)</small> |
| 74 | + </div> |
| 75 | + |
| 76 | + <div class="copyright"> |
| 77 | + <p>Copyright © @DateTime.Now.Year Fabian Wennink - All rights reserved</p> |
| 78 | + <p> |
| 79 | + <small> |
| 80 | + IconCaptcha is licensed under <a href="https://www.fabianwennink.nl/projects/IconCaptcha-ASP.NET/license" class="link-underline" target="_blank" rel="noopener">MIT</a>. |
| 81 | + Icons made by <a href="https://blendicons.com" class="link-underline" target="_blank" rel="nofollow noopener">BlendIcons</a>. |
| 82 | + </small> |
| 83 | + </p> |
| 84 | + </div> |
| 85 | + </div> |
| 86 | + |
| 87 | + <a href="../"> |
| 88 | + <div class="btn btn-bottom"> |
| 89 | + <span>GO BACK</span> |
| 90 | + </div> |
| 91 | + </a> |
| 92 | + |
| 93 | + <a href="https://github.com/fabianwennink/IconCaptcha-ASP.NET/" target="_blank" rel="noopener"> |
| 94 | + <div class="corner-ribbon top-left">STAR ME ON GITHUB</div> |
| 95 | + </a> |
| 96 | + |
| 97 | + <!-- Buy Me A Coffee widget - JUST FOR THE DEMO PAGE --> |
| 98 | + <script data-name="BMC-Widget" src="https://cdnjs.buymeacoffee.com/1.0.0/widget.prod.min.js" data-id="fabianwennink" |
| 99 | + data-description="Support me on Buy me a coffee!" data-message="If you like IconCaptcha, consider buying me a coffee!" |
| 100 | + data-color="#ffffff" data-position="right" data-x_margin="25" data-y_margin="25"></script> |
| 101 | + |
| 102 | + <!-- Include IconCaptcha script - REQUIRED --> |
| 103 | + <script src="/js/icon-captcha.min.js" type="text/javascript"></script> |
| 104 | + |
| 105 | + <!-- Include jQuery Library --> |
| 106 | + <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script> |
| 107 | + |
| 108 | + <!-- Include IconCaptcha script - REQUIRED --> |
| 109 | + <script src="/js/icon-captcha.min.js" type="text/javascript"></script> |
| 110 | + |
| 111 | + <!-- Initialize the IconCaptcha - REQUIRED --> |
| 112 | + <script type="text/javascript"> |
| 113 | + $(document).ready(function() { |
| 114 | + $('.iconcaptcha-holder').iconCaptcha({ |
| 115 | + general: { |
| 116 | + validationPath: '/iconcaptcha', |
| 117 | + fontFamily: 'Poppins', |
| 118 | + credits: 'show', |
| 119 | + }, |
| 120 | + security: { |
| 121 | + clickDelay: 500, |
| 122 | + hoverDetection: true, |
| 123 | + enableInitialMessage: true, |
| 124 | + initializeDelay: 500, |
| 125 | + selectionResetDelay: 3000, |
| 126 | + loadingAnimationDelay: 1000, |
| 127 | + invalidateTime: 1000 * 60 * 2, |
| 128 | + }, |
| 129 | + messages: { |
| 130 | + initialization: { |
| 131 | + verify: 'Verify that you are human.', |
| 132 | + loading: 'Loading challenge...', |
| 133 | + }, |
| 134 | + header: 'Select the image displayed the <u>least</u> amount of times', |
| 135 | + correct: 'Verification complete.', |
| 136 | + incorrect: { |
| 137 | + title: 'Uh oh.', |
| 138 | + subtitle: "You've selected the wrong image." |
| 139 | + }, |
| 140 | + timeout: { |
| 141 | + title: 'Please wait 60 sec.', |
| 142 | + subtitle: 'You made too many incorrect selections.' |
| 143 | + } |
| 144 | + } |
| 145 | + }) |
| 146 | + // .bind('init', function(e) { // You can bind to custom events, in case you want to execute custom code. |
| 147 | + // console.log('Event: Captcha initialized', e.detail.captchaId); |
| 148 | + // }).bind('selected', function(e) { |
| 149 | + // console.log('Event: Icon selected', e.detail.captchaId); |
| 150 | + // }).bind('refreshed', function(e) { |
| 151 | + // console.log('Event: Captcha refreshed', e.detail.captchaId); |
| 152 | + // }).bind('invalidated', function(e) { |
| 153 | + // console.log('Event: Invalidated', e.detail.captchaId); |
| 154 | + // }).bind('reset', function(e) { |
| 155 | + // console.log('Event: Reset', e.detail.captchaId); |
| 156 | + // }).bind('success', function(e) { |
| 157 | + // console.log('Event: Correct input', e.detail.captchaId); |
| 158 | + // }).bind('error', function(e) { |
| 159 | + // console.log('Event: Wrong input', e.detail.captchaId); |
| 160 | + // }); |
| 161 | + }); |
| 162 | + </script> |
| 163 | + |
| 164 | + <!-- |
| 165 | + Script to submit the form(s) with Ajax. |
| 166 | +
|
| 167 | + NOTE: If you want to use FormData instead of .serialize(), make sure to |
| 168 | + include the inputs 'ic-hf-se', 'ic-hf-id' and 'ic-hf-hp' into your FormData object. |
| 169 | + Take a look at the commented code down below. |
| 170 | + --> |
| 171 | + <script type="text/javascript"> |
| 172 | + $(document).ready(function() { |
| 173 | + $('form').submit(function(e) { |
| 174 | + e.preventDefault(); |
| 175 | +
|
| 176 | + // Get the form element. |
| 177 | + const form = $(this); |
| 178 | +
|
| 179 | + // Perform the AJAX call. |
| 180 | + $.ajax({ |
| 181 | + type: 'POST', |
| 182 | + url: form.attr('action'), |
| 183 | + data: form.serialize() |
| 184 | + }).done(function (data) { |
| 185 | + $('.message').html(data); |
| 186 | + }).fail(function () { |
| 187 | + console.log('Error: Failed to submit form.') |
| 188 | + }); |
| 189 | +
|
| 190 | + // // FormData example: |
| 191 | + // |
| 192 | + // // Get the form element. |
| 193 | + // const form = $(this); |
| 194 | + // |
| 195 | + // // Build the FormData object. |
| 196 | + // const formData = new FormData(); |
| 197 | + // formData.append('ic-hf-se', form.find('input[name="ic-hf-se"]').val()); |
| 198 | + // formData.append('ic-hf-id', form.find('input[name="ic-hf-id"]').val()); |
| 199 | + // formData.append('ic-hf-hp', form.find('input[name="ic-hf-hp"]').val()); |
| 200 | + // |
| 201 | + // // Perform the AJAX call. |
| 202 | + // $.ajax({ |
| 203 | + // type: 'POST', |
| 204 | + // url: form.attr('action'), |
| 205 | + // data: formData, |
| 206 | + // processData: false, |
| 207 | + // contentType: false |
| 208 | + // }).done(function (data) { |
| 209 | + // $('.message').html(data); |
| 210 | + // }).fail(function () { |
| 211 | + // console.log('Error: Failed to submit form.') |
| 212 | + // }); |
| 213 | + }); |
| 214 | + }); |
| 215 | + </script> |
| 216 | + </body> |
| 217 | +</html> |
0 commit comments