Calendar html page

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Hitit

    #1

    Calendar html page

    I found the script below in internet and I want it to create a page with
    links for each date changing according to date. For example:

    For August 10, the link in calendar page should point to:
    /cgi-bin/calendar_day.pl ?userdir=calend &dept=boys&week ends=1&datestam p=20040
    810

    For August 11, the link in calendar page should point to:
    /cgi-bin/calendar_day.pl ?userdir=calend &dept=boys&week ends=1&datestam p=20040
    811

    So far I did not succeed, any hints please?

    Thanks in advance.

    Webminor
    -------


    <html>
    <head>
    <title>Takvim </title>
    </head>
    <body bgcolor="#FFFFF F" link="#008000" vlink="#800040" text="#000000">

    <!-- begin calendar -->
    <SCRIPT LANGUAGE="JavaS cript">
    <!-- Begin
    title="javascri pt for Calendar";
    // if you comment url and un-comment new_url a click on any day links to
    edit-day
    // otherwise a click on any day simply brings up the whole calendar
    // note - there are two places where this choice is made , see later in the
    script
    // CHANGE HERE!
    //url="<a
    href=\"/cgi-bin/calendar.pl\?us erdir=calend\&d ept=boys\&weeke nds=1\">";
    new_url="<a
    href=\"/cgi-bin/calendar_day.pl \?userdir=calen d\&dept=boys\&w eekends=1\&date
    stamp=thisyear\ "";
    monthnames = new Array(
    "January",
    "Februrary" ,
    "March",
    "April",
    "May",
    "June",
    "July",
    "August",
    "September" ,
    "October",
    "November",
    "Decemeber" );
    var linkcount=0;
    function addlink(month, day, href) {
    var entry = new Array(3);
    entry[0] = month;
    entry[1] = day;
    entry[2] = href;
    this[linkcount++] = entry;
    }
    Array.prototype .addlink = addlink;
    linkdays = new Array();
    monthdays = new Array(12);
    monthdays[0]=31;
    monthdays[1]=28;
    monthdays[2]=31;
    monthdays[3]=30;
    monthdays[4]=31;
    monthdays[5]=30;
    monthdays[6]=31;
    monthdays[7]=31;
    monthdays[8]=30;
    monthdays[9]=31;
    monthdays[10]=30;
    monthdays[11]=31;
    todayDate=new Date();
    thisday=todayDa te.getDay();
    thismonth=today Date.getMonth() ;
    thisdate=todayD ate.getDate();
    thisyear=todayD ate.getYear();
    thisyear = thisyear % 100;
    thisyear = ((thisyear < 50) ? (2000 + thisyear) : (1900 + thisyear));
    if (((thisyear % 4 == 0)
    && !(thisyear % 100 == 0))
    ||(thisyear % 400 == 0)) monthdays[1]++;
    startspaces=thi sdate;
    while (startspaces > 7) startspaces-=7;
    startspaces = thisday - startspaces + 1;
    if (startspaces < 0) startspaces+=7;
    document.write( "<table border=2 bgcolor=white ");
    document.write( "bordercolor=bl ack>");

    document.write( "<tr><th colspan=7 bgcolor=yellow> <font color=black><st rong>"
    + title + "<br>"
    + monthnames[thismonth] + " " + thisdate + ", " + thisyear
    + "</strong></font></th></tr>");

    document.write( "<tr>");
    document.write( "<td align=center><b ><font color=red>Su</font></b></td>");
    document.write( "<td align=center>M</td>");
    document.write( "<td align=center>Tu </td>");
    document.write( "<td align=center>W</td>");
    document.write( "<td align=center>Th </td>");
    document.write( "<td align=center>F</td>");
    document.write( "<td align=center><b ><font color=red>Sa</font></b></td>");
    document.write( "</font></tr>");
    document.write( "<tr>");
    for (s=0;s<startspa ces;s++) {
    document.write( "<td></td>");
    }
    count=1;
    while (count <= monthdays[thismonth]) {
    for (b = startspaces;b<7 ;b++) {
    if (count==thisdat e) {
    document.write( "\n<td bgcolor=yellow> ");
    }
    else {document.write ("\n<td>");}
    if (count==thisdat e) {
    document.write( "<font size=+1><strong >");
    }
    if (count <= monthdays[thismonth]) {


    // CHANGE HERE!


    //document.write( url + count + "</a>");
    document.write( new_url + thisyear + thismonth + count + "\">" +
    count + "</a>");
    }
    else {
    document.write( " ");
    }
    if (count==thisdat e) {
    document.write( "</strong></font>");
    }
    document.write( "</td>");
    count++;
    }
    document.write( "</tr>");
    document.write( "<tr>");
    startspaces=0;
    }
    document.write( "<tr><th colspan=7 bgcolor=yellow> <strong>"
    + "Click on a day"
    + "</strong></font></th></tr>");
    document.write( "</table></p>");
    // End -->
    </SCRIPT>
    <!-- end calendar -->

    </body>
    </html>


  • Dr John Stockton

    #2
    Re: Calendar html page

    JRS: In article <2nsg6oF46pc5U1 @uni-berlin.de>, dated Tue, 10 Aug 2004
    20:50:11, seen in news:comp.lang. javascript, Hitit <hit.it@gmx.net >
    posted :[color=blue]
    >I found the script below in internet and I want it to create a page with
    >links for each date changing according to date.[/color]

    It's not a good script; its author did not have a good understanding of
    the language.

    When posting code to news, it is the POSTER's duty to ensure that his
    system does not, by line-wrapping, break the code. Readers should not
    have to do this. <FAQENTRY>
    [color=blue]
    >For example:
    >
    >For August 10, the link in calendar page should point to:
    >/cgi-bin/calendar_day.pl ?userdir=calend &dept=boys&week ends=1&datestam p=20040
    >810[/color]


    [color=blue]
    ><SCRIPT LANGUAGE="JavaS cript">[/color]

    Deprecated. Use <script type="text/javascript">


    [color=blue]
    >new_url="<a
    >href=\"/cgi-bin/calendar_day.pl \?userdir=calen d\&dept=boys\&w eekends=1\&date
    >stamp=thisyear \"";[/color]
    ^^^^^^^^^^ ------------------- REMOVE 10 chars[color=blue]
    >monthnames = new Array(
    >"January",
    >"Februrary" ,[/color]

    There are better ways of spelling some of those months, and
    monthnames = ["January", "February", ... "December"]
    is simpler.

    Use Mo We Fr, not M W F.

    IIRC, CSS can be used to centre the cell contents.

    [color=blue]
    > if (count <= monthdays[thismonth]) {
    >
    >
    > // CHANGE HERE!
    >
    >
    > //document.write( url + count + "</a>");
    > document.write( new_url + thisyear + thismonth + count + "\">" +
    >count + "</a>");[/color]

    document.write( new_url +
    ((thisyear*100 + thismonth)*100 + count) +
    "\">" + count + "</a>");
    ^^^^^ ---- What's that meant to do ?


    Read the FAQ (see below), etc., and you will learn much.

    There may be an error in the code for positioning the 1st of the month
    in the right column; test for another month, or make the week run in ISO
    form, Mon..Sun.

    To satisfy my copy of the validator TIDY, "</a>" should be "<\/a>"
    "</td>" should be "<\/td>" and other cases of </ in strings likewise.

    --
    © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
    <URL:http://jibbering.com/faq/> JL / RC : FAQ for news:comp.lang. javascript
    <URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
    <URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.

    Comment

    Working...