02.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. $(document).ready(function () {
  2. 'use strict';
  3. $('#selected-plays > li').addClass('horizontal');
  4. $('#selected-plays li:not(.horizontal)').addClass('sub-level');
  5. $('a[href^="mailto:"]').addClass('mailto');
  6. $('a[href$=".pdf"]').addClass('pdflink');
  7. $('a[href^="http"][href*="henry"]').addClass('henrylink');
  8. $('tr:nth-child(odd)').addClass('alt');
  9. $('a').filter(function () {
  10. return this.hostname && this.hostname != location.hostname;
  11. }).addClass('external');
  12. // $('td:contains(Henry)').nextAll().addBack().addClass('highlight');
  13. // $('td:contains(Henry)').parent().children().addClass('highlight');
  14. $('td:contains(Henry)') // Find every cell containing "Henry"
  15. .parent() // Select its parent
  16. .find('td:eq(1)') // Find the 2nd descendant cell
  17. .addClass('highlight') // Add the "highlight" class
  18. .end() // Finish current filtering, return to previous state: the result of parent()
  19. .find('td:eq(2)') // Find the 3rd descendant cell
  20. .addClass('highlight'); // Add the "highlight" class
  21. $('#selected-plays > li').find('li').addClass('special');
  22. $('tr').find('td:eq(2)').addClass('year');
  23. $($('td:contains(Tragedy)')[0]).parent().addClass('special');
  24. // Would there be a way with has() ?
  25. $('li>a').parent().next().addClass('afterlink');
  26. $('a[href$=".pdf"]').closest('ul').addClass('tragedy');
  27. });
  28. // Function end() does not empty the stack, but returns the second-topmost element.