Create App.html
Browse files
App.html
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html>
|
| 3 |
+
<head>
|
| 4 |
+
<title>Time Logger with Export</title>
|
| 5 |
+
<style>
|
| 6 |
+
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; display: flex; flex-direction: column; align-items: center; padding: 40px; background-color: #f4f4f9; }
|
| 7 |
+
.card { background: white; padding: 20px; border-radius: 12px; box-shadow: 0 4px 6px rgba(0,0,0,0.1); text-align: center; width: 350px; }
|
| 8 |
+
button { padding: 12px 24px; font-size: 16px; cursor: pointer; border: none; border-radius: 6px; transition: 0.2s; margin: 5px; }
|
| 9 |
+
.log-btn { background: #28a745; color: white; width: 100%; font-weight: bold; }
|
| 10 |
+
.log-btn:active { transform: scale(0.98); }
|
| 11 |
+
.export-btn { background: #007bff; color: white; font-size: 14px; }
|
| 12 |
+
.clear-btn { background: #f8d7da; color: #721c24; font-size: 12px; }
|
| 13 |
+
#logDisplay { margin-top: 20px; height: 150px; border: 1px solid #eee; overflow-y: auto; padding: 10px; background: #fafafa; font-family: monospace; text-align: left; font-size: 13px; }
|
| 14 |
+
</style>
|
| 15 |
+
</head>
|
| 16 |
+
<body>
|
| 17 |
+
|
| 18 |
+
<div class="card">
|
| 19 |
+
<h2>Time Logger</h2>
|
| 20 |
+
<button class="log-btn" onclick="logTime()">LOG CURRENT TIME</button>
|
| 21 |
+
|
| 22 |
+
<div id="logDisplay"></div>
|
| 23 |
+
|
| 24 |
+
<div style="margin-top: 15px;">
|
| 25 |
+
<button class="export-btn" onclick="exportToFile()">Download .txt File</button>
|
| 26 |
+
<br>
|
| 27 |
+
<button class="clear-btn" onclick="clearLogs()">Clear Browser Cache</button>
|
| 28 |
+
</div>
|
| 29 |
+
</div>
|
| 30 |
+
|
| 31 |
+
<script>
|
| 32 |
+
const logDisplay = document.getElementById('logDisplay');
|
| 33 |
+
|
| 34 |
+
// Initial Load
|
| 35 |
+
window.onload = displayLogs;
|
| 36 |
+
|
| 37 |
+
function logTime() {
|
| 38 |
+
const timestamp = new Date().toLocaleString();
|
| 39 |
+
let logs = JSON.parse(localStorage.getItem('buttonPresses')) || [];
|
| 40 |
+
logs.push(timestamp);
|
| 41 |
+
localStorage.setItem('buttonPresses', JSON.stringify(logs));
|
| 42 |
+
displayLogs();
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
function displayLogs() {
|
| 46 |
+
const logs = JSON.parse(localStorage.getItem('buttonPresses')) || [];
|
| 47 |
+
logDisplay.innerHTML = logs.map(t => `<div>> ${t}</div>`).reverse().join('');
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
function exportToFile() {
|
| 51 |
+
const logs = JSON.parse(localStorage.getItem('buttonPresses')) || [];
|
| 52 |
+
if (logs.length === 0) {
|
| 53 |
+
alert("No logs to export!");
|
| 54 |
+
return;
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
// Join the array into a string with new lines
|
| 58 |
+
const fileContent = logs.join('\n');
|
| 59 |
+
|
| 60 |
+
// Create a "Blob" (the file data)
|
| 61 |
+
const blob = new Blob([fileContent], { type: 'text/plain' });
|
| 62 |
+
|
| 63 |
+
// Create a hidden link to trigger the download
|
| 64 |
+
const link = document.createElement('a');
|
| 65 |
+
link.href = URL.createObjectURL(blob);
|
| 66 |
+
link.download = 'my_button_logs.txt';
|
| 67 |
+
|
| 68 |
+
// Click the link automatically and clean up
|
| 69 |
+
link.click();
|
| 70 |
+
URL.revokeObjectURL(link.href);
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
function clearLogs() {
|
| 74 |
+
if(confirm("This will wipe the browser's memory for this page. Continue?")) {
|
| 75 |
+
localStorage.removeItem('buttonPresses');
|
| 76 |
+
displayLogs();
|
| 77 |
+
}
|
| 78 |
+
}
|
| 79 |
+
</script>
|
| 80 |
+
</body>
|
| 81 |
+
</html>
|