Guest User

Untitled

a guest
Dec 11th, 2019
77
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. _createSpecialDays: function () {
  2. var that = this,
  3. oCalendar = this.getView().byId("calendar"),
  4. dStartDate = oCalendar.getAggregation("month")[0]._getVisibleDays()[0]._oUDate.oDate,
  5. iLastMonthIndex = oCalendar.getAggregation("month").length - 1,
  6. iLastDayIndex = oCalendar.getAggregation("month")[iLastMonthIndex]._getVisibleDays().length - 1,
  7. dEndDate = oCalendar.getAggregation("month")[iLastMonthIndex]._getVisibleDays()[iLastDayIndex]._oUDate.oDate,
  8. filtredSpecialDays, filtredBackground, filtredBackgroundInitial, mergedTable = [];
  9.  
  10. dStartDate = Formatter.clearDateHMS(dStartDate);
  11. dEndDate = Formatter.clearDateHMS(dEndDate);
  12.  
  13. if (!dStartDate && !dEndDate) {
  14. var dActualDate = new Date();
  15. dStartDate = new Date(dActualDate.getFullYear(), dActualDate.getMonth() - 1, 1);
  16. dEndDate = new Date(dActualDate.getFullYear(), dActualDate.getMonth() + 1, 0);
  17. }
  18.  
  19. oCalendar.removeAllSpecialDates();
  20. filtredSpecialDays = this.oDataManager.getData().SpecialDaySet.filter(function (oDate) {
  21. return oDate.startDate.getTime() >= dStartDate.getTime() && oDate.startDate.getTime() <= dEndDate.getTime();
  22. });
  23. // Uzupełnianie luk
  24. filtredBackgroundInitial = this.oDataManager.getData().SpecialDayBackgroundSet.filter(function (oDate) {
  25. return oDate.startDate.getTime() >= dStartDate.getTime() && oDate.startDate.getTime() <= dEndDate.getTime();
  26. });
  27. filtredBackground = filtredBackgroundInitial.filter((oBack) => {
  28. return filtredSpecialDays.find((oSpecial) => {
  29. return oSpecial.startDate.getTime() === oBack.startDate.getTime();
  30. }) === undefined ? true : false;
  31. });
  32. mergedTable = [...filtredSpecialDays, ...filtredBackground];
  33.  
  34. mergedTable.forEach(function (oObject) {
  35. oCalendar.addSpecialDate(new DateTypeRange({
  36. startDate: Formatter.createDateObject(oObject.startDate),
  37. type: Formatter.specialDayType(oObject.type),
  38. tooltip: oObject.tooltip
  39. }));
  40. });
  41.  
  42. },
RAW Paste Data