<commit_before>// View.js
// -------
define(["jquery", "backbone", "models/Record", "models/User", "collections/Collection", "text!templates/Records.html",  "THREE", "tween", "TrackballControls", "CSS3DRenderer"],

    function($, Backbone, Record, Authenticated_User, Collection, template){

        var User = Backbone.View.extend({

            // The DOM Element associated with this view
            el: ".example",
            user: 'salazr',
            page: '1',

            // View constructor
            initialize: function() {

                _.bind('render', 'updateUser', this);
                var view = this;

                //Update user on init
                view.updateUser();


                
                //Wire up form
                $('form button[type="submit"]').on('click',function(event){
                    event.preventDefault();


                    if ($('form input').val() !== '') {

                            $('.example').html('');
                            $('h1').html('Loading...')
                    
                            view.user = $('form input').val();
                           
                            view.updateUser();


                   }

            })


            },

            // View Event Handlers
            events: {

            },

            updateUser: function(){
                var view = this;
                // Get User's Collection  with hard coded username
                this.collection = new Collection(view.user);

                // console.log(this.collection)

                this.collection.fetch({ 
                                success: function(c,response){
                                    // console.log(c.models[0])
                                    // Calls the view's render method
                                    view.render(c.models[0].attributes.data.releases);

                                    var Auth_User = new Authenticated_User({username: view.user});

                                    // Auth_User.username = 'salazr'
                                    // console.log(Auth_User)
                                    Auth_User.fetch({ 
                                                    success: function(c,response){
                                                        // console.log(response)
                                                        // Calls the view's render method
                                                        $('header h1').html("" + response.data.name + " has " + response.data.num_collection + " records, here's 100 of them");

                                                        // $('.example > h3').html("These are the newest records.")

                                                    }, 
                                                    error: function(c,response){
                                                        console.log(response)

                                                    }  

                                    });  



                                }, 
                                error: function(c,response){
                                    console.log(response)

                                } 
                 });  
            },

            // Renders the view's template to the UI
            render: function(data) {
<commit_msg>Basic error handling<commit_after>// View.js
// -------
define(["jquery", "backbone", "models/Record", "models/User", "collections/Collection", "text!templates/Records.html",  "THREE", "tween", "TrackballControls", "CSS3DRenderer"],

    function($, Backbone, Record, Authenticated_User, Collection, template){

        var User = Backbone.View.extend({

            // The DOM Element associated with this view
            el: ".example",
            user: 'salazr',
            page: '1',

            // View constructor
            initialize: function() {

                _.bind('render', 'updateUser', this);
                var view = this;

                //Update user on init
                view.updateUser();


                
                //Wire up form
                $('form button[type="submit"]').on('click',function(event){
                    event.preventDefault();


                    if ($('form input').val() !== '') {

                            $('.example').html('');
                            $('h1').html('Loading...')
                    
                            view.user = $('form input').val();
                           
                            view.updateUser();


                   }

            })


            },

            // View Event Handlers
            events: {

            },

            updateUser: function(){
                var view = this;
                // Get User's Collection  with hard coded username
                this.collection = new Collection(view.user);

                // console.log(this.collection)

                this.collection.fetch({ 
                                success: function(c,response){
                                    // console.log(c.models[0])
                                    // Calls the view's render method
                                    view.render(c.models[0].attributes.data.releases);

                                    var Auth_User = new Authenticated_User({username: view.user});

                                    // Auth_User.username = 'salazr'
                                    // console.log(Auth_User)
                                    Auth_User.fetch({ 
                                                    success: function(c,response){
                                                        // console.log(response)
                                                        // Calls the view's render method
                                                        $('header h1').html("" + response.data.name + " has " + response.data.num_collection + " records, here's 100 of them");

                                                        // $('.example > h3').html("These are the newest records.")

                                                    }, 
                                                    error: function(c,response){
                                                        console.log(response)

                                                    }  

                                    });  



                                }, 
                                error: function(c,response){
                                    console.log(response)
                                    $('header h1').html("There was an error retrieving data from discogs, the request timed out. Try again.");

                                } 
                 });  
            },

            // Renders the view's template to the UI
            render: function(data) {

{'fraction_non_alphanumeric': 0.10629693818601964, 'fraction_numerical': 0.0030329289428076256, 'mean_word_length': 0.8066788416384033, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 55, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3487432', 'n_tokens_mistral': 1465, 'n_tokens_neox': 1299, 'n_words': 301}