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

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-fei committed Aug 10, 2015
1 parent 1cef786 commit 642ba8d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
14 changes: 7 additions & 7 deletions src/Templater.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ module.exports = {
setOptions: setOptions
}

var opt = {}
opt.templatePattern = /\{(.*?)\}/g
var options = {}
options.templatePattern = /\{(.*?)\}/g

function setOptions(_opt){
opt = _opt || {}
opt.templatePattern = _opt.templatePattern || /\{(.*?)\}/g
function setOptions(_options){
options = _options || {}
options.templatePattern = _options.templatePattern || /\{(.*?)\}/g
}

function compile(t, data){
return t.replace(opt.templatePattern, function(match, prop) {
function compile(template, data){
return template.replace(options.templatePattern, function(match, prop) {
return data[prop] || match
})
}
8 changes: 3 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,14 @@

function registerInput(){
options.searchInput.addEventListener('keyup', function(e){
if( e.target.value.length == 0 ){
emptyResultsContainer()
return
emptyResultsContainer()
if( e.target.value.length > 0 ){
render( repository.search(e.target.value) )
}
render( repository.search(e.target.value) )
})
}

function render(results){
emptyResultsContainer()
if( results.length == 0 ){
return appendToResultsContainer(options.noResultsText)
}
Expand Down

0 comments on commit 642ba8d

Please sign in to comment.