From 6854cb3f4d8219cf1829e32122eb2502a916eae9 Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Sat, 1 Feb 2020 09:05:48 +0100 Subject: initial checkin --- vendor/dapphp/securimage/securimage.js | 252 +++++++++++++++++++++++++++++++++ 1 file changed, 252 insertions(+) create mode 100644 vendor/dapphp/securimage/securimage.js (limited to 'vendor/dapphp/securimage/securimage.js') diff --git a/vendor/dapphp/securimage/securimage.js b/vendor/dapphp/securimage/securimage.js new file mode 100644 index 0000000..481e9e6 --- /dev/null +++ b/vendor/dapphp/securimage/securimage.js @@ -0,0 +1,252 @@ +/*! + * 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 + */ + +var SecurimageAudio = function(options) { + this.html5Support = true; + this.flashFallback = false; + 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]); + + var objAu = this.audioElement.getElementsByTagName('object'); + if (objAu.length > 0) { + objAu = objAu[0]; + } else { + objAu = null; + } + + 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; + + if (objAu) { + this.flashFallback = true; + } + + 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