<commit_before>'use strict';
(function(module) {
  try {
    module = angular.module('tink.interactivetable');
  } catch (e) {
    module = angular.module('tink.interactivetable', ['tink.popover','tink.sorttable','ngLodash']);
  }
  module.directive('tinkInteractiveTable',['$compile','$rootScope','$filter',function($compile,$rootScope,$filter){
  return{
    restrict:'EA',
    templateUrl:'templates/reorder.html',
    scope:{
      ngModel:'=',
      tinkHeaders:'=',
      tinkActions:'=',
      tinkForceResponsive:'=',
      tinkColumnReorder:'=',
      tinkRowClick:'&',
      tinkChange:'&',
      tinkEmptyMessage:'@'
    },
    link:function(scope,element){
      scope.checkB = [];

      var currentSort = {field:null,order:null};

      scope.hasAction = function(){
        if(scope.viewActions && scope.viewActions instanceof Array && scope.viewActions.length > 0){
          return true;
        }
          return false;
      };
      scope.hasReorder = function(){
        if(scope.tinkColumnReorder === false || scope.tinkColumnReorder === 'false'){
          return false;
        }
        return true;
      };
      scope.forceResponsive = function(){
        if(scope.tinkForceResponsive === true || scope.tinkForceResponsive === 'true'){
          return true;
        }
        return false;
      };

        scope.buildTable = function(){
          if(scope.ngModel){
            changeAction();
            var tableEl = element.find('table');
            //Create a new table object
            var table = document.createElement('table');
            $(tableEl).addClass('table-interactive');
            $(tableEl).attr('tink-callback','sortHeader($property,$order,$type)');

            createHeaders(table,scope.tinkHeaders);
            //create the body of the table
            createBody(table,scope.ngModel);

            scope.checkB = scope.createArray(scope.ngModel.length);
            fullChecked();

            tableEl.children('thead').html($(table).children('thead').children());
            tableEl.children('tbody').html($(table).children('tbody').children());
            $compile(tableEl.children('thead'))(scope);
            $compile(tableEl.children('tbody'))(scope);
          }
        };

        function createCheckbox(row,i,hulp){
        if(!hulp){
          hulp ='';
        }
        var random = Math.random().toString(36).substring(7);
        var checkbox = '<div class="checkbox">'+
                          '<input type="checkbox" ng-change="checkChange('+row+')" ng-model="checkB['+row+']._checked" id="'+random+row+'" name="'+random+row+'" value="'+row+'">'+
                          '<label for="'+random+row+'"></label>'+
                        '</div>';
        return checkbox;
      }

        function createBody(table,content){
          if(scope.tinkHeaders instanceof Array && content instanceof Array){
            var body = table.createTBody();
            for(var i=scope.tinkHeaders.length-1;i>=0;i--){
              for(var j=0;j<content.length;j++){
                var row;
                if(body.rows[j]){
                  row = body.rows[j];
                  //row
                }else{
                  row = body.insertRow(j);
                  //If we have action add a checkbox.
                  $(row).attr('ng-click','rowClick('+j+')');
                  if(scope.hasAction()){
                    var check = row.insertCell(0);
                    check.innerHTML = createCheckbox(j, j);
                    $(check).attr('ng-click', 'preventEvent($event)');
                  }
                }
                var fieldExpression = scope.tinkHeaders[i].field;
                var fieldNames = scope.tinkHeaders[i].field.split('+');
                angular.forEach(fieldNames, function (fieldName) {
                    fieldName = fieldName.trim();
                    if (fieldName.indexOf('"') < 0) {
                        var splittedFieldNames = fieldName.split('.');
                        var fieldValue = content[j];
                        angular.forEach(splittedFieldNames, function (splittedFieldName) {
                            fieldValue = fieldValue[splittedFieldName];
                        });
                        fieldExpression = fieldExpression.replace(fieldName, '"' + fieldValue + '"');
                        if(fieldExpression === undefined || fieldExpression === null){
                          fieldExpression = '-';
                        }
                    }
                });
                /*jshint -W061 */
                var fieldValueComplete = eval(fieldExpression);
                var cell;
                if (scope.hasAction()) {
                    cell = row.insertCell(1);
                } else {
                    cell = row.insertCell(0);
                }
                $(cell).attr('ng-if', 'tinkHeaders[' + i + '].checked');
                if (scope.tinkHeaders[i].filter) {
                    cell.innerHTML = $filter(scope.tinkHeaders[i].filter)(fieldValueComplete, scope.tinkHeaders[i].filterArg);
                }
                else {
                    cell.innerHTML = fieldValueComplete;
                }
              }
            }
          }
        }

        function changeAction(){
          if(scope.tinkActions instanceof Array){
            scope.viewActions = [];
            for(var i=0;i<scope.tinkActions.length;i++){<commit_msg>Fix bij null of undefined '-'<commit_after>'use strict';
(function(module) {
  try {
    module = angular.module('tink.interactivetable');
  } catch (e) {
    module = angular.module('tink.interactivetable', ['tink.popover','tink.sorttable','ngLodash']);
  }
  module.directive('tinkInteractiveTable',['$compile','$rootScope','$filter',function($compile,$rootScope,$filter){
  return{
    restrict:'EA',
    templateUrl:'templates/reorder.html',
    scope:{
      ngModel:'=',
      tinkHeaders:'=',
      tinkActions:'=',
      tinkForceResponsive:'=',
      tinkColumnReorder:'=',
      tinkRowClick:'&',
      tinkChange:'&',
      tinkEmptyMessage:'@'
    },
    link:function(scope,element){
      scope.checkB = [];

      var currentSort = {field:null,order:null};

      scope.hasAction = function(){
        if(scope.viewActions && scope.viewActions instanceof Array && scope.viewActions.length > 0){
          return true;
        }
          return false;
      };
      scope.hasReorder = function(){
        if(scope.tinkColumnReorder === false || scope.tinkColumnReorder === 'false'){
          return false;
        }
        return true;
      };
      scope.forceResponsive = function(){
        if(scope.tinkForceResponsive === true || scope.tinkForceResponsive === 'true'){
          return true;
        }
        return false;
      };

        scope.buildTable = function(){
          if(scope.ngModel){
            changeAction();
            var tableEl = element.find('table');
            //Create a new table object
            var table = document.createElement('table');
            $(tableEl).addClass('table-interactive');
            $(tableEl).attr('tink-callback','sortHeader($property,$order,$type)');

            createHeaders(table,scope.tinkHeaders);
            //create the body of the table
            createBody(table,scope.ngModel);

            scope.checkB = scope.createArray(scope.ngModel.length);
            fullChecked();

            tableEl.children('thead').html($(table).children('thead').children());
            tableEl.children('tbody').html($(table).children('tbody').children());
            $compile(tableEl.children('thead'))(scope);
            $compile(tableEl.children('tbody'))(scope);
          }
        };

        function createCheckbox(row,i,hulp){
        if(!hulp){
          hulp ='';
        }
        var random = Math.random().toString(36).substring(7);
        var checkbox = '<div class="checkbox">'+
                          '<input type="checkbox" ng-change="checkChange('+row+')" ng-model="checkB['+row+']._checked" id="'+random+row+'" name="'+random+row+'" value="'+row+'">'+
                          '<label for="'+random+row+'"></label>'+
                        '</div>';
        return checkbox;
      }

        function createBody(table,content){
          if(scope.tinkHeaders instanceof Array && content instanceof Array){
            var body = table.createTBody();
            for(var i=scope.tinkHeaders.length-1;i>=0;i--){
              for(var j=0;j<content.length;j++){
                var row;
                if(body.rows[j]){
                  row = body.rows[j];
                  //row
                }else{
                  row = body.insertRow(j);
                  //If we have action add a checkbox.
                  $(row).attr('ng-click','rowClick('+j+')');
                  if(scope.hasAction()){
                    var check = row.insertCell(0);
                    check.innerHTML = createCheckbox(j, j);
                    $(check).attr('ng-click', 'preventEvent($event)');
                  }
                }
                var fieldExpression = scope.tinkHeaders[i].field;
                var fieldNames = scope.tinkHeaders[i].field.split('+');
                angular.forEach(fieldNames, function (fieldName) {
                    fieldName = fieldName.trim();
                    if (fieldName.indexOf('"') < 0) {
                        var splittedFieldNames = fieldName.split('.');
                        var fieldValue = content[j];
                        angular.forEach(splittedFieldNames, function (splittedFieldName) {
                            fieldValue = fieldValue[splittedFieldName];
                        });
                        if (fieldValue === null || fieldValue === undefined) {
                        	fieldExpression = fieldExpression.replace(fieldName, '"-"');
                        }
                        else {
                        	fieldExpression = fieldExpression.replace(fieldName, '"' + fieldValue + '"');
                        }
                    }
                });
                /*jshint -W061 */
                var fieldValueComplete = eval(fieldExpression);
                var cell;
                if (scope.hasAction()) {
                    cell = row.insertCell(1);
                } else {
                    cell = row.insertCell(0);
                }
                $(cell).attr('ng-if', 'tinkHeaders[' + i + '].checked');
                if (scope.tinkHeaders[i].filter) {
                    cell.innerHTML = $filter(scope.tinkHeaders[i].filter)(fieldValueComplete, scope.tinkHeaders[i].filterArg);
                }
                else {
                    cell.innerHTML = fieldValueComplete;
                }
              }
            }
          }
        }

        function changeAction(){
          if(scope.tinkActions instanceof Array){
            scope.viewActions = [];
            for(var i=0;i<scope.tinkActions.length;i++){
{'fraction_non_alphanumeric': 0.14496314496314497, 'fraction_numerical': 0.00273000273000273, 'mean_word_length': 1.6687712481787276, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 17, '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': '3001676', 'n_tokens_mistral': 2949, 'n_tokens_neox': 2824, 'n_words': 455}