JSFiddle - React, Tailwind, and code Playground

by jmjpro

HTML

Dictionary file: <span id="dictionaryFilePath"/>
<br/>
<span id="wordsInFile">Hello</span>
<br/>
<label>Word to lookup in dictionary</label><input type="text" id="wordToLookup" /><input type="submit" id="submit"/>
<span id="lookupResult"/>

JavaScript

var dictionary, dictionaryFilePath, reader;
reader = new FileReader();
dictionaryFilePath = "C:/Users/yehoshua/Documents/clients/singers/adapt/res/dict.txt";
$('#dictionaryFilePath').text() = dictionaryFilePath;
reader.readAsText(dictionaryFilePath);
// When loaded, set image data as background of page
reader.onloadend = function(){
    dictionary = this.result.split('\r\n');
    $('#wordsInFile').text(this.result);
}

$("#submit").on("click", function(){
    var found = false;
    for( var word in dictionary ) {
        if( dictionary[word] == $('#wordToLookup').val() ) {
            found = true;
            break;
        }
    }
    $('#lookupResult').text('Word found in dictionary = ' + found);
});