Guest User

Untitled

a guest
Nov 21st, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.74 KB | None | 0 0
  1. sundayFirstCalendar = 'cal && date "+%-m %-d %y"'
  2.  
  3. mondayFirstCalendar = 'cal | awk \'{ print " "$0; getline; print "Mo Tu We Th Fr Sa Su"; \
  4. getline; if (substr($0,1,2) == " 1") print " 1 "; \
  5. do { prevline=$0; if (getline == 0) exit; print " " \
  6. substr(prevline,4,17) " " substr($0,1,2) " "; } while (1) }\' && date "+%-m %-d %y"'
  7.  
  8. command: sundayFirstCalendar
  9.  
  10. #Set this to true to enable previous and next month dates, or false to disable
  11. otherMonths: true
  12.  
  13. refreshFrequency: 3600000
  14.  
  15. style: """
  16. top: 100px
  17. left: 0px
  18. color: #fff
  19. font-family: -apple-system
  20. width: 325px
  21.  
  22. table
  23. border-collapse: collapse
  24. table-layout: fixed
  25. width: 100%;
  26.  
  27. thead
  28. text-align: left
  29.  
  30. td
  31. padding: 8px 8px
  32. white-space: nowrap
  33. width: 100%
  34. text-align: center
  35.  
  36.  
  37. thead tr
  38. &:first-child td
  39. font-size: 35px
  40. text-align: left
  41.  
  42. &:last-child td
  43. font-size: 20px
  44. padding-bottom: 10px
  45. font-weight: 500
  46.  
  47. tbody td
  48. font-size: 20px
  49.  
  50.  
  51. .today
  52. font-weight: bold
  53. background-color: rgb(255,59,48)
  54.  
  55. .grey
  56. color: rgba(#C0C0C0, .7)
  57.  
  58.  
  59. """
  60.  
  61. render: -> """
  62. <table>
  63. <thead>
  64. </thead>
  65. <tbody>
  66. </tbody>
  67. </table>
  68. """
  69.  
  70.  
  71. updateHeader: (rows, table) ->
  72. thead = table.find("thead")
  73. thead.empty()
  74.  
  75. thead.append "<tr><td colspan='7'>#{rows[0]}</td></tr>"
  76. tableRow = $("<tr></tr>").appendTo(thead)
  77. daysOfWeek = rows[1].split(/\s+/)
  78.  
  79. for dayOfWeek in daysOfWeek
  80. tableRow.append "<td>#{dayOfWeek}</td>"
  81.  
  82. updateBody: (rows, table) ->
  83. #Set to 1 to enable previous and next month dates, 0 to disable
  84. PrevAndNext = 1
  85.  
  86. tbody = table.find("tbody")
  87. tbody.empty()
  88.  
  89. rows.splice 0, 2
  90. rows.pop()
  91.  
  92. today = rows.pop().split(/\s+/)
  93. month = today[0]
  94. date = today[1].replace(/\D/g, '')
  95. year = today[2]
  96.  
  97. lengths = [31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30]
  98. if year%4 == 0
  99. lengths[2] = 29
  100.  
  101. for week, i in rows
  102. days = week.split(/\s+/).filter((day) -> day.length > 0)
  103. tableRow = $("<tr></tr>").appendTo(tbody)
  104.  
  105. if i == 0 and days.length < 7
  106. for j in [days.length...7]
  107. if @otherMonths == true
  108. k = 6 - j
  109. cell = $("<td>#{lengths[month-1]-k}</td>").appendTo(tableRow)
  110. cell.addClass("grey")
  111. else
  112. cell = $("<td></td>").appendTo(tableRow)
  113.  
  114. for day in days
  115. day = day.replace(/\D/g, '')
  116. cell = $("<td>#{day}</td>").appendTo(tableRow)
  117. cell.addClass("today") if day == date
  118.  
  119. if i != 0 and 0 < days.length < 7 and @otherMonths == true
  120. for j in [1..7-days.length]
  121. cell = $("<td>#{j}</td>").appendTo(tableRow)
  122. cell.addClass("grey")
  123.  
  124. update: (output, domEl) ->
  125. rows = output.split("\n")
  126. table = $(domEl).find("table")
  127.  
  128. @updateHeader rows, table
  129. @updateBody rows, table
Add Comment
Please, Sign In to add comment