Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sundayFirstCalendar = 'cal && date "+%-m %-d %y"'
- mondayFirstCalendar = 'cal | awk \'{ print " "$0; getline; print "Mo Tu We Th Fr Sa Su"; \
- getline; if (substr($0,1,2) == " 1") print " 1 "; \
- do { prevline=$0; if (getline == 0) exit; print " " \
- substr(prevline,4,17) " " substr($0,1,2) " "; } while (1) }\' && date "+%-m %-d %y"'
- command: sundayFirstCalendar
- #Set this to true to enable previous and next month dates, or false to disable
- otherMonths: true
- refreshFrequency: 3600000
- style: """
- top: 100px
- left: 0px
- color: #fff
- font-family: -apple-system
- width: 325px
- table
- border-collapse: collapse
- table-layout: fixed
- width: 100%;
- thead
- text-align: left
- td
- padding: 8px 8px
- white-space: nowrap
- width: 100%
- text-align: center
- thead tr
- &:first-child td
- font-size: 35px
- text-align: left
- &:last-child td
- font-size: 20px
- padding-bottom: 10px
- font-weight: 500
- tbody td
- font-size: 20px
- .today
- font-weight: bold
- background-color: rgb(255,59,48)
- .grey
- color: rgba(#C0C0C0, .7)
- """
- render: -> """
- <table>
- <thead>
- </thead>
- <tbody>
- </tbody>
- </table>
- """
- updateHeader: (rows, table) ->
- thead = table.find("thead")
- thead.empty()
- thead.append "<tr><td colspan='7'>#{rows[0]}</td></tr>"
- tableRow = $("<tr></tr>").appendTo(thead)
- daysOfWeek = rows[1].split(/\s+/)
- for dayOfWeek in daysOfWeek
- tableRow.append "<td>#{dayOfWeek}</td>"
- updateBody: (rows, table) ->
- #Set to 1 to enable previous and next month dates, 0 to disable
- PrevAndNext = 1
- tbody = table.find("tbody")
- tbody.empty()
- rows.splice 0, 2
- rows.pop()
- today = rows.pop().split(/\s+/)
- month = today[0]
- date = today[1].replace(/\D/g, '')
- year = today[2]
- lengths = [31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30]
- if year%4 == 0
- lengths[2] = 29
- for week, i in rows
- days = week.split(/\s+/).filter((day) -> day.length > 0)
- tableRow = $("<tr></tr>").appendTo(tbody)
- if i == 0 and days.length < 7
- for j in [days.length...7]
- if @otherMonths == true
- k = 6 - j
- cell = $("<td>#{lengths[month-1]-k}</td>").appendTo(tableRow)
- cell.addClass("grey")
- else
- cell = $("<td></td>").appendTo(tableRow)
- for day in days
- day = day.replace(/\D/g, '')
- cell = $("<td>#{day}</td>").appendTo(tableRow)
- cell.addClass("today") if day == date
- if i != 0 and 0 < days.length < 7 and @otherMonths == true
- for j in [1..7-days.length]
- cell = $("<td>#{j}</td>").appendTo(tableRow)
- cell.addClass("grey")
- update: (output, domEl) ->
- rows = output.split("\n")
- table = $(domEl).find("table")
- @updateHeader rows, table
- @updateBody rows, table
Add Comment
Please, Sign In to add comment