-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
25 lines (21 loc) · 754 Bytes
/
script.js
File metadata and controls
25 lines (21 loc) · 754 Bytes
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
/* global SearchContainer, ResultContainer, Loader, IssuesParser, _ */
const searchContainer = new SearchContainer('.search');
const resultContainer = new ResultContainer('.search-result');
const loader = new Loader('.loader');
const parser = new IssuesParser();
function handleResult(result) {
resultContainer.renderResult(result);
loader.deactivate();
}
function handleError(err) {
resultContainer.renderError(err);
loader.deactivate();
}
function handleInput() {
resultContainer.clear();
loader.activate();
parser.get(searchContainer.queryString())
.then((result) => handleResult(result))
.catch((err) => handleError(err));
}
searchContainer.searchButton.addEventListener('click', _.debounce(_.throttle(handleInput, 1000)));