<commit_before>/*global
 define
 */
/*jslint
 browser: true,
 white: true
 */
define([
    'kb/common/html',
    'kb/common/domEvent',
    'jquery',
    'bluebird',
    'kb_plugin_login'
],
function (html, domEvent, $, Promise, Plugin) {
    'use strict';


    function widget(config) {
        var mount, container, runtime = config.runtime,
            nextRequest,
            events;

        // This should be somewhere else, and handle all types of fields
        // I'm sure we've done this already.
        function getFieldValue(name) {
            var field = $(container).find(' form [name="' + name + '"]');
            if (field) {
                return field.val();
            }
        }
        function node(selector) {
            return $(container).find(selector);
        }
        function element(name) {
            return node('[data-element="' + name + '"]');
        }

        function handleLogin(e) {
            e.preventDefault();

            // TODO: add support for nextPath, nextURL

            var username = getFieldValue('username'),
                    password = getFieldValue('password');

            if (!username) {
                element('error').html('The username is required').show();
                return;
            }
            if (!password) {
                element('error').html('The password is required').show();
                return;
            }

            element('error').hide();
            element('sign-in').hide();
            element('signing-in').show();
            runtime.send('ui', 'setTitle', 'Signing in ...');
            runtime.getService('session').login({
                username: username,
                password: password
            })
                    .then(function () {
                        runtime.send('ui', 'setTitle', 'Successful Sign In!');
                        runtime.send('app', 'loggedin');
                        /* TODO should be configurable default login location */
                        if (nextRequest) {
                            runtime.send('app', 'navigate', nextRequest);
                        } else {
                            runtime.send('app', 'navigate', '');
                        }
                    })
                    .catch(function (errorMsg) {
                        runtime.send('ui', 'setTitle', 'Sign In Error');
                        element('running').hide();
                        if (errorMsg === "LoginFailure: Authentication failed.") {
                            errorMsg = "Login Failed: your username/password is incorrect.";
                        }
                        element('error').html(errorMsg).show();
                        element('sign-in').show();
                        element('signing-in').hide();
                    })
                    .done();
        }
        
        var currentUsername; 
        function handleUsernameKeyup(e) {
            e.preventDefault();
            
            // validate the username!
            var potentialUsername = e.target.value,
                messageElement = container.querySelector('[data-element="username-message"]'),
                invalidCharsRe = /[\s@]/,
                message;
            
            currentUsername = potentialUsername;
            if (currentUsername && currentUsername.length > 0) {                
                if (invalidCharsRe.test(currentUsername)) {
                    message = 'Invalid characters in username: spaces and @ are not allowed';
                    messageElement.innerHTML = message;
                    messageElement.style.display = 'block';
                    messageElement.classList.add('alert-danger');
                    return;
                }
            }
            messageElement.innerHTML = '';
            messageElement.style.display = 'none';
            messageElement.classList.remove('alert-danger');
        }

        function renderForm() {
            var form = html.tag('form'),
                    input = html.tag('input'),
                    button = html.tag('button'),
                    div = html.tag('div'),
                    p = html.tag('p'),
                    h1 = html.tag('h1'),
                    legend = html.tag('legend'),
                    i = html.tag('i'),
                    a = html.tag('a');

            /* TODO: use the actual next path */
            // Variables for form.
            var nextPath = 'next path',
                    nextURL = 'next url';

            // eventMan.reset();
            var doodlePath = Plugin.plugin.fullPath + '/doodle.png';
            
            return div({class: 'container', style: 'margin-top: 4em', dataWidget: 'login'}, [
                div({}, [
                    div({style: {
                            position: 'absolute',
                            backgroundImage: 'url(' + doodlePath + ')',
                            backgroundRepeat: 'no-repeat',
                            backgroundSize: '35%',
                            top: '0',
                            left: '0',
                            bottom: '0',
                            right: '0',
                            opacity: '0.1',
                            zIndex: '-1000'
                        }})
                ]),
                div({class: 'row'}, [
                    div({class: 'col-sm-7 col-sm-offset-1'}, [
                        h1({style: 'font-size:1.6em'}, ['Welcome to KBase']),
                        p([
                            'After signing in, you can start working with KBase. Upload your experimental data and perform comparative genomics and systems biology analyses by creating ', 
                            i('Narratives'), 
                            ': interactive, dynamic, and shareable documents. Narratives include all your analysis steps, commentary, and visualizations.'
                        ]),
                        p([
                            'Want to learn more?  Check out the ',
                            a({href: 'http://kbase.us/narrative-guide', target: '_blank'}, 'Narrative Interface User Guide'),
                            ' or the ',
                            a({href: 'https://youtu.be/6ql7HAUzU7U', target: '_blank'}, 'Narrative Interface video tutorial'),
                            ', and a ',
                            a({href: 'http://kbase.us/tutorials', target: '_blank'}, 'library of tutorials'), 
                            ' that show you how to use various KBase apps to analyze your data.'
                        ])
                    ]),
                    div({class: 'col-sm-3'}, [
                        div({class: 'well well-kbase'}, [
                            form({class: 'form login-form', id: events.addEvent('submit', handleLogin)}, [<commit_msg>Update text on login page, as per KBASE-4144<commit_after>/*global
 define
 */
/*jslint
 browser: true,
 white: true
 */
define([
    'kb/common/html',
    'kb/common/domEvent',
    'jquery',
    'bluebird',
    'kb_plugin_login'
],
function (html, domEvent, $, Promise, Plugin) {
    'use strict';


    function widget(config) {
        var mount, container, runtime = config.runtime,
            nextRequest,
            events;

        // This should be somewhere else, and handle all types of fields
        // I'm sure we've done this already.
        function getFieldValue(name) {
            var field = $(container).find(' form [name="' + name + '"]');
            if (field) {
                return field.val();
            }
        }
        function node(selector) {
            return $(container).find(selector);
        }
        function element(name) {
            return node('[data-element="' + name + '"]');
        }

        function handleLogin(e) {
            e.preventDefault();

            // TODO: add support for nextPath, nextURL

            var username = getFieldValue('username'),
                    password = getFieldValue('password');

            if (!username) {
                element('error').html('The username is required').show();
                return;
            }
            if (!password) {
                element('error').html('The password is required').show();
                return;
            }

            element('error').hide();
            element('sign-in').hide();
            element('signing-in').show();
            runtime.send('ui', 'setTitle', 'Signing in ...');
            runtime.getService('session').login({
                username: username,
                password: password
            })
                    .then(function () {
                        runtime.send('ui', 'setTitle', 'Successful Sign In!');
                        runtime.send('app', 'loggedin');
                        /* TODO should be configurable default login location */
                        if (nextRequest) {
                            runtime.send('app', 'navigate', nextRequest);
                        } else {
                            runtime.send('app', 'navigate', '');
                        }
                    })
                    .catch(function (errorMsg) {
                        runtime.send('ui', 'setTitle', 'Sign In Error');
                        element('running').hide();
                        if (errorMsg === "LoginFailure: Authentication failed.") {
                            errorMsg = "Login Failed: your username/password is incorrect.";
                        }
                        element('error').html(errorMsg).show();
                        element('sign-in').show();
                        element('signing-in').hide();
                    })
                    .done();
        }
        
        var currentUsername; 
        function handleUsernameKeyup(e) {
            e.preventDefault();
            
            // validate the username!
            var potentialUsername = e.target.value,
                messageElement = container.querySelector('[data-element="username-message"]'),
                invalidCharsRe = /[\s@]/,
                message;
            
            currentUsername = potentialUsername;
            if (currentUsername && currentUsername.length > 0) {                
                if (invalidCharsRe.test(currentUsername)) {
                    message = 'Invalid characters in username: spaces and @ are not allowed';
                    messageElement.innerHTML = message;
                    messageElement.style.display = 'block';
                    messageElement.classList.add('alert-danger');
                    return;
                }
            }
            messageElement.innerHTML = '';
            messageElement.style.display = 'none';
            messageElement.classList.remove('alert-danger');
        }

        function renderForm() {
            var form = html.tag('form'),
                    input = html.tag('input'),
                    button = html.tag('button'),
                    div = html.tag('div'),
                    p = html.tag('p'),
                    h1 = html.tag('h1'),
                    legend = html.tag('legend'),
                    i = html.tag('i'),
                    a = html.tag('a');

            /* TODO: use the actual next path */
            // Variables for form.
            var nextPath = 'next path',
                    nextURL = 'next url';

            // eventMan.reset();
            var doodlePath = Plugin.plugin.fullPath + '/doodle.png';
            
            return div({class: 'container', style: 'margin-top: 4em', dataWidget: 'login'}, [
                div({}, [
                    div({style: {
                            position: 'absolute',
                            backgroundImage: 'url(' + doodlePath + ')',
                            backgroundRepeat: 'no-repeat',
                            backgroundSize: '35%',
                            top: '0',
                            left: '0',
                            bottom: '0',
                            right: '0',
                            opacity: '0.1',
                            zIndex: '-1000'
                        }})
                ]),
                div({class: 'row'}, [
                    div({class: 'col-sm-7 col-sm-offset-1'}, [
                        h1({style: 'font-size:1.6em'}, ['Welcome to KBase']),
                        p([
                            'After signing in, you can start working with KBase. Upload your experimental data and perform comparative genomics and systems biology analyses by creating ', 
                            i('Narratives'), 
                            ': interactive, dynamic, and shareable documents. Narratives include all your analysis steps, commentary, and visualizations.'
                        ]),
                        p([
                            'Want to learn more?  Check out the ',
                            a({href: runtime.config('resources.documentation.narrativeGuide.url')}, 'Narrative Interface User Guide'),
                            ' or the ',
                            a({href: 'https://youtu.be/6ql7HAUzU7U'}, 'Narrative Interface video tutorial'),
                            ', and a ',
                            a({href: runtime.config('resources.documentation.tutorials.url')}, 'library of tutorials'), 
                            ' that show you how to use various KBase apps to analyze your data.'
                        ])
                    ]),
                    div({class: 'col-sm-3'}, [
                        div({class: 'well well-kbase'}, [
                            form({class: 'form login-form', id: events.addEvent('submit', handleLogin)}, [
{'fraction_non_alphanumeric': 0.12118348357080547, 'fraction_numerical': 0.003925559755742949, 'mean_word_length': 1.1739886219974716, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6607438', 'n_tokens_mistral': 3269, 'n_tokens_neox': 3057, 'n_words': 759}