Wiki source code of Displayer

Last modified by superadmin on 2025/05/22 17:44

Show last authors
1 {{velocity}}
2 #set ($discard = $xwiki.linkx.use($services.webjars.url('org.xwiki.platform:xwiki-platform-captcha-jcaptcha-webjar','captcha.css'), {'type': 'text/css', 'rel': 'stylesheet'}))
3 #set ($type = $captchaParameters.type)
4 #set ($engine = $captchaParameters.engine)
5 #set ($params = {})
6 #set ($discard = $params.put("cache-buster", ${datetool.date.time}))
7 {{html clean='false'}}
8 #if ($type == 'image')
9 ## Most of the time, the caching policy is respected, but in cases like the comments section (when the tab is reloaded) we are still forced to use a "cache buster".
10 <img src='$services.jcaptcha.getURL($type, $engine, $params)' class='captcha captcha-challenge' alt="$escapetool.xml($services.localization.render('captcha.jcaptcha.displayer.image.alt'))" />
11 #elseif ($type == 'sound')
12 ## Workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=1129121 on Firefox is to use a "cache busting" parameter to force a GET every time.
13 <audio src='$services.jcaptcha.getURL($type, $engine, $params)' class="captcha captcha-challenge">
14 #error($escapetool.xml($services.localization.render('captcha.jcaptcha.displayer.audio.error.audioElementNotSupported')))
15 </audio>
16 <a class='btn btn-link captcha captcha-play' href='#playCaptcha'>$services.icon.renderHTML('play') $escapetool.xml($services.localization.render('captcha.jcaptcha.displayer.audio.play'))</a>
17 #elseif ($type == 'text')
18 <iframe src='$services.jcaptcha.getURL($type, $engine, $params)' class="captcha captcha-challenge" frameborder="0"></iframe>
19 #else
20 #set ($jCaptchaError = true)
21 #error($escapetool.xml($services.localization.render('captcha.jcaptcha.displayer.error.unsupportedType')))
22 #end
23 #if (!$jCaptchaError)
24 <a class='btn btn-link captcha captcha-refresh' href='#refreshCaptcha'>
25 $services.icon.renderHTML('refresh') $escapetool.xml($services.localization.render('captcha.jcaptcha.displayer.refresh'))
26 </a>
27 ## Use autocomplete="off" so that when pressing the back button, the old answer is discarded.
28 ## Use an explicit empty value="" to avoid caching.
29 <input type="text" autocomplete="off" class="captcha captcha-answer" name="captchaAnswer" value="" placeholder="Answer" />
30 #end
31 <script src="$services.webjars.url('org.xwiki.platform:xwiki-platform-captcha-jcaptcha-webjar','captcha.js')"></script>
32 {{/html}}
33 {{/velocity}}