<commit_before>
$(document).ready(function() {
	router = new AppRouter();
	Backbone.history.start();
});	


// set up the routes
var AppRouter = Backbone.Router.extend({
	
	
	queryEditor: null,
	container: null,
	dataset: null,
	rec: null,
	dataPromise: null,
	
	
	initialize: function() {
		this.dataset = new recline.Model.Dataset({
        url: 'https://docs.google.com/spreadsheets/d/1B6LKp6QzNqZFqRXoZ63lgK_T3pluSwtgCN7B1HSV0HU/edit#gid=0',
        backend: 'gdocs'
      });
	  dataPromise = this.dataset.fetch();
	  this.queryEditor = new recline.View.QueryEditor({
			model: this.dataset.queryState
	  });
	  $('#search').append(this.queryEditor.el); 
	},
	
    routes: {
		"": "startPage",
        "items/:id": "getItem",
        "search/:qy": "searchItems"
    },
	
	startPage: function (){
		console.log('ran startPage');
	 },
	
	getItem: function (itemId){
		console.log('ran getItem');
		$.when(dataPromise).then( function(d){
		this.rec = d.records.get(itemId);
			
		   $('#item-display').show();
		   $('#data-display').hide();
		   $('#item-display').html(
			   '<b>'+ this.rec.get('title') + '</b> '
				   + this.rec.get('description')
		   );
		});	


       
	}
});

/*
// function that updates the data displayed
function doSearch(qy){

  fetchData(function(d){
      d.query({"q": qy});<commit_msg>adding grid view, although not quite working yet<commit_after>
$(document).ready(function() {
	router = new AppRouter();
	Backbone.history.start();
});	


// set up the routes
var AppRouter = Backbone.Router.extend({
	
	queryEditor: null,
	resultView: null,
	recordView: null,
	dataset: null,
	rec: null,
	dataPromise: null,
	
	
	initialize: function() {
		this.dataset = new recline.Model.Dataset({
			url: 'https://docs.google.com/spreadsheets/d/1B6LKp6QzNqZFqRXoZ63lgK_T3pluSwtgCN7B1HSV0HU/edit#gid=0',
			backend: 'gdocs'
		});
		this.dataPromise = this.dataset.fetch();
		this.queryEditor = new recline.View.QueryEditor({
			model: this.dataset.queryState
		});
		$('#search').append(this.queryEditor.el);		
		
		this.dataView = new recline.View.SlickGrid({
			model: this.dataset,
		});
		$('#data-display').append(this.dataView.el);
		this.dataView.visible = true;
		this.dataView.render();
		this.dataset.records.bind('reset', this.dataView.render);
	
	},
	
    routes: {
		"": "startPage",
        "items/:id": "getItem",
        "search/:qy": "searchItems"
    },
	
	startPage: function (){
		console.log('ran startPage');
		this.dataView.render();
	 },
	 
	 searchItem: function(qy){
		this.dataset.query("q", qy); 
	 },
	 
	
	getItem: function (itemId){
		console.log('ran getItem');
		$.when(this.dataPromise).then( function(d){
		this.rec = d.records.get(itemId);
			
		   $('#item-display').show();
		   $('#data-display').hide();
		   $('#item-display').html(
			   '<b>'+ this.rec.get('title') + '</b> '
				    + this.rec.get('description')
		   );
		});	
	}
});



/*
// function that updates the data displayed
function doSearch(qy){

  fetchData(function(d){
      d.query({"q": qy});
{'fraction_non_alphanumeric': 0.18797489263296993, 'fraction_numerical': 0.006607201850016518, 'mean_word_length': 3.3072546230440967, 'pattern_counts': {'":': 8, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, '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': '5113149', 'n_tokens_mistral': 1190, 'n_tokens_neox': 1075, 'n_words': 178}