<commit_before>// AV.Router: Extends Backbone.Router for the AKHMATOVIZ Project
// -------------------------------------------------------------
// Most of our calls to all of the models and things should come from here.

AV.Router = Backbone.Router.extend({
    initialize: function() {
        this.sourceModel = new AV.SourceModel();
        this.uploadSourceView = new AV.UploadSourceView(
            {model: this.sourceModel});
        this.viewSourceView = new AV.ViewSourceView({model:this.sourceModel});
        this.sourceCollection = new AV.SourceCollection();
        this.sourceCollectionView = new AV.SourceCollectionView(
            {collection:this.sourceCollection});
    },
    
    routes: {
        '': 'index',
        'sources': 'sources',
        'view/:idToView': 'view',
        'source/upload/': 'upload',
	'transform/:idToTransform':'transform'
    },

    index: function() {
        this.sources();
    },
    
    sources: function () {
        this.sourceCollection.fetch({reset: true});
    },
    view: function(idToView) {
        this.sourceModel.set('id', idToView);
        this.sourceModel.url = this.sourceModel.urlRoot + '/' +
                               this.sourceModel.id + '.json';
        this.sourceModel.fetch({success: _.bind(function()
                                                {this.viewSourceView.render();},
                                                this)});

        
    },
    upload: function () {
        this.uploadSourceView.render();
    },

    transform: function (idToTransform) {
	console.log("about to transform!");
	var url = "/juxta/transform";
	var request = { source: idToTransform };
	$.ajax({
		type: 'POST',
		url: url,
		data: JSON.stringify(request),
		contentType: 'application/json',
		success: function(){ test('transform success'); },
		error: function(e) { test(e); }
   		});
	this.navigate('index');
	}
});<commit_msg>added comments to router<commit_after>// AV.Router: Extends Backbone.Router for the AKHMATOVIZ Project
// -------------------------------------------------------------
// Most of our calls to all of the models and things should come from here.

AV.Router = Backbone.Router.extend({
    initialize: function() {
        this.sourceModel = new AV.SourceModel();
        this.uploadSourceView = new AV.UploadSourceView(
            {model: this.sourceModel});
        this.viewSourceView = new AV.ViewSourceView({model:this.sourceModel});
        this.sourceCollection = new AV.SourceCollection();
        this.sourceCollectionView = new AV.SourceCollectionView(
            {collection:this.sourceCollection});
    },
    
    routes: {
        '': 'index',
        'sources': 'sources',
        'view/:idToView': 'view',
        'source/upload/': 'upload',
	'transform/:idToTransform':'transform'
    },

    index: function() {
        this.sources();
    },
    
    sources: function () {
        this.sourceCollection.fetch({reset: true});
    },
    //this route displays the contents of the source
    view: function(idToView) {
        this.sourceModel.set('id', idToView);
        this.sourceModel.url = this.sourceModel.urlRoot + '/' +
                               this.sourceModel.id + '.json';
        this.sourceModel.fetch({success: _.bind(function()
                                                {this.viewSourceView.render();},
                                                this)});

        
    },
    upload: function () {
        this.uploadSourceView.render();
    },

    transform: function (idToTransform) {
	console.log("about to transform!");
	var url = "/juxta/transform";
	var request = { source: idToTransform };
	//We use AJAX to send the request directly from here.
	$.ajax({
		type: 'POST',
		url: url,
		data: JSON.stringify(request),
		contentType: 'application/json',
		success: function(){ test('transform success'); },
		error: function(e) { test(e); }
   		});
	this.navigate('index');
	}
});
{'fraction_non_alphanumeric': 0.16738414788554065, 'fraction_numerical': 0.0, 'mean_word_length': 2.0478395061728394, 'pattern_counts': {'":': 0, '<': 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': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2859147', 'n_tokens_mistral': 1079, 'n_tokens_neox': 1061, 'n_words': 233}