1 2jQuery(function () { 3 var $wrap = jQuery('#plugin__captcha_wrapper'); 4 if(!$wrap.length) return; 5 6 /** 7 * Autofill and hide the whole CAPTCHA stuff in the simple JS mode 8 */ 9 var $code = jQuery('#plugin__captcha_code'); 10 if ($code.length) { 11 var $box = $wrap.find('input[type=text]'); 12 $box.first().val($code.text().replace(/([^A-Z])+/g, '')); 13 $wrap.hide(); 14 } 15 16 /** 17 * Add a HTML5 player for the audio version of the CAPTCHA 18 */ 19 var $audiolink = $wrap.find('a'); 20 if($audiolink.length) { 21 var audio = document.createElement('audio'); 22 if(audio) { 23 audio.src = $audiolink.attr('href'); 24 $wrap.append(audio); 25 $audiolink.click(function (e) { 26 audio.play(); 27 e.preventDefault(); 28 e.stopPropagation(); 29 }); 30 } 31 } 32}); 33