|
CalendarXP.net Support Most forums here are private and invisible to public.
|
View previous topic :: View next topic |
Author |
Message |
Cady36
Joined: 16 Dec 2005 Posts: 25
|
Posted: Fri Dec 30, 2005 7:39 pm Post subject: Calling a function in Agenda.js from Plugins.js |
|
|
Hi, me again (she ducks...)
OK, I have a function in Agenda.js to highlight a series of dates based on the duration; (see previous post regarding duration);
(It's called "fFakeSelection" because I realized that I didn't actually need to SELECT anything but the first date, if I knew the duration - It just adds events based on "Selected" colors.)
function fFakeSelection(y,m,d) {
fakeSelect = new Array()
aStartDate = new Date(gContainer.rStartYear, gContainer.rStartMonth-1, gContainer.rStartDate);
for (i = 0; i < gContainer.rDuration; i++) {
fakeSelect[2]=aStartDate.getDate();
fakeSelect[1]=aStartDate.getMonth()+1;
fakeSelect[0]=aStartDate.getFullYear();
if (fakeSelect[2]==d&&fakeSelect[1]==m&&fakeSelect[0]==y) {
//Make it look the same as SELECTED dates...
fAddEvent(fakeSelect[0], fakeSelect[1], fakeSelect[2], "", null, gcBGSelected, gcFGSelected);
}
with (aStartDate) {
setDate(getDate()+1);
}}}
This works like a charm. If I set rDuration to 14 days and my start out selection is January 11, 2006, 14 days are highlighted:
Within my HTML document, if I call fFakeSelection with a new Year, Month, and Date, it erases the previous items and loads the new 14 day period, e.g.:
rStartMonth = 12;
rStartDate= 14;
rStartYear= 2005;
fFakeSelection(rStartYear,rStartMonth,rStartDate)
I need to be able to call this function from fAfterSelected(y,m,d), though, to base it on the selected date. I've tried every combination I can think of, but it won't work. (I've even tried defining a function IN my HTML page that CALLED the agenda function with passed variables, but it didn't work either.)
Do you have any suggestions?
Thanks,
Julie
|
|
Back to top |
|
|
Cady36
Joined: 16 Dec 2005 Posts: 25
|
Posted: Fri Dec 30, 2005 8:02 pm Post subject: Calling a function...additional information |
|
|
By the way, I'm using a variation on the Triplex theme, so the agenda is shared.
Thx.
Julie
|
|
Back to top |
|
|
Cady36
Joined: 16 Dec 2005 Posts: 25
|
Posted: Fri Dec 30, 2005 8:12 pm Post subject: Even MORE information... |
|
|
Sorry about the additions, but this is a project I am actively working on right now.
I just noted in the Tutorial regarding agendas:
"Note: When sharing the agenda.js file, it's important to know that any function definition, except fHoliday(), will not be shared, which means you should NOT declare any other functions in the agenda.js. If you really need an utility function, define it in the plugins.js instead. "
I moved the function to the plugins.js file and it still works (mostly) as I said before, but even calling it directly from fAfterSelected, though it is in the same file, does not work. (I created a separate version of it that gets the m/d/y variables locally.)
Thanks,
Julie
|
|
Back to top |
|
|
calendarxp Site Admin
Joined: 30 Jan 2005 Posts: 409
|
Posted: Fri Dec 30, 2005 11:28 pm Post subject: |
|
|
Julie,
After looking into your request, I found you only need to add the following code in plugins.js file of the Triplex theme:
Code: | function fAfterSelected(y,m,d,e) {
var dt=new Date(y, m-1, d);
if (!gContainer._duration)
gContainer._duration=[];
for (var i=0; i<gContainer.rDuration; i++) {
gContainer._duration[i]=[dt.getFullYear(), dt.getMonth()+1, dt.getDate()];
dt.setDate(dt.getDate()+1);
}
gContainer.gfFlat_1.fRepaint();
gContainer.gfFlat_2.fRepaint();
gContainer.gfFlat_3.fRepaint();
}
function fIsSelected(y,m,d) {
if (!gContainer._duration) return false;
var dur=gContainer._duration;
for (var i=0; i<dur.length; i++) {
if (y==dur[i][0]&&m==dur[i][1]&&d==dur[i][2])
return true;
}
return false;
} |
The selected dates will be stored in the _duration array in your HTML page (container), and the length of duration is determined by rDuration in the same page. Of course, you can hard code the rDuration (replace gContainer.rDuration with 14) in the fAfterSelected() function if you don't want to customize it in your HTML page.
_________________ Copyright 2003-2011 Idemfactor Solutions, Inc. All rights reserved. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
Copyright 2003- Idemfactor Solutions, Inc. All rights reserved.
Powered by phpBB © 2001, 2005 phpBB Group
|