<commit_before><!DOCTYPE html>
<html>
<head>
  	<meta charset="utf8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0">

</head>
<body>
<input type="file" id="file_sel" multiple onchange="go(this.files)">
<output id="error"></output>
<div id="text"></div>
<script>

const dbName = "the_db";
var db;
var layers=[];
var n;
var num;
var workers=[];
if (!localStorage["idb_version"])
{
	localStorage["idb_version"]=1;


	var req = indexedDB.deleteDatabase(dbName);
	req.onsuccess = function () {
	    console.log("Deleted database successfully");
	};
	req.onerror = function () {
	    console.log("Couldn't delete database");
	}
	req.onblocked = function () {
	    console.log("Couldn't delete database due to the operation being blocked")
	}
}



  function go(the_files)
  {
  var n_workers;
 //var the_files = evt.target.files;
 
 var dbrequest = indexedDB.open(dbName,localStorage["idb_version"]++);
	dbrequest.onerror = function(event) 
	{
		console.log("Problems opening data base");
	};
	dbrequest.onblocked = function(event) {
	 console.log("DB is blocked");
	};

dbrequest.onupgradeneeded = function(event) {
	 console.log("Ok, lets upgrade");
	 db = event.target.result;

for (var f=0,len=the_files.length;f<len;f++)

{
	var the_name = the_files[f].name.split(".")[0];
	layers.push({"the_name":the_name, "the_file":the_files[f]});
	if(db.objectStoreNames.contains(the_name)) 
		db.deleteObjectStore(the_name);
		
		
	var objectStore = db.createObjectStore(the_name, { keyPath: "gid" });  
		objectStore.transaction.oncomplete=function (e) {		
		console.log("Ok, we are here");
		}
}	
}
  
  	dbrequest.onsuccess = function(event) {
	for (var f=0,len=layers.length;f<len;f++)
	{
	 var worker = new Worker('attributes_worker.js');
				 
				worker.onmessage = function(e) {				
				num++;
				if(num==n_workers)
					console.log("Finnished");
					
				  };

				  worker.onerror = function(e) {
				    document.querySelector('#error').textContent = [
					'ERROR: Line ', e.lineno, ' in ', e.filename, ': ', e.message].join('');
				  };
	worker.postMessage(layers[f]);
	}
	
	
	 console.log("Yes, it worked");
	};
  }
   
  </script><commit_msg>Return error code when problems opening Indexeddb<commit_after><!DOCTYPE html>
<html>
<head>
  	<meta charset="utf8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0">

</head>
<body>
<input type="file" id="file_sel" multiple onchange="go(this.files)">
<output id="error"></output>
<div id="text"></div>
<script>

const dbName = "the_db";
var db;
var layers=[];
var n;
var num;
var workers=[];
if (!localStorage["idb_version"])
{
	localStorage["idb_version"]=1;


	var req = indexedDB.deleteDatabase(dbName);
	req.onsuccess = function () {
	    console.log("Deleted database successfully");
	};
	req.onerror = function () {
	    console.log("Couldn't delete database");
	}
	req.onblocked = function () {
	    console.log("Couldn't delete database due to the operation being blocked")
	}
}



  function go(the_files)
  {
  var n_workers;
 //var the_files = evt.target.files;
 
 var dbrequest = indexedDB.open(dbName,localStorage["idb_version"]++);
	dbrequest.onerror = function(event) 
	{
		console.log("Problems opening data base: " + event.target.errorCode);
	};
	dbrequest.onblocked = function(event) {
	 console.log("DB is blocked");
	};

dbrequest.onupgradeneeded = function(event) {
	 console.log("Ok, lets upgrade");
	 db = event.target.result;

for (var f=0,len=the_files.length;f<len;f++)

{
	var the_name = the_files[f].name.split(".")[0];
	layers.push({"the_name":the_name, "the_file":the_files[f]});
	if(db.objectStoreNames.contains(the_name)) 
		db.deleteObjectStore(the_name);
		
		
	var objectStore = db.createObjectStore(the_name, { keyPath: "gid" });  
		objectStore.transaction.oncomplete=function (e) {		
		console.log("Ok, we are here");
		}
}	
}
  
  	dbrequest.onsuccess = function(event) {
	for (var f=0,len=layers.length;f<len;f++)
	{
	 var worker = new Worker('attributes_worker.js');
				 
				worker.onmessage = function(e) {				
				num++;
				if(num==n_workers)
					console.log("Finnished");
					
				  };

				  worker.onerror = function(e) {
				    document.querySelector('#error').textContent = [
					'ERROR: Line ', e.lineno, ' in ', e.filename, ': ', e.message].join('');
				  };
	worker.postMessage(layers[f]);
	}
	
	
	 console.log("Yes, it worked");
	};
  }
   
  </script>
{'fraction_non_alphanumeric': 0.17493768411511443, 'fraction_numerical': 0.0031724450487196918, 'mean_word_length': 4.085253456221198, 'pattern_counts': {'":': 4, '<': 35, '<?xml version=': 0, '>': 31, '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': '5481422', 'n_tokens_mistral': 1729, 'n_tokens_neox': 1560, 'n_words': 284}