Jump to content

need some help editing this function to remove any disabled weeks returned


Greywacke
 Share

Recommended Posts

hi there,the following function is part of the mod_D_Calendar module in the Joomla installation for Parktown Boys' High School. the issue is with the module generating 7 rows for the calendar months... i am struggling a bit to resolve this issue.would anybody mind helping with a bit of direction and clarity here? i am usually well versed with javascript.thanks in advance!

Link to comment
Share on other sites

is it because of the loops in the prepareDays function? The loops are set to run 7 times, in bi-month mode too. Perhaps set them to 6? (lines 148 + 200). It seems like it should handle given the ways the days start, but I don't think you'll ever need a calender to show more than six rows for weeks in month.

function prepareDays()119{120 updateReferenceDays();121 d_calendar.months[0].year = d_calendar.referenceDay.Year;122 d_calendar.months[0].monthNumber = d_calendar.referenceDay.Month;123124 var rowsToFill = 0;125 if(d_calendar.mode == "week"){126 rowsToFill = 0;127 }128 else{129 rowsToFill = d_calendar.referenceDay.getRow();130 }131 var daysInMonth0 = d_calendar.numberOfDaysInMonth[d_calendar.months[0].monthNumber - 1];132 var previousMonth0 = d_calendar.months[0].monthNumber - 2;133 if(previousMonth0 == -1){134 previousMonth0 = 11;135 }136 var daysInPreviousMonth0 = d_calendar.numberOfDaysInMonth[previousMonth0];137 var daysInNextMonth0 = 1;138 //care for leap years.139 if((d_calendar.months[0].year % 4 == 0) && (d_calendar.months[0].monthNumber == 2)){140 daysInMonth0++;141 }142 if((d_calendar.months[0].year % 4 == 0) && (previousMonth0 == 1)){143 daysInPreviousMonth0++;144 }145 var startPoint = d_calendar.referenceDay.Date - (7 * rowsToFill + d_calendar.referenceDay.Day); //count back to the start of the calendar146 for( var x = 0; x < d_calendar.months[0].weeks.length; x++)147 {148 for( var y = 0; y < 7; y++)  //change to six here?149 {150151 if(startPoint < 1)152 {153 d_calendar.months[0].weeks[x].days[y].dayNumber = 0 - (daysInPreviousMonth0 + startPoint);//"";154 }155 else if(startPoint > daysInMonth0)//d_calendar.numberOfDaysInMonth[d_calendar.months[0].monthNumber - 1])156 {157 d_calendar.months[0].weeks[x].days[y].dayNumber = 0 - daysInNextMonth0;//"";158 daysInNextMonth0++;159 }160 else161 {162 d_calendar.months[0].weeks[x].days[y].dayNumber = startPoint;163 }164 startPoint++;165 }166 }167168 if(d_calendar.mode == "bimonth")169 {170 d_calendar.months[1].year = d_calendar.referenceDayNextMonth.Year;171 d_calendar.months[1].monthNumber = d_calendar.referenceDayNextMonth.Month;172173 var rowsToFill2 = 0;174 if(d_calendar.mode == "week"){175 rowsToFill2 = 0;176 }177 else{178 rowsToFill2 = d_calendar.referenceDayNextMonth.getRow();179 }180 var daysInMonth1 = d_calendar.numberOfDaysInMonth[d_calendar.months[1].monthNumber - 1];181 var previousMonth1 = d_calendar.months[1].monthNumber - 2;182 if(previousMonth1 == -1){183 previousMonth1 = 11;184 }185 var daysInPreviousMonth1 = d_calendar.numberOfDaysInMonth[previousMonth1];186 var daysInNextMonth1 = 1;187188 //care for leap years.189 if((d_calendar.months[1].year % 4 == 0) && (d_calendar.months[1].monthNumber == 2))190 {191 daysInMonth1++;192 }193 if((d_calendar.months[1].year % 4 == 0) && (previousMonth1 == 1)){194 daysInPreviousMonth1++;195 }196197 var startPoint2 = d_calendar.referenceDayNextMonth.Date - (7 * rowsToFill2 + d_calendar.referenceDayNextMonth.Day); //count back to the start of the calendar198 for( var x = 0; x < d_calendar.months[1].weeks.length; x++)199 {200 for( var y = 0; y < 7; y++)  //change to six here?201 {202 if(startPoint2 < 1)203 {204 d_calendar.months[1].weeks[x].days[y].dayNumber = 0 - (daysInPreviousMonth1 + startPoint2);//"";205206 }207 else if(startPoint2 > daysInMonth1)//d_calendar.numberOfDaysInMonth[d_calendar.months[1].monthNumber - 1])208 {209 d_calendar.months[1].weeks[x].days[y].dayNumber = 0 - daysInNextMonth1;//"";210 daysInNextMonth1++;211 }212 else213 {214 d_calendar.months[1].weeks[x].days[y].dayNumber = startPoint2;215 }216 startPoint2++;217 }218 }219 }220221222}

Edited by thescientist
Link to comment
Share on other sites

nevermind, have resized the components to encompass the size :)issue is now resolved :)ps: will change to 6 if the client wants that... another line 145 and 197, and i am sure more also use the number 7 that would possibly impact the script...

Edited by Pierre 'Greywacke' du Toit
Link to comment
Share on other sites

hi there, attempted modifying this in the D_Calendar.js file where this function is called and unfortunately then - the calendar does not render! :) have an idea they will settle for the 7 line calendar then...just this other issue that is left ( http://w3schools.invisionzone.com/index.ph...st&p=198670 ) then done :)

Edited by Pierre 'Greywacke' du Toit
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...