<commit_before>'use strict';
/* jshint browser: true */
/* global confirm: false */

var React = require('react');

var SceneTextEditor = require('../scene-text-editor.jsx');
var SceneStore = require('../../stores/scene-store');
var FileUploadStore = require('../../stores/file-upload-store');
var Authentication = require('../../mixins/Authentication');
var HubSendActions = require('../../actions/hub-send-actions');
var SceneActions = require('../../actions/scene-actions');
var MediaObjectList = require('../scene-editor/media-object-list.jsx');
var Loader = require('../loader.jsx');
var TagUnion = require('../tag-union.jsx');
var Router = require('react-router');
var DropZone = require('../drop-zone.jsx');
var FileUploadAlert = require('../file-upload-alert.jsx');
var AddMediaObject = require('../scene-editor/add-media-object.jsx');
var Router = require('react-router'),
    Link = Router.Link;



var Scene = React.createClass({

    mixins: [Router.State, Authentication],

    getStateFromStores: function() {
        return {
            scene: SceneStore.getScene(this.getParams().id),
            uploads: FileUploadStore.getStates(),
            focusedMediaObject: null
        }; 
    },

    componentDidMount:function(){
        SceneStore.addChangeListener(this._onChange);
        FileUploadStore.addChangeListener(this._onChange);
        HubSendActions.loadScene(this.getParams().id);
    },

    componentWillUnmount: function() {
        SceneStore.removeChangeListener(this._onChange);
        FileUploadStore.removeChangeListener(this._onChange);
    },

    _onChange:function(){
        this.setState(this.getStateFromStores());
    },

    getInitialState: function() {
        return this.getStateFromStores();
    },

    fileHandler: function(fileList) {
        for (var i = 0; i < fileList.length; i++) {
            SceneActions.uploadAsset(this.state.scene._id, fileList[i]);
        }
    },

    deleteSceneHandler: function(event) {
        if (confirm('Deleting a scene will remove all associated images and tags.\n\nAre you sure?')) {
            HubSendActions.deleteScene(this.state.scene._id);
        }
    },

    thumbClickHandler: function(index) {
        this.setState({focusedMediaObject: index});
    },

    render: function() {
        var uploads = this.state.uploads;

        var fileUploads = Object.keys(uploads).map(function(name) {
            return <FileUploadAlert key={name} name={name} state={uploads[name]} />;
        });        

        var viewerUrl = '/viewer.html#/scenes/' + this.getParams().id;

        return (
            <DropZone className='flex-container' handler={this.fileHandler}>
                <div className='top-bar'>
                    <div className='page-nav'>
                        <Link className='btn' to='scenes'>&lt; Back to Scene List</Link>
                        <a className='btn' href={viewerUrl}>Open in Scene Viewer</a>
                    </div>

                    <div className='scene-controls'>
                        <a className='btn' onClick={this.deleteSceneHandler}>Delete Scene</a>
                    </div>
                    <Loader loaded={this.state.scene ? true: false} message='Loading Scene...'>
                        <h4 className='scene-name'>{this.state.scene ? this.state.scene.name : ''}</h4>
                    </Loader>
                </div>

                <AddMediaObject scene={this.state.scene} />

                <div className="thumbs-and-json">
                    <MediaObjectList focusHandler={this.thumbClickHandler} 
                     scene={this.state.scene} />
                    <SceneTextEditor focusedMediaObject={this.state.focusedMediaObject} 
                     scene={this.state.scene || {} } />
                    
                </div>
                <TagUnion scene={this.state.scene} 
                 focusedMediaObject={this.state.focusedMediaObject}/>

                <div className="file-upload-status">
                    {fileUploads}
                </div>
            </DropZone>
        );
    }

});

module.exports = Scene;<commit_msg>prevent cursor from jumping around in text editor<commit_after>'use strict';
/* jshint browser: true */
/* global confirm: false */

