Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. <div class="calendar">
  2. <table>
  3. <tr>
  4. <th><h4>PON</h4></th>
  5. <th><h4>WTO</h4></th>
  6. <th><h4>SRO</h4></th>
  7. <th><h4>CZW</h4></th>
  8. <th><h4>PIĄ</h4></th>
  9. <th><h4>SOB</h4></th>
  10. <th><h4>NIE</h4></th>
  11. </tr>
  12. </table>
  13. </div>
  14.  
  15. var Calendar = {
  16.  
  17. customDate: function (date) {
  18. return new Date(date)
  19. },
  20.  
  21. currentDay: function () {
  22. return new Date().getDay();
  23. },
  24.  
  25. currentMonth: function () {
  26. return new Date().getMonth() + 1;
  27. },
  28.  
  29. currentYear: function () {
  30. return new Date().getFullYear();
  31. },
  32.  
  33. getMonthDays: function (year, month) {
  34. return new Date(year, month, 0).getDate();
  35. },
  36.  
  37. currentMonthDays: function () {
  38. return this.getMonthDays(this.currentYear(), this.currentMonth());
  39. }
  40.  
  41. Calendar.createCustomCalendar = function (month, year) {
  42.  
  43. var currentDays = Calendar.getMonthDays(year, month),
  44. day = 1,
  45. monthDay = Calendar.currentDay(month, year),
  46. calendar = jQuery('.calendar'),
  47. table = calendar.find('table');
  48.  
  49. calendar.prepend('<h2>' + month + ' ' + year + '</h2>');
  50.  
  51.  
  52. for (var row = 1; row <= Math.ceil(currentDays / 7); row++) {
  53.  
  54. var tableRow = jQuery('<tr class="calendarRow"></tr>');
  55.  
  56. for (col = 1; col <= 7 && day <= currentDays; col++, day++) {
  57. jQuery(tableRow).append('<td>' + day + '</td>');
  58. }
  59.  
  60. table.append(tableRow);
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement