PageSourceSearch

https://www.biotechrabbit.com/js/mage/captcha.js

js biotechrabbit.com collected 2026-09-24 11:24:11 UTC 2,677 bytes, 76 lines download raw bytes

1/**
2 * OpenMage
3 *
4 * This source file is subject to the Academic Free License (AFL 3.0)
5 * that is bundled with this package in the file LICENSE_AFL.txt.
6 * It is also available at https://opensource.org/license/afl-3-0-php
7 *
8 * @category    Mage
9 * @package     js
10 * @copyright   Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com)
11 * @copyright   Copyright (c) 2022 The OpenMage Contributors (https://www.openmage.org)
12 * @license     https://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
13 */
14var Captcha = Class.create();
15Captcha.prototype = {
16    initialize: function(url, formId){
17        this.url = url;
18        this.formId = formId;
19    },
20    refresh: function(elem) {
21        formId = this.formId;
22        if (elem) Element.addClassName(elem, 'refreshing');
23        new Ajax.Request(this.url, {
24            onSuccess: function (response) {
25                if (response.responseText.isJSON()) {
26                    var json = response.responseText.evalJSON();
27                    if (!json.error && json.imgSrc) {
28                        $(formId).writeAttribute('src', json.imgSrc);
29                        if (elem) Element.removeClassName(elem, 'refreshing');
30                    } else {
31                        if (elem) Element.removeClassName(elem, 'refreshing');
32                    }
33                }
34            },
35            method: 'post',
36            parameters: {
37                'formId'   : this.formId
38            }
39        });
40    }
41};
42
43document.observe('billing-request:completed', function(event) {
44    if (typeof window.checkout != 'undefined') {
45        if (window.checkout.method == 'guest' && $('guest_checkout')){
46            $('guest_checkout').captcha.refresh();
47        }
48        if (window.checkout.method == 'register' && $('register_during_checkout')){
49            $('register_during_checkout').captcha.refresh();
50        }
51    }
52});
53
54
55document.observe('login:setMethod', function(event) {
56    var switchCaptchaElement = function(shown, hidden) {
57        var inputPrefix = 'captcha-input-box-', imagePrefix = 'captcha-image-box-';
58        if ($(inputPrefix + hidden)) {
59            $(inputPrefix + hidden).hide();
60            $(imagePrefix + hidden).hide();
61        }
62        if ($(inputPrefix + shown)) {
63            $(inputPrefix + shown).show();
64            $(imagePrefix + shown).show();
65        }
66    };
67
68    switch (event.memo.method) {
69        case 'guest':
70            switchCaptchaElement('guest_checkout', 'register_during_checkout');
71            break;
72        case 'register':
73            switchCaptchaElement('register_during_checkout', 'guest_checkout');
74            break;
75    }
76});

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.