timezones.html 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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: '2014-09-12',
  37. timezone: currentTimezone,
  38. editable: true,
  39. eventLimit: true, // allow "more" link when too many events
  40. events: {
  41. url: 'php/get-events.php',
  42. error: function() {
  43. $('#script-warning').show();
  44. }
  45. },
  46. loading: function(bool) {
  47. $('#loading').toggle(bool);
  48. },
  49. eventRender: function(event, el) {
  50. // render the timezone offset below the event title
  51. if (event.start.hasZone()) {
  52. el.find('.fc-title').after(
  53. $('<div class="tzo"/>').text(event.start.format('Z'))
  54. );
  55. }
  56. }
  57. });
  58. }
  59. renderCalendar();
  60. });
  61. </script>
  62. <style>
  63. body {
  64. margin: 0;
  65. padding: 0;
  66. font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
  67. font-size: 14px;
  68. }
  69. #top {
  70. background: #eee;
  71. border-bottom: 1px solid #ddd;
  72. padding: 0 10px;
  73. line-height: 40px;
  74. font-size: 12px;
  75. }
  76. .left { float: left }
  77. .right { float: right }
  78. .clear { clear: both }
  79. #script-warning, #loading { display: none }
  80. #script-warning { font-weight: bold; color: red }
  81. #calendar {
  82. max-width: 900px;
  83. margin: 40px auto;
  84. padding: 0 10px;
  85. }
  86. .tzo {
  87. color: #000;
  88. }
  89. </style>
  90. </head>
  91. <body>
  92. <div id='top'>
  93. <div class='left'>
  94. Timezone:
  95. <select id='timezone-selector'>
  96. <option value='' selected>none</option>
  97. <option value='local'>local</option>
  98. <option value='UTC'>UTC</option>
  99. </select>
  100. </div>
  101. <div class='right'>
  102. <span id='loading'>loading...</span>
  103. <span id='script-warning'><code>php/get-events.php</code> must be running.</span>
  104. </div>
  105. <div class='clear'></div>
  106. </div>
  107. <div id='calendar'></div>
  108. </body>
  109. </html>