Static website for local motocross track (circa Jun 2004)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

185 lines
4.3 KiB

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2. <html>
  3. <head>
  4. <title>
  5. Striped Tables
  6. </title>
  7. <link rel="stylesheet" type="text/css" href="tables.css" />
  8. <style type="text/css">
  9. #playlist {
  10. border: 1px solid #666666;
  11. }
  12. #playlist tbody tr td {
  13. font-family: "lucida grande", verdana, sans-serif;
  14. font-size: 8pt;
  15. padding: 3px 8px;
  16. border-left: 1px solid #D9D9D9;
  17. }
  18. #playlist tbody tr.selected td {
  19. background-color: #3d80df;
  20. color: #ffffff;
  21. font-weight: bold;
  22. border-left: 1px solid #346DBE;
  23. border-bottom: 1px solid #7DAAEA;
  24. }
  25. </style>
  26. <script type="text/javascript">
  27. <!--
  28. // this function is need to work around
  29. // a bug in IE related to element attributes
  30. function hasClass(obj) {
  31. var result = false;
  32. if (obj.getAttributeNode("class") != null) {
  33. result = obj.getAttributeNode("class").value;
  34. }
  35. return result;
  36. }
  37. function stripe(id) {
  38. // the flag we'll use to keep track of
  39. // whether the current row is odd or even
  40. var even = false;
  41. // if arguments are provided to specify the colours
  42. // of the even & odd rows, then use the them;
  43. // otherwise use the following defaults:
  44. var evenColor = arguments[1] ? arguments[1] : "#fff";
  45. var oddColor = arguments[2] ? arguments[2] : "#eee";
  46. // obtain a reference to the desired table
  47. // if no such table exists, abort
  48. var table = document.getElementById(id);
  49. if (! table) { return; }
  50. // by definition, tables can have more than one tbody
  51. // element, so we'll have to get the list of child
  52. // &lt;tbody&gt;s
  53. var tbodies = table.getElementsByTagName("tbody");
  54. // and iterate through them...
  55. for (var h = 0; h < tbodies.length; h++) {
  56. // find all the &lt;tr&gt; elements...
  57. var trs = tbodies[h].getElementsByTagName("tr");
  58. // ... and iterate through them
  59. for (var i = 0; i < trs.length; i++) {
  60. // avoid rows that have a class attribute
  61. // or backgroundColor style
  62. if (!hasClass(trs[i]) && ! trs[i].style.backgroundColor) {
  63. // get all the cells in this row...
  64. var tds = trs[i].getElementsByTagName("td");
  65. // and iterate through them...
  66. for (var j = 0; j < tds.length; j++) {
  67. var mytd = tds[j];
  68. // avoid cells that have a class attribute
  69. // or backgroundColor style
  70. if (! hasClass(mytd) && ! mytd.style.backgroundColor) {
  71. mytd.style.backgroundColor = even ? evenColor : oddColor;
  72. }
  73. }
  74. }
  75. // flip from odd to even, or vice-versa
  76. even = ! even;
  77. }
  78. }
  79. }
  80. // -->
  81. </script>
  82. </head>
  83. <body onload="stripe('playlist', '#fff', '#ede');"><a name="top"></a>
  84. <div id="bottle">
  85. <h1>iTunes Stripes</h1>
  86. <table id="playlist" cellspacing="0">
  87. <tbody>
  88. <tr>
  89. <td>1</td>
  90. <td>Lost In The Plot</td>
  91. <td>The Dears</td>
  92. </tr>
  93. <tr>
  94. <td>2</td>
  95. <td>Poison</td>
  96. <td>The Constantines</td>
  97. </tr>
  98. <tr class="selected">
  99. <td>3</td>
  100. <td>Plea From A Cat Named Virtute</td>
  101. <td>The Weakerthans</td>
  102. </tr>
  103. <tr>
  104. <td>4</td>
  105. <td>Melissa Louise</td>
  106. <td>Chixdiggit!</td>
  107. </tr>
  108. </tbody>
  109. <tbody>
  110. <tr>
  111. <td>5</td>
  112. <td>Living Room</td>
  113. <td>Tegan And Sara</td>
  114. </tr>
  115. <tr>
  116. <td>6</td>
  117. <td>Speed</td>
  118. <td>Bran Van 3000</td>
  119. </tr>
  120. <tr>
  121. <td>7</td>
  122. <td>Fast Money Blessing</td>
  123. <td>King Cobb Steelie</td>
  124. </tr>
  125. </tbody>
  126. <tbody>
  127. <tr class="selected">
  128. <td>8</td>
  129. <td>Sore</td>
  130. <td>Buck 65</td>
  131. </tr>
  132. <tr class="selected">
  133. <td>9</td>
  134. <td>Love Travel</td>
  135. <td>Danko Jones</td>
  136. </tr>
  137. <tr>
  138. <td>10</td>
  139. <td>You Never Let Me Down</td>
  140. <td>Furnaceface</td>
  141. </tr>
  142. </tbody>
  143. </table>
  144. <p>
  145. An example of using JavaScript and the <acronym title="Document Object Model">DOM</acronym> to apply <code>background-color</code> styles to table cells. And because we aren&#8217;t applying classes to any of the table rows to achieve the effect, we can use classes for more specific uses, such as indicating selected rows in the table (rows marked #3, #8, and #9).
  146. </p>
  147. </div>
  148. </body>
  149. </html>