Is there anyone familiar with worker.js, I tried to read the tutorial on https://developer.mozilla.org/en-US/...ng_web_workers
And tried to fix my code under such worker.js fashion. I manipulate the code but still it doesn't work. Anyone has idea? It seems that I need to separate this code into two parts, one is for main page '.html' file and the other one is javascript '.js'. But I am not sure how they work.

My code is:



<!doctype html>
<html>
<head>
<title>reading file</title>
<script>
function readText(obj){
var file = obj.files[0],
div=document.getElementById('main');
if(file){
div.innerHTML='';
var reader = new FileReader();
reader.onerror = function(event){
div.innerHTML='The file can\'t be read! Error ' + event.target.error.code;
}
reader.onload = function(event){
var log = event.target.result.split("\n");
for(var i=0; i<log.length; i++){
var values = {};
var str = log[i].split(',');
//div.innerHTML+='EventTime='+str[0]+'<br />';
values["EventTime"]=str[0];
for (var j=0; j<str.length; j++) {
var name = str[j].split('=');
if (name[0]=="ci"||name[0]=='si') {
value = name[1].replace("'","");
for (var nameIndex=2;nameIndex<name.length;nameIndex++)
{
value += '=' + name[nameIndex].replace("'","");
}
values[name[0]] = value;
//div.innerHTML+=str[j]+'<br />';
}else {
continue;
}
}
div.innerHTML+='**********************************'+'<br />'
div.innerHTML+= JSON.stringify(values) + '<br />'
div.innerHTML+='**********************************'+'<br />'
div.innerHTML+='<br />';

}
}
reader.readAsText(file);
}
}

window.onload=function(){
document.getElementById('ff').onchange=function(){readText(this);}
}

</script>
</head>
<body>
<input type="file" id="ff" />
<div id="main"></div>
</body>

</html>