Skip to content
This repository was archived by the owner on Mar 16, 2022. It is now read-only.

Commit 642ba8d

Browse files
committed
cleanup
1 parent 1cef786 commit 642ba8d

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

src/Templater.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ module.exports = {
33
setOptions: setOptions
44
}
55

6-
var opt = {}
7-
opt.templatePattern = /\{(.*?)\}/g
6+
var options = {}
7+
options.templatePattern = /\{(.*?)\}/g
88

9-
function setOptions(_opt){
10-
opt = _opt || {}
11-
opt.templatePattern = _opt.templatePattern || /\{(.*?)\}/g
9+
function setOptions(_options){
10+
options = _options || {}
11+
options.templatePattern = _options.templatePattern || /\{(.*?)\}/g
1212
}
1313

14-
function compile(t, data){
15-
return t.replace(opt.templatePattern, function(match, prop) {
14+
function compile(template, data){
15+
return template.replace(options.templatePattern, function(match, prop) {
1616
return data[prop] || match
1717
})
1818
}

src/index.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,14 @@
7272

7373
function registerInput(){
7474
options.searchInput.addEventListener('keyup', function(e){
75-
if( e.target.value.length == 0 ){
76-
emptyResultsContainer()
77-
return
75+
emptyResultsContainer()
76+
if( e.target.value.length > 0 ){
77+
render( repository.search(e.target.value) )
7878
}
79-
render( repository.search(e.target.value) )
8079
})
8180
}
8281

8382
function render(results){
84-
emptyResultsContainer()
8583
if( results.length == 0 ){
8684
return appendToResultsContainer(options.noResultsText)
8785
}

0 commit comments

Comments
 (0)