calendars2.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. if (CalendarList.length === 0) {
  36. var cList = JSON.parse(localStorage.getItem('calendarList2'))
  37. for (var i = 0; i < cList.length; i++) {
  38. console.log(cList[i].id)
  39. var calendar = new CalendarInfo()
  40. calendar.id = cList[i].id
  41. calendar.name = cList[i].name
  42. calendar.color = cList[i].color
  43. calendar.bgColor = cList[i].bgColor
  44. calendar.dragBgColor = cList[i].dragBgColor
  45. calendar.borderColor = cList[i].borderColor
  46. addCalendar(calendar)
  47. }
  48. }
  49. })()