Last active
July 30, 2024 07:57
-
-
Save viartemev/b327bdad538306c509126f4924a7f888 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="ru"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Число дня</title> | |
<script src="https://telegram.org/js/telegram-web-app.js"></script> | |
<style> | |
body { | |
font-family: Arial, sans-serif; | |
display: flex; | |
justify-content: center; | |
align-items: center; | |
height: 100vh; | |
margin: 0; | |
background-color: #f0f0f0; | |
} | |
.container { | |
text-align: center; | |
background-color: white; | |
padding: 20px; | |
border-radius: 10px; | |
box-shadow: 0 0 10px rgba(0,0,0,0.1); | |
} | |
button { | |
padding: 10px 20px; | |
font-size: 16px; | |
cursor: pointer; | |
background-color: #0088cc; | |
color: white; | |
border: none; | |
border-radius: 5px; | |
margin-top: 20px; | |
} | |
#result { | |
font-size: 24px; | |
margin-top: 20px; | |
} | |
</style> | |
</head> | |
<body> | |
<div class="container"> | |
<h1>Ваше число дня</h1> | |
<p>Нажмите кнопку, чтобы получить ваше уникальное число дня.</p> | |
<button id="generateBtn">Получить число</button> | |
<p id="result"></p> | |
</div> | |
<script> | |
let tg = window.Telegram.WebApp; | |
tg.expand(); | |
document.getElementById('generateBtn').addEventListener('click', function() { | |
let randomNumber = Math.floor(Math.random() * 100) + 1; | |
document.getElementById('result').textContent = 'Ваше число дня: ' + randomNumber; | |
setTimeout(() => { | |
tg.sendData(randomNumber.toString()); | |
tg.close(); | |
}, 1500); // Задержка в 1.5 секунды перед закрытием WebApp | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment