<commit_before>var KNAPSACK = {};
KNAPSACK.acc = [];
var index = 0;
var actualName;

function isnSet(value) {
  return (typeof value === 'undefined');
}

JSC.on_pass(function(obj) {
  if(isnSet(actualName)) {actualName = obj.name;}
  if(obj.name === actualName && index >= KNAPSACK.acc.length) {
    KNAPSACK.acc.push({
      name: obj.name,
      errorMessages: [],
      errorInputs: [],
      pass: 1,
      lost: 0,
      fail: 0
    });  
  } else if(obj.name === actualName) {
    KNAPSACK.acc[index].pass++;
  } else {
    actualName = obj.name;
    index++;
    KNAPSACK.acc.push({
      name: obj.name,
      errorMessages: [],
      errorInputs: [],
      pass: 1,
      lost: 0,
      fail: 0
    }); 
  }
});

JSC.on_fail(function(obj) {
  if(isnSet(actualName)) {actualName = obj.name;}
  if(obj.name === actualName && index >= KNAPSACK.acc.length) {
    KNAPSACK.acc.push({
      name: obj.name,
      errorMessages: [],
      errorInputs: [{serial: obj.serial, input: obj.args}],
      pass: 0,
      lost: 0,
      fail: 1
    });  
  } else if(obj.name === actualName){
    KNAPSACK.acc[index].fail++;
    KNAPSACK.acc[index].errorInputs.push({serial: obj.serial, input: obj.args});
  } else {
    actualName = obj.name;
    index++;
    KNAPSACK.acc.push({
      name: obj.name,
      errorMessages: [],
      errorInputs: [{serial: obj.serial, input: obj.args}],
      pass: 0,
      lost: 0,
      fail: 1
    }); 
  }
});

JSC.on_lost(function(obj) {
  if(isnSet(actualName)) {actualName = obj.name;}
  if(obj.name === actualName && index >= KNAPSACK.acc.length) {
    KNAPSACK.acc.push({
      name: obj.name,
      errorMessages: [{serial: obj.serial, msg: obj.exception.message}],
      errorInputs: [],
      pass: 0,
      lost: 1,
      fail: 0
    });  
  } else if(obj.name === actualName && set === true) {
    KNAPSACK.acc[index].lost++;
    KNAPSACK.acc[index].errorMessages.push({serial: obj.serial, msg: obj.exception.message});
  } else {
    actualName = obj.name;
    index++;
    KNAPSACK.acc.push({
      name: obj.name,
      errorMessages: [{serial: obj.serial, msg: obj.exception.message}],
      errorInputs: [],
      pass: 0,
      lost: 1,
      fail: 0
    }); 
  }
}); 

JSC.on_result(function(obj) {
  // paints the view as pure html
  var _render = function ($anchor, $template, data) {
    var template = $template.text() ? $template.text() : $template.html();
    $anchor.setTemplate(template);  // .text() won't work on IE!!!'
    $anchor.processTemplate(data);
  };
  _render($('#jTemplates'),$('#sampleTemplate'),KNAPSACK);
});<commit_msg>Refactoring variable name on JSCsetup code<commit_after>var TEMPLATE = {};
TEMPLATE.acc = [];
var index = 0;
var actualName;

function isnSet(value) {
  return (typeof value === 'undefined');
}

JSC.on_pass(function(obj) {
  if(isnSet(actualName)) {actualName = obj.name;}
  if(obj.name === actualName && index >= TEMPLATE.acc.length) {
    TEMPLATE.acc.push({
      name: obj.name,
      errorMessages: [],
      errorInputs: [],
      pass: 1,
      lost: 0,
      fail: 0
    });  
  } else if(obj.name === actualName) {
    TEMPLATE.acc[index].pass++;
  } else {
    actualName = obj.name;
    index++;
    TEMPLATE.acc.push({
      name: obj.name,
      errorMessages: [],
      errorInputs: [],
      pass: 1,
      lost: 0,
      fail: 0
    }); 
  }
});

JSC.on_fail(function(obj) {
  if(isnSet(actualName)) {actualName = obj.name;}
  if(obj.name === actualName && index >= TEMPLATE.acc.length) {
    TEMPLATE.acc.push({
      name: obj.name,
      errorMessages: [],
      errorInputs: [{serial: obj.serial, input: obj.args}],
      pass: 0,
      lost: 0,
      fail: 1
    });  
  } else if(obj.name === actualName){
    TEMPLATE.acc[index].fail++;
    TEMPLATE.acc[index].errorInputs.push({serial: obj.serial, input: obj.args});
  } else {
    actualName = obj.name;
    index++;
    TEMPLATE.acc.push({
      name: obj.name,
      errorMessages: [],
      errorInputs: [{serial: obj.serial, input: obj.args}],
      pass: 0,
      lost: 0,
      fail: 1
    }); 
  }
});

JSC.on_lost(function(obj) {
  if(isnSet(actualName)) {actualName = obj.name;}
  if(obj.name === actualName && index >= TEMPLATE.acc.length) {
    TEMPLATE.acc.push({
      name: obj.name,
      errorMessages: [{serial: obj.serial, msg: obj.exception.message}],
      errorInputs: [],
      pass: 0,
      lost: 1,
      fail: 0
    });  
  } else if(obj.name === actualName && set === true) {
    TEMPLATE.acc[index].lost++;
    TEMPLATE.acc[index].errorMessages.push({serial: obj.serial, msg: obj.exception.message});
  } else {
    actualName = obj.name;
    index++;
    TEMPLATE.acc.push({
      name: obj.name,
      errorMessages: [{serial: obj.serial, msg: obj.exception.message}],
      errorInputs: [],
      pass: 0,
      lost: 1,
      fail: 0
    }); 
  }
}); 

JSC.on_result(function(obj) {
  // paints the view as pure html
  var _render = function ($anchor, $template, data) {
    var template = $template.text() ? $template.text() : $template.html();
    $anchor.setTemplate(template);  // .text() won't work on IE!!!'
    $anchor.processTemplate(data);
  };
  _render($('#jTemplates'),$('#sampleTemplate'),TEMPLATE);
});
{'fraction_non_alphanumeric': 0.1786467318382212, 'fraction_numerical': 0.007283879624305156, 'mean_word_length': 2.669479606188467, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '1493319', 'n_tokens_mistral': 1913, 'n_tokens_neox': 1842, 'n_words': 365}