108 lines
3.9 KiB
HTML
108 lines
3.9 KiB
HTML
<!doctype html>
|
|
<html lang="cs">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>Výsledky pro "{{ query }}" - vontor.cz</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
|
|
<script>
|
|
function download(format) {
|
|
const resultsJsonElement = document.getElementById('json-data');
|
|
const results = JSON.parse(resultsJsonElement.textContent);
|
|
const requestPayload = { format, results };
|
|
|
|
fetch('/export', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify(requestPayload)
|
|
})
|
|
.then(function(response) {
|
|
if (response.ok){
|
|
return response.blob();
|
|
}
|
|
|
|
//error
|
|
return response.json().then(function(errorBody) { throw errorBody; });
|
|
})
|
|
.then(function(fileBlob) {
|
|
//blob
|
|
const objectUrl = window.URL.createObjectURL(fileBlob);
|
|
|
|
const downloadLink = document.createElement('a');
|
|
|
|
downloadLink.href = objectUrl;
|
|
downloadLink.download = 'results.' + format;
|
|
document.body.appendChild(downloadLink);
|
|
|
|
downloadLink.click();
|
|
downloadLink.remove();
|
|
|
|
window.URL.revokeObjectURL(objectUrl);
|
|
})
|
|
.catch(function(error) {
|
|
alert('Export failed: ' + JSON.stringify(error));
|
|
});
|
|
}
|
|
</script>
|
|
</head>
|
|
<body class="bg-light min-vh-100 d-flex">
|
|
<main class="container my-auto py-4">
|
|
<div class="d-flex justify-content-between align-items-center mb-3">
|
|
<h1 class="h3 mb-0">Výsledky pro "{{ query }}"</h1>
|
|
<a class="btn btn-outline-secondary" href="/">Nové hledání</a>
|
|
</div>
|
|
|
|
{% if notice %}
|
|
<div class="alert alert-warning" role="alert">
|
|
{{ notice }}
|
|
</div>
|
|
{% endif %}
|
|
|
|
<div class="card shadow-sm mb-3">
|
|
<div class="card-body">
|
|
<div class="d-flex flex-wrap gap-2 justify-content-between align-items-center">
|
|
<div class="text-muted">Počet výsledků: <strong>{{ results|length }}</strong></div>
|
|
<div class="d-flex gap-2">
|
|
<button class="btn btn-sm btn-outline-primary" onclick="download('json')">Stáhnout JSON</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{% if results and results|length > 0 %}
|
|
<ol class="list-group list-group-numbered">
|
|
|
|
{% for item in results %}
|
|
<li class="list-group-item">
|
|
<div class="d-flex gap-3 align-items-start">
|
|
{% if item.icon %}
|
|
<img src="{{ item.icon }}" alt="" width="20" height="20" class="rounded mt-1" onerror="this.style.display='none'">
|
|
{% endif %}
|
|
|
|
<div class="flex-grow-1">
|
|
<a class="fw-semibold" href="{{ item.link }}" target="_blank" rel="noopener noreferrer">{{ item.title }}</a>
|
|
|
|
{% if item.snippet %}
|
|
<small class="text-muted d-block">{{ item.snippet }}</small>
|
|
{% endif %}
|
|
|
|
<small class="text-break text-secondary">{{ item.link }}</small>
|
|
</div>
|
|
</div>
|
|
</li>
|
|
{% endfor %}
|
|
|
|
</ol>
|
|
{% else %}
|
|
<div class="alert alert-info" role="alert">
|
|
Žádné položky k zobrazení.
|
|
</div>
|
|
{% endif %}
|
|
|
|
<script id="json-data" type="application/json">{{ results|tojson }}</script>
|
|
</main>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
|
|
</body>
|
|
</html>
|