<commit_before>(function () {
  'use strict';

  $.widget("custom.newsByCategory", {
    
    _create: function() {
      this.getNews();
    },
    
    getParameters: function () {
      var category = $('.kunta-api-news-by-category').attr('data-category');
      var maxResults = $('.kunta-api-news-by-category').attr('data-max-results');
      
      return {
        category: category,
        maxResults: maxResults
      };
    },
    
    getNews: function () {
      $.ajax({
        url : '/ajax/newsByTag',
        data: this.getParameters(),
        success : $.proxy(function(data) {
          this.appendNews(data);
        }, this)
      });
    },
    
    appendNews: function (news) {
      for (var i = 0; i < news.length; i++) {
        var article = news[i];
        var imageSrc = '/newsArticleImages/' + article.id + '/' + article.imageId;

        $('.kunta-api-news-by-category > .row').append(
            $('<div/>', {'class': 'news-article thumb-article'}).append(
                $('<div/>', {'class': 'news-article-image'})
            )
            .append(
                $('<div/>', {'class': 'details'}).append(
                    $('<div/>', {'class': 'date'}).append(
                      $('<span/>', {'text': moment(article.published).format("D.M.YYYY")})
                    )
                )
                .append(
                  $('<div/>', {'class': 'title'}).append(
                    $('<a/>', {'id': 'news-article-link-' + i, 'href': '/uutiset/' + article.slug}).append(
                      $('<span/>', {'text': article.title})
                    )
                  )
                )
            )
        );
        $('.news-article-image').attr('data-lazy-bg-image', imageSrc);
      }

      $('*[data-lazy-bg-image]').each(function (index, element) {
        $(element).lazyBackgroundImage();
      });
    }
  });
  
  $(document).ready(function () {
    $('.kunta-api-news-by-category').newsByCategory();
  });
  
}).call(this);<commit_msg>Fixed news list<commit_after>(function () {
  'use strict';

  $.widget("custom.newsByCategory", {
    
    _create: function() {
      this.getNews();
    },
    
    getParameters: function () {
      var category = this.element.attr('data-category');
      var maxResults = this.element.attr('data-max-results');
      
      return {
        category: category,
        maxResults: maxResults
      };
    },
    
    getNews: function () {
      $.ajax({
        url : '/ajax/newsByTag',
        data: this.getParameters(),
        success : $.proxy(function(news) {
          var row = $('<div>').addClass('row').appendTo(this.element);
          for (var i = 0; i < news.length; i++) {
            var article = news[i];
            this.appendArticle(row, article);
          }
        }, this)
      });
    },
    
    appendArticle: function (row, article) {        
      var imageSrc = '/newsArticleImages/' + article.id + '/' + article.imageId;
      
      row.append(
        $('<div/>', {'class': 'news-article thumb-article'}).append(
          $('<div/>', {'class': 'news-article-image'})
            .attr('data-lazy-bg-image', imageSrc)
        )
        .append(
          $('<div/>', {'class': 'details'}).append(
            $('<div/>', {'class': 'date'}).append(
              $('<span/>', {'text': moment(article.published).format("D.M.YYYY")})
            )
          )
          .append(
            $('<div/>', {'class': 'title'}).append(
              $('<a/>', {'href': '/uutiset/' + article.slug}).append(
                $('<span/>', {'text': article.title})
              )
            )
          )
        )
      );
      row.find('*[data-lazy-bg-image]').lazyBackgroundImage();
    }
  });
  
  $(document).ready(function () {
    $('.kunta-api-news-by-category').newsByCategory();
  });
  
}).call(this);
{'fraction_non_alphanumeric': 0.206279190451479, 'fraction_numerical': 0.0005189413596263622, 'mean_word_length': 1.6808066759388038, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 21, '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': '7032649', 'n_tokens_mistral': 1184, 'n_tokens_neox': 1156, 'n_words': 181}