<commit_before>$(function(){
    var app = $('#app').data('app');
    var module = $('#app').data('module');

    $('#app').load('/' + app + '/'+ module);
    $('#app').addClass(app);
    var ws = $.websocket("ws://" + document.domain + ":" + window.location.port + "/ws", {
        open: function() {
            console.log('Connexion established.');
        },
        close: function() {
            console.log('Connexion closed.');
        },
        events: {
            switch: function(msg){
                console.log('Attempting to switch to ' + msg.url);
                $('#app').load(msg.url, function(response, status){
                    if(status == 'error') {
                        console.log('Failed to switch to ' + msg.url);
                    } else {
                        $('#app').removeClass().addClass(msg.url.split('/')[1]);
                        console.log('Switched to ' + msg.url);
                    }
                });
            }
        }
    });
});<commit_msg>Updated js to trigger events so the app frontend can react to a switch<commit_after>$(function(){
    var app = $('#app').data('app');
    var module = $('#app').data('module');

    $('#app').load('/' + app + '/'+ module);
    $('#app').addClass(app).trigger(app + '.' + module + '.activate');
    var ws = $.websocket("ws://" + document.domain + ":" + window.location.port + "/ws", {
        open: function() {
            console.log('Connexion established.');
        },
        close: function() {
            console.log('Connexion closed.');
        },
        events: {
            switch: function(msg){
                var tokens = msg.url.split('/');
                var app = tokens[1];
                var module = tokens[2];
                console.log('Attempting to switch to ' + msg.url);
                $('#app').load(msg.url, function(response, status){
                    if(status == 'error') {
                        console.log('Failed to switch to ' + msg.url);
                    } else {
                        $('#app').trigger($('#app').data('app') + '.' + $('#app').data('module') + '.deactivate');
                        $('#app').removeClass().addClass(msg.url.split('/')[1]);
                        $('#app').data('app', app).data('module', module);
                        $('#app').trigger(app + '.' + module + '.activate');
                        console.log('Switched to ' + msg.url);
                    }
                });
            }
        }
    });
});
{'fraction_non_alphanumeric': 0.2015873015873016, 'fraction_numerical': 0.0015873015873015873, 'mean_word_length': 1.5034756703078451, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, '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': '6540980', 'n_tokens_mistral': 673, 'n_tokens_neox': 657, 'n_words': 129}