var totalEpisodes = 0;\nvar avgEpisodeDuration = 0;\nvar hoursPerDay = 0;\n\nfunction calculateShowDuration() {\n // Get input values\n var numEpisodesInput = document.getElementById('numEpisodes');\n var avgDurationInput = document.getElementById('avgEpisodeDuration');\n var hoursPerDayInput = document.getElementById('hoursPerDay');\n\n // Parse values, defaulting to 0 if invalid\n totalEpisodes = parseFloat(numEpisodesInput.value) || 0;\n avgEpisodeDuration = parseFloat(avgDurationInput.value) || 0;\n hoursPerDay = parseFloat(hoursPerDayInput.value) || 0;\n\n // Calculate total hours\n var totalHours = (totalEpisodes * avgEpisodeDuration) / 60;\n\n // Calculate days required\n var daysRequired = totalHours / hoursPerDay;\n\n // Display results\n document.getElementById('totalHoursResult').value = totalHours.toFixed(2);\n document.getElementById('daysRequiredResult').value = daysRequired.toFixed(2);\n\n updateChart();\n}\n\nfunction updateChart() {\n var ctx = document.getElementById('progressChart').getContext('2d');\n \n var totalHours = (totalEpisodes * avgEpisodeDuration) / 60;\n var hoursPerDay = parseFloat(document.getElementById('hoursPerDay').value) || 0;\n \n // Clear previous chart\n if (window.myChart) {\n window.myChart.destroy();\n }\n \n // Create new chart only if we have valid data\n if (totalHours > 0 && hoursPerDay > 0) {\n var daysRequired = totalHours / hoursPerDay;\n \n // Create bars: Watched vs Remaining\n var data = {\n labels: ['Watched', 'Remaining'],\n datasets: [{\n label: 'Hours',\n data: [totalHours, 0],\n backgroundColor: ['#004a99', '#e0e0e0'],\n borderWidth: 0\n }]\n };\n \n window.myChart = new Chart(ctx, {\n type: 'bar',\n data: data,\n options: {\n responsive: true,\n maintainAspectRatio: false,\n scales: {\n y: {\n beginAtZero: true,\n max: totalHours * 1.1,\n title: {\n display: true,\n text: 'Hours'\n }\n },\n x: {\n grid: {\n display: false\n }\n }\n }\n }\n });\n }\n}\n\nfunction resetCalculator() {\n document.getElementById('numEpisodes').value = ";\n document.getElementById('avgEpisodeDuration').value = ";\n document.getElementById('hoursPerDay').value = ";\n document.getElementById('totalHoursResult').value = ";\n document.getElementById('daysRequiredResult').value = ";\n \n if (window.myChart) {\n window.myChart.destroy();\n }\n}\n\n// Add event listeners for real-time updates\ndocument.getElementById('numEpisodes').addEventListener('input', calculateShowDuration);\ndocument.getElementById('avgEpisodeDuration').addEventListener('input', calculateShowDuration);\ndocument.getElementById('hoursPerDay').addEventListener('input', calculateShowDuration);\n\n// Initial calculation\ncalculateShowDuration();\n\n
\n
\n
\n\n
\n \n
\n
\n
\n \n \n | Metric | \n Value | \n
\n \n \n \n | Total Hours | \n 0 | \n
\n \n | Days to Complete | \n 0 | \n
\n \n
\n
\n
\n
Results
\n
Total Hours: 0
\n
Days to Complete: 0
\n
\n
\n\n\n\n\n
\n
\n
Calculate Time Spent Watching TV Shows – [Your Website]\n
\n
\n\n\n\n\n
\n\n
\n \n TV Show Time Calculator
\n\n \n \n \n \n
\n\n \n \n \n \n
\n\n \n \n \n \n
\n\n \n \n \n
\n\n \n
Results
\n
\n
\n
Days to Complete
\n
0
\n
\n
\n\n \n
\n \n \n | Metric | \n Value | \n
\n \n \n \n | Total Hours | \n 0 | \n
\n \n | Days to Complete | \n 0 | \n
\n \n
\n
\n\n \n \n
\n\n \n \n \n\n