Sempervivum

Untitled

Feb 11th, 2017
184
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <style>
  2. #termine {
  3. border-collapse: collapse;
  4. }
  5. </style>
  6. <table id="termine">
  7. <thead>
  8. <tr>
  9. <th><strong>Thema</strong></th>
  10. <th><strong>Datum</strong></th>
  11. <th><strong>Uhrzeit</strong></th>
  12. <th><strong>Ort</strong></th>
  13. </tr>
  14. </thead>
  15. <tbody>
  16. <tr>
  17. <td>Beispiel</td>
  18. <td id="Datum1">21.12.2017</td>
  19. <td>12:15</td>
  20. <td>Kursort 1</td>
  21. </tr>
  22. <tr class="zweitezeile">
  23. <td>Beispiel</td>
  24. <td id="Datum2">15.12.2017</td>
  25. <td>13:45</td>
  26. <td>Kursort 2</td>
  27. </tr>
  28. <tr>
  29. <td>Beispiel</td>
  30. <td id="Datum3">04.01.2017</td>
  31. <td>12:15</td>
  32. <td>Kursort 1</td>
  33. </tr>
  34. <tr class="zweitezeile">
  35. <td>Beispiel</td>
  36. <td id="Datum4">03.03.2017</td>
  37. <td>12:15</td>
  38. <td>Kursort 2</td>
  39. </tr>
  40. <tr>
  41. <td>Beispiel</td>
  42. <td id="Datum5">05.01.2017</td>
  43. <td>12:15</td>
  44. <td>Kursort 1</td>
  45. </tr>
  46. </tbody>
  47. </table>
  48. <script>
  49. function myParseDate(rows, rowIdx) {
  50. var datearr = rows[rowIdx].cells[1].innerHTML.split(".");
  51. var timearr = rows[rowIdx].cells[2].innerHTML.split(":");
  52. return new Date(parseInt(datearr[2]), parseInt(datearr[1]) - 1, parseInt(datearr[0]),
  53. parseInt(timearr[1]), parseInt(timearr[0]), 0);
  54. }
  55. var now = new Date().getTime();
  56. var rows = document.getElementById("termine").rows;
  57. var nextTime = new Date(2099, 0, 1).getTime();
  58. var rowIdx = 1;
  59. for (var i = 1; i < rows.length; i++) {
  60. var currentTime = myParseDate(rows, i).getTime();
  61. if (currentTime < nextTime && currentTime > now) {
  62. rowIdx = i;
  63. nextTime = currentTime;
  64. }
  65. }
  66. console.log(rowIdx);
  67. rows[rowIdx].style.backgroundColor = "lightblue";
  68. rows[rowIdx].style.border = "thin solid blue";
  69. </script>
RAW Paste Data