-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
35 lines (30 loc) · 1 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
var $ = require("jquery");
var CorpusViewer = require("./js/CorpusViewer.js");
var InputCorpus = require("./js/InputCorpus.js");
var Validator = require("./js/Validator.js");
var DICT_URL = "http://localhost:8000/top100kWords.txt";
var IN_SELECTOR = "#input";
var SUBMIT_SELECTOR = "#checkInput";
/** Click handler for submit */
var submit = function() {
CorpusViewer.renderLoadingDivs();
$.get(DICT_URL, function(text) {
var words = text.split("\n");
var dictionary = {};
words.forEach(function(maybeWord) {
if (maybeWord[0] !== "#") {
dictionary[maybeWord] = true;
}
});
var inputCorpus = new InputCorpus(getInputValue());
var validator = new Validator(inputCorpus, dictionary);
validator.runAll();
CorpusViewer.render(inputCorpus);
});
};
/** @return {String} value of input textarea */
var getInputValue = function() {
return $(IN_SELECTOR)[0].value;
};
/** main */
$(SUBMIT_SELECTOR).click(submit);