1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <!DOCTYPE html>
- <html>
- <head>
- <title>OVI - File Downloader</title>
- <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
- </head>
- <body>
-
- <div class="m-3 form-outline w-25 mb-4">
- <textarea class="form-control" id="text-input" rows="8" placeholder="Inserire del testo da scaricare in diversi formati"></textarea>
- </div>
- <button type="button" class="btn btn-outline-primary" id="txt-download-button">Download .txt</button>
- <button type="button" class="btn btn-outline-primary" id="doc-download-button">Download .doc</button>
- <button type="button" class="btn btn-outline-primary" id="rtf-download-button">Download .rtf</button>
- <button type="button" class="btn btn-outline-primary" id="docx-download-button">Download .docx</button>
-
- <script>
- const txtDownloadButton = document.getElementById("txt-download-button");
- const docDownloadButton = document.getElementById("doc-download-button");
- const rtfDownloadButton = document.getElementById("rtf-download-button");
- const docxDownloadButton = document.getElementById("docx-download-button");
- const textInput = document.getElementById("text-input");
- txtDownloadButton.addEventListener("click", function () {
- const text = textInput.value;
- const blob = new Blob([text], { type: "text/plain" });
- const link = document.createElement("a");
- link.download = "file.txt";
- link.href = URL.createObjectURL(blob);
- link.click();
- });
- docDownloadButton.addEventListener("click", function () {
- const text = textInput.value;
- const blob = new Blob([text], { type: "application/msword" });
- const link = document.createElement("a");
- link.download = "file.doc";
- link.href = URL.createObjectURL(blob);
- link.click();
- });
- rtfDownloadButton.addEventListener("click", function () {
- const text = textInput.value;
- const blob = new Blob([text], { type: "application/rtf" });
- const link = document.createElement("a");
- link.download = "file.rtf";
- link.href = URL.createObjectURL(blob);
- link.click();
- });
- docxDownloadButton.addEventListener("click", function () {
- const text = textInput.value;
- const blob = new Blob([text], { type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" });
- const link = document.createElement("a");
- link.download = "file.docx";
- link.href = URL.createObjectURL(blob);
- link.click();
- });
- </script>
- </body>
- </html>
|