<commit_before>/* Essage - elegant way to display tips/message
 * https://github.com/sofish/Essage
 */
~function(win, doc) {

  var Essage = function() {
    this.el = doc.createElement('div');
    this.el.className = 'essage';

    return this;
  };

  Essage.prototype.setClass = function(classname) {
    this.el.className = classname;
    return this;
  };

  Essage.prototype._height = function() {
    return this.el.offsetHeight || this.el.clientHeight;
  };

  Essage.prototype.show = function(message, duration) {
    var el = this.el
      , self = this
      , interval, timeout;

    el.innerHTML = message;

    // first apply
    if(!el.parentNode || (el.parentNode.nodeName !== 'BODY')) doc.body.appendChild(el);

    var top = -this._height();

    // disppear automaticlly
    if(this._timeout) clearTimeout(this._timeout);
    duration && (timeout = function() {
      return setTimeout(function() {
        self.hide();
      }, duration);
    });

    interval = setInterval(function() {
      if(top === 0) {
        self._timeout = timeout && timeout();
        return clearInterval(interval);
      }
      el.style.top = (top += 1) + 'px';
    }, 10);

    return this;
  };

  Essage.prototype.hide = function() {
    var top = +this.el.style.top.slice(0, -2)
      , dest = -this._height()
      , self = this
      , interval;

    interval = setInterval(function() {
      if(top === dest) return interval && clearInterval(interval);
      self.el.style.top = (top -= 1) + 'px';
    }, 10);
    return this;
  }

  // export to window
  win.Essage = new Essage();

}(window, document);<commit_msg>show and hide faster<commit_after>/* Essage - elegant way to display tips/message
 * https://github.com/sofish/Essage
 */
~function(win, doc) {

  var Essage = function() {
    this.el = doc.createElement('div');
    this.el.className = 'essage';

    return this;
  };

  Essage.prototype.setClass = function(classname) {
    this.el.className = classname;
    return this;
  };

  Essage.prototype._height = function() {
    return this.el.offsetHeight || this.el.clientHeight;
  };

  Essage.prototype.show = function(message, duration) {
    var el = this.el
      , self = this
      , interval, timeout;

    el.innerHTML = message;

    // first apply
    if(!el.parentNode || (el.parentNode.nodeName !== 'BODY')) doc.body.appendChild(el);

    var top = -this._height();

    // disppear automaticlly
    if(this._timeout) clearTimeout(this._timeout);
    duration && (timeout = function() {
      return setTimeout(function() {
        self.hide();
      }, duration);
    });

    interval = setInterval(function() {
      if(top === 0) {
        self._timeout = timeout && timeout();
        return clearInterval(interval);
      }
      el.style.top = (top += 1) + 'px';
    }, 3);

    return this;
  };

  Essage.prototype.hide = function() {
    var top = +this.el.style.top.slice(0, -2)
      , dest = -this._height()
      , self = this
      , interval;

    interval = setInterval(function() {
      if(top === dest) return interval && clearInterval(interval);
      self.el.style.top = (top -= 1) + 'px';
    }, 3);
    return this;
  }

  // export to window
  win.Essage = new Essage();

}(window, document);
{'fraction_non_alphanumeric': 0.15791090629800308, 'fraction_numerical': 0.004915514592933948, 'mean_word_length': 2.5161987041036715, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '4453773', 'n_tokens_mistral': 1050, 'n_tokens_neox': 1009, 'n_words': 224}