Ver Mensaje Individual
  #1 (permalink)  
Antiguo 25/11/2010, 11:34
mysterio069
 
Fecha de Ingreso: abril-2010
Mensajes: 62
Antigüedad: 14 años, 1 mes
Puntos: 0
Pregunta alguien me puede explicar el funcionamiento de este script??

Hola a todos, estoy trabajando con este calendario, pero no consigo entenderlo por completo, quiero hacer una consulta a la BD y si un dia y un mes estan en la BD que me marque ese dia con un enlace, pero primero necesito saber su funcionamiento.
Código Javascript:
Ver original
  1. <script LANGUAGE="JavaScript">
  2.  
  3. <!-- Begin
  4. monthnames = new Array(
  5. "Enero",
  6. "Febrero",
  7. "Marzo",
  8. "Abril",
  9. "Mayo",
  10. "Junio",
  11. "Julio",
  12. "Agosto",
  13. "Septiembre",
  14. "Octubre",
  15. "Noviembre",
  16. "Diciembre");
  17. var linkcount=0;
  18. function addlink(month, day, href) {
  19. var entry = new Array(3);
  20. entry[0] = month;
  21. entry[1] = day;
  22. entry[2] = href;
  23. this[linkcount++] = entry;
  24. }
  25. Array.prototype.addlink = addlink;
  26. linkdays = new Array();
  27. monthdays = new Array(12);
  28. monthdays[0]=31;
  29. monthdays[1]=28;
  30. monthdays[2]=31;
  31. monthdays[3]=30;
  32. monthdays[4]=31;
  33. monthdays[5]=30;
  34. monthdays[6]=31;
  35. monthdays[7]=31;
  36. monthdays[8]=30;
  37. monthdays[9]=31;
  38. monthdays[10]=30;
  39. monthdays[11]=31;
  40. todayDate=new Date();
  41. thisday=todayDate.getDay();
  42. thismonth=todayDate.getMonth();
  43. thisdate=todayDate.getDate();
  44. thisyear=todayDate.getYear();
  45. thisyear = thisyear % 100;
  46. thisyear = ((thisyear < 50) ? (2000 + thisyear) : (1900 + thisyear));
  47. if (((thisyear % 4 == 0)
  48. && !(thisyear % 100 == 0))
  49. ||(thisyear % 400 == 0)) monthdays[1]++;
  50. startspaces=thisdate;
  51. while (startspaces > 7) startspaces-=7;
  52. startspaces = thisday - startspaces + 0;
  53. if (startspaces < 0) startspaces+=7;
  54. document.write('<table id="calendar" cellspacing="0" cellpadding="0" ');
  55. document.write("<caption><a href='#' title='previous month' class='nav'>&laquo;</a> "
  56. + monthnames[thismonth] + " " + thisyear
  57. + " <a href='#' title='siguiente mes' class='nav'>&raquo;</a></caption>");
  58. document.write("<tr>");
  59. document.write("<th scope='col'>Lu</th>");
  60. document.write("<th scope='col'>Ma</th>");
  61. document.write("<th scope='col'>Mi</th>");
  62. document.write("<th scope='col'>Ju</th>");
  63. document.write("<th scope='col'>Vi</th>");
  64. document.write("<th scope='col'>Sa</th>");
  65. document.write("<th scope='col'>Do</th>");
  66. document.write("</tr>");
  67. document.write("<tr>");
  68. for (s=0;s<startspaces;s++) {
  69. document.write("<td> </td>");
  70. }
  71. count=1;
  72. while (count <= monthdays[thismonth]) {
  73. for (b = startspaces;b<7;b++) {
  74. linktrue=false;
  75. document.write("<td");
  76. for (c=0;c<linkdays.length;c++) {
  77. if (linkdays[c] != null) {
  78. if ((linkdays[c][0]==thismonth + 1) && (linkdays[c][1]==count)) {
  79. document.write("><a href=\"" + linkdays[c][2] + "\">");
  80. linktrue=true;
  81.       }
  82.    }
  83. }
  84. if (count==thisdate) {
  85. document.write(" class='today'>" + count);
  86. }
  87. else{
  88. if (count <= monthdays[thismonth]) {
  89. document.write(">" + count);
  90. }
  91. else {
  92. document.write(" ");
  93. }
  94. }
  95. if (linktrue)
  96. document.write("</a>");
  97. document.write("</td>");
  98. count++;
  99. }
  100. document.write("</tr>");
  101. document.write("<tr>");
  102. startspaces=0;
  103. }
  104. document.write("</table></p>");
  105. // End -->
  106. </script>

espero me podais ayudar graciass!!