EUR-DZD_currency_converter/index.html

186 lines
5.1 KiB
HTML
Raw Normal View History

2024-04-09 09:29:48 +02:00
<!DOCTYPE html>
<html>
<head>
2024-04-09 09:53:54 +02:00
<title>EUR DZD</title>
2024-04-09 09:29:48 +02:00
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="manifest" href="/manifest.json">
2024-04-09 09:36:24 +02:00
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-title" content="EUR-DZD Calculator">
<link rel="apple-touch-icon" href="icon.png">
2024-04-09 09:29:48 +02:00
<style>
body {
font-family: Arial, sans-serif;
background-color: #f5f5f5;
padding: 20px;
}
h1 {
text-align: center;
margin-top: 20px;
}
form {
max-width: 400px;
margin: 0 auto;
background-color: #fff;
padding: 20px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0,0,0,0.2);
}
label {
display: block;
margin-bottom: 10px;
font-weight: bold;
}
input[type="number"] {
padding: 10px;
border-radius: 5px;
border: 1px solid #ccc;
width: 100%;
margin-bottom: 20px;
}
button[type="submit"] {
background-color: #4CAF50;
color: #fff;
border: none;
border-radius: 5px;
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
width: 100%;
}
p.result {
font-size: 20px;
font-weight: bold;
margin-top: 20px;
text-align: center;
}
#recentCalculations {
margin-top: 40px;
border-top: 2px solid #ccc;
padding-top: 20px;
}
#calculationList {
list-style-type: none;
padding: 0;
text-align: center;
}
#calculationList li {
margin-bottom: 10px;
}
footer {
text-align: center;
margin-top: 40px;
padding-top: 20px;
border-top: 1px solid #ddd;
color: #666;
font-size: 12px;
}
2024-04-09 10:02:43 +02:00
#installButton {
display: block;
margin: 0 auto;
padding: 10px 20px;
font-size: 16px;
background-color: #4CAF50;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
2024-04-09 10:13:47 +02:00
margin-top: 20px;
2024-04-09 10:02:43 +02:00
}
#install-instructions {
display: none;
text-align: center;
padding: 20px;
}
</style>
2024-04-09 09:29:48 +02:00
</head>
<body>
2024-04-09 10:13:47 +02:00
<h1>Exchange Rate Calculator</h1>
<!-- Installation instructions (hidden by default) -->
<div id="install-instructions">
2024-04-09 09:57:34 +02:00
<p>For the best experience, add this web app to your home screen:</p>
<p>1. Tap the <strong>Share</strong> button.</p>
<p>2. Tap <strong>Add to Home Screen</strong>.</p>
</div>
2024-04-09 10:06:44 +02:00
2024-04-09 10:13:47 +02:00
<!-- Installation button (hidden by default) -->
<button id="installButton" onclick="installApp()">Install App</button>
2024-04-09 10:02:43 +02:00
2024-04-09 10:13:47 +02:00
<form onsubmit="convert(event)">
<label for="euro">Enter amount in Euro:</label>
2024-04-09 09:29:48 +02:00
<input type="number" id="euro" placeholder="Enter amount in Euro">
2024-04-09 10:13:47 +02:00
<label for="dinar">Enter amount in Algerian Dinar:</label>
2024-04-09 09:29:48 +02:00
<input type="number" id="dinar" placeholder="Enter amount in Algerian Dinar">
2024-04-09 10:13:47 +02:00
<button type="submit">Convert</button>
2024-04-09 09:29:48 +02:00
</form>
2024-04-09 10:13:47 +02:00
2024-04-09 09:29:48 +02:00
<p class="result" id="result"></p>
<div id="recentCalculations">
<h2>Recent Calculations</h2>
<ul id="calculationList"></ul>
</div>
<footer>
<hr>
<p>EUR-DZD Calculator Version 1.2 (C) by KABI Fancy Media and Communication</p>
</footer>
<script>
2024-04-09 10:17:26 +02:00
let deferredPrompt;
window.addEventListener('beforeinstallprompt', (event) => {
// Prevent the default installation prompt
2024-04-09 09:29:48 +02:00
event.preventDefault();
2024-04-09 10:17:26 +02:00
// Stash the event so it can be triggered later
deferredPrompt = event;
// Show installation instructions only if app is not already installed
if (!window.matchMedia('(display-mode: standalone)').matches) {
document.getElementById('install-instructions').style.display = 'block';
document.getElementById('installButton').style.display = 'block';
}
});
2024-04-09 10:13:47 +02:00
function installApp() {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/service-worker.js')
.then(registration => {
console.log('Service Worker registered with scope:', registration.scope);
})
.catch(error => {
console.error('Service Worker registration failed:', error);
});
}
2024-04-09 10:17:26 +02:00
2024-04-09 10:13:47 +02:00
// Show installation instructions and button only if not already installed
if (!window.matchMedia('(display-mode: standalone)').matches) {
document.getElementById('install-instructions').style.display = 'block';
document.getElementById('installButton').style.display = 'block';
}
2024-04-09 10:17:26 +02:00
// Listen for the app installed event
window.addEventListener('appinstalled', () => {
// Hide the installation button once the app is installed
document.getElementById('installButton').style.display = 'none';
});
// Prompt the user to install the PWA
if (deferredPrompt) {
deferredPrompt.prompt();
deferredPrompt.userChoice.then((choiceResult) => {
if (choiceResult.outcome === 'accepted') {
console.log('User accepted the A2HS prompt');
}
deferredPrompt = null;
});
}
2024-04-09 10:02:43 +02:00
}
2024-04-09 10:13:47 +02:00
</script>
2024-04-09 10:17:26 +02:00
2024-04-09 09:29:48 +02:00
</body>
</html>