ex.html 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. {% extends "base.html" %}
  2. {% block title %}Задание{% endblock %}
  3. {% block content %}
  4. <form action="{{ id }}" method="post" autocomplete="off">
  5. <input type="hidden" name="mode" value="{% block exercise_mode %}{% endblock %}">
  6. {% block exercise_body %}
  7. {% endblock %}
  8. <br>
  9. <input type="submit" value="Дальше" id="submit">
  10. <p>Нажмите = для ввода макрона.</p>
  11. </form>
  12. <script>
  13. answer = document.getElementById('answer0');
  14. submit = document.getElementById('submit');
  15. if (answer) {
  16. answer.focus();
  17. } else if (submit) {
  18. submit.focus();
  19. }
  20. var macrons = [["a", "ā"],
  21. ["o", "ō"],
  22. ["e", "ē"],
  23. ["i", "ī"],
  24. ["u", "ū"],
  25. ["y", "ȳ"]];
  26. var dead_macron = "=";
  27. function add_macrons (input) {
  28. var old_cursor = input.selectionStart;
  29. var old_value = input.value;
  30. var new_value = old_value;
  31. for (var i = 0; i < macrons.length; ++i) {
  32. new_value = new_value.replace(macrons[i][0] + dead_macron, macrons[i][1]);
  33. }
  34. var delta = old_value.length - new_value.length;
  35. input.value = new_value;
  36. input.selectionStart = old_cursor - delta;
  37. input.selectionEnd = old_cursor - delta;
  38. }
  39. </script>
  40. {% endblock %}