<commit_before>/*
 * Image Map/Area Editor (c) 2014 Octopods Development Team
 * 
 */

imagemap = (function($) {
  var self = {};
  
  self.start = function() {
    self.coords = [];
  }

  self.create_map = function(image) {
    var name = get_name();
    
    image.attr('usemap', '#'+name);
    
    self.map = $('<map />').attr('name', name);
    
    self.map.insertAfter(image);
  }
  
  self.finish = function() {
    var area = get_area(self.coords);
    
    self.map.append(area);
    
    return area;
  }
  
  $.fn.imagemap = function(options) {
    
    self.settings = $.extend({
      scale: 1
    }, options);
    
    self.create_map(this);
    
    this.each(function() {
      $(this).click(bind_click);
    });
    
    self.start();
    
    return self;
  }
  
  function bind_click(e) {
    var x = e.offsetX * self.settings.scale;
    var y = e.offsetY * self.settings.scale;
    
    self.coords.push({x: x, y: y});
  }
  
  function get_area(coords) {
    var area = $('<area />').attr({
      shape: 'poly',
      href: '#'
    });
    
    coords.map(function(coord) {
      var coords_attr = area.attr('coords');
      
      area.attr(
        'coords',
        '{0}{1},{2}'.format(
          coords_attr ? coords_attr+',' : '', 
          coord.x, 
          coord.y
        )
      );
    });
    
    return area;
  }
  
  function get_name() {
    return 'm{0}'.format((new Date).getTime());
  }
  
  return self;
  
})(jQuery);<commit_msg>last point equals first one<commit_after>/*
 * Image Map/Area Editor (c) 2014 Octopods Development Team
 * 
 */

imagemap = (function($) {
  var self = {};
  
  self.start = function() {
    self.coords = [];
  }

  self.create_map = function(image) {
    var name = get_name();
    
    image.attr('usemap', '#'+name);
    
    self.map = $('<map />').attr('name', name);
    
    self.map.insertAfter(image);
  }
  
  self.finish = function() {
    var area = get_area(self.coords);
    
    self.map.append(area);
    
    return area;
  }
  
  $.fn.imagemap = function(options) {
    
    self.settings = $.extend({
      scale: 1
    }, options);
    
    self.create_map(this);
    
    this.each(function() {
      $(this).click(bind_click);
    });
    
    self.start();
    
    return self;
  }
  
  function bind_click(e) {
    var x = e.offsetX * self.settings.scale;
    var y = e.offsetY * self.settings.scale;
    
    self.coords.push({x: x, y: y});
  }
  
  function get_area(coords) {
    
    if (coords) {
      var area = $('<area />').attr({
        shape: 'poly',
        href: '#'
      });
    
      coords.map(function(coord, index) {
        var coords_attr = area.attr('coords');
        
        if (index != coords.length-1) {
          coords_attr = '{0}{1},{2}'.format(
            coords_attr ? coords_attr+',' : '', 
            coord.x, 
            coord.y
          )
        }
        else {
          // last point must equal the first one
          
          coords_attr = '{0},{1},{2}'.format(
            area.attr('coords'),
            coords[0].x,
            coords[0].y
          )
        }
        
        area.attr('coords', coords_attr);
      });
    }
    
    return area;
  }
  
  function get_name() {
    return 'm{0}'.format((new Date).getTime());
  }
  
  if (!String.prototype.format) {
    String.prototype.format = function() {
      var args = arguments;
    
      return this.replace(/{(\d+)}/g, function(match, number) { 
        return typeof args[number] != 'undefined'
          ? args[number]
          : match
        ;
      });
    };
  }
  
  return self;
  
})(jQuery);
{'fraction_non_alphanumeric': 0.16813914964108229, 'fraction_numerical': 0.006626173384870237, 'mean_word_length': 1.7405446293494704, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5141170', 'n_tokens_mistral': 1279, 'n_tokens_neox': 1257, 'n_words': 226}