Problem
2008/02/02 17:18
Viewed 3108 times
Replies: 3/3

Hi!

I have a page generated with ajax. The page generates a code into a div, and I thought it should work, but not! My question is: this calendar is compatible with the ajax (i mean, it is a working solution or not?)?

p.s: the page is: http://www.babaszemesz.hu/vizsgalat.html, sorry for the bad english

last
» Re: Problem, by Ranga [ quick view ]
» Re: Problem, by Ranga [ quick view ]
» Re: Problem, by Ranga [ quick view ]
Duplucate key events after alert() in IE
2008/02/05 22:04
Viewed 2142 times
Replies: 0/0
by void

I have an issue with the DHtml Calendar in IE6 (haven't tried IE7): after I click the About button ("?"), the keyboard events are duplicated. The first alert makes the day change twice, the second three times, and so on. Is this a known bug? Has anyone found a solution for this issue?

Thanks in advance.

P.S. Nice work, it's still my favorite calendar :)

P.P.S. Please add a link/button for creating new threads, it's counter-intuitive having to go back to the 'root' to able to do so.

last
returning week or month
2008/02/07 15:41
Viewed 2262 times
Replies: 1/1

Great Widget, very cool.

I have successfully setup a calendar to fill in a form field with the selected date.

Has anyone coded a method of having the calendar return a selected month(and year) or week(and year)

Ideally it would return the start date of the selection.
eg. if the viewer selected March 10th. 2008 it would return 2008/03/10(does that already)
but if the viewer selected March 2008, then it would return 2008/03/01
and if the viewer selected Week 11 of 2008, it would return 2008/03/17

TIA

Paul

last
Re: returning week or month
2008/02/16 00:36
Viewed 2712 times
Replies: 0/0

Interesting idea, but it would probably require adding in your own event handlers for clicking other objects in the calendar that currently don't have any particular user interaction (such as clicking a week number, which currently does nothing) or overriding methods that are only internally controlled (like selecting a month from the drop list). In theory you could write your own methods to the Calendar object. There's another calendar widget out there that allows you to construct the calendar based on the type of selection you want returned:
http://www.mattkruse.com/javascript/calendarpopup
You can see at the bottom of the demo the different types of calendars you can generate.

last
Calendar transparent ie7
2008/02/12 03:38
Viewed 2335 times
Replies: 0/0

I am having trouble with the calendar - only in IE7.

When I activate it, it shows up transparently over the other items on the screen. The odd thing is that it is almost as if the CSS is not being read. The fonts are wrong, there are no graphics / colours, etc. (except for the main Month, year at the top which is wierd). It seems to work though. If I pick a date it is entered correctly in my input field.

Note that this has been working for several years in Mozilla, ie6, opera, etc. but this is my first time testing it in ie7. I've also tried it on 2 different ie7 machines - both with the same problem.

Thanks in advance for any help.

last
Date.prototype patch-ins
2008/02/14 03:25
Viewed 2271 times
Replies: 0/0

Just thought these might come in handy for someone. i shortened the Date.prototype.equalsTo method - i don't know if it's any faster, since it calls print(), but if someone wants to benchmark it, please follow up the results.
Also added two other methods for comparing dates: isBefore, isAfter do pretty much what they look like.
i've left alternate approaches commented. i primarily use these in determining date status (disabled or not).

And by the way: i used this widget two years ago on a project and it was awesome then. It's phenomenal now. Any thoughts on porting the code to any of the popular libraries like Prototype or Mootools?

** Checks date and time equality *
Date.prototype.equalsTo = function(date) {
return parseInt(this.print('%Y%m%d')) == parseInt(date.print('%Y%m%d'));
// return ((this.getFullYear() == date.getFullYear()) &&
// (this.getMonth() == date.getMonth()) &&
// (this.getDate() == date.getDate()) &&
// (this.getHours() == date.getHours()) &&
// (this.getMinutes() == date.getMinutes()));
};

/** Checks if current Date object is earlier than (date) -- IGNORES TIME for now */
Date.prototype.isBefore = function(date){
return parseInt(this.print('%Y%m%d')) < parseInt(date.print('%Y%m%d'));
// var thisD = {yr:this.getFullYear(),mo:this.getMonth(),da:this.getDate()/*,hr:this.getHours(),mi:this.getMinutes()*/};
// var dateD = {yr:date.getFullYear(),mo:date.getMonth(),da:date.getDate()/*,hr:date.getHours(),mi:date.getMinutes()*/};
// return ((thisD.yr < dateD.yr) ||
// (thisD.yr == dateD.yr && thisD.mo < dateD.mo) ||
// (thisD.yr == dateD.yr && thisD.mo == dateD.mo && thisD.da < dateD.da)/* ||
// (thisD.yr == dateD.yr && thisD.mo == dateD.mo && thisD.da == dateD.da && thisD.hr < dateD.hr) ||
// (thisD.yr == dateD.yr && thisD.mo == dateD.mo && thisD.da == dateD.da && thisD.hr == dateD.hr && thisD.mi < dateD.mi)*/);
};

/** Checks if current Date object is later than (date) -- IGNORES TIME for now */
Date.prototype.isAfter = function(date){
return parseInt(this.print('%Y%m%d')) > parseInt(date.print('%Y%m%d'));
// var thisD = {yr:this.getFullYear(),mo:this.getMonth(),da:this.getDate()/*,hr:this.getHours(),mi:this.getMinutes()*/};
// var dateD = {yr:date.getFullYear(),mo:date.getMonth(),da:date.getDate()/*,hr:date.getHours(),mi:date.getMinutes()*/};
// return ((thisD.yr > dateD.yr) ||
// (thisD.yr == dateD.yr && thisD.mo > dateD.mo) ||
// (thisD.yr == dateD.yr && thisD.mo == dateD.mo && thisD.da > dateD.da)/* ||
// (thisD.yr == dateD.yr && thisD.mo == dateD.mo && thisD.da == dateD.da && thisD.hr > dateD.hr) ||
// (thisD.yr == dateD.yr && thisD.mo == dateD.mo && thisD.da == dateD.da && thisD.hr == dateD.hr && thisD.mi > dateD.mi)*/);
};

last
Unary Function? Help!
2008/02/14 18:24
Viewed 2110 times
Replies: 1/1

from line 1257 of calendar.js:
/**
* Allows customization of what dates are enabled. The "unaryFunction"
* parameter must be a function object that receives the date (as a JS Date
* object) and returns a boolean value. If the returned value is true then
* the passed date will be marked as disabled.
*/
Calendar.prototype.setDateStatusHandler = Calendar.prototype.setDisabledHandler = function (unaryFunction) {
this.getDateStatus = unaryFunction;
};

How exactly do I set the unary function?
I want to disable all dates after today

I tried this to no avail:
Calendar.prototype.unaryFunction = function (date){
var myDate = new Date();

if (date>myDate){
return true;
}
return false;
}

Help? Anyone?

last
Re: Unary Function? Help!
2008/02/16 00:22
Viewed 2785 times
Replies: 0/0

At 2008/02/14 18:24, trickyidiot wrote:

from line 1257 of calendar.js:
/**
* Allows customization of what dates are enabled. The "unaryFunction"
* parameter must be a function object that receives the date (as a JS Date
* object) and returns a boolean value. If the returned value is true then
* the passed date will be marked as disabled.
*/
Calendar.prototype.setDateStatusHandler = Calendar.prototype.setDisabledHandler = function (unaryFunction) {
this.getDateStatus = unaryFunction;
};

How exactly do I set the unary function?
I want to disable all dates after today

I tried this to no avail:
Calendar.prototype.unaryFunction = function (date){
var myDate = new Date();

if (date>myDate){
return true;
}
return false;
}

Help? Anyone?

"unaryFunction" is just a variable referring to a function Object passed into the  setDateStatusHandler (or setDisabledHandler) method when you're setting up the calendar.

Depending on which construction method you use (per the detailed documentation), your construction might look something like:

var calendarSelectFunction = function(calendar, date){
  // Stuff to do with the calendar and date variables
  calendar.callCloseHandler();
}
var setDisabledDatesFunction = function(date,year,month,day){
  return new Date() < date;

  /* "date" is a date on the currently displayed month
of the calendar, so this function is called for EACH
day of the month visible to the user. When a user
changes months/years, this function is called again
for each day of the newly-displayed month. When the
user goes to next or last month, its dates are evaluated
against this code: */
// Should return FALSE until you hit tomorrow's date,
// then becomes TRUE for any dates after today:
// This function would also be used to determine if
// "date" is among user-defined special dates...see manual
}
var calendarCloseFunction = function(calendar){ calendar.hide(); }
Calendar.setup({
displayArea:'divIDToPutChosenDate',
onSelect:calendarSelectFunction,
onClose:closeCalendar,
dateStatusFunc:setDisabledDatesFunction
});

Notice how the functions i defined are actually assigned to variables? It makes them a lot more portable and easier to pass into other Objects (such as the options list defining the Calendar. Also notice that although the functions that the variables are assigned to accept required arguments, when you place that variable in the Calendar construction, you don't include the argument list. That's kind of the jist of a unary Function. It's just a function object, then the code inside the Calendar class makes use of that function reference later, adding the arguments to the call.

If you're taking the object constructor approach [var calVariable = new Calendar()], then you SET the dateStatusFunc through a method. In this case, your set up would look more like (using the same user-defined functions as above):

var cal = new Calendar(0,null,calendarSelectFunction,calendarCloseFunction);
cal.setDateStatusHandler(setDisabledDatesFunction);
etc.

Remove the "Calendar.prototype.unaryFunction" code you added to the calendar.js file (or wherever it currently is). Construct a function that determines the status of dates, then pass the NAME OF THE FUNCTION to setDateStatusHandler() or to the property name dateStatusFunc if using Calendar.setup().


last
How to make sure that start date + duration = exp. date ?
2008/02/15 19:12
Viewed 2197 times
Replies: 0/0

Hi,
I am using a Calendar to choose a start date.
I have also drop down menu where you can select the duration in days.
Once the user select sth in any of the two fields the calculated result (start date + duration) should be presented in exp. date field.

I am using the following function to calculate the exp.Date:

function calculateExpDate(cal) {

var date = cal.date;
var time = date.getTime()
var subscription = document.datesBean.subscriptionDuration.value;

time = time + (Date.DAY * subscription) ;
var date2 = new Date(time); //new date
var expDate = date2.print("%Y-%m-%d");

//set the date in the expDate field
document.datesBean.formExpDate.value = expDate;
}

This method is invoked after changing calendar value and after choosing a dropdown value.

If at first I choose the date in calendar and then duration everything is OK,the function obviously works correctly.

However I have problem if at first I choose the subscription duration, then the method cannot calculate the expDate because the calendar is undefined (cal is null)

And I don't know how to initialize the calendar with the value from datesBean before manually choosing the date in the calendar. The calendar is configured using "regular" setup method.

My second problem is when someone changes the date manually in the input field (without choosing the calendar). How can I make aware the calendar of a new date? (And i don't want to make this field readonly).

Thanks for any suggestions.
I am not very familiar with JS so any help would be appreciated.

Alicja

last
Bug with special characters
2008/02/20 15:03
Viewed 2032 times
Replies: 0/0

I encountered a subtle bug in the Date.parseDate function when using full months names in French (it probably concerns other languages with special characters) too.

The behavior was the following :

  • The values of the date fields are generated server-side in Java, using the same format as used in the Javascript : "ifFormat : "%A %d %B %Y à %k:%M"
  • The calendar works fine, except when the name of the month contains an accentuated character (like in French in "Février", "Août" and "Décembre"), where the date picked by the calendar when clicking on the trigger image seems to be randomly moved, always posterior to the real date. E.g. if the date in the text field is the 20 of february (février), the date displayed in the calendar is the 13 of may or so.

After a few hours digging, I find the cause of the bug and managed to fix it...

Cause of the bug :

  • The string.split() javascript function as used in calendar.js, line 1589 doesn't recognize the accentuated characters in unicode. So it splits the date at the character index, e.g. :

var a = str.split(/\W+/);

normal : "12 janvier 2008 à 12:00" --> ["12", "janvier", "2008", "à", "12", "00"]
with accents : "12 février 2008" --> ["12","f","vrier", "2008", "à", "12", "00"]

This behavior was found on IE7 and Firefox 2.0. I didn't test any other browser.

In my particular date format it caused the index where the hour should have been contained, to contain the year ("2008") instead. So that finally, the Date object was created with an hour value of 2008, which postponed the date of about two and a half months !

Fix :

replace

var a = str.split(/\W+/);

With :

var reg=new RegExp("[ ,:;]+", "g"); //add other possible separators used in your date format here together with the [ ,:;]
var a = str.split(reg);

This fix is made in Calendar.js, line 1589.

Maybe this can be useful and save somebody else a few hours of hair pulling sometime... Or you might even want to include the fix in the official version...

Regards,

Pierre Henry

last
Calendar does not display TIME
2008/02/22 07:42
Viewed 2236 times
Replies: 1/3
by John

Hi Guys,

I downloaded the Calendar and while the examples work great, I cannot get the TIME component to show up at all when I draw the calendar in my JSP. I just get the word TIME: and then there is a blank line after it in the calendar.
When I select the date, the time value DOES get populated in the target text box but it just doesn't show.I am using IE6.0.

My includes are as follows :
<link rel = "stylesheet" href = "styles/calendar-win2k-cold-1.css" type="text/css"/>
<script type="text/javascript" src="scripts/calendar/calendar.js"></script>
<script type="text/javascript" src="scripts/calendar/calendar-setup.js"></script>
<script type="text/javascript" src="scripts/calendar/lang/calendar-en.js"></script>

and I am calling the Calendar as follows:
<script type="text/javascript"> Calendar.setup({ inputField : "studyGroupMeetingTime", ifFormat : "%d/%m/%Y %H:%M", button : "calendarTrigger", showsTime : true, timeFormat : "24"}); </script>

Any help will be MUCH appreciated.
Thanks,
John

last
Re: Calendar does not display TIME
2008/02/22 20:09
Viewed 3031 times
Replies: 1/2

Try changing

timeFormat : "24"

to

timeFormat : 24

without the quotes. That's what I have and it seems to work.

last
Week numbers differ?
2008/02/22 10:11
Viewed 2201 times
Replies: 0/0

What's going on with week numbers?

For example this page:
http://www.dynarch.com/projects/calendar/
shows that it is a week 7.

And this page:
http://www.dynarch.com/demos/jscalendar/
shows that it is a week 8 (that is correct)

Why does this happen and how to deal with it?

last
Calendar not defined
2008/02/25 20:45
Viewed 2959 times
Replies: 0/0

Don't know why but I have to copy and paste all the code in calendar.js into the <head></head> tags of the .html to initialize the calendar. Otherwise I get the error "Calendar it's not defined" [IE 7]
Besides this; all worked fine until I put the html form with the pop-up calendar into the innerHTML property of a DIV by Ajax. It doesn't display anymore and throws no js errors :-S
I´m completely lost !!! Tried the adding of the z-index statement, but nothing :-(
Any sugestions ??

last
Calendar display error: mere frame w/o days (undefined content)
2008/02/28 10:25
Viewed 2796 times
Replies: 0/0

http://r-ws.org/download/08-02-28_calendarbug.jpg

Hi!

I have this screenshot for you to show my problem: The calendar loads in properly, yet the actual calendar-content won't be started right. I am sure I included something wrong, can't figure out what that may be though.

I used the included PHP class DHTML_calendar. I checked the includes (both stripped and un-stripped version)
INCLUDED calendar(_stripped).js
INCLUDED calendar-setup(_stripped).js

The same goes for the language and css file (as the screenshot shows).

What else must I consider?

Please help! Thanks so much!!

last
Google