1/** 2 * Magento 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 * http://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 * DISCLAIMER 15 * 16 * Do not edit or add to this file if you wish to upgrade Magento to newer 17 * versions in the future. If you wish to customize Magento for your 18 * needs please refer to http://www.magento.com for more information. 19 * 20 * @category Mage 21 * @package js 22 * @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com) 23 * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) 24 */ 25var Captcha = Class.create(); 26Captcha.prototype = { 27 initialize: function(url, formId){ 28 this.url = url; 29 this.formId = formId; 30 }, 31 refresh: function(elem) { 32 formId = this.formId; 33 if (elem) Element.addClassName(elem, 'refreshing'); 34 new Ajax.Request(this.url, { 35 onSuccess: function (response) { 36 if (response.responseText.isJSON()) { 37 var json = response.responseText.evalJSON(); 38 if (!json.error && json.imgSrc) { 39 $(formId).writeAttribute('src', json.imgSrc); 40 if (elem) Element.removeClassName(elem, 'refreshing'); 41 } else { 42 if (elem) Element.removeClassName(elem, 'refreshing'); 43 } 44 } 45 }, 46 method: 'post', 47 parameters: { 48 'formId' : this.formId 49 } 50 }); 51 } 52}; 53 54document.observe('billing-request:completed', function(event) { 55 if (typeof window.checkout != 'undefined') { 56 if (window.checkout.method == 'guest' && $('guest_checkout')){ 57 $('guest_checkout').captcha.refresh() 58 } 59 if (window.checkout.method == 'register' && $('register_during_checkout')){ 60 $('register_during_checkout').captcha.refresh() 61 } 62 } 63}); 64 65 66document.observe('login:setMethod', function(event) { 67 var switchCaptchaElement = function(shown, hidden) { 68 var inputPrefix = 'captcha-input-box-', imagePrefix = 'captcha-image-box-'; 69 if ($(inputPrefix + hidden)) { 70 $(inputPrefix + hidden).hide(); 71 $(imagePrefix + hidden).hide(); 72 } 73 if ($(inputPrefix + shown)) { 74 $(inputPrefix + shown).show(); 75 $(imagePrefix + shown).show(); 76 } 77 }; 78 79 switch (event.memo.method) { 80 case 'guest': 81 switchCaptchaElement('guest_checkout', 'register_during_checkout'); 82 break; 83 case 'register': 84 switchCaptchaElement('register_during_checkout', 'guest_checkout'); 85 break; 86 } 87});
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.