contentmatcher/templates/deck/index.html

63 lines
2.3 KiB
HTML
Raw Normal View History

2022-05-22 16:52:01 +02:00
{% extends 'base.html' %}
{% block header %}
2022-06-04 21:53:18 +02:00
{% endblock %}
2022-05-22 16:52:01 +02:00
{% block content %}
<article class="post">
2022-06-04 14:22:54 +02:00
<header>
2022-06-04 21:53:18 +02:00
<p>{{ card['title'] }}</p>
2022-06-04 14:22:54 +02:00
</header>
<canvas id="pdf-doc"></canvas>
<form method="post">
<button input type="submit" name="rate" data-cardtitle=card[title] value="Yes" accesskey="1">Yes</button> <!--ti keyi so alt+shit+key...-->
<button input type="submit" name="rate" value="Maybe" accesskey="2">Maybe</button>
<button input type="submit" name="rate" value="No" accesskey="3">No</button>
2022-06-04 14:22:54 +02:00
</form>
<button input type="submit" name="share" value="share">Share</button>
2022-05-22 16:52:01 +02:00
</article>
2022-06-03 19:13:23 +02:00
2022-06-04 14:22:54 +02:00
<script type="text/javascript" src="{{ url_for('static', filename='js/pdf.js') }}"></script>
<script type="text/javascript" src="{{ url_for('static', filename='js/pdf.worker.js') }}"></script>
2022-06-03 19:13:23 +02:00
<script type="text/javascript">
document.addEventListener('DOMContentLoaded', function (){
2022-06-04 14:22:54 +02:00
var zoomed = false;
var canvas = document.getElementById('pdf-doc');
var context = canvas.getContext('2d');
var openPage = function(pdfFile, pageNumber) {
pdfFile.getPage(pageNumber).then(function(page) {
var scale = 1.5;
var viewport = page.getViewport({ scale: scale, });
// Support HiDPI-screens.
var outputScale = window.devicePixelRatio || 1;
canvas.width = Math.floor(viewport.width * outputScale);
canvas.height = Math.floor(viewport.height * outputScale);
canvas.style.width = Math.floor(viewport.width) + "px";
canvas.style.height = Math.floor(viewport.height) + "px";
var transform = outputScale !== 1
? [outputScale, 0, 0, outputScale, 0, 0]
: null;
var renderContext = {
canvasContext: context,
viewport: viewport,
transform: transform
};
page.render(renderContext);
});
};
pdfjsLib.disableStream = true;
var doc = pdfjsLib.getDocument('{{ card["item_location"] }}');
doc.promise.then(function(pdf) {
// Do something with the PDF file stored in the `pdf` variable
openPage(pdf, 1);
});
});
2022-06-03 19:13:23 +02:00
</script>
2022-05-22 16:52:01 +02:00
{% endblock %}