<commit_before>App.con = App.Controller = {
    
    initialize: function () {
        App.debug('App.Controller.initialize()');
        App.instance = this;
        // Set up error handling
        // Get initial fragment
        App.con.fragment = window.location.hash.substring(1);
        // Set up colors
        PrimeColor.setSeed(225, 76, 17);
        // Create models
        App.con.userModel = new App.UserModel();
        App.con.mediaSources = new App.MediaModel({parse:true});
        App.con.mediaExplorer = new App.MediaExploreView({
            mediaSources: App.con.mediaSources
        });
        App.con.queryCollection = new App.QueryCollection();
        App.con.legendView = new App.LegendView({
            collection: App.con.queryCollection
        });
        // Create view manager and app-level views
        App.con.vm = new App.ViewManager({
            "selector": '.content .container-fixed'
        });
        App.con.queryVm = new App.ViewManager({
            "selector": ".content .container-fluid"
        });
        App.con.controlsView = new App.ControlsView({ userModel: App.con.userModel });
        App.con.toolView = new App.ToolListView({
            collection:App.con.queryCollection
        });
        $('.brand-toolbar .links').append(App.con.toolView.el);
        $('.controls').append(App.con.controlsView.el);
        $('.drawer .container').html(App.con.legendView.el);
        App.con.router = new App.Router();
        // Bind event handlers
        _.bindAll(this, 'onSignIn');
        _.bindAll(this, 'onSignOut');
        // Listener for events
        App.con.queryCollection.resources.on('error', function (model_or_controller, request) {
            App.debug('Received error: ' + request.status);
            if (request.status == 401 || request.status == 403) {
                App.con.userModel.signOut();
            } else {
                var content = JSON.parse(request.responseText);
                var error = new Backbone.Model({
                    "message": content.error
                });
                App.con.getErrorCollection().add(error);
            }
        });
        // Start navigation and log user in
        App.con.userModel.on('signin', App.con.onSignIn);
        App.con.userModel.on('signout', App.con.onSignOut);
        App.con.userModel.on('unauthorized', App.con.onUnauthorized);
        Backbone.history.start();
        App.con.userModel.signIn({});
    },
    
    onSignIn: function () {
        App.debug('App.Controller.onSignIn()');
        App.con.router.navigate('', true);
        if (typeof(App.con.fragment) !== 'undefined'
            && App.con.fragment !== ''
            && App.con.fragment != 'login'
        ) {
            App.con.router.navigate(App.con.fragment, true);
            delete App.con.fragment;
        } else {
            App.con.router.navigate('', true);
        }
    },
    
    onSignOut: function () {
        App.debug('App.Controller.onSignOut()');
        App.con.router.navigate('login', true);
    },
    
    onUnauthorized: function () {
        App.debug('App.Controller.onUnauthorized()');
        App.con.router.navigate('login', true);
    },
    
    onQuery: function (queryCollection) {
        App.debug('App.Controller.onQuery()');
        App.debug(queryCollection);
        App.con.errorCollection.reset();
        var path = queryCollection.dashboardUrl();
        App.debug('Path: ' + path);
        App.con.router.navigate(path);
        App.con.showResults(queryCollection);
    },
    
    onDemoQuery: function (queryCollection) {
        App.debug('App.Controller.onQuery()');
        App.debug(queryCollection);
        var path = queryCollection.dashboardDemoUrl();
        App.debug('Path: ' + path);
        App.con.router.navigate(path);
        App.con.showResults(queryCollection);
    },
    
    showResults: function (queryCollection) {
        App.debug("App.Controller.showResults")
    },
    
    routeLogin: function () {
        App.debug('Route: login');
        App.con.loginView = App.con.vm.getView(App.LoginView, { model: App.con.userModel });
        App.con.vm.showView(App.con.loginView);
        App.con.queryVm.showViews([]);
    },
    
    routeHome: function () {
        App.debug('Route: home');
        if (!App.con.userModel.get('authenticated')) {
            App.con.router.navigate('demo', true);
            return;
        }
        // Defaults media
        App.con.mediaModel = new App.MediaModel();
        App.con.comparisonMediaModel = new App.MediaModel();
        App.con.mediaSources.get('tags').getDeferred(8875027).then(function (m) {
            App.con.mediaModel.get('tags').add(m);
        });
        App.con.mediaSources.get('tags').getDeferred(8875027).then(function (m) {
            App.con.comparisonMediaModel.get('tags').add(m);
        });
        // Default tags
        // Defaults dates
        var dayMs = 24 * 60 * 60 * 1000;
        var ts = new Date().getTime();
        var start = new Date(ts - 15*dayMs);
        var end = new Date(ts - 1*dayMs);
        var attributes = {
            start: start.getFullYear() + '-' + (start.getMonth()+1) + '-' + start.getDate()
            , end: end.getFullYear() + '-' + (end.getMonth()+1) + '-' + end.getDate()<commit_msg>Clear queries on login page, for #192.<commit_after>App.con = App.Controller = {
    
    initialize: function () {
        App.debug('App.Controller.initialize()');
        App.instance = this;
        // Set up error handling
        // Get initial fragment
        App.con.fragment = window.location.hash.substring(1);
        // Set up colors
        PrimeColor.setSeed(225, 76, 17);
        // Create models
        App.con.userModel = new App.UserModel();
        App.con.mediaSources = new App.MediaModel({parse:true});
        App.con.mediaExplorer = new App.MediaExploreView({
            mediaSources: App.con.mediaSources
        });
        App.con.queryCollection = new App.QueryCollection();
        App.con.legendView = new App.LegendView({
            collection: App.con.queryCollection
        });
        // Create view manager and app-level views
        App.con.vm = new App.ViewManager({
            "selector": '.content .container-fixed'
        });
        App.con.queryVm = new App.ViewManager({
            "selector": ".content .container-fluid"
        });
        App.con.controlsView = new App.ControlsView({ userModel: App.con.userModel });
        App.con.toolView = new App.ToolListView({
            collection:App.con.queryCollection
        });
        $('.brand-toolbar .links').append(App.con.toolView.el);
        $('.controls').append(App.con.controlsView.el);
        $('.drawer .container').html(App.con.legendView.el);
        App.con.router = new App.Router();
        // Bind event handlers
        _.bindAll(this, 'onSignIn');
        _.bindAll(this, 'onSignOut');
        // Listener for events
        App.con.queryCollection.resources.on('error', function (model_or_controller, request) {
            App.debug('Received error: ' + request.status);
            if (request.status == 401 || request.status == 403) {
                App.con.userModel.signOut();
            } else {
                var content = JSON.parse(request.responseText);
                var error = new Backbone.Model({
                    "message": content.error
                });
                App.con.getErrorCollection().add(error);
            }
        });
        // Start navigation and log user in
        App.con.userModel.on('signin', App.con.onSignIn);
        App.con.userModel.on('signout', App.con.onSignOut);
        App.con.userModel.on('unauthorized', App.con.onUnauthorized);
        Backbone.history.start();
        App.con.userModel.signIn({});
    },
    
    onSignIn: function () {
        App.debug('App.Controller.onSignIn()');
        App.con.router.navigate('', true);
        if (typeof(App.con.fragment) !== 'undefined'
            && App.con.fragment !== ''
            && App.con.fragment != 'login'
        ) {
            App.con.router.navigate(App.con.fragment, true);
            delete App.con.fragment;
        } else {
            App.con.router.navigate('', true);
        }
    },
    
    onSignOut: function () {
        App.debug('App.Controller.onSignOut()');
        App.con.router.navigate('login', true);
    },
    
    onUnauthorized: function () {
        App.debug('App.Controller.onUnauthorized()');
        App.con.router.navigate('login', true);
    },
    
    onQuery: function (queryCollection) {
        App.debug('App.Controller.onQuery()');
        App.debug(queryCollection);
        App.con.errorCollection.reset();
        var path = queryCollection.dashboardUrl();
        App.debug('Path: ' + path);
        App.con.router.navigate(path);
        App.con.showResults(queryCollection);
    },
    
    onDemoQuery: function (queryCollection) {
        App.debug('App.Controller.onQuery()');
        App.debug(queryCollection);
        var path = queryCollection.dashboardDemoUrl();
        App.debug('Path: ' + path);
        App.con.router.navigate(path);
        App.con.showResults(queryCollection);
    },
    
    showResults: function (queryCollection) {
        App.debug("App.Controller.showResults")
    },
    
    routeLogin: function () {
        App.debug('Route: login');
        App.con.queryCollection.reset([]);
        App.con.loginView = App.con.vm.getView(App.LoginView, { model: App.con.userModel });
        App.con.vm.showView(App.con.loginView);
        App.con.queryVm.showViews([]);
    },
    
    routeHome: function () {
        App.debug('Route: home');
        if (!App.con.userModel.get('authenticated')) {
            App.con.router.navigate('demo', true);
            return;
        }
        // Defaults media
        App.con.mediaModel = new App.MediaModel();
        App.con.comparisonMediaModel = new App.MediaModel();
        App.con.mediaSources.get('tags').getDeferred(8875027).then(function (m) {
            App.con.mediaModel.get('tags').add(m);
        });
        App.con.mediaSources.get('tags').getDeferred(8875027).then(function (m) {
            App.con.comparisonMediaModel.get('tags').add(m);
        });
        // Default tags
        // Defaults dates
        var dayMs = 24 * 60 * 60 * 1000;
        var ts = new Date().getTime();
        var start = new Date(ts - 15*dayMs);
        var end = new Date(ts - 1*dayMs);
        var attributes = {
            start: start.getFullYear() + '-' + (start.getMonth()+1) + '-' + start.getDate()
            , end: end.getFullYear() + '-' + (end.getMonth()+1) + '-' + end.getDate()
{'fraction_non_alphanumeric': 0.15212507021157087, 'fraction_numerical': 0.008331773076202958, 'mean_word_length': 2.0263456090651557, 'pattern_counts': {'":': 6, '<': 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': '800372', 'n_tokens_mistral': 3199, 'n_tokens_neox': 3094, 'n_words': 506}