Popup Calendar

L

Lasse Reichstein Nielsen

danilo said:
This Javascript + DHTML source code able to show a popup calendar to select
one date in your web pages, complete the full sourcecode and its free
distribuite (GNU lic) http://www.prioregroup.com/dhtmlcalendar.html :)

Looks nice. Works in Opera 7. However, it fails in Mozilla. I noticed
a use of "innerText", which is a proprietary Microsoft invention not
implemented by Mozilla. There might be more.

The only comment I have to how it looks is that it always has Sundays
first, where I would expect, e.g., German calendars to have Sundays
last.

For the code, I would prefer a more parameterized design, where you
create a new calendar by giving it the names of days and months and
the format of text dates (and whether to put Sundays first :), instead
of having that information hardcoded in various parts of the code.
That would make it, slightly, easier to adjust to other nationalities.

Likewise for the generated HTML. Instead of inlining a lot of styles,
the elements could have classes so the author could just swap a
stylesheet to make the calendar look different.

And for addEvent, I would use feature detection instead of try/catch.
It's cleaner and more likely to work in older browsers (but the calendar
probably doesn't work in older browsers anyway).


Good job
/L
 
A

Alberto

He is working on that, he is using event.srcElement, I suggested to him in
an italian newsgroup, in order to produce compatibility with Mozilla which
he desires,
to give a name to the argument passed as an event, say (traditionally) "e":

function foo(e){
var object==(typeof(event)!="undefined")?event.srcElement:e.target;
//bla bla
}

that should be the good start to work latger on on Mozilla too.

Achieved with a shortcut statement, alternative way:

var object;
if( typeof(event)!="undefined") ){
object=event.srcElement;
}
else{
object=e.target;
};
if(!object) bla bla, dont think he can achieve compatibility with NS4, but
that was arguably never his goal.

The code above can be changed removing the brackets after typeof if one
doesn't like them, and the trailing column if one doesn't like it.
Irrelevant details.

innerText should be replaced with innerHTML. Reichstein is absolutely right
about it. Yeah, to be precise, the W3C recommandation argues nodes should be
added one at a time. Yet if he does that by innerHTML, he achieves the
result as well, which is what matters to not too purist eyes.

It's so nifty an application that I linked him to my website.
I suggest everybody have a look at what a nice thing he has done. Worth your
time, and it seems to me Reichstein concurs.

Additionally, he could provide a drop down menu with the returned formats of
the date. Reichstein suggests that as well. Actually, he should _at_least_
allow for the latin and anglo saxon format, say
<option>mm/dd/yyy (anglo saxon)
<option>dd/mm/yyy (latin)

Note that the application has buttons that move forward or backward month by
month, those buttons are small and could escape at a first perusal.
I suggest enlarging them a bit or giving to them a stronger color, they are
so nice a feature it is bad that at first sight they don't appear
immediately available.

It's a terrific job, a very very very nice application (I DO like stressing
good sides of the things), and I feel like praising him even if he was
using innerText - he can just "fix" that and a couple of details and he will
achieve perfection.

Speak of constructive observations expressed in a civilized manner that
doesn't belittle the achievement in the name of a few implementation details
LOL
ciao
Alberto
http://www.unitedscripters.com/
 
B

Brynn

I built this from scratch ... could eaily build that one.

If there is a high need, let me know ... I will build it, and have it
where you can pull the data from a textfile or database for the day.



This Javascript + DHTML source code able to show a popup calendar to select
one date in your web pages, complete the full sourcecode and its free
distribuite (GNU lic) http://www.prioregroup.com/dhtmlcalendar.html :)
Sorry for my english.
- Danilo

Brynn
www.coolpier.com

I participate in the group to help give examples of code.
I do not guarantee the effects of any code posted.
Test all code before use!
 
L

Lasse Reichstein Nielsen

Alberto said:
He is working on that,

On what? (You have no quoted context, so it's hard to see what you are
referring to)

function foo(e){
var object==(typeof(event)!="undefined")?event.srcElement:e.target;

Indeed. I usually start my event handler functions as:
---
function foo(event) {
event = event || window.event; // IE sucks
var tgt = event.target || event.srcElement; // do.
...
---
(yes, the comments are usually there too :)
dont think he can achieve compatibility with NS4, but that was
arguably never his goal.

It might be possible, by putting the calendar into a NS4-layer. That
could allow changing the content as well as positioning the calendar.
However, it would require a completely spearate way of doing pretty
much everything, so it's unlikely that it's worth doing. Netscape 4
is not as dead as it should be, but it's damn close :)
innerText should be replaced with innerHTML. Reichstein is absolutely right
about it. Yeah, to be precise, the W3C recommandation argues nodes should be
added one at a time. Yet if he does that by innerHTML, he achieves the
result as well, which is what matters to not too purist eyes.

innerHTML is probably the non-standard property that is most widely
implemented. If one is only aiming at the most common modern browsers,
then it should work.

Now, I *am* apurist at heart, so I would probably make a fallback :)
/L
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,131
Latest member
IsiahLiebe
Top