simple-2.html 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <html style="background-color: buttonface; color: buttontext;">
  2. <head>
  3. <meta http-equiv="content-type" content="text/xml; charset=utf-8" />
  4. <title>Simple calendar setup [flat calendar]</title>
  5. <!-- calendar stylesheet -->
  6. <link rel="stylesheet" type="text/css" media="all" href="calendar-win2k-cold-1.css" title="win2k-cold-1" />
  7. <!-- main calendar program -->
  8. <script type="text/javascript" src="calendar.js"></script>
  9. <!-- language for the calendar -->
  10. <script type="text/javascript" src="lang/calendar-en.js"></script>
  11. <!-- the following script defines the Calendar.setup helper function, which makes
  12. adding a calendar a matter of 1 or 2 lines of code. -->
  13. <script type="text/javascript" src="calendar-setup.js"></script>
  14. </head>
  15. <body>
  16. <h2>DHTML Calendar &mdash; for the impatient</h2>
  17. <blockquote>
  18. <p>
  19. This page demonstrates how to setup a flat calendar. Examples of
  20. <em>popup</em> calendars are available in <a
  21. href="simple-1.html">another page</a>.
  22. </p>
  23. <p>
  24. The code in this page uses a helper function defined in
  25. "calendar-setup.js". With it you can setup the calendar in
  26. minutes. If you're not <em>that</em> impatient, ;-) <a
  27. href="doc/html/reference.html">complete documenation</a> is
  28. available.
  29. </p>
  30. </blockquote>
  31. <hr />
  32. <div style="float: right; margin-left: 1em; margin-bottom: 1em;"
  33. id="calendar-container"></div>
  34. <script type="text/javascript">
  35. function dateChanged(calendar) {
  36. // Beware that this function is called even if the end-user only
  37. // changed the month/year. In order to determine if a date was
  38. // clicked you can use the dateClicked property of the calendar:
  39. if (calendar.dateClicked) {
  40. // OK, a date was clicked, redirect to /yyyy/mm/dd/index.php
  41. var y = calendar.date.getFullYear();
  42. var m = calendar.date.getMonth(); // integer, 0..11
  43. var d = calendar.date.getDate(); // integer, 1..31
  44. // redirect...
  45. window.location = "/" + y + "/" + m + "/" + d + "/index.php";
  46. }
  47. };
  48. Calendar.setup(
  49. {
  50. flat : "calendar-container", // ID of the parent element
  51. flatCallback : dateChanged // our callback function
  52. }
  53. );
  54. </script>
  55. <p>The positioning of the DIV that contains the calendar is entirely your
  56. job. For instance, the "calendar-container" DIV from this page has the
  57. following style: "float: right; margin-left: 1em; margin-bottom: 1em".</p>
  58. <p>Following there is the code that has been used to create this calendar.
  59. You can find the full description of the <tt>Calendar.setup()</tt> function
  60. in the <a href="doc/html/reference.html">calendar documenation</a>.</p>
  61. <pre
  62. >&lt;div style="float: right; margin-left: 1em; margin-bottom: 1em;"
  63. id="calendar-container"&gt;&lt;/div&gt;
  64. &lt;script type="text/javascript"&gt;
  65. function dateChanged(calendar) {
  66. // Beware that this function is called even if the end-user only
  67. // changed the month/year. In order to determine if a date was
  68. // clicked you can use the dateClicked property of the calendar:
  69. if (calendar.dateClicked) {
  70. // OK, a date was clicked, redirect to /yyyy/mm/dd/index.php
  71. var y = calendar.date.getFullYear();
  72. var m = calendar.date.getMonth(); // integer, 0..11
  73. var d = calendar.date.getDate(); // integer, 1..31
  74. // redirect...
  75. window.location = "/" + y + "/" + m + "/" + d + "/index.php";
  76. }
  77. };
  78. Calendar.setup(
  79. {
  80. flat : "calendar-container", // ID of the parent element
  81. flatCallback : dateChanged // our callback function
  82. }
  83. );
  84. &lt;/script&gt;</pre>
  85. </body>
  86. </html>