Witam,

mam taki app.js znaleziony gdzieś w necie:

[JAVASCRIPT] pobierz, plaintext
  1. var app = app || {};
  2.  
  3. app.calendar = {
  4. date: {
  5. names: {
  6. months: ['Styczeń','Luty','Marzec','Kwiecień','Maj','Czerwiec','Lipiec','Sierpień','Wrzesień','Październik','Listopad','Grudzień'],
  7. monthsShortEng: ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],
  8. days: ['Niedziela','Poniedziałek','Wtorek','Środa','Czwartek','Piątek','Sobota'],
  9. daysShort: ['Pon.','Wt.','Śr.','Czw.','Piąt.','Sob.','Niedz.']
  10. },
  11. actual: {
  12. dayOfWeek: new Date().getDay(),
  13. day: new Date().getDate(),
  14. month: new Date().getMonth(),
  15. year: new Date().getFullYear(),
  16. hour: parseInt((new Date().getHours()<10?'0':'') + new Date().getHours()),
  17. minutes: parseInt((new Date().getMinutes()<10?'0':'') + new Date().getMinutes())
  18. },
  19. get: {
  20. firstDayOfMonth: function(month,year){
  21. return new Date(year,month,0).getDay();
  22. },
  23. monthsBetwenDates: function(month1,year1,month2,year2){
  24. var date1 = new Date(year1,month1,1),
  25. date2 = new Date(year2,month2,1),
  26. year1 = date1.getFullYear(),
  27. year2 = date2.getFullYear(),
  28. month1 = date1.getMonth(),
  29. month2 = date2.getMonth();
  30. if(month1 === 0){
  31. month1++;
  32. month2++;
  33. }
  34. return (year2 - year1) * 12 + (month2 - month1);
  35. },
  36. dayInMonth: function(month,year){
  37. return new Date(year,month+1,0).getDate();
  38. },
  39. dayInLastMonth: function(month,year){
  40. return new Date(year,month,0).getDate();
  41. },
  42. dayInNextMonth: function(month,year){
  43. return new Date(year,month+2,0).getDate();
  44. }
  45. }
  46. },
  47. currentMonthDays: function(month,year,dayInMonth,numberOfLastMonthDay){
  48. var numberOfDays = 42;
  49.  
  50. // 0 - disable, 1 - this month disable, 2 - enable, 3 - current day
  51. var typeOfDaysToRender = [];
  52. var actualDateTime = parseInt((new Date().getTime() / 1000).toFixed(0));
  53.  
  54. for(var i0=1;i0<=numberOfLastMonthDay;++i0){ typeOfDaysToRender.push(0); numberOfDays--; }
  55. for(var i1=1;i1<=dayInMonth;++i1){
  56. var dateTime = parseInt((new Date(i1+'-'+this.date.names.monthsShortEng[month]+'-'+year).getTime() / 1000).toFixed(0));
  57. if(dateTime < actualDateTime && parseInt(dateTime + 86400) > actualDateTime){
  58. typeOfDaysToRender.push(3);
  59. }else if(dateTime < actualDateTime){
  60. typeOfDaysToRender.push(1);
  61. }else{
  62. typeOfDaysToRender.push(2);
  63. }
  64. numberOfDays--;
  65. }
  66. for(var i2=1;i2<=numberOfDays;++i2){ typeOfDaysToRender.push(0); }
  67.  
  68. return typeOfDaysToRender;
  69. },
  70. renderCalendarClock: function(){
  71. var getHours = new Date().getHours(),
  72. getMinutes = new Date().getMinutes();
  73.  
  74. if(getHours < 10){
  75. getHours = '0'+getHours;
  76. }
  77. if(getMinutes < 10){
  78. getMinutes = '0'+getMinutes;
  79. }
  80.  
  81. $('#calendar-control').find('.time-hours').html(getHours);
  82. $('#calendar-control').find('.time-minutes').html(getMinutes);
  83. setTimeout(function(){
  84. app.calendar.renderCalendarClock();
  85. },1000);
  86. },
  87. renderCalendarNavi: function(month,year){
  88. var newMonthPrev, newMonthNext, newYearPrev, newYearNext, monthModifier;
  89. var actualMonth = this.date.actual.month,
  90. actualYear = this.date.actual.year;
  91.  
  92. if(month == 0 || month == 11){
  93. if(month == 0){
  94. newMonthPrev = parseInt(11);
  95. newMonthNext = parseInt(month + 1);
  96. newYearPrev = parseInt(year - 1);
  97. newYearNext = parseInt(year);
  98. monthModifier = parseInt(0);
  99. }else{
  100. newMonthPrev = parseInt(month - 1);
  101. newMonthNext = parseInt(0);
  102. newYearPrev = parseInt(year);
  103. newYearNext = parseInt(year - -1);
  104. monthModifier = parseInt(0);
  105. }
  106. }else{
  107. newMonthPrev = parseInt(month);
  108. newMonthNext = parseInt(month);
  109. newYearPrev = parseInt(year);
  110. newYearNext = parseInt(year);
  111. monthModifier = parseInt(1);
  112. }
  113.  
  114. $('#calendar-last-month,#calendar-next-month').removeClass('disable');
  115.  
  116. if(this.date.get.monthsBetwenDates(actualMonth,actualYear,month,year) > 11){
  117. $('#calendar-next-month').attr('data-calendar-navi','false').addClass('disable');
  118. }else{
  119. $('#calendar-next-month').attr('data-calendar-navi',parseInt(newMonthNext+monthModifier)+'/'+parseInt(newYearNext));
  120. }
  121.  
  122. if(this.date.get.monthsBetwenDates(actualMonth,actualYear,month,year) < -2){
  123. $('#calendar-last-month').attr('data-calendar-navi','false').addClass('disable');
  124. }else{
  125. $('#calendar-last-month').attr('data-calendar-navi',parseInt(newMonthPrev-monthModifier)+'/'+parseInt(newYearPrev));
  126. }
  127.  
  128. $('#calendar-control').find('.month').html(this.date.names.months[month]);
  129. $('#calendar-control').find('.year').html(year);
  130. },
  131. renderCalendar: function(month,year){
  132. var dayInMonth = this.date.get.dayInMonth(month,year),
  133. dayInLastMonth = this.date.get.dayInLastMonth(month,year),
  134. dayInNextMonth = this.date.get.dayInNextMonth(month,year),
  135. numberOfLastMonthDay = this.date.get.firstDayOfMonth(month,year);
  136.  
  137. if(numberOfLastMonthDay == 0){
  138. numberOfLastMonthDay = 7;
  139. }
  140.  
  141. var typeOfDaysToRender = this.currentMonthDays(month,year,dayInMonth,numberOfLastMonthDay),
  142. lastMonthStartDay = parseInt(dayInLastMonth - numberOfLastMonthDay);
  143. var actualDay, day = 0, dayNameOfWeek = 0, lastMonth = true;
  144.  
  145. this.renderCalendarNavi(month,year);
  146.  
  147. $('#calendar').empty();
  148.  
  149. $.ajax({
  150. type: 'POST',
  151. url: '/wp-admin/admin.php?page=multi_booking_calendar',
  152. data: {
  153. action: 'getCalendar',
  154. month: month,
  155. },
  156. success: function(response){
  157. window.dayInCalendar = JSON.parse(response.split('<!--CUT-->')[1]);
  158.  
  159. $.each(typeOfDaysToRender,function(i){
  160. var specialClass, dayCopyElement, thisMonth, dataAttrDate, thisDayOccupied = false;
  161.  
  162. val = typeOfDaysToRender[i];
  163. if(val == 0){
  164. lastMonthStartDay++;
  165. actualDay = lastMonthStartDay;
  166. specialClass = 'disable';
  167. }else{
  168. day++;
  169. actualDay = day;
  170. if(val == 1){
  171. specialClass = 'block';
  172. }
  173. if(val == 3){
  174. specialClass = 'today active';
  175. }
  176. if($.inArray(parseInt(actualDay),window.dayInCalendar) > -1){
  177. thisDayOccupied = true;
  178. specialClass += ' busy';
  179. }
  180. dataAttrDate = (actualDay<10?'0'+actualDay:actualDay)+'/'+(parseInt(month+1)<10?'0'+parseInt(month+1):parseInt(month+1))+'/'+year;
  181. }
  182.  
  183. dayCopyElement = $('#calendar-elems').children('.day').clone();
  184. dayCopyElement.addClass(specialClass);
  185. dayCopyElement.attr('data-attr-date',dataAttrDate);
  186. dayCopyElement.find('.day').html(actualDay);
  187. dayCopyElement.find('.day-name').html(app.calendar.date.names.daysShort[dayNameOfWeek]);
  188. if(thisDayOccupied){
  189. dayCopyElement.find('select').val(1);
  190. }
  191. thisDayOccupied
  192.  
  193. $('#calendar').append(dayCopyElement);
  194.  
  195. if(lastMonthStartDay == dayInLastMonth){
  196. lastMonthStartDay = 0;
  197. }
  198.  
  199. dayNameOfWeek++;
  200. if(dayNameOfWeek == 7){
  201. dayNameOfWeek = 0;
  202. lastMonth = false;
  203. }
  204. });
  205.  
  206. }
  207. });
  208. }
  209. };
[JAVASCRIPT] pobierz, plaintext



Ten skrypt generuje kalendarz na rok od bieżącej daty a chciałbym mieć na dwa lata... Jest to na pewno jakaś mała zmiana ale nie jestem w stanie go do końca zrozumieć i tego znaleść... myślałem, że to tutaj:
[JAVASCRIPT] pobierz, plaintext
  1. if(this.date.get.monthsBetwenDates(actualMonth,actualYear,month,year) > 25){
  2. $('#calendar-next-month').attr('data-calendar-navi','false').addClass('disable');
  3. }else{
  4. $('#calendar-next-month').attr('data-calendar-navi',parseInt(newMonthNext+monthModifier)+'/'+parseInt(newYearNext));
  5. }
[JAVASCRIPT] pobierz, plaintext


ale jednak nie...

z góry wielkie dzięki bo już za długo nad tym siedzę..

ktos, coś ? mogę nawet zlecić to komuś smile.gif