1/** 2 * OpenMage 3 * 4 * NOTICE OF LICENSE 5 * 6 * This source file is subject to the Academic Free License (AFL 3.0) 7 * that is bundled with this package in the file LICENSE_AFL.txt. 8 * It is also available through the world-wide-web at this URL: 9 * https://opensource.org/licenses/afl-3.0.php 10 * If you did not receive a copy of the license and are unable to 11 * obtain it through the world-wide-web, please send an email 12 * to [email protected] so we can send you a copy immediately. 13 * 14 * @category Mage 15 * @package js 16 * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) 17 * @license https://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) 18 */ 19var Captcha = Class.create(); 20Captcha.prototype = { 21 initialize: function(url, formId){ 22 this.url = url; 23 this.formId = formId; 24 }, 25 refresh: function(elem) { 26 formId = this.formId; 27 if (elem) Element.addClassName(elem, 'refreshing'); 28 new Ajax.Request(this.url, { 29 onSuccess: function (response) { 30 if (response.responseText.isJSON()) { 31 var json = response.responseText.evalJSON(); 32 if (!json.error && json.imgSrc) { 33 $(formId).writeAttribute('src', json.imgSrc); 34 if (elem) Element.removeClassName(elem, 'refreshing'); 35 } else { 36 if (elem) Element.removeClassName(elem, 'refreshing'); 37 } 38 } 39 }, 40 method: 'post', 41 parameters: { 42 'formId' : this.formId 43 } 44 }); 45 } 46}; 47 48document.observe('billing-request:completed', function(event) { 49 if (typeof window.checkout != 'undefined') { 50 if (window.checkout.method == 'guest' && $('guest_checkout')){ 51 $('guest_checkout').captcha.refresh(); 52 } 53 if (window.checkout.method == 'register' && $('register_during_checkout')){ 54 $('register_during_checkout').captcha.refresh(); 55 } 56 } 57}); 58 59 60document.observe('login:setMethod', function(event) { 61 var switchCaptchaElement = function(shown, hidden) { 62 var inputPrefix = 'captcha-input-box-', imagePrefix = 'captcha-image-box-'; 63 if ($(inputPrefix + hidden)) { 64 $(inputPrefix + hidden).hide(); 65 $(imagePrefix + hidden).hide(); 66 } 67 if ($(inputPrefix + shown)) { 68 $(inputPrefix + shown).show(); 69 $(imagePrefix + shown).show(); 70 } 71 }; 72 73 switch (event.memo.method) { 74 case 'guest': 75 switchCaptchaElement('guest_checkout', 'register_during_checkout'); 76 break; 77 case 'register': 78 switchCaptchaElement('register_during_checkout', 'guest_checkout'); 79 break; 80 } 81});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.