Skip to content
Snippets Groups Projects
Assignments.html 3.02 KiB
Newer Older
<!doctype html>
<html lang="de">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Student Course</title>
        <link rel="stylesheet" type="text/css" href="style.css" />
        <link
            href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css"
            rel="stylesheet"
        />
        <script src="script.js" defer></script>
        <script src="theme.js" defer></script>
        <style>
            .main-content {
                grid-template-columns: 1fr;
            }

            #UL {
                display: grid;
                grid-template-columns: 1fr 1fr 1fr 1fr;
                grid-gap: 10px;
            }
        </style>
    </head>
    <body>
        <nav class="navbar">
            <div class="logo">
                <a href="Homepage.html">LOGO</a>
            </div>
            <div class="nav-dots">
                <h1>Prog 1</h1>
            </div>
            <a href="#" class="account-btn">Account</a>
        </nav>
        <main class="main-content">
            <ul id="UL">
                <li>
                    <button id="downloadButton" class="box">
                        Assignment 1
                    </button>
                </li>
                <li>
                    <button id="downloadButton" class="box">
                        Assignment 2
                    </button>
                </li>
                <li>
                    <button id="downloadButton" class="box">
                        Assignment 3
                    </button>
                </li>
                <li>
                    <button id="downloadButton" class="box">
                        Assignment 4
                    </button>
                </li>
                <li>
                    <button id="downloadButton" class="box">
                        Assignment 5
                    </button>
                </li>
            </ul>
        </main>
        <script>
            // Download-Funktion
            const downloadButton = document.getElementById("downloadButton");

            downloadButton.addEventListener("click", () => {
                const fileName = "assignment.txt"; // Name der herunterzuladenden Datei
                const fileContent = "Hier ist der Inhalt des Assignments."; // Inhalt der Datei

                // Erstelle einen Blob aus dem Inhalt
                const blob = new Blob([fileContent], { type: "text/plain" });

                // Erstelle eine URL für den Blob
                const url = URL.createObjectURL(blob);

                // Erstelle ein unsichtbares <a>-Element
                const a = document.createElement("a");
                a.href = url;
                a.download = fileName; // Dateiname für den Download

                // Klicke auf den Link, um den Download zu starten
                a.click();

                // Speicher freigeben
                URL.revokeObjectURL(url);
            });
        </script>
    </body>
</html>