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.

69 lines
2.2 KiB

  1. // this function is needed to work around
  2. // a bug in IE related to element attributes
  3. function hasClass(obj) {
  4. var result = false;
  5. if (obj.getAttributeNode("class") != null) {
  6. result = obj.getAttributeNode("class").value;
  7. }
  8. return result;
  9. }
  10. function stripe(id) {
  11. // the flag we'll use to keep track of
  12. // whether the current row is odd or even
  13. var even = false;
  14. // if arguments are provided to specify the colours
  15. // of the even & odd rows, then use the them;
  16. // otherwise use the following defaults:
  17. var evenColor = arguments[1] ? arguments[1] : "#fff";
  18. var oddColor = arguments[2] ? arguments[2] : "#eee";
  19. // obtain a reference to the desired table
  20. // if no such table exists, abort
  21. var table = document.getElementById(id);
  22. if (! table) { return; }
  23. // by definition, tables can have more than one tbody
  24. // element, so we'll have to get the list of child
  25. // <tbody>s
  26. var tbodies = table.getElementsByTagName("tbody");
  27. // and iterate through them...
  28. for (var h = 0; h < tbodies.length; h++) {
  29. // find all the &lt;tr&gt; elements...
  30. var trs = tbodies[h].getElementsByTagName("tr");
  31. // ... and iterate through them
  32. for (var i = 0; i < trs.length; i++) {
  33. // avoid rows that have a class attribute
  34. // or backgroundColor style
  35. if (! hasClass(trs[i]) &&
  36. ! trs[i].style.backgroundColor) {
  37. // get all the cells in this row...
  38. var tds = trs[i].getElementsByTagName("td");
  39. // and iterate through them...
  40. for (var j = 0; j < tds.length; j++) {
  41. var mytd = tds[j];
  42. // avoid cells that have a class attribute
  43. // or backgroundColor style
  44. if (! hasClass(mytd) &&
  45. ! mytd.style.backgroundColor) {
  46. mytd.style.backgroundColor =
  47. even ? evenColor : oddColor;
  48. }
  49. }
  50. }
  51. // flip from odd to even, or vice-versa
  52. even = ! even;
  53. }
  54. }
  55. }