diff --git a/static/download_results.js b/static/download_results.js new file mode 100644 index 0000000..ac0901a --- /dev/null +++ b/static/download_results.js @@ -0,0 +1,59 @@ +function deleteFiles(filePaths) { + fetch('/delete_files', { + method: 'POST', + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + }, + body: new URLSearchParams({ + 'file_paths': filePaths + }) + }) + .then(response => response.json()) + .then(data => { + if (data.success) { + alert('Files deleted successfully'); + location.reload(); + } else { + alert('Error deleting files: ' + JSON.stringify(data.errors)); + } + }); +} + +function deleteSelectedFiles() { + const selectedFiles = Array.from(document.querySelectorAll('input[name="fileCheckbox"]:checked')) + .map(checkbox => checkbox.value); + if (selectedFiles.length > 0) { + deleteFiles(selectedFiles); + } else { + alert('No files selected'); + } +} + +function downloadSelectedFiles() { + const selectedFiles = Array.from(document.querySelectorAll('input[name="fileCheckbox"]:checked')) + .map(checkbox => checkbox.value); + if (selectedFiles.length > 0) { + selectedFiles.forEach(file => { + const link = document.createElement('a'); + link.href = file; + link.download = file.split('/').pop(); + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); + }); + } else { + alert('No files selected'); + } +} + +// Function to check or uncheck all checkboxes in a table by checking or unchecking the "CheckAll" checkbox +function checkAllCheckboxes(tableId, checkAllCheckboxId) { + const table = document.getElementById(tableId); + const checkboxes = table.querySelectorAll('input[type="checkbox"][name="fileCheckbox"]'); + const checkAllCheckbox = document.getElementById(checkAllCheckboxId); + const isChecked = checkAllCheckbox.checked; + + checkboxes.forEach(checkbox => { + checkbox.checked = isChecked; + }); +} \ No newline at end of file diff --git a/templates/download_results.html b/templates/download_results.html index 92b0795..9ac43db 100644 --- a/templates/download_results.html +++ b/templates/download_results.html @@ -1,88 +1,5 @@ - - - - - Your page title - - - - {{ bootstrap.load_css() }} - - - - -
-

Torn User Activity Scraper

- -
+{% include "header.html" %}
@@ -91,16 +8,18 @@

Data Files

-
- - +
+
+ + +
- + @@ -117,7 +36,7 @@ {% endfor %} @@ -128,11 +47,12 @@

Log Files

-
- - +
+
+ + +
-
Select Select File Name Last Modified Created{{ file.created | datetimeformat }} {{ file.size }} - +
@@ -153,7 +73,7 @@ {% endfor %} @@ -162,5 +82,8 @@ - - \ No newline at end of file + {% block scripts %} + {{ bootstrap.load_js() }} + + {% endblock %} + {% include "footer.html" %} \ No newline at end of file diff --git a/templates/footer.html b/templates/footer.html new file mode 100644 index 0000000..691287b --- /dev/null +++ b/templates/footer.html @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/templates/header.html b/templates/header.html new file mode 100644 index 0000000..3b9b0a1 --- /dev/null +++ b/templates/header.html @@ -0,0 +1,23 @@ + + + + + Your page title + + + + {{ bootstrap.load_css() }} + + + +
+

Torn User Activity Scraper

+ +
\ No newline at end of file diff --git a/templates/index.html b/templates/index.html index 5db5540..dfd15c9 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,26 +1,4 @@ - - - - - Your page title - - - - {{ bootstrap.load_css() }} - - - -
-

Torn User Activity Scraper

- -
+{% include "header.html" %}
@@ -67,5 +45,4 @@ {{ bootstrap.load_js() }} {% endblock %} - - \ No newline at end of file + {% include "footer.html" %} \ No newline at end of file
{{ file.created | datetimeformat }} {{ file.size }} - +