var React = require('react');
var _ = require('lodash');
var SceneTextEditor = require('../scene-text-editor.jsx');
var SceneStore = require('../../stores/scene-store');
var FileUploadStore = require('../../stores/file-upload-store');
var Authentication = require('../../mixins/Authentication');
var HubSendActions = require('../../actions/hub-send-actions');
var SceneActions = require('../../actions/scene-actions');
var MediaObjectList = require('../scene-editor/media-object-list.jsx');
var Loader = require('../loader.jsx');
var TagUnion = require('../tag-union.jsx');
var Router = require('react-router');
var DropZone = require('../drop-zone.jsx');
var FileUploadAlert = require('../file-upload-alert.jsx');
var AddMediaObject = require('../scene-editor/add-media-object.jsx');
var Router = require('react-router'),
    Link = Router.Link;



var Scene = React.createClass({

    mixins: [Router.State, Authentication],

    getStateFromStores: function() {
        return {
            scene: SceneStore.getScene(this.getParams().id),
            uploads: FileUploadStore.getStates()
        }; 
    },

    componentDidMount:function(){
        SceneStore.addChangeListener(this._onChange);
        FileUploadStore.addChangeListener(this._onChange);
        HubSendActions.loadScene(this.getParams().id);
    },

    componentWillUnmount: function() {
        SceneStore.removeChangeListener(this._onChange);
        FileUploadStore.removeChangeListener(this._onChange);
    },

    _onChange:function(){
        this.setState(this.getStateFromStores());
    },

    getInitialState: function() {
        return _.extend(this.getStateFromStores(), {
            focusedMediaObject: null
        });
    },

    fileHandler: function(fileList) {
        for (var i = 0; i < fileList.length; i++) {
            SceneActions.uploadAsset(this.state.scene._id, fileList[i]);
        }
    },

    deleteSceneHandler: function(event) {
        if (confirm('Deleting a scene will remove all associated images and tags.\n\nAre you sure?')) {
            HubSendActions.deleteScene(this.state.scene._id);
        }
    },

    thumbClickHandler: function(index) {
        this.setState({focusedMediaObject: index});
    },

    render: function() {
        var uploads = this.state.uploads;

        var fileUploads = Object.keys(uploads).map(function(name) {
            return <FileUploadAlert key={name} name={name} state={uploads[name]} />;
        });        

        var viewerUrl = '/viewer.html#/scenes/' + this.getParams().id;

        return (
            <DropZone className='flex-container' handler={this.fileHandler}>
                <div className='top-bar'>
                    <div className='page-nav'>
                        <Link className='btn' to='scenes'>&lt; Back to Scene List</Link>
                        <a className='btn' href={viewerUrl}>Open in Scene Viewer</a>
                    </div>

                    <div className='scene-controls'>
                        <a className='btn' onClick={this.deleteSceneHandler}>Delete Scene</a>
                    </div>
                    <Loader loaded={this.state.scene ? true: false} message='Loading Scene...'>
                        <h4 className='scene-name'>{this.state.scene ? this.state.scene.name : ''}</h4>
                    </Loader>
                </div>

                <AddMediaObject scene={this.state.scene} />

                <div className="thumbs-and-json">
                    <MediaObjectList focusHandler={this.thumbClickHandler} 
                     scene={this.state.scene} />
                    <SceneTextEditor focusedMediaObject={this.state.focusedMediaObject} 
                     scene={this.state.scene || {} } />
                    
                </div>
                <TagUnion scene={this.state.scene} 
                 focusedMediaObject={this.state.focusedMediaObject}/>

                <div className="file-upload-status">
                    {fileUploads}
                </div>
            </DropZone>
        );
    }

});

module.exports = Scene;
{'fraction_non_alphanumeric': 0.14544364508393284, 'fraction_numerical': 0.0007194244604316547, 'mean_word_length': 2.1860198624904505, 'pattern_counts': {'":': 0, '<': 59, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '3608657', 'n_tokens_mistral': 2340, 'n_tokens_neox': 2199, 'n_words': 396}