<commit_before>
/*
//Reference prior, cached database
var dbOLD = Ti.Database.install('PuntaCana.sqlite', 'PuntaCana');
//Destroy it
dbOLD.remove();
*/
//Install new database
var db;

    if (Ti.Platform.name === 'android' && Ti.Filesystem.isExternalStoragePresent()) {
	 
	 db = Titanium.Database.install('/PuntaCana.sqlite','PuntaCana.sqlite');
	 //db.execute('CREATE TABLE "Categorias" ("id" INTEGER PRIMARY KEY  NOT NULL  UNIQUE , "nombre" TEXT NOT NULL  UNIQUE )');
	 //db.execute('INSERT INTO Categorias (id,nombre) VALUES (?,?)',1,'Comidas');
	 db = Ti.Database.open('PuntaCana.sqlite');
    }else{
    	var dbOLD = Ti.Database.install('PuntaCana.sqlite', 'PuntaCana');
		//Destroy it
		if(dbOLD){
			Ti.API.info('remove');
			dbOLD.close();
			dbOLD.remove();
		}
      db = Ti.Database.install('PuntaCana.sqlite', 'PuntaCana');
    }



/*
db.execute('CREATE TABLE "Categorias" ("id" INTEGER PRIMARY KEY  NOT NULL  UNIQUE , "nombre" TEXT NOT NULL  UNIQUE )');
db.execute('INSERT INTO Categorias (id,nombre) VALUES (?,?)',1,'Comidas');
*/
function ApplicationWindow(title,id) {
	
	var titleBg = Ti.Filesystem.getFile(Titanium.Filesystem.resourcesDirectory,'images/top-bar-bg.png');
	var self = Ti.UI.createWindow({
		title:title,
		backgroundColor:'black',
		barImage:titleBg
	});

	
	var table = Ti.UI.createTableView({
		data:generarTabla(id)
	});
	
	table.addEventListener('click', function(e){
		/*
		 	For example, some of the key properties of that event object include:
			 *index 	– the ordinal index number of the row that received the event
			 *row 		– the object representing the row that received the event
			 *rowData 	– the properties of the row that received the event
			 *source 	– the object that received the original event
			 *section 	– the table section that received the event
		 */
		//alert('You clicked row '+e.index+' with id:'+e.row.id);
		if(e.row.hijo !== 0){
		var GuideWindows = require('ui/common/GuideWindows');
		var win = new GuideWindows(L('tabName1'),e.row.id)
		self.containingTab.open(win);
		}else{
			alert('You clicked row '+e.index+' with id:'+e.row.id);
		}
	});

	self.add(table);
	
	return self;
};


module.exports = ApplicationWindow;

	
function generarTabla(id){
	
	dataBD = db.execute('SELECT * FROM Categorias WHERE padre='+id);
	
	var tbl_data = crearFilasTabla(dataBD);
	
	dataBD.close();<commit_msg>avanzando con las listas multiples<commit_after>
/*
//Reference prior, cached database
var dbOLD = Ti.Database.install('PuntaCana.sqlite', 'PuntaCana');
//Destroy it
dbOLD.remove();
*/
//Install new database
var db;

    if (Ti.Platform.name === 'android' && Ti.Filesystem.isExternalStoragePresent()) {
	 
	 db = Titanium.Database.install('/PuntaCana.sqlite','PuntaCana.sqlite');
	 //db.execute('CREATE TABLE "Categorias" ("id" INTEGER PRIMARY KEY  NOT NULL  UNIQUE , "nombre" TEXT NOT NULL  UNIQUE )');
	 //db.execute('INSERT INTO Categorias (id,nombre) VALUES (?,?)',1,'Comidas');
	 db = Ti.Database.open('PuntaCana.sqlite');
    }else{
    	var dbOLD = Ti.Database.install('PuntaCana.sqlite', 'PuntaCana');
		//Destroy it
		if(dbOLD){
			Ti.API.info('remove');
			dbOLD.close();
			dbOLD.remove();
		}
      db = Ti.Database.install('PuntaCana.sqlite', 'PuntaCana');
    }



/*
db.execute('CREATE TABLE "Categorias" ("id" INTEGER PRIMARY KEY  NOT NULL  UNIQUE , "nombre" TEXT NOT NULL  UNIQUE )');
db.execute('INSERT INTO Categorias (id,nombre) VALUES (?,?)',1,'Comidas');
*/
function ApplicationWindow(title,id) {
	
	var titleBg = Ti.Filesystem.getFile(Titanium.Filesystem.resourcesDirectory,'images/top-bar-bg.png');
	var self = Ti.UI.createWindow({
		title:title,
		backgroundColor:'black',
		barImage:titleBg
	});

	
	var table = Ti.UI.createTableView({
		data:generarTabla(id)
	});
	
	table.addEventListener('click', function(e){
		/*
		 	For example, some of the key properties of that event object include:
			 *index 	– the ordinal index number of the row that received the event
			 *row 		– the object representing the row that received the event
			 *rowData 	– the properties of the row that received the event
			 *source 	– the object that received the original event
			 *section 	– the table section that received the event
		 */
		//alert('You clicked row '+e.index+' with id:'+e.row.id);
		
		var GuideWindows = require('ui/common/GuideWindows');
		var win = new GuideWindows(L('tabName1'),e.row.id)
		win.containingTab = self.containingTab;
		self.containingTab.open(win);
		
	});

	self.add(table);
	
	return self;
};


module.exports = ApplicationWindow;

	
function generarTabla(id){
	
	dataBD = db.execute('SELECT * FROM Categorias WHERE padre='+id);
	
	var tbl_data = crearFilasTabla(dataBD);
	
	dataBD.close();
{'fraction_non_alphanumeric': 0.1481402763018066, 'fraction_numerical': 0.001487778958554729, 'mean_word_length': 4.033155080213904, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '910778', 'n_tokens_mistral': 1740, 'n_tokens_neox': 1567, 'n_words': 402}