<commit_before>function getProcessGraphWidget(widgetId, bagName) {
  var widgetdataname = document.getElementById('widgetdata' + widgetId);
  var widgetdatawait = document.getElementById('widgetdatawait' + widgetId);
  
  Element.hide($(widgetdataname));
  Element.show($(widgetdatawait));
  var extraAttr;
  if($("widgetselect" + widgetId)!=null) {
  	extraAttr = $("widgetselect" + widgetId).value;
  }
  AjaxServices.getProcessGraphWidget(widgetId,bagName,extraAttr,handleGraphWidget);  
}

function handleGraphWidget(widget) {
  
  calcNotAnalysed(widget);
    
  Element.hide($('widgetdatanoresults' + widget.id));
 // if(widget.hasResults) {
    var widgetdataname = document.getElementById('widgetdata' + widget.id);
    var widgetdatawait = document.getElementById('widgetdatawait' + widget.id); 

    Element.update($(widgetdataname),widget.html);
    Element.hide($(widgetdatawait));
    Element.show($(widgetdataname));
  //} else {
  //	Element.hide($('widgetdatawait' + widget.id));
  //  Element.hide($('widgetdata' + widget.id));
  //  Element.show($('widgetdatanoresults' + widget.id));
  //  toggleWidget('widgetcontainer' + widget.id, 'togglelink' + widget.id);
  //}  
}

function getProcessTableWidget(widgetId, bagName) {
  AjaxServices.getProcessTableWidget(widgetId,bagName,handleTableWidget);
}

function handleTableWidget(widget) {

  calcNotAnalysed(widget);

  Element.hide($('widgetdatanoresults' + widget.id));
    
  //if(widget.hasResults) {
	  removeChildren($("tablewidget"+widget.id+"head"));
	  removeChildren($("tablewidget"+widget.id+"body"));
	  var widgetdataname = document.getElementById('widgetdata' + widget.id);
	  var widgetdatawait = document.getElementById('widgetdatawait' + widget.id);
	  	  
	  var row = null;
	  row = document.createElement("tr");
	  for(var i = 0; i < widget.columns.length ; i++){
	    var cell = document.createElement("th");
	    cell.innerHTML = widget.columns[i];
	    row.appendChild(cell);
	  }
	  $("tablewidget"+widget.id+"head").appendChild(row);
	  for(var i = 0; i < widget.flattenedResults.length ; i++){
	  	row = document.createElement("tr");
	  	var columns = widget.flattenedResults[i];
	    for(var j = 0; j < columns.length ; j++){
	     var cell = document.createElement("td");
	     if(columns[j]!=null) {
	       if(columns[j][1] != null) {
	       	var link = document.createElement("a");
	       	link.setAttribute("href",columns[j][1]);
	        link.innerHTML = columns[j][0];
	       	cell.appendChild(link);
	       } else {
	        cell.innerHTML = columns[j][0];
	       }
	     }
	     row.appendChild(cell);
	    }
	    $("tablewidget"+widget.id+"body").appendChild(row);
	  }
	  Element.hide($(widgetdatawait));
      Element.show($(widgetdataname));
  //} else {
  //  Element.hide($('widgetdatawait' + widget.id));
  //  Element.hide($('widgetdata' + widget.id));
  //  Element.show($('widgetdatanoresults' + widget.id));
  //    toggleWidget('widgetcontainer' + widget.id, 'togglelink' + widget.id);
  //}
}

function getProcessEnrichmentWidget(widgetId, bagName) {
  var widgetdataname = document.getElementById('widgetdata' + widgetId);
  var widgetdatawait = document.getElementById('widgetdatawait' + widgetId); 
  
  Element.hide($(widgetdataname));
  Element.show($(widgetdatawait));
  var errorCorrection;
  if($("errorCorrection" + widgetId)!=null) {
    errorCorrection = $("errorCorrection" + widgetId).value;
  }
  var max;
  if($("max" + widgetId)!=null) {
    max = $("max" + widgetId).value;
  }
  var extraAttr;
  if($("widgetselect" + widgetId)!=null) {
    extraAttr = $("widgetselect" + widgetId).value;
  }
  var externalLink;
  if($("externalLink" + widgetId)!=null) {
    externalLink = $("externalLink" + widgetId).value;
  }
  
  var externalLinkLabel;
  if($("externalLinkLabel" + widgetId)!=null) {
    externalLinkLabel = $("externalLinkLabel" + widgetId).value;
  }
  
  AjaxServices.getProcessEnrichmentWidget(widgetId,bagName,errorCorrection,max,extraAttr,externalLink,externalLinkLabel,handleTableWidget);
}

function removeChildren(node) {
	while(node.childNodes.length > 0) {
		node.removeChild(node.childNodes[0]);
	}
}

function checkSelected(formName) {
  var elts = Form.getElements(formName);
  for(var i=0;i<elts.length;i++) {
    if( $(elts[i]).name=='selected' && $(elts[i]).checked ) {
     return true;
    }
  }
  alert("Please select some items")
  return false;
}

function submitWidgetForm(widgetId,type,extra) {
  if(checkSelected('widgetaction'+widgetId)){
  	$('action'+widgetId).value=type;
  	$('export' + widgetId).value=extra;
  	$('widgetaction' + widgetId).submit();	
  }
}

