<commit_before>/************************************************************
 *
 * Mosaic Instagram Admin
 *
 ***********************************************************/

var MosaicInstagramAdmin = Class.extend({
  
  options: {
    http: {
      host: 'localhost'
      ,port: '3333'
    }
  }
  
  // Constructor
  // --------------------------------------------------------
  ,init: function() {
    
    var self = this;
    
    this.getQueuedImages(2, function() {
      
      // Approve / decline buttons events
      $('div#approved-btn').click(function(e) {
        if(!self.locked) {
          $(this).addClass('highlight');
          self.updateImage($('#instagram-images li:first-child'), true);
        }
      });

      $('div#declined-btn').click(function(e) {
        if(!self.locked) {
          $(this).addClass('highlight');
          self.updateImage($('#instagram-images li:first-child'), false);
        }
      });
      
    });
    
    
  }
  
  // 
  // --------------------------------------------------------
  ,getQueuedImages: function(limit, callback) {
    
    var self = this;
    
    // Get queued images json
    $.getJSON(
      'http://' 
      + this.options.http.host 
      + ':' 
      + this.options.http.port 
      + '/images/queued/' 
      + limit
      
      ,function(images) {
        
        // Add images
        self.addImages(images, callback);
      }
    );
  }
  
  // 
  // --------------------------------------------------------
  ,addImages: function(images, callback) {
    
    var check_img = function(queue, cb) {
      
      if(queue.length == 0) {
        cb();
        return;
      }
      
      var image = queue.pop();<commit_msg>fixed queue when no images are available<commit_after>/************************************************************
 *
 * Mosaic Instagram Admin
 *
 ***********************************************************/

var MosaicInstagramAdmin = Class.extend({
  
  options: {
    http: {
      host: 'localhost'
      ,port: '3333'
    }
  }
  
  // Constructor
  // --------------------------------------------------------
  ,init: function() {
    
    var self = this;
    
    this.getQueuedImages(2, function() {
      
      // Approve / decline buttons events
      $('div#approved-btn').click(function(e) {
        if(!self.locked) {
          $(this).addClass('highlight');
          self.updateImage($('#instagram-images li:first-child'), true);
        }
      });

      $('div#declined-btn').click(function(e) {
        if(!self.locked) {
          $(this).addClass('highlight');
          self.updateImage($('#instagram-images li:first-child'), false);
        }
      });
      
    });
    
    
  }
  
  // 
  // --------------------------------------------------------
  ,getQueuedImages: function(limit, callback) {
    
    var self = this;
    
    // Get queued images json
    $.getJSON(
      'http://' 
      + this.options.http.host 
      + ':' 
      + this.options.http.port 
      + '/images/queued/' 
      + limit
      + '/0/0/'
      
      ,function(images) {
        
        // Add images
        self.addImages(images, callback);
      }
    );
  }
  
  // 
  // --------------------------------------------------------
  ,addImages: function(images, callback) {
    
    var check_img = function(queue, cb) {
      
      if(queue.length == 0) {
        cb();
        return;
      }
      
      var image = queue.pop();
{'fraction_non_alphanumeric': 0.29685244008085476, 'fraction_numerical': 0.0040427375108287615, 'mean_word_length': 1.3532608695652173, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4436163', 'n_tokens_mistral': 987, 'n_tokens_neox': 946, 'n_words': 150}