<commit_before>/**
 * ngul 0.4
 * Copyright 2013 <NAME>. and other contributors; https://github.com/gkodes/ngul
 * @license: MIT
 */

(function(angular, nu) {
'use strict';
/*global nu, angular: true, FileReader: true*/
  var list = angular.module('nu.list', []);
  list.directive('nuList', [
    function() { // try to rename it to collection or list
      return {
        template: '<div class="nu list"></div>',
        restrict: 'EACM', // 145 550 ? 12118
        replace: true,
        controller: ['$scope', '$element', '$attrs', function($scope, $element) {
          this.$render = angular.noop; // invokde for rending an element, expected an compiler
          this.$filter = angular.noop; // invokde before render if return false wont render that element
          this.$link = angular.noop; // invokde after render with the element

          this.$indexOf = angular.noop;
          var nuList = this;

          var render = function(item) {
            var node = nuList.$render(item);
            node.data('src', item);
            nuList.$link(node);
          };

          this.$indexOf = function(node) {
            for(var i = 0; i < nuList.$src.length; i++) {
              if( angular.equals(node, nuList.$src[i]) ) {
                return i;
              }
            }
            return -1;
          };

          this.$add = function(item) {
            if(item) {
              nuList.$src.push(item);
            }
          };

          this.$remove = function(node) {
            nuList.$src.splice(nuList.$indexOf(node), 1);
          };

          this.$empty = function() {
            $element.empty();
          };

          this.$draw = function() {
            nuList.$empty();
            angular.forEach(nuList.$src, function(item) {
              if( nu.isDefinedAndNotNull(item) ) {
                render(item);
              }
            });
          };
        }],
        link: function(scope, element, attrs, nuList) {
          var src = attrs[attrs.nuList? 'nuList' : 'src'];
          scope.$watchCollection(src, function(value) {
            nuList.$src = value? value : [];
            nuList.$draw();
          });
        }
      };
    }
  ]);

  list.directive('nuListType', [
    function() {
      var nodes = {
        'img': angular.element('<span class="item thumb"><img></img></span>'),
        'txt': angular.element('<span class="item"></span>')
      };

      var engines = {
        'img': function(node) {
          return function(value) {
            node.removeClass('async').find('img')
              .attr('src', value);
          };
        },
        'txt': function(node) {
          return function(value) {
            node.removeClass('async').text(value);
          };
        }
      };

      return {
        restrict: 'A',
        require: 'nuList',
        link: function(scope, element, attr, nuList) {
          var engine, baseNode;
          nuList.$formatters = [];

          attr.$observe('nuListType', function(value) {
            var isIMG = value == 'img';
            engine = engines[(isIMG)? 'img' : 'txt'];
            baseNode = nodes[(isIMG)? 'img' : 'txt'];
          });

          nuList.$render = function(item) {
            //TODO: Node Pooling
            var node = baseNode.clone();
            nu.pipeLine(nuList.$formatters, engine(node))
              .onAsync(function(){
                node.addClass('async');
              }).next(item);
            nuList.$render.append(node);
            return node;
          };
          nuList.$render.append = function(node) {
            element.append(node); // angular.element(element[0])
          };
        }
      };
    }
  ]);

  list.directive('nuListRemovable', [
    function() { // ClickToRemove
      return {
        restrict: 'A',
        require: 'nuList',
        link: function(scope, element, attr, nuList) {
          var canRemove, remove_event = function(event) {
            nuList.$remove(target.data('src'));
            scope.$digest();
          };
          
          nuList.$link = function(node) {
            if(canRemove === false) { return; }
            node.addClass('remove').on('click', remove_event);
          };<commit_msg>Update list digest issue<commit_after>/**
 * ngul 0.4
 * Copyright 2013 <NAME>. and other contributors; https://github.com/gkodes/ngul
 * @license: MIT
 */

(function(angular, nu) {
'use strict';
/*global nu, angular: true, FileReader: true*/
  var list = angular.module('nu.list', []);
  list.directive('nuList', [
    function() { // try to rename it to collection or list
      return {
        template: '<div class="nu list"></div>',
        restrict: 'EACM', // 145 550 ? 12118
        replace: true,
        controller: ['$scope', '$element', '$attrs', function($scope, $element) {
          this.$render = angular.noop; // invokde for rending an element, expected an compiler
          this.$filter = angular.noop; // invokde before render if return false wont render that element
          this.$link = angular.noop; // invokde after render with the element

          this.$indexOf = angular.noop;
          var nuList = this;

          var render = function(item) {
            var node = nuList.$render(item);
            node.data('src', item);
            nuList.$link(node);
          };

          this.$indexOf = function(node) {
            for(var i = 0; i < nuList.$src.length; i++) {
              if( angular.equals(node, nuList.$src[i]) ) {
                return i;
              }
            }
            return -1;
          };

          this.$add = function(item) {
            if(item) {
              nuList.$src.push(item);
            }
          };

          this.$remove = function(node) {
            nuList.$src.splice(nuList.$indexOf(node), 1);
          };

          this.$empty = function() {
            $element.empty();
          };

          this.$draw = function() {
            nuList.$empty();
            angular.forEach(nuList.$src, function(item) {
              if( nu.isDefinedAndNotNull(item) ) {
                render(item);
              }
            });
          };
        }],
        link: function(scope, element, attrs, nuList) {
          var src = attrs[attrs.nuList? 'nuList' : 'src'];
          scope.$watchCollection(src, function(value) {
            nuList.$src = value? value : [];
            nuList.$draw();
          });
        }
      };
    }
  ]);

  list.directive('nuListType', [
    function() {
      var nodes = {
        'img': angular.element('<span class="item thumb"><img></img></span>'),
        'txt': angular.element('<span class="item"></span>')
      };

      var engines = {
        'img': function(node) {
          return function(value) {
            node.removeClass('async').find('img')
              .attr('src', value);
          };
        },
        'txt': function(node) {
          return function(value) {
            node.removeClass('async').text(value);
          };
        }
      };

      return {
        restrict: 'A',
        require: 'nuList',
        link: function(scope, element, attr, nuList) {
          var engine, baseNode;
          nuList.$formatters = [];

          attr.$observe('nuListType', function(value) {
            var isIMG = value == 'img';
            engine = engines[(isIMG)? 'img' : 'txt'];
            baseNode = nodes[(isIMG)? 'img' : 'txt'];
          });

          nuList.$render = function(item) {
            //TODO: Node Pooling
            var node = baseNode.clone();
            nu.pipeLine(nuList.$formatters, engine(node))
              .onAsync(function(){
                node.addClass('async');
              }).next(item);
            nuList.$render.append(node);
            return node;
          };
          nuList.$render.append = function(node) {
            element.append(node); // angular.element(element[0])
          };
        }
      };
    }
  ]);

  list.directive('nuListRemovable', [
    function() { // ClickToRemove
      return {
        restrict: 'A',
        require: 'nuList',
        link: function(scope, element, attr, nuList) {
          var canRemove, remove_event = function(event) {
            var target = angular.element(event.currentTarget);
            nuList.$remove(target.data('src'));
            scope.$digest();
          };
          
          nuList.$link = function(node) {
            if(canRemove === false) { return; }
            node.addClass('remove').on('click', remove_event);
          };
{'fraction_non_alphanumeric': 0.15339578454332553, 'fraction_numerical': 0.004918032786885246, 'mean_word_length': 1.6167279411764706, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 21, 'https://': 2, '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': '2826390', 'n_tokens_mistral': 2422, 'n_tokens_neox': 2357, 'n_words': 498}