reading_comprehension.tpl 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <div class="question-{{ id }}">
  2. <div id="question-{{ id }}-text" class="center-block question-text" onselectstart="return false">
  3. {{ text }}
  4. </div>
  5. </div>
  6. <style>
  7. .question-text {
  8. color: #FFF;
  9. text-align: justify;
  10. }
  11. .text-highlight.blur {
  12. color:#eee; /* Old browsers don't go transparent. */
  13. text-shadow:
  14. 0 0 3px #ddd, /* Many shadows blur out the area around the text */
  15. 5px 0 5px #ddd,
  16. 0 3px 3px #ddd,
  17. -6px 0 6px #ddd,
  18. 0 -3px 3px #ddd;
  19. }
  20. .text-highlight.active {
  21. color: rgba(0, 0, 0, 1);
  22. text-shadow: none;
  23. }
  24. .text-highlight.border {
  25. color: #bbb;
  26. text-shadow: none;
  27. }
  28. .radio.hide-reading-answers, .question_title.hide-reading-answers {
  29. display: none;
  30. }
  31. </style>
  32. <script>
  33. $(document).on('ready', function () {
  34. var index = 0,
  35. total = $('#question-{{ id }}-text .text-highlight').length;
  36. function updateView()
  37. {
  38. $('#question-{{ id }}-text .text-highlight').removeClass('active');
  39. if (index >= total) {
  40. window.clearInterval(timeOuId);
  41. $('.radio').removeClass('hide-reading-answers');
  42. $('.question_title').removeClass('hide-reading-answers');
  43. $('.text-highlight').removeClass('border');
  44. return;
  45. }
  46. var current = $('#question-{{ id }}-text .text-highlight').get(index);
  47. $(current).addClass('active');
  48. if (index > 0) {
  49. $('#question-{{ id }}-text .text-highlight').removeClass('border');
  50. var previousWord = $('#question-{{ id }}-text .text-highlight').get(index-1);
  51. $(previousWord).addClass('border');
  52. }
  53. if (index < total) {
  54. $('#question-{{ id+1 }}-text .text-highlight').removeClass('border');
  55. var nextWord = $('#question-{{ id }}-text .text-highlight').get(index+1);
  56. $(nextWord).addClass('border');
  57. }
  58. index++;
  59. }
  60. updateView();
  61. var timeOuId = window.setInterval(updateView, {{ refreshTime }} * 1000);
  62. });
  63. </script>