timezones.html 2.9 KB

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