selectable.html 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset='utf-8' />
  5. <link href='../lib/main.css' rel='stylesheet' />
  6. <script src='../lib/main.js'></script>
  7. <script>
  8. document.addEventListener('DOMContentLoaded', function() {
  9. var calendarEl = document.getElementById('calendar');
  10. var calendar = new FullCalendar.Calendar(calendarEl, {
  11. headerToolbar: {
  12. left: 'prev,next today',
  13. center: 'title',
  14. right: 'dayGridMonth,timeGridWeek,timeGridDay'
  15. },
  16. initialDate: '2020-06-12',
  17. navLinks: true, // can click day/week names to navigate views
  18. selectable: true,
  19. selectMirror: true,
  20. select: function(arg) {
  21. var title = prompt('Event Title:');
  22. if (title) {
  23. calendar.addEvent({
  24. title: title,
  25. start: arg.start,
  26. end: arg.end,
  27. allDay: arg.allDay
  28. })
  29. }
  30. calendar.unselect()
  31. },
  32. eventClick: function(arg) {
  33. if (confirm('Are you sure you want to delete this event?')) {
  34. arg.event.remove()
  35. }
  36. },
  37. editable: true,
  38. dayMaxEvents: true, // allow "more" link when too many events
  39. events: [
  40. {
  41. title: 'All Day Event',
  42. start: '2020-06-01'
  43. },
  44. {
  45. title: 'Long Event',
  46. start: '2020-06-07',
  47. end: '2020-06-10'
  48. },
  49. {
  50. groupId: 999,
  51. title: 'Repeating Event',
  52. start: '2020-06-09T16:00:00'
  53. },
  54. {
  55. groupId: 999,
  56. title: 'Repeating Event',
  57. start: '2020-06-16T16:00:00'
  58. },
  59. {
  60. title: 'Conference',
  61. start: '2020-06-11',
  62. end: '2020-06-13'
  63. },
  64. {
  65. title: 'Meeting',
  66. start: '2020-06-12T10:30:00',
  67. end: '2020-06-12T12:30:00'
  68. },
  69. {
  70. title: 'Lunch',
  71. start: '2020-06-12T12:00:00'
  72. },
  73. {
  74. title: 'Meeting',
  75. start: '2020-06-12T14:30:00'
  76. },
  77. {
  78. title: 'Happy Hour',
  79. start: '2020-06-12T17:30:00'
  80. },
  81. {
  82. title: 'Dinner',
  83. start: '2020-06-12T20:00:00'
  84. },
  85. {
  86. title: 'Birthday Party',
  87. start: '2020-06-13T07:00:00'
  88. },
  89. {
  90. title: 'Click for Google',
  91. url: 'http://google.com/',
  92. start: '2020-06-28'
  93. }
  94. ]
  95. });
  96. calendar.render();
  97. });
  98. </script>
  99. <style>
  100. body {
  101. margin: 40px 10px;
  102. padding: 0;
  103. font-family: Arial, Helvetica Neue, Helvetica, sans-serif;
  104. font-size: 14px;
  105. }
  106. #calendar {
  107. max-width: 1100px;
  108. margin: 0 auto;
  109. }
  110. </style>
  111. </head>
  112. <body>
  113. <div id='calendar'></div>
  114. </body>
  115. </html>