Skip to content

Commit

Permalink
changed script location
Browse files Browse the repository at this point in the history
  • Loading branch information
4-dash committed Feb 3, 2025
1 parent a5201f8 commit 4d10f03
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
12 changes: 12 additions & 0 deletions media/copy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function copyToClipboard(button) {
const text = button.getAttribute("data-text");

navigator.clipboard.writeText(text).then(function() {
const alertBox = document.createElement("span");
alertBox.className = "text-success ms-2";
alertBox.innerText = "Copied!";

button.parentElement.appendChild(alertBox);
setTimeout(() => alertBox.remove(), 2000);
}).catch(err => console.error('Copy failed:', err));
}
20 changes: 5 additions & 15 deletions src/templates/intern/free_questions.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
{% extends "bestellung_base.html" %}
{% load i18n %}
{% load static %}

{% block title %}{% translate "Freie Fragen Liste" %}{% endblock %}

{% block extra_header %}
<script type="text/javascript" src="{% static "copy.js" %}"></script>
{% endblock %}

{% block content %}
<h1>{% translate "Liste der freien Fragen im aktuellen Semester" %}</h1>
<br>
Expand Down Expand Up @@ -32,19 +37,4 @@ <h2>{{ v.name }}</h2>
{% endif %}
{% endfor %}

<script>
function copyToClipboard(button) {
var text = button.getAttribute("data-text");

navigator.clipboard.writeText(text).then(function() {
let alertBox = document.createElement("span");
alertBox.className = "text-success ms-2";
alertBox.innerText = "Copied!";

button.parentElement.appendChild(alertBox);
setTimeout(() => alertBox.remove(), 2000);
}).catch(err => console.error('Copy failed:', err));
}
</script>

{% endblock %}

0 comments on commit 4d10f03

Please sign in to comment.