-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
97 lines (89 loc) · 4.39 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Microwave Time Converter</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css" rel="stylesheet">
<link rel="manifest" href="manifest.json">
<link rel="icon" type="image/x-icon" href="fav64.png">
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-gray-100 font-sans leading-normal tracking-normal">
<div class="container mx-auto p-8">
<div class="bg-white shadow-md rounded px-8 pt-6 pb-8 mb-4">
<h1 class="block text-gray-700 text-xl font-bold mb-2">On the Package...</h1>
<div class="mb-6">
<label class="block text-gray-700 text-sm font-bold" for="package-watt">
Watt
</label>
<input class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" id="package-watt" type="number" placeholder="Enter wattage" oninput="convert()">
<label class="block text-gray-700 text-sm font-bold mt-2" for="package-time">
Seconds
</label>
<input class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 mb-3 leading-tight focus:outline-none focus:shadow-outline" id="package-time" placeholder="Enter seconds" oninput="convert()">
</div>
<h1 class="block text-gray-700 text-xl font-bold mb-2">Convert to...</h1>
<div class="mb-4">
<label class="block text-gray-700 text-sm font-bold" for="home-watt">
Watt
</label>
<input class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" id="home-watt" type="number" placeholder="Enter wattage to convert to" oninput="convert()">
</div>
<div class="mt-4">
<p id="result-text" class="text-gray-700 text-sm" style="display: none";>
= <span id="minutes-seconds"></span><br>
(which is <span id="total-seconds"></span> secs)
</p>
</div>
</div>
</div>
<script>
document.getElementById('package-watt').value = localStorage.getItem('packageWatt') || '';
document.getElementById('package-time').value = localStorage.getItem('packageTime') || '';
document.getElementById('home-watt').value = localStorage.getItem('homeWatt') || '';
convert();
function convert() {
const packageWattInput = document.getElementById('package-watt').value;
const packageTimeInput = document.getElementById('package-time').value;
const homeWattInput = document.getElementById('home-watt').value;
const resultText = document.getElementById('result-text');
const minutesSeconds = document.getElementById('minutes-seconds');
const totalSeconds = document.getElementById('total-seconds');
if (packageWattInput && packageTimeInput && homeWattInput) {
// Perform the conversion based on the input and output wattage
const inputWattage = parseInt(packageWattInput);
const outputWattage = parseInt(homeWattInput);
const inputSeconds = parseInt(packageTimeInput);
const convertedSeconds = Math.round((inputWattage * inputSeconds) / outputWattage);
// Convert seconds to minutes and seconds for display
const mins = Math.floor(convertedSeconds / 60);
const secs = convertedSeconds % 60;
minutesSeconds.textContent = `${mins} min ${secs} secs`;
totalSeconds.textContent = `${convertedSeconds}`;
localStorage.setItem('packageWatt', packageWattInput);
localStorage.setItem('packageTime', packageTimeInput);
localStorage.setItem('homeWatt', homeWattInput);
// Show the result text
resultText.style.display = 'block';
} else {
// Hide the result text if any field is empty
resultText.style.display = 'none';
}
}
</script>
<script>
if ('serviceWorker' in navigator) {
window.addEventListener('load', function() {
navigator.serviceWorker.register('./service-worker.js')
.then(function(registration) {
console.log('Service Worker Registered!', registration);
})
.catch(function(error) {
console.log('Service Worker Registration Failed!', error);
});
});
}
</script>
</body>
</html>