memory_leak.html 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset='utf-8' />
  5. <link href='../dist/fullcalendar.css' rel='stylesheet' />
  6. <link href='../dist/fullcalendar.print.css' rel='stylesheet' media='print' />
  7. <script src='../lib/moment/moment.js'></script>
  8. <script src='../lib/jquery/dist/jquery.js'></script>
  9. <script src='../lib/jquery-ui/ui/jquery-ui.js'></script>
  10. <script src='../dist/fullcalendar.js'></script>
  11. <script>
  12. $(document).ready(function() {
  13. var count = 0;
  14. var intervalID;
  15. $('#start').on('click', start);
  16. $('#stop').on('click', stop);
  17. function start() {
  18. initCalendar();
  19. intervalID = setInterval(function() {
  20. destroyCalendar();
  21. initCalendar();
  22. if (count > 100) {
  23. stop();
  24. }
  25. count++;
  26. }, 200);
  27. }
  28. function stop() {
  29. if (intervalID) {
  30. clearInterval(intervalID);
  31. intervalID = null;
  32. }
  33. destroyCalendar();
  34. }
  35. function initCalendar() {
  36. $('#calendar').fullCalendar({
  37. header: {
  38. left: 'prev,next today',
  39. center: 'title',
  40. right: 'month,agendaWeek,agendaDay'
  41. },
  42. defaultDate: '2014-06-12',
  43. defaultView: 'month', // agendaWeek
  44. editable: true,
  45. selectable: true,
  46. droppable: true,
  47. events: [
  48. {
  49. title: 'All Day Event',
  50. start: '2014-06-01'
  51. },
  52. {
  53. title: 'Long Event',
  54. start: '2014-06-07',
  55. end: '2014-06-10'
  56. },
  57. {
  58. id: 999,
  59. title: 'Repeating Event',
  60. start: '2014-06-09T16:00:00'
  61. },
  62. {
  63. id: 999,
  64. title: 'Repeating Event',
  65. start: '2014-06-16T16:00:00'
  66. },
  67. {
  68. title: 'Meeting',
  69. start: '2014-06-12T10:30:00',
  70. end: '2014-06-12T12:30:00'
  71. },
  72. {
  73. title: 'Lunch',
  74. start: '2014-06-12T12:00:00'
  75. },
  76. {
  77. title: 'Birthday Party',
  78. start: '2014-06-13T07:00:00'
  79. },
  80. {
  81. title: 'Click for Google',
  82. url: 'http://google.com/',
  83. start: '2014-06-28'
  84. }
  85. ]
  86. });
  87. }
  88. function destroyCalendar() {
  89. $('#calendar').fullCalendar('destroy');
  90. }
  91. });
  92. </script>
  93. <style>
  94. body {
  95. margin: 0;
  96. padding: 0;
  97. font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
  98. font-size: 14px;
  99. }
  100. #calendar {
  101. width: 900px;
  102. margin: 40px auto;
  103. }
  104. </style>
  105. </head>
  106. <body>
  107. <button id='start'>START</button>
  108. <button id='stop'>STOP</button>
  109. <div id='calendar'></div>
  110. </body>
  111. </html>