From 3f7c886874a96e96fb78bae7474b9b3a5ac43990 Mon Sep 17 00:00:00 2001 From: gnuboard Date: Thu, 3 Jan 2013 15:12:23 +0900 Subject: [PATCH] =?UTF-8?q?html5=20=EC=A7=80=EC=9B=90=EB=B8=8C=EB=9D=BC?= =?UTF-8?q?=EC=9A=B0=EC=A0=80=20=EC=9D=BC=EB=95=8C=EC=99=80=20=EC=95=84?= =?UTF-8?q?=EB=8B=90=EB=95=8C=EB=A1=9C=20=EB=82=98=EB=88=84=EC=96=B4=20wav?= =?UTF-8?q?=20=ED=8C=8C=EC=9D=BC=EC=9D=84=20=EC=8B=A4=ED=96=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/captcha/captcha.js | 102 ++++++++++++++++++++++++++++++++++---- 1 file changed, 92 insertions(+), 10 deletions(-) diff --git a/plugin/captcha/captcha.js b/plugin/captcha/captcha.js index be50abe14..6289dfc7b 100644 --- a/plugin/captcha/captcha.js +++ b/plugin/captcha/captcha.js @@ -1,11 +1,11 @@ function chk_captcha(input_key) { - if (typeof(input_key) != 'undefined') { + if (typeof(input_key) != "undefined") { var captcha_result = false; $.ajax({ - type: 'POST', - url: g4_path+'/plugin/captcha/get.php', - data: { 'captcha_key': input_key.value }, + type: "POST", + url: g4_path+"/plugin/captcha/get.php", + data: { "captcha_key": input_key.value }, cache: false, async: false, success: function(result) { @@ -13,7 +13,7 @@ function chk_captcha(input_key) } }); if (!captcha_result) { - alert('숫자가 틀렸거나 입력 횟수가 넘었습니다.\n\n이미지를 클릭하여 다시 입력해 주십시오.'); + alert("숫자가 틀렸거나 입력 횟수가 넘었습니다.\n\n이미지를 클릭하여 다시 입력해 주십시오."); input_key.select(); return false; } @@ -21,12 +21,94 @@ function chk_captcha(input_key) return true; } +function l_PlaySound(url, placeholderId) { + if (document.getElementById) { + var soundUrl = url; + var placeholder = document.getElementById(placeholderId); + + placeholder.innerHTML = ""; + + document.body.style.cursor = 'wait'; + var html5SoundPlayed = false; + var browserCompatibilityCheck = document.createElement('audio'); + if (!!(browserCompatibilityCheck.canPlayType) && + !!(browserCompatibilityCheck.canPlayType("audio/wav")) && + !l_DetectFirefox3()) { + sound = new Audio(soundUrl); + sound.id = 'LBD_CaptchaSoundAudio'; + sound.autoplay = true; + sound.controls = false; + sound.autobuffer = false; + sound.loop = false; + + placeholder.appendChild(sound); + html5SoundPlayed = true; + } + + if (!html5SoundPlayed) { + var objectSrc = ""; + + placeholder.innerHTML = objectSrc; + } + + document.body.style.cursor = 'default'; + } +} + +function l_DetectFirefox3() { + var detected = false; + if (navigator && navigator.userAgent) { + var matches = navigator.userAgent.match(/(Firefox)\/(3\.6\.[^;\+,\/\s]+)/); + if (matches) { + detected = true; + } + } + return detected; +} + $(function() { - $('#captcha').click(function() { - this.setAttribute('src', g4_path+'/plugin/captcha/run.php?t='+(new Date).getTime()); - //$('#captcha_key').focus();//이미지 새로고침 후 입력박스에 포커스 : 지운아빠 2012-07-13 + $("#captcha").click(function() { + this.setAttribute("src", g4_path+"/plugin/captcha/run.php?t="+(new Date).getTime()); + //$("#captcha_key").focus();//이미지 새로고침 후 입력박스에 포커스 : 지운아빠 2012-07-13 //캡챠 클릭 시에 포커스 줘야 하는데 페이지 새로 고침되면 포커스를 줘서 주석처리 : 지운아빠 2012-08-03 }) - .css('cursor', 'pointer') - .trigger('click'); + .css("cursor", "pointer") + .trigger("click"); + + $("#captcha_wav").click(function(){ + $("body").css("cursor", "wait"); + + var wav_url = this.href+"?t="+new Date().getTime(); + + var html5use = false; + var html5audio = document.createElement("audio"); + if (html5audio.canPlayType && html5audio.canPlayType("audio/wav")) { + var wav = new Audio(wav_url); + wav.id = "wav_audio"; + wav.autoplay = true; + wav.controls = false; + wav.autobuffer = false; + wav.loop = false; + + if ($("#wav_audio").length) $("#wav_audio").remove(); + $("#captcha_wav").after(wav); + + html5use = true; + } + + if (!html5use) { + var object = ''; + object += ''; + object += ''; + object += ''; + object += ''; + object += ''; + object += ''; + if ($("#wav_object").length) $("#wav_object").remove(); + $("#captcha_wav").after(object); + } + + $("body").css("cursor", "default"); + return false; + }); }); \ No newline at end of file