calendarxp Site Admin
Joined: 30 Jan 2005 Posts: 409
|
Posted: Tue Feb 15, 2005 6:36 pm Post subject: How can I reset the system defined "today" to a date specified in the server end? |
|
|
The calendar engine uses 2 system objects gd and gToday to control the date of today. You may override them in the plugins.js file with any date you like, you can even rename it to plugins.asp to take advantage of ASP generated date.
1st, you need to prepend the following lines of code to the top of plugins.js file.
Code: | gd=new Date(2003,3-1,11); // You may use any date you want.
gToday=[gd.getFullYear(),gd.getMonth()+1,gd.getDate()];
gCurMonth=eval(gTheme[0]); // re-init the gCurMonth in case it using gToday. |
2nd, you need to search through the theme-name.js file, e.g. normal.js, for any references to gToday, and copy them to the plugins.js file and put them behind the above gCurMonth definition so that they can be re-initialized. e.g.
Code: | gd=new Date(2003,3-1,11); // You may use any date you want.
gToday=[gd.getFullYear(),gd.getMonth()+1,gd.getDate()];
gCurMonth=eval(gTheme[0]); // re-init the gCurMonth in case it using gToday.
gsBottom="..."; // re-init gsBottom if it contains reference to gToday. (optional)
gdSelect=gToday; // re-init gdSelect if it references to gToday. (optional) |
Finally, you may want to rename the plugins file to plugins.asp and use a date generated from ASP variables to replace the static one:
Code: | gd=new Date(<%= year %>,<%= month %>-1,<%= day %>); // year, month, day are server-end variables
... |
Remember to modify the name & id of the calendar iframe tag accordingly to reflect the above renaming - e.g. "gToday:normal:agenda.js::plugins.asp". You can also use path in the name & id, more details can be found in the HelloWorld tutorial.
Also note that all options in the theme-name.js can be reset and overwritten in this manner.
_________________ Copyright 2003-2011 Idemfactor Solutions, Inc. All rights reserved. |
|