Commit 60c42524 authored by Lukas Böhm's avatar Lukas Böhm 🎱
Browse files

share button

parent 9d90d728
......@@ -101,5 +101,4 @@ def upload():
@app.route('/shared/<string:share_id>')
def shared(share_id):
url = url_for('download', share_id=share_id)
return render_template('Shared.html', url=url)
return render_template('Shared.html', share_id=share_id)
......@@ -9,41 +9,63 @@
<div class="card mb-4 shadow text-center">
<div class="input-group mb-3">
<input type="text" class="form-control" aria-label="Shared URL" aria-describedby="copy-url" id="url" readonly value="not loaded yet">
<input type="text" class="form-control" aria-label="Shared URL" aria-describedby="copy-url" id="url"
readonly value="not loaded yet">
<div class="input-group-append">
<button class="input-group-text" id="copy-url">
<svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-clipboard-plus" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" d="M4 1.5H3a2 2 0 0 0-2 2V14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V3.5a2 2 0 0 0-2-2h-1v1h1a1 1 0 0 1 1 1V14a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V3.5a1 1 0 0 1 1-1h1v-1z"></path>
<path fill-rule="evenodd" d="M9.5 1h-3a.5.5 0 0 0-.5.5v1a.5.5 0 0 0 .5.5h3a.5.5 0 0 0 .5-.5v-1a.5.5 0 0 0-.5-.5zm-3-1A1.5 1.5 0 0 0 5 1.5v1A1.5 1.5 0 0 0 6.5 4h3A1.5 1.5 0 0 0 11 2.5v-1A1.5 1.5 0 0 0 9.5 0h-3zM8 7a.5.5 0 0 1 .5.5V9H10a.5.5 0 0 1 0 1H8.5v1.5a.5.5 0 0 1-1 0V10H6a.5.5 0 0 1 0-1h1.5V7.5A.5.5 0 0 1 8 7z"></path>
<svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-clipboard-plus" fill="currentColor"
xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd"
d="M4 1.5H3a2 2 0 0 0-2 2V14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V3.5a2 2 0 0 0-2-2h-1v1h1a1 1 0 0 1 1 1V14a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V3.5a1 1 0 0 1 1-1h1v-1z"></path>
<path fill-rule="evenodd"
d="M9.5 1h-3a.5.5 0 0 0-.5.5v1a.5.5 0 0 0 .5.5h3a.5.5 0 0 0 .5-.5v-1a.5.5 0 0 0-.5-.5zm-3-1A1.5 1.5 0 0 0 5 1.5v1A1.5 1.5 0 0 0 6.5 4h3A1.5 1.5 0 0 0 11 2.5v-1A1.5 1.5 0 0 0 9.5 0h-3zM8 7a.5.5 0 0 1 .5.5V9H10a.5.5 0 0 1 0 1H8.5v1.5a.5.5 0 0 1-1 0V10H6a.5.5 0 0 1 0-1h1.5V7.5A.5.5 0 0 1 8 7z"></path>
</svg>
</button>
</div>
</div>
<div class="input-group align-content-center center">
<div id="qrcode" class="text-center btn-outline-primary"></div>
<a href="{{ url }}" class="btn btn-lg btn-block btn-primary">Zum Download</a>
<a href="{{ url_for('download', share_id=share_id) }}" class="btn btn-lg btn-block btn-primary">Zum Download</a>
<button id="share-button" class="btn btn-lg btn-block btn-success">Teilen</button>
</div>
<script>
$(window).on("load",function() {
$("#url").val(window.location.origin + "{{ url }}");
</div>
$("#copy-url").click(function(){
/* Get the text field */
let copyText = document.getElementById("url");
/* Select the text field */
copyText.select();
copyText.setSelectionRange(0, 99999); /*For mobile devices*/
/* Copy the text inside the text field */
document.execCommand("copy");
});
});
</script>
<script src="{{ url_for('static', filename='js/qrcode.js') }}"></script>
<script>
new QRCode(document.getElementById("qrcode"), window.location.origin + "{{ url }}");
</script>
<script>
const URL = window.location.origin + "{{ url_for('download', share_id=share_id) }}";
</script>
<script>
$(window).on("load", function () {
$("#url").val(URL);
</div>
$("#copy-url").click(function () {
/* Get the text field */
let copyText = document.getElementById("url");
/* Select the text field */
copyText.select();
copyText.setSelectionRange(0, 99999); /*For mobile devices*/
/* Copy the text inside the text field */
document.execCommand("copy");
});
});
</script>
<script>
const shareData = {
title: 'ChiefSend',
text: 'Download these files I shared!',
url: URL,
}
const btn = document.getElementById('share-button');
btn.addEventListener('click', async () => {
try {
await navigator.share(shareData)
} catch (err) {
console.log(err);
}
});
</script>
<script src="{{ url_for('static', filename='js/qrcode.js') }}"></script>
<script>
new QRCode(document.getElementById("qrcode"), URL);
</script>
{% endblock content %}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment