<commit_before>'use strict';
var $ = require('jquery');
var Backbone = require('backbone');
var TranscriptionListElementView = require('./transcription_list_element_view');
var render = require('./utils').render;

/**
 * Backbone view for transcriptions list
 * @class TranscriptionsListView
 * @constructor
 * @extends Backbone.View
 */
module.exports = Backbone.View.extend({
  tagName: 'div',
  className: 'container',
  initialize: function() {
    var transcriptions = this.collection;
    this.listenTo(transcriptions, 'sync',   this.render);
    this.listenTo(transcriptions, 'destroy', this.render);
    this.listenTo(transcriptions, 'add',     this.render);

    // Temporary way to auto update on transcription status change. unit in
    // milliseconds, checking for transcriptions update every 1/2 minute.
    setInterval(function() {
      if (transcriptions.remaining().length > 0) {
        transcriptions.fetch({reset: true});
      }
    }, 30000);
  },

  render: function() {
    // if there are  transcriptions it shows
    this.$el.empty();
    this.$el.append("<ol class='breadcrumb'><li class='active'>Transcriptions</li></ol>");
    if (!this.collection.isEmpty()) {
      this.collection.each(this.addOne, this);
      return this;
      // if there are no transcriptions it shows helpfull message to create a new one
    } else {
      this.$el.html(render('homePage'));
      return this;
    }
  },
  
  addOne: function(transcriptionItem) {
    var transcriptionView = new TranscriptionListElementView({model: transcriptionItem});
    this.$el.append(transcriptionView.render().el);
  }
});<commit_msg>Add in "delete pending transcriptions" button<commit_after>'use strict';
var $ = require('jquery');
var Backbone = require('backbone');
var TranscriptionListElementView = require('./transcription_list_element_view');
var render = require('./utils').render;

/**
 * Backbone view for transcriptions list
 * @class TranscriptionsListView
 * @constructor
 * @extends Backbone.View
 */
module.exports = Backbone.View.extend({
  tagName: 'div',
  className: 'container',
  initialize: function() {
    var transcriptions = this.collection;
    this.listenTo(transcriptions, 'sync',   this.render);
    this.listenTo(transcriptions, 'destroy', this.render);
    this.listenTo(transcriptions, 'add',     this.render);

    // Temporary way to auto update on transcription status change. unit in
    // milliseconds, checking for transcriptions update every 1/2 minute.
    setInterval(function() {
      if (transcriptions.remaining().length > 0) {
        transcriptions.fetch({reset: true});
      }
    }, 30000);
  },
  events:{
    "click button.deletePendingBtn": "deletePending"
  },
  render: function() {
    // if there are  transcriptions it shows
    this.$el.empty();
    this.$el.append("<ol class='breadcrumb'><li class='active'>Transcriptions</li>");

    // add remove processing transcripts button
    this.$el.append(`
        <button type="button" class="btn btn-danger btn-xs deletePendingBtn">
          Delete Pending Transcripts <span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
        </button>
      </ol>`);

    if (!this.collection.isEmpty()) {
      this.collection.each(this.addOne, this);
      return this;
      // if there are no transcriptions it shows helpfull message to create a new one
    } else {
      this.$el.html(render('homePage'));
      return this;
    }
  },

  addOne: function(transcriptionItem) {
    var transcriptionView = new TranscriptionListElementView({model: transcriptionItem});
    this.$el.append(transcriptionView.render().el);
  },

  deletePending: function() {
    for (var i = 0; i <  appTranscription.transcriptionsList.models.length; i++) {
      if(!appTranscription.transcriptionsList.models[i].attributes.status){
        appTranscription.transcriptionsList.models[i].destroy();
      }
    }
  }
});
{'fraction_non_alphanumeric': 0.13738508682328907, 'fraction_numerical': 0.004341164453524004, 'mean_word_length': 3.66865315852205, 'pattern_counts': {'":': 1, '<': 16, '<?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': '3092790', 'n_tokens_mistral': 1125, 'n_tokens_neox': 1092, 'n_words': 267}