This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| useWorkerToDo = (fn, data) -> | |
| window.URL or = window.webkitURL | |
| workerSupported = window.Worker and window.URL and window.Blob | |
| callbacks = [] | |
| done = false | |
| returnVal = undefined | |
| resolve = -> | |
| while callbacks.length | |
| returnVal = callbacks.shift()(returnVal) | |
| return |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Trie | |
| constructor: (strings = [], @root = {}) -> | |
| @addString string for string in strings | |
| addString: (string) -> | |
| chars = string.split "" | |
| string = "" | |
| node = @root | |
| for char in chars | |
| string += char |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| paginationTemplate = (data) -> | |
| url = data.url | |
| currentPage = +data.currentPage | |
| totalPages = +data.totalPages | |
| lis = [] | |
| if totalPages < 7 | |
| for i in [1..totalPages] | |
| li = if i is currentPage then "<li class='active'><a>#{i}</a></li>" else "<li><a href='#{url}/page#{i}'>#{i}</a></li>" | |
| lis.push(li) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var yearsMonthsDaysBetween = function(date) { | |
| var andString, days, daysString, months, monthsString, s, today, years, yearsString; | |
| today = new Date(); | |
| date = new Date(date); | |
| years = today.getFullYear() - date.getFullYear(); | |
| months = today.getMonth() - date.getMonth(); | |
| days = today.getDate() - date.getDate(); | |
| if (days < 0) { | |
| months -= 1; | |
| days = Math.floor((today - new Date(today.getFullYear(), today.getMonth() - 1, date.getDate())) / 1000 / 60 / 60 / 24); |
NewerOlder