Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Translation App</title>
- <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
- <style>
- .translation-content {
- display: none;
- }
- .counter {
- position: absolute;
- top: 20px;
- left: 50%;
- transform: translateX(-50%);
- font-size: 18px;
- border: 2px solid #000;
- border-radius: 50%;
- padding: 10px;
- width: 50px;
- height: 50px;
- display: flex;
- align-items: center;
- justify-content: center;
- text-align: center;
- }
- </style>
- </head>
- <body>
- <div class="container mt-5">
- <div class="counter">
- {{ session['correct'] }}/{{ session['total'] }}
- </div>
- <h1>Welcome, {{ current_user.username }}!</h1>
- <form action="{{ url_for('index') }}" method="POST" class="form-inline mb-3">
- <input type="text" name="term" class="form-control mr-2" placeholder="Enter term">
- <select name="direction" class="form-control mr-2">
- <option value="en_cz">English to Czech</option>
- <option value="cz_en">Czech to English</option>
- </select>
- <button type="submit" class="btn btn-primary">Translate</button>
- </form>
- {% with messages = get_flashed_messages(with_categories=true) %}
- {% if messages %}
- <div class="alert alert-info">
- {% for category, message in messages %}
- <p>{{ message }}</p>
- {% endfor %}
- </div>
- {% endif %}
- {% endwith %}
- {% if error %}
- <div class="alert alert-danger">{{ error }}</div>
- {% endif %}
- <div class="btn-group mb-3" role="group" aria-label="Basic example">
- <form action="{{ url_for('delete_all') }}" method="POST">
- <button type="submit" class="btn btn-danger">Delete All Translations</button>
- </form>
- <form action="{{ url_for('reset_counter') }}" method="POST">
- <button type="submit" class="btn btn-warning">Reset Counter</button>
- </form>
- <a href="{{ url_for('quiz') }}" id="take-quiz-btn" class="btn btn-info">Take a Quiz</a>
- <a href="{{ url_for('logout') }}" class="btn btn-secondary">Logout</a>
- </div>
- <h2>Your Translations (EN-CZ)</h2>
- <ul class="list-group mb-3">
- {% for translation in en_cz_translations %}
- <li class="list-group-item">
- <strong>{{ translation.term }}</strong>
- <div class="float-right">
- <button class="btn btn-sm btn-secondary toggle-btn" type="button">Toggle</button>
- <form action="{{ url_for('delete', id=translation.id) }}" method="POST" class="d-inline">
- <button type="submit" class="btn btn-sm btn-danger">Delete</button>
- </form>
- </div>
- <div class="translation-content mt-2">
- {% for trans_group in translation.translations %}
- <ul>
- {% for trans in trans_group %}
- <li>
- {% if trans.morf %}
- <strong>Morfo: </strong>{{ trans.morf }}<br>
- {% endif %}
- {% if trans.desc %}
- <strong>Desc: </strong>{{ trans.desc|safe }}<br>
- {% endif %}
- {% if trans.note %}
- <strong>Note: </strong>{{ trans.note|safe }}<br>
- {% endif %}
- {% if trans.samples %}
- <strong>Samples: </strong>
- <ul>
- {% for sample in trans.samples %}
- <li>{{ sample|safe }}</li>
- {% endfor %}
- </ul>
- {% endif %}
- {% if trans.trans %}
- <strong>Translations: </strong>
- <ul>
- {% for t in trans.trans %}
- <li>{{ t|safe }}</li>
- {% endfor %}
- </ul>
- {% endif %}
- {% if trans.coll2 %}
- <strong>Collocations: </strong>
- <ul>
- {% for coll in trans.coll2 %}
- <li>{{ coll|safe }}</li>
- {% endfor %}
- </ul>
- {% endif %}
- </li>
- {% endfor %}
- </ul>
- {% endfor %}
- </div>
- </li>
- {% endfor %}
- </ul>
- <h2>Your Translations (CZ-EN)</h2>
- <ul class="list-group mb-3">
- {% for translation in cz_en_translations %}
- <li class="list-group-item">
- <strong>{{ translation.term }}</strong>
- <div class="float-right">
- <button class="btn btn-sm btn-secondary toggle-btn" type="button">Toggle</button>
- <form action="{{ url_for('delete', id=translation.id) }}" method="POST" class="d-inline">
- <button type="submit" class="btn btn-sm btn-danger">Delete</button>
- </form>
- </div>
- <div class="translation-content mt-2">
- {% for trans_group in translation.translations %}
- <ul>
- {% for trans in trans_group %}
- <li>
- {% if trans.morf %}
- <strong>Morfo: </strong>{{ trans.morf }}<br>
- {% endif %}
- {% if trans.desc %}
- <strong>Desc: </strong>{{ trans.desc|safe }}<br>
- {% endif %}
- {% if trans.note %}
- <strong>Note: </strong>{{ trans.note|safe }}<br>
- {% endif %}
- {% if trans.samples %}
- <strong>Samples: </strong>
- <ul>
- {% for sample in trans.samples %}
- <li>{{ sample|safe }}</li>
- {% endfor %}
- </ul>
- {% endif %}
- {% if trans.trans %}
- <strong>Translations: </strong>
- <ul>
- {% for t in trans.trans %}
- <li>{{ t|safe }}</li>
- {% endfor %}
- </ul>
- {% endif %}
- {% if trans.coll2 %}
- <strong>Collocations: </strong>
- <ul>
- {% for coll in trans.coll2 %}
- <li>{{ coll|safe }}</li>
- {% endfor %}
- </ul>
- {% endif %}
- </li>
- {% endfor %}
- </ul>
- {% endfor %}
- </div>
- </li>
- {% endfor %}
- </ul>
- </div>
- <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
- <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.4/dist/umd/popper.min.js"></script>
- <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
- <script>
- document.addEventListener('DOMContentLoaded', function() {
- var toggleButtons = document.querySelectorAll('.toggle-btn');
- toggleButtons.forEach(function(button) {
- button.addEventListener('click', function() {
- var content = this.parentElement.nextElementSibling;
- if (content.style.display === 'none' || content.style.display === '') {
- content.style.display = 'block';
- } else {
- content.style.display = 'none';
- }
- });
- });
- document.getElementById('take-quiz-btn').addEventListener('click', function() {
- fetch('/get_translations')
- .then(response => response.json())
- .then(data => {
- console.log('Translations:', data.translations);
- // Perform any additional actions with the data here
- window.location.href = "{{ url_for('quiz') }}";
- })
- .catch(error => {
- console.error('Error fetching translations:', error);
- });
- });
- });
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement