{% extends "head.html" %}

{% block title %}Salvage Vehicles Database{% endblock %}

{% block content %}
<div class="container-lg py-4">
    <div class="p-5 mb-4 bg-light rounded-3">
        <h1 class="display-4">Buying a Used Car? Check it!</h1>
        <p class="lead">
            <a href="https://www.salvagedb.com/" title="Salvagedb.com" rel="nofollow">Salvagedb.com</a> provides
            information about salvage or junk vehicles; damage from hail, flood or fire; mileage discrepancies or
            odometer rollback; and gray market vehicles. We do not claim that the car got in our databank has salvage
            title, but the fact that it has been damaged for sure. Our site helps people avoid buying a damaged vehicle
            in the past.
        </p>
    </div>

    <div class="table-responsive">
        <table class="table table-hover align-middle">
            <thead class="table-light">
            <tr>
                <th scope="col">VIN</th>
                <th scope="col">Make</th>
                <th scope="col">Model</th>
                <th scope="col">Year</th>
            </tr>
            </thead>
            <tbody>
            {% for row in pg %}
            <tr>
                <td><a href="/detail/{{ row[1] }}.html" class="text-decoration-none">{{ row[1] }}</a></td>
                <td>{{ row[2] }}</td>
                <td>{{ row[3] }}</td>
                <td>{{ row[4] }}</td>
            </tr>
            {% endfor %}
            </tbody>
        </table>
    </div>

    <nav aria-label="Page navigation" class="my-4">
        <ul class="pagination justify-content-center">
            {% if cur_page > 1 %}
                <li class="page-item">
                    <a class="page-link" href="/database/page1.html">First</a>
                </li>
                <li class="page-item">
                    <a class="page-link" href="/database/page{{cur_page-1}}.html">Prev</a>
                </li>
            {% endif %}
            
            {% if cur_page > 3 %}
                <li class="page-item disabled">
                    <span class="page-link">...</span>
                </li>
            {% endif %}
            
            {% set start_page = cur_page - 2 %}
            {% if start_page < 1 %}
                {% set start_page = 1 %}
            {% endif %}
            
            {% set end_page = cur_page + 2 %}
            {% if end_page > max_page %}
                {% set end_page = max_page %}
            {% endif %}
            
            {% for page in range(start_page, end_page + 1) %}
                <li class="page-item {% if page == cur_page %}active{% endif %}">
                    {% if page == cur_page %}
                        <span class="page-link">{{page}}</span>
                    {% else %}
                        <a class="page-link" href="/database/page{{page}}.html">{{page}}</a>
                    {% endif %}
                </li>
            {% endfor %}
            
            {% if cur_page < max_page-2 %}
                <li class="page-item disabled">
                    <span class="page-link">...</span>
                </li>
            {% endif %}
            
            {% if cur_page < max_page %}
                <li class="page-item">
                    <a class="page-link" href="/database/page{{cur_page+1}}.html">Next</a>
                </li>
                <li class="page-item">
                    <a class="page-link" href="/database/page{{max_page}}.html">Last</a>
                </li>
            {% endif %}
        </ul>
    </nav>
</div>
<hr class="my-4">

{% endblock %}
