<commit_before>/*
Copyright 2015, 2016 OpenMarket Ltd

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

'use strict';

var React = require('react');
var DIV_ID = 'mx_recaptcha';

/**
 * A pure UI component which displays a captcha form.
 */
module.exports = React.createClass({
    displayName: 'CaptchaForm',

    propTypes: {
        sitePublicKey: React.PropTypes.string,

        // called with the captcha response
        onCaptchaResponse: React.PropTypes.func,
    },

    getDefaultProps: function() {
        return {
            onCaptchaResponse: () => {},
        };
    },

    getInitialState: function() {
        return {
            errorText: null,
        };
    },

    componentDidMount: function() {
        // Just putting a script tag into the returned jsx doesn't work, annoyingly,
        // so we do this instead.
        if (global.grecaptcha) {
            // already loaded
            this._onCaptchaLoaded();
        } else {
            console.log("Loading recaptcha script...");
            var scriptTag = document.createElement('script');
            window.mx_on_recaptcha_loaded = () => {this._onCaptchaLoaded()};
            scriptTag.setAttribute(
                'src', global.location.protocol+"//www.google.com/recaptcha/api.js?onload=mx_on_recaptcha_loaded&render=explicit"
            );
            this.refs.recaptchaContainer.appendChild(scriptTag);
        }
    },

    _renderRecaptcha: function(divId) {
        if (!global.grecaptcha) {
            console.error("grecaptcha not loaded!");
            throw new Error("Recaptcha did not load successfully");
        }

        var publicKey = this.props.sitePublicKey;
        if (!publicKey) {
            console.error("No public key for recaptcha!");
            throw new Error(
                "This server has not supplied enough information for Recaptcha "
                    + "authentication");
        }
<commit_msg>blind fix for captcha on electron<commit_after>/*
Copyright 2015, 2016 OpenMarket Ltd

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

'use strict';

var React = require('react');
var DIV_ID = 'mx_recaptcha';

/**
 * A pure UI component which displays a captcha form.
 */
module.exports = React.createClass({
    displayName: 'CaptchaForm',

    propTypes: {
        sitePublicKey: React.PropTypes.string,

        // called with the captcha response
        onCaptchaResponse: React.PropTypes.func,
    },

    getDefaultProps: function() {
        return {
            onCaptchaResponse: () => {},
        };
    },

    getInitialState: function() {
        return {
            errorText: null,
        };
    },

    componentDidMount: function() {
        // Just putting a script tag into the returned jsx doesn't work, annoyingly,
        // so we do this instead.
        if (global.grecaptcha) {
            // already loaded
            this._onCaptchaLoaded();
        } else {
            console.log("Loading recaptcha script...");
            var scriptTag = document.createElement('script');
            window.mx_on_recaptcha_loaded = () => {this._onCaptchaLoaded()};
            var protocol = global.location.protocol === "file:" ? "https:" : global.location.protocol;
            scriptTag.setAttribute(
                'src', protocol+"//www.google.com/recaptcha/api.js?onload=mx_on_recaptcha_loaded&render=explicit"
            );
            this.refs.recaptchaContainer.appendChild(scriptTag);
        }
    },

    _renderRecaptcha: function(divId) {
        if (!global.grecaptcha) {
            console.error("grecaptcha not loaded!");
            throw new Error("Recaptcha did not load successfully");
        }

        var publicKey = this.props.sitePublicKey;
        if (!publicKey) {
            console.error("No public key for recaptcha!");
            throw new Error(
                "This server has not supplied enough information for Recaptcha "
                    + "authentication");
        }

{'fraction_non_alphanumeric': 0.09758571718401299, 'fraction_numerical': 0.004869141813755326, 'mean_word_length': 2.3767123287671232, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '964717', 'n_tokens_mistral': 1335, 'n_tokens_neox': 1275, 'n_words': 407}