1 /**
  2  * @name setupData
  3  * @param {Object} obj JSON object of the cell data.
  4  * @memberOf LoadDataWorker
  5  * @method 
  6  * @description This method will create string format of of the workbook sheet row with the provided cell data in json format. and it will post back to the caller.
  7  * @function
  8  */
  9 function setupData(obj){
 10 		
 11 		var content = JSON.parse(obj.result);
 12 		var pos=0;
 13 		var row =1;
 14 		var col = 1;
 15 		var tr ="";
 16 		var tableRowHTML = [];
 17 		var SHEET_ID=0;
 18 		var printed=false;
 19 		var LOG="";
 20 		var ERR_LOG='';
 21 		var logs=0;
 22 		while(true){
 23 			if(pos < content.length){
 24 				var cell = content[pos];
 25 				SHEET_ID = cell.sheetId;
 26 				if(cell.row == row){
 27 					if(cell.col == col){
 28 						if(col==1 && cell.value.length==0)
 29 							tr = tr+'<td data-row="'+row+'" data-col="'+col+'"><img src="img/w1px.png"/></td>';
 30 						else
 31 							tr = tr+'<td data-row="'+row+'" data-col="'+col+'">'+cell.value+'</td>';
 32 						pos++;
 33 					}
 34 					else{
 35 						if(col==1)
 36 							tr = tr+'<td data-row="'+row+'" data-col="'+col+'"><img src="img/w1px.png"/></td>';
 37 						else
 38 							tr = tr +'<td data-row="'+row+'" data-col="'+col+'"></td>';
 39 					}
 40 				//	LOG=LOG+"\tR:"+row+" \tCOL:"+col;
 41 					col++;
 42 				}else{
 43 					if(col==1)
 44 						tr = tr+'<td data-row="'+row+'" data-col="'+col+'"><img src="img/w1px.png" style="width:1px"/></td>';
 45 					else
 46 						tr = tr +'<td data-row="'+row+'" data-col="'+col+'"></td>';
 47 				//	LOG=LOG+"\tR:"+row+" \tCOL:"+col;
 48 					col++;
 49 				}
 50 			}else{
 51 				if(col==1)
 52 						tr = tr+'<td data-row="'+row+'" data-col="'+col+'"><img src="img/w1px.png" style="width:1px"/></td>';
 53 					else
 54 						tr = tr +'<td data-row="'+row+'" data-col="'+col+'"></td>';
 55 				//	LOG=LOG+"\tR:"+row+" \tCOL:"+col;
 56 				col++;
 57 			}
 58 			
 59 			if(col > obj.sheet.cols){
 60 				col =1;
 61 				tableRowHTML[row-1]="<tr>"+tr+"</tr>";
 62 				row++;
 63 				tr ="";
 64 			//	LOG=LOG+"\n";
 65 			}
 66 			if(row > obj.sheet.rows)
 67 				break;
 68 		}
 69 		console.log('Worker Message :');
 70 		postMessage({SHEET_ID:SHEET_ID, ROW_DATA:tableRowHTML});//tableRowHTML);
 71 		
 72 }
 73 /**
 74  * A Worker Class to handle cell data and creates the row html for the screen
 75  * @name LoadDataWorker
 76  * @class LoadDataWorker
 77  * @version 1.0
 78  * @module LoadDataWorker
 79  **/
 80 self.addEventListener('message', function (event) {
 81 	var result = event.data;
 82 	setupData(result);
 83 
 84 }, false);