<commit_before>import '../css/main.scss';
import './django/csrf';
import React from 'react';
import ReactDOM from 'react-dom';
import Dashboard from './Dashboard';
import MapView from './MapView';
import ModelView from './ModelView';
import Console from './Console';
import $ from 'jquery';

$(function(){
    $("[data-dashboard]").each(function(){
        ReactDOM.render(<Dashboard/>, $(this).get(0));
    });

    $("[data-mapview]").each(function(){
        let props = $(this).data();
        delete(props.mapview);
        ReactDOM.render(<MapView {...props}/>, $(this).get(0));
    });

    $("[data-modelview]").each(function(){
        let props = $(this).data();
        delete(props.modelview);
        ReactDOM.render(<ModelView {...props}/>, $(this).get(0));
    });

    $("[data-console]").each(function(){
        ReactDOM.render(<Console 
                lang={$(this).data("console-lang")}
                height={$(this).data("console-height")}
                autoscroll={typeof $(this).attr("autoscroll") !== 'undefined' && $(this).attr("autoscroll") !== false}
            >{$(this).text()}</Console>, $(this).get(0));
    });
});<commit_msg>Fixes #45<commit_after>import '../css/main.scss';
import './django/csrf';
import React from 'react';
import ReactDOM from 'react-dom';
import Dashboard from './Dashboard';
import MapView from './MapView';
import ModelView from './ModelView';
import Console from './Console';
import $ from 'jquery';

$(function(){
    $("[data-dashboard]").each(function(){
        ReactDOM.render(<Dashboard/>, $(this).get(0));
    });

    $("[data-mapview]").each(function(){
        let props = $(this).data();
        delete(props.mapview);
        ReactDOM.render(<MapView {...props}/>, $(this).get(0));
    });

    $("[data-modelview]").each(function(){
        let props = $(this).data();
        delete(props.modelview);
        ReactDOM.render(<ModelView {...props}/>, $(this).get(0));
    });

    $("[data-console]").each(function(){
        ReactDOM.render(<Console 
                lang={$(this).data("console-lang")}
                height={$(this).data("console-height")}
                autoscroll={typeof $(this).attr("autoscroll") !== 'undefined' && $(this).attr("autoscroll") !== false}
            >{$(this).text()}</Console>, $(this).get(0));
    });

    // Warn users if there's any sort of work in progress before
    // they press the back button on the browser
    // Yes it's a hack. No we're not going to track state in React just
    // for this.
    window.onbeforeunload = function() {
        let found = false; 
        $(".progress-bar:visible").each(function(){ 
            try{
                let value = parseFloat($(this).text());
                if (!isNaN(value) && value > 0 && value < 100) found = true;
            }catch(e){
                // Do nothing
            }
        });
        return found ? "Your changes will be lost. Are you sure you want to leave?" : undefined; 
    };
    
});
{'fraction_non_alphanumeric': 0.20843091334894615, 'fraction_numerical': 0.00468384074941452, 'mean_word_length': 2.589435774309724, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, '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': '4301640', 'n_tokens_mistral': 900, 'n_tokens_neox': 882, 'n_words': 196}