timezones.html 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset='utf-8' />
  5. <link href='../fullcalendar.min.css' rel='stylesheet' />
  6. <link href='../fullcalendar.print.min.css' rel='stylesheet' media='print' />
  7. <script src='../lib/moment.min.js'></script>
  8. <script src='../lib/jquery.min.js'></script>
  9. <script src='../fullcalendar.min.js'></script>
  10. <script>
  11. $(document).ready(function() {
  12. $('#calendar').fullCalendar({
  13. header: {
  14. left: 'prev,next today',
  15. center: 'title',
  16. right: 'month,agendaWeek,agendaDay,listWeek'
  17. },
  18. defaultDate: '2020-05-12',
  19. navLinks: true, // can click day/week names to navigate views
  20. editable: true,
  21. selectable: true,
  22. eventLimit: true, // allow "more" link when too many events
  23. events: {
  24. url: 'php/get-events.php',
  25. error: function() {
  26. $('#script-warning').show();
  27. }
  28. },
  29. loading: function(bool) {
  30. $('#loading').toggle(bool);
  31. },
  32. eventRender: function(event, el) {
  33. // render the timezone offset below the event title
  34. if (event.start.hasZone()) {
  35. el.find('.fc-title').after(
  36. $('<div class="tzo"/>').text(event.start.format('Z'))
  37. );
  38. }
  39. },
  40. dayClick: function(date) {
  41. console.log('dayClick', date.format());
  42. },
  43. select: function(startDate, endDate) {
  44. console.log('select', startDate.format(), endDate.format());
  45. }
  46. });
  47. // load the list of available timezones, build the <select> options
  48. $.getJSON('php/get-timezones.php', function(timezones) {
  49. $.each(timezones, function(i, timezone) {
  50. if (timezone != 'UTC') { // UTC is already in the list
  51. $('#timezone-selector').append(
  52. $("<option/>").text(timezone).attr('value', timezone)
  53. );
  54. }
  55. });
  56. });
  57. // when the timezone selector changes, dynamically change the calendar option
  58. $('#timezone-selector').on('change', function() {
  59. $('#calendar').fullCalendar('option', 'timezone', this.value || false);
  60. });
  61. });
  62. </script>
  63. <style>
  64. body {
  65. margin: 0;
  66. padding: 0;
  67. font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
  68. font-size: 14px;
  69. }
  70. #top {
  71. background: #eee;
  72. border-bottom: 1px solid #ddd;
  73. padding: 0 10px;
  74. line-height: 40px;
  75. font-size: 12px;
  76. }
  77. .left { float: left }
  78. .right { float: right }
  79. .clear { clear: both }
  80. #script-warning, #loading { display: none }
  81. #script-warning { font-weight: bold; color: red }
  82. #calendar {
  83. max-width: 900px;
  84. margin: 40px auto;
  85. padding: 0 10px;
  86. }
  87. .tzo {
  88. color: #000;
  89. }
  90. </style>
  91. </head>
  92. <body>
  93. <div id='top'>
  94. <div class='left'>
  95. Timezone:
  96. <select id='timezone-selector'>
  97. <option value='' selected>none</option>
  98. <option value='local'>local</option>
  99. <option value='UTC'>UTC</option>
  100. </select>
  101. </div>
  102. <div class='right'>
  103. <span id='loading'>loading...</span>
  104. <span id='script-warning'><code>php/get-events.php</code> must be running.</span>
  105. </div>
  106. <div class='clear'></div>
  107. </div>
  108. <div id='calendar'></div>
  109. </body>
  110. </html>