<commit_before>var $ = require('jquery');
var isInvalid = require('npm-user-validate').username;

var LinkUpdater = function(el){
  this.el = $(el);
  this.updater = this.el.find(".link-updater");
  this.input = this.el.find("input");

  this.input.on("input", function(e){
    this.updateValue(e.target.value);
  }.bind(this));

  this.pathDisplay = this.el.find("p strong");
  this.demoValue = this.input.attr("placeholder") || "username";
};

LinkUpdater.prototype.updateValue = function(inputValue){
  if(!this.input[0].checkValidity() || isInvalid(inputValue)){
    if(inputValue === "") {
      this.pathDisplay.text(this.demoValue);
    }
  } else {
    this.pathDisplay.text(inputValue);
  }
};

$(function(){
  var linkUpdater = $(".link-updater-container");

  $.each(linkUpdater, function(idx, el){
    new LinkUpdater(el);
  });<commit_msg>fix(forms): link updater always shows demoValue when empty<commit_after>var $ = require('jquery');
var isInvalid = require('npm-user-validate').username;

var LinkUpdater = function(el){
  this.el = $(el);
  this.updater = this.el.find(".link-updater");
  this.input = this.el.find("input");

  this.input.on("input", function(e){
    this.updateValue(e.target.value);
  }.bind(this));

  this.pathDisplay = this.el.find("p strong");
  this.demoValue = this.input.attr("placeholder") || "username";
};

LinkUpdater.prototype.updateValue = function(inputValue){
  if(inputValue === "") {
    this.pathDisplay.text(this.demoValue);
  } else if (!this.input[0].checkValidity() || isInvalid(inputValue)){
    //noop
  } else {
    this.pathDisplay.text(inputValue);
  }
};

$(function(){
  var linkUpdater = $(".link-updater-container");

  $.each(linkUpdater, function(idx, el){
    new LinkUpdater(el);
  });
{'fraction_non_alphanumeric': 0.19397042093287828, 'fraction_numerical': 0.0011376564277588168, 'mean_word_length': 4.412307692307692, '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': '3741343', 'n_tokens_mistral': 599, 'n_tokens_neox': 603, 'n_words': 92}