/*! * Securimage CAPTCHA Audio Library * https://www.phpcaptcha.org/ * * Copyright 2015 phpcaptcha.org * Released under the BSD-3 license * See https://github.com/dapphp/securimage/blob/master/README.md */ function securimageRefreshCaptcha(captcha_image, captcha_audio) { var captchaId = ''; var chars = "abcdefghijklmnopqrstuvwxyz0123456789"; for (var i = 0; i < 40; ++i) { captchaId += chars.charAt(Math.floor(Math.random() * chars.length)); } document.getElementById(captcha_image + '_captcha_id').value = captchaId; document.getElementById(captcha_image).src = document.getElementById(captcha_image).src.replace(/([?|&])id=[a-zA-Z0-9]+/, '$1id=' + captchaId); if (captcha_audio != '' && typeof window[captcha_audio] == 'object') { window[captcha_audio].refresh(captchaId); } } var SecurimageAudio = function(options) { this.html5Support = true; this.captchaId = null; this.playing = false; this.reload = false; this.audioElement = null; this.controlsElement = null; this.playButton = null; this.playButtonImage = null; this.loadingImage = null; if (options.audioElement) { this.audioElement = document.getElementById(options.audioElement); } if (options.controlsElement) { this.controlsElement = document.getElementById(options.controlsElement); } this.init(); } SecurimageAudio.prototype.init = function() { var ua = navigator.userAgent.toLowerCase(); var ieVer = (ua.indexOf('msie') != -1) ? parseInt(ua.split('msie')[1]) : false; // ie 11+ detection if (!ieVer && null != (ieVer = ua.match(/trident\/.*rv:(\d+\.\d+)/))) { ieVer = parseInt(ieVer[1]); } if (ieVer) { if (ieVer < 9) { // no html5 audio support, hide player controls this.controlsElement.style.display = 'none'; this.html5Support = false; return ; } else if ('' == this.audioElement.canPlayType('audio/wav')) { // check for mpeg tag - if not found then fallback to flash var sources = this.audioElement.getElementsByTagName('source'); var mp3support = false; var type; for (var i = 0; i < sources.length; ++i) { type = sources[i].attributes["type"].value; if (type.toLowerCase().indexOf('mpeg') >= 0 || type.toLowerCase().indexOf('mp3') >= 0) { mp3support = true; break; } } if (false == mp3support) { // browser supports