<commit_before>var p5DOM = (function(){

  var self = {};

  // Extending PElement and adding some more features

  // value() with no arguments returns current value
  // with argument, sets value
  p5.PElement.prototype.value = function() { 
    if (arguments.length > 0) {
      this.elt.value = arguments[0];
    } else {
      return this.elt.value;
    }
  };

  self.getElement = function (e) {
    var res = document.getElementById(e);
    if (res) {
      return new p5.PElement(res);
    } else {
      return null;
    }
  };

  self.getElements = function (e) {
    var arr = [];
    var res = document.getElementsByClassName(e);
    if (res) {
      for (var j = 0; j < res.length; j++) {
        var obj = new p5.PElement(res[j]);
        arr.push(obj);
      }
    }
    return arr;
  };

  ['div', 'p', 'span', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'].forEach(function(tag) {
    var method = 'create' + tag.charAt(0).toUpperCase() + tag.slice(1);
    self[method] = function(html) {
      console.log(tag)
      var elt = document.createElement(tag);
      elt.innerHTML = html;
      document.body.appendChild(elt);
      var c = new p5.PElement(elt);
      return c;
    }
  });

  self.createImg = function(src, alt) {
    var elt = document.createElement('img');
    elt.src = src;
    if (typeof alt !== 'undefined') {
      elt.alt = alt;
    }
    document.body.appendChild(elt);
    var c = new p5.PElement(elt);
    return c;  
  };

  self.createA = function(href, html, target) {
    var elt = document.createElement('a');
    elt.href = href;
    elt.innerHTML = html;
    if (target) elt.target = target;
    document.body.appendChild(elt);
    var c = new p5.PElement(elt);
    return c;  
  };

  /** INPUT **/
  self.createSlider = function(min, max, value) {
    var elt = document.createElement('input');
    elt.type = 'range';
    elt.min = min;
    elt.max = max;
    if (value) elt.value = value;
    document.body.appendChild(elt);
    var c = new p5.PElement(elt);
    return c;  
  };

  self.createButton = function(label, value) {
    var elt = document.createElement('button');
    elt.innerHTML = label;
    elt.value = value;
    if (value) elt.value = value;
    document.body.appendChild(elt);
    var c = new p5.PElement(elt);
    return c;  
  };

  self.createInput = function(value) {
    var elt = document.createElement('input');
    elt.type = 'text';
    if (value) elt.value = value;
    document.body.appendChild(elt);
    var c = new p5.PElement(elt);
    return c;  
  };

  return self;


})();





  // p5.prototype.getId = function (e) {
  //   for (var i = 0; i < _elements.length; i++) {
  //     if (_elements[i].elt.id === e) {
  //       return _elements[i];<commit_msg>yeah why not just attach?<commit_after>var p5DOM = (function(){

  // Extending PElement and adding some more features

  // value() with no arguments returns current value
  // with argument, sets value
  p5.PElement.prototype.value = function() { 
    if (arguments.length > 0) {
      this.elt.value = arguments[0];
    } else {
      return this.elt.value;
    }
  };

  // Extending p5 and adding some more methods
  p5.prototype.getElement = function (e) {
    var res = document.getElementById(e);
    if (res) {
      return new p5.PElement(res);
    } else {
      return null;
    }
  };

  p5.prototype.getElements = function (e) {
    var arr = [];
    var res = document.getElementsByClassName(e);
    if (res) {
      for (var j = 0; j < res.length; j++) {
        var obj = new p5.PElement(res[j]);
        arr.push(obj);
      }
    }
    return arr;
  };

  var tags = ['div', 'p', 'span', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
  tags.forEach(function(tag) {
    var method = 'create' + tag.charAt(0).toUpperCase() + tag.slice(1);
    p5.prototype[method] = function(html) {
      var elt = document.createElement(tag);
      elt.innerHTML = html;
      document.body.appendChild(elt);
      var c = new p5.PElement(elt);
      return c;
    }
  });

  p5.prototype.createImg = function(src, alt) {
    var elt = document.createElement('img');
    elt.src = src;
    if (typeof alt !== 'undefined') {
      elt.alt = alt;
    }
    document.body.appendChild(elt);
    var c = new p5.PElement(elt);
    return c;  
  };

  p5.prototype.createA = function(href, html, target) {
    var elt = document.createElement('a');
    elt.href = href;
    elt.innerHTML = html;
    if (target) elt.target = target;
    document.body.appendChild(elt);
    var c = new p5.PElement(elt);
    return c;  
  };

  /** INPUT **/
  p5.prototype.createSlider = function(min, max, value) {
    var elt = document.createElement('input');
    elt.type = 'range';
    elt.min = min;
    elt.max = max;
    if (value) elt.value = value;
    document.body.appendChild(elt);
    var c = new p5.PElement(elt);
    return c;  
  };

  p5.prototype.createButton = function(label, value) {
    var elt = document.createElement('button');
    elt.innerHTML = label;
    elt.value = value;
    if (value) elt.value = value;
    document.body.appendChild(elt);
    var c = new p5.PElement(elt);
    return c;  
  };

  p5.prototype.createInput = function(value) {
    var elt = document.createElement('input');
    elt.type = 'text';
    if (value) elt.value = value;
    document.body.appendChild(elt);
    var c = new p5.PElement(elt);
    return c;  
  };

  /** VIDEO STUFF **/
  p5.prototype.createVideo = function(src) {
    var elt = document.createElement('video');
    elt.src = src;
    document.body.appendChild(elt);
    var c = new p5.PElement(elt);
    c.play = function() {
      c.elt.play();
    };
    c.loop = function(val) {
      c.elt.setAttribute('loop', val);
    };
    return c;  
  };

  p5.prototype.video = function(v, x, y, w, h, c) {
    this.curElement.context.drawImage(v.elt, x, y, w, h);
  };

})();





  // p5.prototype.getId = function (e) {
  //   for (var i = 0; i < _elements.length; i++) {
  //     if (_elements[i].elt.id === e) {
  //       return _elements[i];
{'fraction_non_alphanumeric': 0.15988709945210028, 'fraction_numerical': 0.009629752614975926, 'mean_word_length': 2.4285714285714284, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '4968379', 'n_tokens_mistral': 2135, 'n_tokens_neox': 2074, 'n_words': 491}