Initial commit
This commit is contained in:
132
templates/result.html
Normal file
132
templates/result.html
Normal file
@@ -0,0 +1,132 @@
|
||||
{% extends "layout.html" %}
|
||||
{% block content %}
|
||||
|
||||
<div class="text-center mb-5">
|
||||
<h1 class="fw-bold">Результаты выбора платформы</h1>
|
||||
</div>
|
||||
|
||||
<div class="results-container">
|
||||
<div class="card shadow-sm mb-4 p-4">
|
||||
<canvas id="platformChart" height="100"></canvas>
|
||||
</div>
|
||||
|
||||
{% for platform, score in scores.items() %}
|
||||
<div class="card mb-3 shadow-sm">
|
||||
<div class="card-body">
|
||||
<h4 class="card-title text-primary mb-2">{{ platform }} — {{ "%.2f"|format(score) }}%</h4>
|
||||
|
||||
{% if unsupported_features[platform] %}
|
||||
<p class="text-danger fw-semibold mb-1">Не поддерживается:</p>
|
||||
<ul class="text-danger mb-0">
|
||||
{% for feature in unsupported_features[platform] %}
|
||||
<li>{{ feature }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<p class="text-success mb-0">Все необходимые функции поддерживаются ✅</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
<div class="text-center mt-4">
|
||||
<button class="btn btn-outline-primary btn-lg" onclick="downloadPDF()">Скачать в PDF</button>
|
||||
<a class="btn btn-link mt-3 d-block" href="{{ url_for('choose_survey') }}">← Вернуться к выбору</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
|
||||
<script src="{{ url_for('static', filename='js/jspdf.roboto.js') }}"></script>
|
||||
|
||||
<script>
|
||||
const labels = {{ chart_labels|tojson }};
|
||||
const data = {{ chart_data|tojson }};
|
||||
const scores = {{ scores|tojson }};
|
||||
const unsupported = {{ unsupported_features|tojson }};
|
||||
|
||||
const ctx = document.getElementById('platformChart').getContext('2d');
|
||||
const platformChart = new Chart(ctx, {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: labels,
|
||||
datasets: [{
|
||||
label: 'Совпадение (%)',
|
||||
data: data,
|
||||
backgroundColor: 'rgba(52, 152, 219, 0.6)',
|
||||
borderColor: 'rgba(52, 152, 219, 1)',
|
||||
borderWidth: 1
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
scales: {
|
||||
y: {
|
||||
beginAtZero: true,
|
||||
max: 100,
|
||||
title: {
|
||||
display: true,
|
||||
text: 'Процент совпадения'
|
||||
}
|
||||
},
|
||||
x: {
|
||||
title: {
|
||||
display: true,
|
||||
text: 'Платформы'
|
||||
}
|
||||
}
|
||||
},
|
||||
plugins: {
|
||||
legend: {
|
||||
display: false
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
async function downloadPDF() {
|
||||
const { jsPDF } = window.jspdf;
|
||||
const doc = new jsPDF();
|
||||
|
||||
doc.addFileToVFS("Roboto.ttf", roboto_base64);
|
||||
doc.addFont("Roboto.ttf", "Roboto", "normal");
|
||||
doc.setFont("Roboto");
|
||||
doc.setFontSize(18);
|
||||
doc.text("Результаты выбора платформы", 10, 15);
|
||||
|
||||
const chartCanvas = document.getElementById('platformChart');
|
||||
const chartImage = await html2canvas(chartCanvas);
|
||||
const chartDataUrl = chartImage.toDataURL('image/png');
|
||||
doc.addImage(chartDataUrl, 'PNG', 10, 25, 180, 90);
|
||||
|
||||
let y = 120;
|
||||
doc.setFontSize(12);
|
||||
|
||||
for (let platform of labels) {
|
||||
const score = scores[platform].toFixed(2);
|
||||
doc.text(`${platform}: ${score}%`, 10, y);
|
||||
y += 8;
|
||||
|
||||
const unsupp = unsupported[platform];
|
||||
if (unsupp && unsupp.length) {
|
||||
doc.text("Не поддерживается:", 12, y);
|
||||
y += 8;
|
||||
for (let f of unsupp) {
|
||||
doc.text(`- ${f}`, 16, y);
|
||||
y += 6;
|
||||
if (y > 270) {
|
||||
doc.addPage();
|
||||
y = 20;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
doc.text("✔ Все необходимые функции поддерживаются", 12, y);
|
||||
y += 10;
|
||||
}
|
||||
}
|
||||
|
||||
doc.save("Результаты_платформы.pdf");
|
||||
}
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user