Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 0 additions & 64 deletions client/app/components/searchBar/searchBar.coffee
Original file line number Diff line number Diff line change
@@ -1,62 +1,5 @@
CACHE_TIMEOUT = ms.minutes 10

# improve placeholders

placeholders = [
'Samenvattingen voor %class%'
'Woordenlijsten voor %class%'
'%class% Projecten'
'%class% Powerpoint H%num%'
'samenvatting %class% H%num%'
'%class% project H%num%'
'%name%'
]
fallbackClasses = [
'Nederlands'
'Engels'
'Wiskunde'
'Lichamelijke opvoeding'
]
fallbackNames = [
'Piet'
'Piet Jansen'
'Maria'
'Isaac'
'Josephine'
]

getClassName = ->
currentLesson = Helpers.embox ScheduleFunctions.currentLesson
c = (
if currentLesson?
currentLesson.class()
else
_.sample classes().fetch()
)
if c?
if _.random(1) then c.name else c.abbreviations[0]
else
_.sample fallbackClasses

getName = ->
user = _.sample Meteor.users.find({
_id: $ne: Meteor.userId()
'profile.firstName': $ne: ''
}, {
fields:
_id: 1
'profile.firstName': 1
'profile.lastName': 1
transform: null
}).fetch()

if user?
s = user.profile.firstName
s += " #{user.profile.lastName}" if _.random 1
s
else
_.sample fallbackNames

cache = {}
_fetch = _.throttle ((query, callback) ->
Meteor.apply 'search', [ query ],
Expand Down Expand Up @@ -104,13 +47,6 @@ route = (query, d) ->

Meteor.call 'search.analytics.store', query, d._id

Template.searchBar.helpers
placeholder: ->
_.sample(placeholders)
.replace '%class%', getClassName
.replace '%num%', _.random 1, 15
.replace '%name%', getName

Template.searchBar.events
'keyup input': (event) ->
query = event.target.value
Expand Down
2 changes: 1 addition & 1 deletion client/app/components/searchBar/searchBar.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div id="searchBar">
<i class="fa fa-search"></i>
<input
type="search" placeholder="{{placeholder}}"
type="search" placeholder="Zoeken"
spellcheck="on" autocomplete="off"
/>
</div>
Expand Down