function calcNotAnalysed(widget) {
    var widgetnotanalysed = document.getElementById('widgetnotanalysed' + widget.id);
    widgetnotanalysed.innerHtml = widget.notAnalysed;
}
<commit_msg>hide widgets with no results.  Refs #1678<commit_after>function getProcessGraphWidget(widgetId, bagName) {
  var widgetdataname = document.getElementById('widgetdata' + widgetId);
  var widgetdatawait = document.getElementById('widgetdatawait' + widgetId);
  
  Element.hide($(widgetdataname));
  Element.show($(widgetdatawait));
  var extraAttr;
  if($("widgetselect" + widgetId)!=null) {
  	extraAttr = $("widgetselect" + widgetId).value;
  }
  AjaxServices.getProcessGraphWidget(widgetId,bagName,extraAttr,handleGraphWidget);  
}

function handleGraphWidget(widget) {
  
  calcNotAnalysed(widget);
    
  Element.hide($('widgetdatanoresults' + widget.id));
  if(widget.hasResults) {
    var widgetdataname = document.getElementById('widgetdata' + widget.id);
    var widgetdatawait = document.getElementById('widgetdatawait' + widget.id); 

    Element.update($(widgetdataname),widget.html);
    Element.hide($(widgetdatawait));
    Element.show($(widgetdataname));
  } else {
  	Element.hide($('widgetdatawait' + widget.id));
    Element.hide($('widgetdata' + widget.id));
    Element.show($('widgetdatanoresults' + widget.id));
    toggleWidget('widgetcontainer' + widget.id, 'togglelink' + widget.id);
  }  
}

function getProcessTableWidget(widgetId, bagName) {
  AjaxServices.getProcessTableWidget(widgetId,bagName,handleTableWidget);
}

function handleTableWidget(widget) {

  calcNotAnalysed(widget);

  Element.hide($('widgetdatanoresults' + widget.id));
    
  if(widget.hasResults) {
	  removeChildren($("tablewidget"+widget.id+"head"));
	  removeChildren($("tablewidget"+widget.id+"body"));
	  var widgetdataname = document.getElementById('widgetdata' + widget.id);
	  var widgetdatawait = document.getElementById('widgetdatawait' + widget.id);
	  	  
	  var row = null;
	  row = document.createElement("tr");
	  for(var i = 0; i < widget.columns.length ; i++){
	    var cell = document.createElement("th");
	    cell.innerHTML = widget.columns[i];
	    row.appendChild(cell);
	  }
	  $("tablewidget"+widget.id+"head").appendChild(row);
	  for(var i = 0; i < widget.flattenedResults.length ; i++){
	  	row = document.createElement("tr");
	  	var columns = widget.flattenedResults[i];
	    for(var j = 0; j < columns.length ; j++){
	     var cell = document.createElement("td");
	     if(columns[j]!=null) {
	       if(columns[j][1] != null) {
	       	var link = document.createElement("a");
	       	link.setAttribute("href",columns[j][1]);
	        link.innerHTML = columns[j][0];
	       	cell.appendChild(link);
	       } else {
	        cell.innerHTML = columns[j][0];
	       }
	     }
	     row.appendChild(cell);
	    }
	    $("tablewidget"+widget.id+"body").appendChild(row);
	  }
	  Element.hide($(widgetdatawait));
      Element.show($(widgetdataname));
  } else {
    Element.hide($('widgetdatawait' + widget.id));
    Element.hide($('widgetdata' + widget.id));
    Element.show($('widgetdatanoresults' + widget.id));
      toggleWidget('widgetcontainer' + widget.id, 'togglelink' + widget.id);
  }
}

function getProcessEnrichmentWidget(widgetId, bagName) {
  var widgetdataname = document.getElementById('widgetdata' + widgetId);
  var widgetdatawait = document.getElementById('widgetdatawait' + widgetId); 
  
  Element.hide($(widgetdataname));
  Element.show($(widgetdatawait));
  var errorCorrection;
  if($("errorCorrection" + widgetId)!=null) {
    errorCorrection = $("errorCorrection" + widgetId).value;
  }
  var max;
  if($("max" + widgetId)!=null) {
    max = $("max" + widgetId).value;
  }
  var extraAttr;
  if($("widgetselect" + widgetId)!=null) {
    extraAttr = $("widgetselect" + widgetId).value;
  }
  var externalLink;
  if($("externalLink" + widgetId)!=null) {
    externalLink = $("externalLink" + widgetId).value;
  }
  
  var externalLinkLabel;
  if($("externalLinkLabel" + widgetId)!=null) {
    externalLinkLabel = $("externalLinkLabel" + widgetId).value;
  }
  
  AjaxServices.getProcessEnrichmentWidget(widgetId,bagName,errorCorrection,max,extraAttr,externalLink,externalLinkLabel,handleTableWidget);
}

function removeChildren(node) {
	while(node.childNodes.length > 0) {
		node.removeChild(node.childNodes[0]);
	}
}

function checkSelected(formName) {
  var elts = Form.getElements(formName);
  for(var i=0;i<elts.length;i++) {
    if( $(elts[i]).name=='selected' && $(elts[i]).checked ) {
     return true;
    }
  }
  alert("Please select some items")
  return false;
}

function submitWidgetForm(widgetId,type,extra) {
  if(checkSelected('widgetaction'+widgetId)){
  	$('action'+widgetId).value=type;
  	$('export' + widgetId).value=extra;
  	$('widgetaction' + widgetId).submit();	
  }
}

function calcNotAnalysed(widget) {
    var widgetnotanalysed = document.getElementById('widgetnotanalysed' + widget.id);
    widgetnotanalysed.innerHtml = widget.notAnalysed;
}

{'fraction_non_alphanumeric': 0.1620389556568587, 'fraction_numerical': 0.0024865312888520514, 'mean_word_length': 4.432189082723692, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 5, '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': '3395812', 'n_tokens_mistral': 3171, 'n_tokens_neox': 3090, 'n_words': 452}