gitoria

calendar

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit651752c0651752c0|||PR run the browser gate once per deployAtlas651752c0/lib/month-grid.hl

2.7 KB

  1. // Calendar grid and editor value preparation; no browser state.
  2. import { pad, daysIn, before } from './dates.hl'
  3. static weekdayOf = (Number y, Number m, Number d) => {
  4. t = [0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4]
  5. yy = m < 3 ? y - 1 : y
  6. sun = (yy + (yy - yy % 4) / 4 - (yy - yy % 100) / 100 + (yy - yy % 400) / 400 + t[m - 1] + d) % 7
  7. return (sun + 6) % 7
  8. }
  9. static build = (Number y, Number m, String todayText) => {
  10. py = m == 1 ? y - 1 : y
  11. pm = m == 1 ? 12 : m - 1
  12. ny = m == 12 ? y + 1 : y
  13. nm = m == 12 ? 1 : m + 1
  14. lead = weekdayOf(y, m, 1)
  15. n = daysIn(y, m)
  16. pn = daysIn(py, pm)
  17. out = []
  18. let day = 1 - lead
  19. let w = 0
  20. while (w < 6) {
  21. let i = 0
  22. while (i < 7) {
  23. let cy = y
  24. let cm = m
  25. let cd = day
  26. let cls = ''
  27. if (day < 1) { cy = py cm = pm cd = pn + day cls = 'outside' }
  28. if (day > n) { cy = ny cm = nm cd = day - n cls = 'outside' }
  29. date = cy + '-' + pad(cm) + '-' + pad(cd)
  30. if (date == todayText) { cls = 'today' }
  31. out.push({ n = cd date = date cls = cls })
  32. day = day + 1
  33. i = i + 1
  34. }
  35. w = w + 1
  36. }
  37. return out
  38. }
  39. static fill = (Hybrid list, Hybrid evs) => {
  40. out = []
  41. let i = 0
  42. while (i < list.length) {
  43. d = list[i]
  44. hit = []
  45. let j = 0
  46. while (j < evs.length) {
  47. e = evs[j]
  48. if (!before(d.date, e.first) && !before(e.last, d.date)) { hit.push(e) }
  49. j = j + 1
  50. }
  51. row = { n = d.n date = d.date cls = d.cls addLabel = 'Add event on ' + d.date }
  52. let k = 0
  53. while (k < 4) {
  54. let text = ''
  55. let cls = 'unused'
  56. let id = ''
  57. if (k < hit.length && (hit.length <= 4 || k < 3)) {
  58. e = hit[k]
  59. text = (e.allDay || d.date != e.first ? '' : e.startTime + ' ') + e.title
  60. cls = 'event'
  61. id = e.id
  62. }
  63. if (k == 3 && hit.length > 4) { text = '+' + (hit.length - 3) + ' more' cls = 'more' }
  64. row['t' + k] = text
  65. row['c' + k] = cls
  66. row['v' + k] = id
  67. k = k + 1
  68. }
  69. out.push(row)
  70. i = i + 1
  71. }
  72. return out
  73. }
  74. static blank = (String date, String zone) => {
  75. return { id = '' title = '' allDay = false startDate = date startTime = '09:00' endDate = date endTime = '10:00' place = '' notes = '' zone = zone custom = false rows = [] }
  76. }
  77. static localView = (Hybrid f, Hybrid defRows) => {
  78. allDay = f.allDay
  79. last = f.endDate != '' ? f.endDate : f.startDate
  80. mine = []
  81. let k = 0
  82. while (k < f.reminders.length) { mine.push({ unit = f.reminders[k].unit n = f.reminders[k].n time = f.reminders[k].time }) k = k + 1 }
  83. return { id = f.id title = f.title allDay = allDay first = f.startDate last = last
  84. startDate = f.startDate startTime = allDay ? '' : f.startTime endDate = f.endDate endTime = allDay ? '' : f.endTime
  85. place = f.place notes = f.notes start = f.startDate zone = f.zone custom = f.custom rows = f.custom ? mine : defRows }
  86. }

Branches

Latest commits

  • 651752c0|||PR run the browser gate once per deployAtlas
  • e24e28a1|||PR preserve calendar state across month addresses and split dialogsAtlas
  • 384d3d23|||PR give calendar months their own addressAtlas
  • fff2f537Merge branch 'calendar31-lib' into mainAtlas
  • 07cde3dc|||PR keep worker records out of the repo; README vendor is day72Atlas
  • a753b0ab|||PR move shared calendar logic to libAtlas
  • b32a921dMerge branch 'vendor-day72' into mainAtlas
  • 60a0dd19|||PR Hybriel day72 (00c9dbb8) instead of the withdrawn day73Atlas
  • 53f5464dMerge branch 'calendar26-day73' into mainAtlas
  • 338499ec|||PR Keep reminder settings open during editing and rejected savesAtlas
  • ad9e8d59|||PR Use framework page and popover state, Hybriel day73Atlas
  • cab224a1Re-vendor calendar to verified Hybriel day73Atlas
  • f9b8f918Merge branch 'calendar-vendor-day61' into mainAtlas
  • 66341793|||PR Vendor Hybriel day61Atlas
  • 36fc596bMerge branch 'vendor-day59' into mainAtlas
  • b37cc1da|||PR Vendor Hybriel day59Atlas
  • 05665102Merge branch 'vendor-day56' into mainAtlas
  • 687296fb|||PR Vendor Hybriel day56Atlas
  • a6166d4eMerge branch 'hl-standard-3' into mainAtlas
  • 6d0eb3b0|||PR Calendar day add buttons only when signed in (Kunibert minor)Atlas