{"size": 1267, "ext": "js", "max_stars_repo_path": "JS/assets/web-im-1.1.2/demo/javascript/src/components/common/notify.js", "max_stars_repo_name": "sw4655315/angular-requirjs-PC-web", "max_stars_repo_stars_event_min_datetime": "2018-04-19T11:26:38.000Z", "max_stars_repo_stars_event_max_datetime": "2018-04-19T11:26:38.000Z", "max_issues_repo_path": "JS/assets/web-im-1.1.2/demo/javascript/src/components/common/notify.js", "max_issues_repo_name": "sw4655315/angular-requirjs-PC-web", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "JS/assets/web-im-1.1.2/demo/javascript/src/components/common/notify.js", "max_forks_repo_name": "sw4655315/angular-requirjs-PC-web", "max_forks_repo_forks_event_min_datetime": "2020-11-28T04:02:55.000Z", "max_forks_repo_forks_event_max_datetime": "2020-11-28T04:02:55.000Z"}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 22.2280701754, "max_line_length": 75, "alphanum_fraction": 0.5240726125}
var React = require("react");
var ReactDOM = require('react-dom');

var componentsNode = document.getElementById('components');
var dom = document.createElement('div');
componentsNode.appendChild(dom);


var Notify = React.createClass({

    click: function () {
        clearTimeout(this.props.st);
        ReactDOM.unmountComponentAtNode(dom);       
    },
   
    render: function () {
        var className = '';

        if ( this.props.status ) {
            className = ' ' + this.props.status;
        }
        
        return (
            <p onClick={this.click} className={'webim-notify' + className}>
                {this.props.content}
            </p>
        );
    }
});


module.exports = {
    success: function ( content ) {

        var st = setTimeout(function () {
            ReactDOM.unmountComponentAtNode(dom);
        }, 3000);

        ReactDOM.render(
            <Notify st={st} status='success' content={content} />,
            dom 
        );
    },
    error: function ( content ) {

        var st = setTimeout(function () {
            ReactDOM.unmountComponentAtNode(dom);
        }, 3000);

        ReactDOM.render(
            <Notify st={st} status='error' content={content} />,
            dom
        );
        
    }
};
