calendars.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. 'use strict'
  2. /* eslint-disable require-jsdoc, no-unused-vars */
  3. var CalendarList = []
  4. function CalendarInfo () {
  5. this.id = null
  6. this.name = null
  7. this.checked = true
  8. this.color = null
  9. this.bgColor = null
  10. this.borderColor = null
  11. this.dragBgColor = null
  12. }
  13. function addCalendar (calendar) {
  14. CalendarList.push(calendar)
  15. }
  16. function findCalendar (id) {
  17. var found
  18. CalendarList.forEach(function (calendar) {
  19. if (calendar.id === id) {
  20. found = calendar
  21. }
  22. })
  23. return found || CalendarList[0]
  24. }
  25. function hexToRGBA (hex) {
  26. var radix = 16
  27. var r = parseInt(hex.slice(1, 3), radix)
  28. var g = parseInt(hex.slice(3, 5), radix)
  29. var b = parseInt(hex.slice(5, 7), radix)
  30. var a = parseInt(hex.slice(7, 9), radix) / 255 || 1
  31. var rgba = 'rgba(' + r + ', ' + g + ', ' + b + ', ' + a + ')'
  32. return rgba
  33. }
  34. /* (function () {
  35. var calendar
  36. var id = 0
  37. calendar = new CalendarInfo()
  38. id += 1
  39. calendar.id = String(id)
  40. calendar.name = 'My Calendar'
  41. calendar.color = '#ffffff'
  42. calendar.bgColor = '#9e5fff'
  43. calendar.dragBgColor = '#9e5fff'
  44. calendar.borderColor = '#9e5fff'
  45. addCalendar(calendar)
  46. calendar = new CalendarInfo()
  47. id += 1
  48. calendar.id = String(id)
  49. calendar.name = 'Company'
  50. calendar.color = '#ffffff'
  51. calendar.bgColor = '#00a9ff'
  52. calendar.dragBgColor = '#00a9ff'
  53. calendar.borderColor = '#00a9ff'
  54. addCalendar(calendar)
  55. calendar = new CalendarInfo()
  56. id += 1
  57. calendar.id = String(id)
  58. calendar.name = 'Family'
  59. calendar.color = '#ffffff'
  60. calendar.bgColor = '#ff5583'
  61. calendar.dragBgColor = '#ff5583'
  62. calendar.borderColor = '#ff5583'
  63. addCalendar(calendar)
  64. calendar = new CalendarInfo()
  65. id += 1
  66. calendar.id = String(id)
  67. calendar.name = 'Friend'
  68. calendar.color = '#ffffff'
  69. calendar.bgColor = '#03bd9e'
  70. calendar.dragBgColor = '#03bd9e'
  71. calendar.borderColor = '#03bd9e'
  72. addCalendar(calendar)
  73. calendar = new CalendarInfo()
  74. id += 1
  75. calendar.id = String(id)
  76. calendar.name = 'Travel'
  77. calendar.color = '#ffffff'
  78. calendar.bgColor = '#bbdc00'
  79. calendar.dragBgColor = '#bbdc00'
  80. calendar.borderColor = '#bbdc00'
  81. addCalendar(calendar)
  82. calendar = new CalendarInfo()
  83. id += 1
  84. calendar.id = String(id)
  85. calendar.name = 'etc'
  86. calendar.color = '#ffffff'
  87. calendar.bgColor = '#9d9d9d'
  88. calendar.dragBgColor = '#9d9d9d'
  89. calendar.borderColor = '#9d9d9d'
  90. addCalendar(calendar)
  91. calendar = new CalendarInfo()
  92. id += 1
  93. calendar.id = String(id)
  94. calendar.name = 'Birthdays'
  95. calendar.color = '#ffffff'
  96. calendar.bgColor = '#ffbb3b'
  97. calendar.dragBgColor = '#ffbb3b'
  98. calendar.borderColor = '#ffbb3b'
  99. addCalendar(calendar)
  100. calendar = new CalendarInfo()
  101. id += 1
  102. calendar.id = String(id)
  103. calendar.name = 'National Holidays'
  104. calendar.color = '#ffffff'
  105. calendar.bgColor = '#ff4040'
  106. calendar.dragBgColor = '#ff4040'
  107. calendar.borderColor = '#ff4040'
  108. addCalendar(calendar)
  109. })() */
  110. (function () {
  111. if (CalendarList.length === 0) {
  112. var cList = JSON.parse(localStorage.getItem('calendarList'))
  113. for (var i = 0; i < cList.length; i++) {
  114. var calendar = new CalendarInfo()
  115. calendar.id = cList[i].id
  116. calendar.name = cList[i].name
  117. calendar.color = cList[i].color
  118. calendar.bgColor = cList[i].bgColor
  119. calendar.dragBgColor = cList[i].dragBgColor
  120. calendar.borderColor = cList[i].borderColor
  121. addCalendar(calendar)
  122. }
  123. }
  124. })()