<commit_before>function doJSON(stringData) {
        try {
            var jsonData = Ext.util.JSON.decode(stringData);
            return jsonData;
            
        }
        catch (err) {
            Ext.MessageBox.alert('ERROR', 'Could not decode ' + stringData);
        }
            
    }
var json={};
var columnlist=[];

/*
Ext.onReady(function(){

Ext.Ajax.request({
        url : '../static/test1.json' , 
        
        method: 'GET',
            success: function ( result, request ) { 
               
                json=doJSON(result.responseText);   
                maker(json);
                
     
        },
            failure: function ( result, request) { 
                Ext.MessageBox.alert('Failed', result.responseText); 
            } 
        });
	document.write(string);
	json=doJSON({{=ss}});
	try{
		var json=doJSON({{=ss}});
	}
	catch(err)
	{
		alert("Error");
	}
	var word={{=ss}};
	maker(json);
});
*/

function view1(importsheet){
    
    var columnlist=new Array(importsheet.columns);
    for(var i=0;i< importsheet.columns ; i++)
    { 
            temp="column"+i;
//	    temp=eval('('+temp+')');
	    columnlist[i]=temp;
    }
    //columnlist[0]="id";
    //columnlist[0]=eval('('+columnlist[0]+')');
    /*var store=new Ext.data.JsonStore({		
    	 root: 'data',
	 idProperty:'id',
         fields : columnlist,
	 totalProperty : json.rows
    });
   store.loadData(json);*/
   //column model for the grid     
   var columns=(importsheet.columns);
   var column_model=new Array(columns);
   var edit=new Array(importsheet.columns);
   //editor functions for each column 
   for(i=1;i< importsheet.columns+1 ; i++)
   {
       edit[i]=new Ext.form.TextField();
   }
   //makes column model objects
   for( i=1 ; i< importsheet.columns+1 ; i++)
   {
       var obj={};
       obj.header="Column "+i;
       obj.sortable=true;
       obj.dataIndex=columnlist[i-1];
       obj.editor=edit[i];
       column_model[i]=obj;
   }
    var new_row_string="{";
    var sm2 = new Ext.grid.CheckboxSelectionModel();
    column_model[0]=sm2;	//placing the checkboxes before the first column
    importsheet.column_model=column_model;
    var sm1 = new Ext.grid.CellSelectionModel();
    //column_model.push(sm1);
    var row_model=Ext.data.Record.create(columnlist);
    //Configuring the grid
    var grid=new Ext.grid.EditorGridPanel({
       title: '<div align="center"><u>Edit</u> \u2794 Select header row \u2794 Select table \u2794 Map columns to fields<p>Edit the spreadsheet, make sure a row with column titles exists</p></div>',
       renderTo: 'spreadsheet',
       loadMask: true,
       //height: 'auto',
       autoHeight: true,
     //  width: 'auto',
       store: importsheet.datastore,
       columnLines: true,
       sm: sm2,  
       style : 'text-align:left;', 
       frame : true,
       columns: column_model,
       buttons: [ 			
       		  {text : 'Next',
       		  handler:
                            function()
                            {
			       	   importsheet.rows=grid.getStore().getCount();
			     	   //This function stores the grid
                                   var gridsave=new Array(grid.getStore().getCount());
                                   var i=0;
				  //importsheet.columns=json.columns;
                                    grid.getStore().each(function(record)						{
						   	gridsave[i++]=record.data}
							);
                                    grid.hide();
				   view2(importsheet);
                            }
                   }
                 ],
       buttonAlign: 'center',
       listeners: {
               afteredit: function(e){
                 //saves the value in a cell after edit
                 e.record.commit();
                 var temp=e.column;
                 json.data[e.row].temp=e.value;
              }
           
        },
        clicksToEdit: 2,
        stripeRows: true,
        tbar: [
			{text: 'Search',
       		   handler:
		   	     function()
				{
					Ext.Msg.prompt("Search","Enter search text",function(btn,text){
						if(btn=='ok')
						{
							Ext.Msg.alert("Search","Search term was "+text);
						}
					});
				}
			},
							
			
            {
                 text: 'Add row',
                 icon : '../../../img/silk/save.gif',
		 cls : 'x-btn-text-icon',
		 iconCls : 'extra-silk-add',
		 handler: function()
                 {
                         grid.getStore().insert(0,new row_model);
                         grid.startEditing(0,0);
                 }<commit_msg>Basic search functionality added in the first view<commit_after>function doJSON(stringData) {
        try {
            var jsonData = Ext.util.JSON.decode(stringData);
            return jsonData;
            
        }
        catch (err) {
            Ext.MessageBox.alert('ERROR', 'Could not decode ' + stringData);
        }
            
    }
var json={};
var columnlist=[];

/*
Ext.onReady(function(){

Ext.Ajax.request({
        url : '../static/test1.json' , 
        
        method: 'GET',
            success: function ( result, request ) { 
               
                json=doJSON(result.responseText);   
                maker(json);
                
     
        },
            failure: function ( result, request) { 
                Ext.MessageBox.alert('Failed', result.responseText); 
            } 
        });
	document.write(string);
	json=doJSON({{=ss}});
	try{
		var json=doJSON({{=ss}});
	}
	catch(err)
	{
		alert("Error");
	}
	var word={{=ss}};
	maker(json);
});
*/

function view1(importsheet){
    
    var columnlist=new Array(importsheet.columns);
    for(var i=0;i< importsheet.columns ; i++)
    { 
            temp="column"+i;
//	    temp=eval('('+temp+')');
	    columnlist[i]=temp;
    }
    //columnlist[0]="id";
    //columnlist[0]=eval('('+columnlist[0]+')');
    /*var store=new Ext.data.JsonStore({		
    	 root: 'data',
	 idProperty:'id',
         fields : columnlist,
	 totalProperty : json.rows
    });
   store.loadData(json);*/
   //column model for the grid     
   var columns=(importsheet.columns);
   var column_model=new Array(columns);
   var edit=new Array(importsheet.columns);
   //editor functions for each column 
   for(i=1;i< importsheet.columns+1 ; i++)
   {
       edit[i]=new Ext.form.TextField();
   }
   //makes column model objects
   for( i=1 ; i< importsheet.columns+1 ; i++)
   {
       var obj={};
       obj.header="Column "+i;
       obj.sortable=true;
       obj.dataIndex=columnlist[i-1];
       obj.editor=edit[i];
       column_model[i]=obj;
   }
    var new_row_string="{";
    var sm2 = new Ext.grid.CheckboxSelectionModel();
    column_model[0]=sm2;	//placing the checkboxes before the first column
    importsheet.column_model=column_model;
    var sm1 = new Ext.grid.CellSelectionModel();
    //column_model.push(sm1);
    var row_model=Ext.data.Record.create(columnlist);
    //Configuring the grid
    var grid=new Ext.grid.EditorGridPanel({
       title: '<div align="center"><u>Edit</u> \u2794 Select header row \u2794 Select table \u2794 Map columns to fields<p>Edit the spreadsheet, make sure a row with column titles exists</p></div>',
       renderTo: 'spreadsheet',
       loadMask: true,
       height: 300,
       store: importsheet.datastore,
       columnLines: true,
       sm: sm2,  
       style : 'text-align:left;', 
       frame : true,
       columns: column_model,
       buttons: [ 			
       		  {text : 'Next',
       		  handler:
                            function()
                            {
			       	   importsheet.rows=grid.getStore().getCount();
			     	   //This function stores the grid
                                   var gridsave=new Array(grid.getStore().getCount());
                                   var i=0;
				  //importsheet.columns=json.columns;
                                    grid.getStore().each(function(record)						{
						   	gridsave[i++]=record.data}
							);
                                    grid.hide();
				   view2(importsheet);
                            }
                   }
                 ],
       buttonAlign: 'center',
       listeners: {
               afteredit: function(e){
                 //saves the value in a cell after edit
                 e.record.commit();
                 var temp=e.column;
                 json.data[e.row].temp=e.value;
              }
           
        },
        clicksToEdit: 2,
        stripeRows: true,
        tbar: [
			{text: 'Search',
       		   handler:
		   	     function()
				{
					Ext.Msg.prompt("Search","Enter search text",function(btn,text){
						if(btn=='ok')
						{
							var k=-1;
							for(var i=0;i<importsheet.columns;i++)
							{
								k=importsheet.datastore.find('column'+i,text);//,0,true,false);
								if(k!=-1)
									break;
							}
							if(k==(-1))
							{
								Ext.Msg.alert("Not found","Search string not in spreadsheet "+k);
							}
							else
							{
								Ext.Msg.alert("Found","First matching record is at "+k);
								sm2.selectRow(k);								
							}
						}
					});
				}
			},
							
			
            {
                 text: 'Add row',
                 icon : '../../../img/silk/save.gif',
		 cls : 'x-btn-text-icon',
		 iconCls : 'extra-silk-add',
		 handler: function()
                 {
                         grid.getStore().insert(0,new row_model);
                         grid.startEditing(0,0);
                 }
{'fraction_non_alphanumeric': 0.13987717069038544, 'fraction_numerical': 0.008365099534095722, 'mean_word_length': 1.5693688792165397, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 15, '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': '4591253', 'n_tokens_mistral': 3173, 'n_tokens_neox': 2797, 'n_words': 534}