Code Search for Developers
 
 
  

dayinfo.html from Group-Office groupware at Krugle


Show dayinfo.html syntax highlighted

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html> <head>
<title>How to include additional info in day cells</title>
<script type="text/javascript" src="calendar.js"></script>
<script type="text/javascript" src="lang/calendar-en.js"></script>
<script type="text/javascript" src="calendar-setup.js"></script>
<script type="text/javascript">
  // define info for dates in this table:
  var dateInfo = {
    "20050308" : "Mishoo's&nbsp;birthday",
    "20050310" : "foo",
    "20050315" : "bar",
    "20050318" : "25$",
    "20050324" : "60$"
  };
</script>
<style type="text/css">
  @import url(calendar-win2k-1.css);
  .calendar .inf { font-size: 80%; color: #444; }
  .calendar .wn { font-weight: bold; vertical-align: top; }
</style>
</head>

<body>
<h1>How to include additional info in day cells</h1>

<div id="flatcal" style="float: right"></div>

<script type="text/javascript">
  function getDateText(date, d) {
    var inf = dateInfo[date.print("%Y%m%d")];
    if (!inf) {
      return d + "<div class='inf'>&nbsp;</div>";
    } else {
      return d + "<div class='inf'>" + inf + "</div>";
    }
  };
  function flatCallback(cal) {
    if (cal.dateClicked) {
      // do something here
      window.status = "Selected: " + cal.date;
      var inf = dateInfo[cal.date.print("%Y%m%d")];
      if (inf) {
        window.status += ".  Additional info: " + inf;
      }
    }
  };
  Calendar.setup({
     flat: "flatcal",
     dateText: getDateText,
     flatCallback: flatCallback
  });
</script>

<p>The idea is simple:</p>

<ol>
  <li>
    <p>Define a callback that takes two parameters like this:</p>
    <pre>function getDateText(date, d)</pre>
    <p>
      This function will receive the date object as the first
      parameter and the current date number (1..31) as the second (you
      can get it as well by calling date.getDate() but since it's very
      probably useful I thought I'd pass it too so that we can avoid a
      function call).
    </p>
    <p>
      This function <em>must</em> return the text to be inserted in
      the cell of the passed date.  That is, one should at least
      "return d;".
    </p>
  </li>
  <li>
    Pass the above function as the "dateText" parameter to
    Calendar.setup.
  </li>
</ol>

<p>
  The function could simply look like:
</p>

<pre
>  function getDateText(date, d) {
    if (d == 12) {
      return "12th";
    } else if (d == 13) {
      return "bad luck";
    } /* ... etc ... */
  }</pre>

<p>
  but it's easy to imagine that this approach sucks.  For a better
  way, see the source of this page and note the usage of an externally
  defined "dateText" object which maps "date" to "date info", also
  taking into account the year and month.  This object can be easily
  generated from a database, and the getDateText function becomes
  extremely simple (and static).
</p>

<p>
  Cheers!
</p>

<hr />
<address><a href="http://dynarch.com/mishoo/">mishoo</a></address>
<!-- hhmts start --> Last modified: Sat Mar  5 17:18:06 EET 2005 <!-- hhmts end -->
</body> </html>




See more files for this project here

Group-Office groupware

Group-Office is a powerfull modular Internet/Intranet application framework. It features calendaring, project management, e-mail, tasks, addressbook, file management.

Project homepage: http://sourceforge.net/projects/group-office
Programming language(s): JavaScript,Pascal,PHP
License: other

  doc/
    html/
      field-button.jpg
      reference-Z-S.css
      reference.css
      reference.html
    reference.pdf
  lang/
    b5.js
    calendar-af.js
    calendar-al.js
    calendar-bg.js
    calendar-big5-utf8.js
    calendar-big5.js
    calendar-br.js
    calendar-ca.js
    calendar-cs-utf8.js
    calendar-cs-win.js
    calendar-cs.js
    calendar-da.js
    calendar-de.js
    calendar-du.js
    calendar-el.js
    calendar-en.js
    calendar-es.js
    calendar-fi.js
    calendar-fr.js
    calendar-he-utf8.js
    calendar-hr-utf8.js
    calendar-hr.js
    calendar-hu.js
    calendar-it.js
    calendar-ja.js
    calendar-jp.js
    calendar-ko-utf8.js
    calendar-ko.js
    calendar-lang.php
    calendar-lt-utf8.js
    calendar-lt.js
    calendar-lv.js
    calendar-nl.js
    calendar-no.js
    calendar-pl-utf8.js
    calendar-pl.js
    calendar-pt-br.js
    calendar-pt.js
    calendar-ro.js
    calendar-ru.js
    calendar-ru_win_.js
    calendar-si.js
    calendar-sk.js
    calendar-sl.js
    calendar-sp.js
    calendar-sv.js
    calendar-th.js
    calendar-tr.js
    calendar-zh-tw.js
    calendar-zh.js
    cn_utf8.js
  ChangeLog
  README
  bugtest-hidden-selects.html
  calendar-blue.css
  calendar-blue2.css
  calendar-brown.css
  calendar-go.css
  calendar-green.css
  calendar-lang.php
  calendar-setup.js
  calendar-setup_stripped.js
  calendar-system.css
  calendar-tas.css
  calendar-win2k-1.css
  calendar-win2k-2.css
  calendar-win2k-cold-1.css
  calendar-win2k-cold-2.css
  calendar.js
  calendar.php
  calendar_stripped.js
  dayinfo.html
  img.gif
  index.html
  menuarrow.gif
  menuarrow2.gif
  multiple-dates.html
  release-notes.html
  simple-1.html
  simple-2.html
  simple-3.html
  simple-4.html
  test-position.html
  test.php