/[drupal]/contributions/modules/jeopardy/jeopardy.js
ViewVC logotype

Diff of /contributions/modules/jeopardy/jeopardy.js

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.2, Sun Aug 31 12:20:53 2008 UTC revision 1.3, Mon Sep 1 02:27:45 2008 UTC
# Line 2  Line 2 
2  // Global JS Kill Switch  // Global JS Kill Switch
3  if (Drupal.jsEnabled) {  if (Drupal.jsEnabled) {
4    $(document).ready(function() {    $(document).ready(function() {
5      $('td.jeopardy-table-question').click(function () {      $('td.jeopardy-table-question').click(showAnswer);
6        var td = this;      $('td.jeopardy-table-question').mouseover(function () {
7        var loc = this.id.replace('jeopardy-', '');        $(this).addClass('jeopardy-over');
8        $('#question-' + loc).each(function () {      });
9        $('td.jeopardy-table-question').mouseout(function () {
10          $(this).removeClass('jeopardy-over');
11        });
12      });
13    }
14    
15    /**
16     * Bind a click event to each td to show the matching question
17     */
18    function showAnswer() {
19      if ($(".answer-link").size() > 0) {
20        return;
21      }
22      var td = this;
23      $(td).unbind('click', showAnswer);
24      var loc = this.id.replace('jeopardy-', '');
25      $('#question-' + loc).each(function () {
26        var el = this;
27        $('#hidden-jeopardy').each(function () {
28          this.innerHTML = '<div class="question-wrapper">' + el.innerHTML + '</div>';
29        });
30        $(td).addClass("question-visited");
31        $(td).append('<div class="answer-wrapper"><a class="answer-link" id="show-answer-' + loc + '">Answer</a></div>');
32        $('#show-answer-' + loc).click(function () {
33          $('#answer-' + loc).each(function () {
34          var el = this;          var el = this;
35          $('#hidden-jeopardy').each(function () {          $('#hidden-jeopardy').each(function () {
36            this.innerHTML = el.innerHTML;            this.innerHTML = '<div class="question-wrapper">' + el.innerHTML + '</div>';
37          });          });
38          $(td).css("background-color", "red");          $(td).removeClass("question-visited").addClass("answer-visited");
39        });        });
40          $(this).parent().remove();
41      });      });
42    });    });
43  }  }
   

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

  ViewVC Help
Powered by ViewVC 1.1.2