<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
<title>AI Stories</title>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" rel="stylesheet">
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
min-height: 100vh;
background: #f5f5f5;
}
.app-container {
width: 90%;
max-width: 600px;
padding: 20px;
background: white;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
border-radius: 8px;
}
h1 {
text-align: center;
color: #333;
}
.input-section {
display: flex;
flex-direction: column;
align-items: center;
margin-top: 20px;
}
textarea {
width: 100%;
height: 150px;
padding: 10px;
border-radius: 5px;
border: 1px solid #ccc;
margin-bottom: 10px;
font-size: 16px;
resize: none;
}
.actions {
display: flex;
justify-content: space-around;
width: 100%;
}
button {
padding: 10px 20px;
font-size: 16px;
border-radius: 5px;
border: none;
cursor: pointer;
transition: background-color 0.3s;
}
button:hover {
background-color: #ddd;
}
.lang-switch {
position: fixed;
top: 10px;
right: 10px;
cursor: pointer;
}
@media (max-width: 600px) {
.app-container {
width: 95%;
}
button {
width: 45%;
}
}
</style>
</head>
<body>
<!-- Language Switcher -->
<div class="lang-switch">
<i class="fas fa-globe"></i>
<select id="languageSelect">
<option value="ru">RU</option>
<option value="en">EN</option>
</select>
</div>
<!-- Main Application Container -->
<div class="app-container">
<h1>AI Stories</h1>
<div class="input-section">
<textarea id="storyInput" placeholder="Начните вашу историю здесь..."></textarea>
<div class="actions">
<button id="randomStoryBtn"><i class="fas fa-magic"></i></button>
<button id="startStoryBtn">Начать историю</button>
</div>
</div>
</div>
<script type="module">
// Placeholder for requestAI function
function requestAI(prompt, callback) {
// This function is a placeholder and should be implemented with actual AI request logic
console.log('AI Request:', prompt);
callback(`AI Response based on: ${prompt}`);
}
function initApp() {
const languageSelect = document.getElementById("languageSelect");
const storyInput = document.getElementById("storyInput");
const randomStoryBtn = document.getElementById("randomStoryBtn");
const startStoryBtn = document.getElementById("startStoryBtn");
languageSelect.addEventListener("change", (event) => {
const lang = event.target.value;
document.documentElement.lang = lang;
updateLanguage(lang);
});
randomStoryBtn.addEventListener("click", () => {
requestAI("Random Story", (response) => {
storyInput.value = response;
});
});
startStoryBtn.addEventListener("click", () => {
const storyStart = storyInput.value;
requestAI(storyStart, (response) => {
console.log("AI Story Continuation:", response);
});
});
// Default language setup
updateLanguage("ru");
}
function updateLanguage(lang) {
const title = document.querySelector('h1');
if (lang === 'en') {
title.textContent = 'AI Stories';
document.getElementById('storyInput').placeholder = 'Start your story here...';
document.getElementById('startStoryBtn').textContent = 'Start Story';
} else {
title.textContent = 'AI Stories';
document.getElementById('storyInput').placeholder = 'Начните вашу историю здесь...';
document.getElementById('startStoryBtn').textContent = 'Начать историю';
}
}
document.addEventListener("DOMContentLoaded", () => {
initApp();
});
</script>
</body>
</html>