Calculator Tools Calculator Tools
Create

Potty Training Tracker

Jan 7, 2024

About this app

A fun and interactive web app to track your toddler's potty training progress.

Potty Training Tracker 🚽 Potty Training Tracker 🧒 Log Pee 🟡 Log Poop 💩 Log Pee Accident 🟡💦 Log Poop Accident 💩💦

Related apps

Put this on your site

Source

                    <html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">

<title>Potty Training Tracker</title>
<meta name="description" content="A fun and interactive web app to track your toddler's potty training progress.">
<meta name="keywords" content="potty training, toddler, child, parenting, toilet training">

<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.5.1/chart.min.js"></script>

<style>
/* App CSS Goes Here */
body {
background: linear-gradient(to bottom, #f9a8d4, #fffcdc);
font-family: 'Comic Sans MS', 'Chalkboard SE', 'Comic Neue', sans-serif;
}
.emoji {
font-size: 2em;
}
#chart {
width: 80%;
margin: 0 auto;
}
#log {
text-align: center;
}
.log-button {
margin: 10px;
}
</style>

<script type="text/javascript">
try {
// App Javascript Goes Here. Place your entire script content inside the try block for error handling.
let logs = [];

function saveLocal() {
localStorage.setItem('logs', JSON.stringify(logs));
}

function loadLocal() {
const storedLogs = localStorage.getItem('logs');
if (storedLogs) {
logs = JSON.parse(storedLogs);
updateChart();
}
}

function logEvent(type) {
const event = { type, timestamp: new Date().toISOString() };
logs.push(event);
saveLocal();
updateChart();
}

function updateChart() {
const ctx = document.getElementById('chart').getContext('2d');
const labels = logs.map(log => new Date(log.timestamp).toLocaleTimeString());
const data = logs.map(log => log.type);
new Chart(ctx, {
type: 'line',
data: {
labels,
datasets: [{
label: 'Potty Events',
data,
fill: false,
borderColor: 'rgb(75, 192, 192)',
tension: 0.1
}]
},
});
}

// This will run when the DOM is ready.
document.addEventListener("DOMContentLoaded", function() {
loadLocal();
document.getElementById('log-pee').addEventListener('click', () => logEvent('pee'));
document.getElementById('log-poop').addEventListener('click', () => logEvent('poop'));
document.getElementById('log-accident-pee').addEventListener('click', () => logEvent('accident-pee'));
document.getElementById('log-accident-poop').addEventListener('click', () => logEvent('accident-poop'));
});

} catch (error) {
// This will throw the error to the parent window.
throw error;
}
</script>
</head>
<body>
<div id="main-container" class="container">
<!-- App HTML Goes Here -->
<h1 class="text-center">🚽 Potty Training Tracker 🧒</h1>
<div id="log">
<button id="log-pee" class="log-button">Log Pee 🟡</button>
<button id="log-poop" class="log-button">Log Poop 💩</button>
<button id="log-accident-pee" class="log-button">Log Pee Accident 🟡💦</button>
<button id="log-accident-poop" class="log-button">Log Poop Accident 💩💦</button>
</div>
<canvas id="chart"></canvas>
</div>
</body>
</html>