JSFiddle - React, Tailwind, and code Playground

by etiennenoel

HTML

<input type="search" id="search" >

JavaScript

function Suggestion() {
  var self = this;

  self.command = '';
  self.commandSearchedFor = '';
  self.preciseness = -1; //-1 == init value, 0 == not similar at all, 1 == perfect
  
}
function Command() {
}

Command.prototype = {
  keyword: '',

  init : function (keyword) {
    this.keyword = keyword;
  },
  execute: function() {

  }
};

function LoadCommand() {
  Command.call(this);

  this.init('load');
}

LoadCommand.prototype = Object.create(Command.prototype, {
  init: {
    value: function(keyword) {
      Command.prototype.init.apply(this, arguments);

      //Init the NodeClickedState state with the list

    },
    enumerable: true,
    configurable: true,
    writable: true
  },
  execute: {
    value: function(data) {
        //We here verify if the
    },
    enumerable: true,
    configurable: true,
    writable: true
  }



})

function CommandManager() {
  var self = this;

  self.commands = new Array();
  self.commandsFound = new Array();

  self.init = function() {
    self.commands.push(new LoadCommand());
  }




  self.getEditDistance = function getEditDistance(string1, string2) {
    var m = string1.length;
    var n = string2.length;
    var d = 0;
    var c = new Array();

    for(var k = 0; k <= m; k++)
      c[k] = [0];

    for(var l = 1; l <= n; l++)
      c[0][l] = 0;

    for(var i = 1; i <= m; i++) {
      for(var j = 1; j <= n; j++) {
        if(string1.charAt(i-1) == string2.charAt(j-1))
          d = 0;
        else
          d = 1;

        c[i][j] = Math.min(c[i-1][j-1]+d,Math.min(c[i-1][j] + 1,c[i][j-1] + 1));
      }

    }

    return c[m][n];
  }

  self.getNumberOfCharacterSimilarFromBeginning = function(string1, string2) {
    var shortestString = string1,
      longestString = string2;

    if(string1.length > string2.length) {
      shortestString = string2;
      longestString = string1;
    }

    var numberOfCharacterSimilarFromBeginning = 0;
    for(var i = 0; i < shortestString.length; i++) {
     ...