Spaces:
Running
Running
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<title>Farmers Training</title> | |
<style> | |
/* Chat Interface Styles */ | |
.chat-container { | |
position: fixed; | |
bottom: 20px; | |
right: 20px; | |
width: 300px; | |
height: 400px; | |
background: white; | |
border-radius: 10px; | |
box-shadow: 0 0 10px rgba(0,0,0,0.1); | |
display: flex; | |
flex-direction: column; | |
overflow: hidden; | |
z-index: 1000; | |
} | |
.chat-header { | |
background: #2e7d32; | |
color: white; | |
padding: 10px; | |
font-weight: bold; | |
} | |
.chat-messages { | |
flex-grow: 1; | |
overflow-y: auto; | |
padding: 10px; | |
} | |
.chat-message { | |
margin-bottom: 10px; | |
padding: 8px 12px; | |
border-radius: 15px; | |
max-width: 80%; | |
} | |
.user-message { | |
background: #e3f2fd; | |
margin-left: auto; | |
} | |
.bot-message { | |
background: #f5f5f5; | |
} | |
.chat-input { | |
display: flex; | |
padding: 10px; | |
border-top: 1px solid #eee; | |
} | |
.chat-input input { | |
flex-grow: 1; | |
padding: 8px; | |
border: 1px solid #ddd; | |
border-radius: 20px; | |
margin-right: 8px; | |
} | |
.chat-input button { | |
background: #2e7d32; | |
color: white; | |
border: none; | |
padding: 8px 15px; | |
border-radius: 20px; | |
cursor: pointer; | |
} | |
.chat-input button:hover { | |
background: #1b5e20; | |
} | |
/* Global Styles */ | |
* { | |
margin: 0; | |
padding: 0; | |
box-sizing: border-box; | |
font-family: Arial, sans-serif; | |
} | |
body { | |
background: #f4f4f4; | |
color: #333; | |
line-height: 1.6; | |
} | |
/* Header */ | |
header { | |
background: #2e7d32; | |
color: #fff; | |
padding: 20px 40px; | |
display: flex; | |
align-items: center; | |
justify-content: space-between; | |
} | |
header h1 { | |
font-size: 2rem; | |
} | |
.search-container { | |
position: relative; | |
} | |
.search-container input[type="text"] { | |
padding: 8px 12px; | |
border: none; | |
border-radius: 20px; | |
width: 200px; | |
outline: none; | |
transition: width 0.3s ease; | |
} | |
.search-container input[type="text"]:focus { | |
width: 250px; | |
} | |
/* Video Grid */ | |
.video-grid { | |
display: grid; | |
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); | |
gap: 20px; | |
padding: 20px 40px; | |
} | |
.card { | |
background: #fff; | |
border-radius: 10px; | |
overflow: hidden; | |
box-shadow: 0 2px 5px rgba(0,0,0,0.1); | |
transition: transform 0.3s ease, box-shadow 0.3s ease; | |
opacity: 0; | |
transform: translateY(20px); | |
animation: fadeInUp 0.5s forwards; | |
} | |
.card:nth-child(odd) { | |
animation-delay: 0.1s; | |
} | |
.card:nth-child(even) { | |
animation-delay: 0.2s; | |
} | |
.card:hover { | |
transform: scale(1.03); | |
box-shadow: 0 5px 15px rgba(46, 125, 50, 0.3); | |
} | |
.card iframe { | |
width: 100%; | |
height: 200px; | |
border: none; | |
} | |
.card-content { | |
padding: 15px; | |
} | |
.card-content h3 { | |
margin-bottom: 10px; | |
font-size: 1.2rem; | |
color: #2e7d32; | |
} | |
.card-content p { | |
font-size: 0.95rem; | |
color: #666; | |
} | |
@keyframes fadeInUp { | |
to { | |
opacity: 1; | |
transform: translateY(0); | |
} | |
} | |
</style> | |
</head> | |
<body> | |
<header> | |
<h1>Farmers Training</h1> | |
<div class="search-container"> | |
<input type="text" placeholder="Search..."> | |
</div> | |
</header> | |
<main> | |
<div class="video-grid"> | |
<!-- Card 1 --> | |
<div class="card"> | |
<iframe src="https://www.youtube.com/embed/XsLIkggkcw4" allowfullscreen></iframe> | |
<div class="card-content"> | |
<h3>Farming Techniques 101</h3> | |
<p>A quick overview of modern farming techniques to boost productivity.</p> | |
</div> | |
</div> | |
<!-- Card 2 --> | |
<div class="card"> | |
<iframe src="https://www.youtube.com/embed/QxK4YbPrWXk" allowfullscreen></iframe> | |
<div class="card-content"> | |
<h3>Organic Farming</h3> | |
<p>Learn how to switch to organic methods for sustainable agriculture.</p> | |
</div> | |
</div> | |
<!-- Card 3 --> | |
<div class="card"> | |
<iframe src="https://www.youtube.com/embed/Z9HAy9EYKKs" allowfullscreen></iframe> | |
<div class="card-content"> | |
<h3>Irrigation Systems</h3> | |
<p>Explore different irrigation systems and their benefits.</p> | |
</div> | |
</div> | |
<!-- Card 4 --> | |
<div class="card"> | |
<iframe src="https://www.youtube.com/embed/XeNA6XdMoF8" allowfullscreen></iframe> | |
<div class="card-content"> | |
<h3>Crop Rotation Strategies</h3> | |
<p>Understanding the importance of crop rotation for soil health.</p> | |
</div> | |
</div> | |
<!-- Card 5 --> | |
<div class="card"> | |
<iframe src="https://www.youtube.com/embed/L14woJZEJnk" allowfullscreen></iframe> | |
<div class="card-content"> | |
<h3>Soil Fertility</h3> | |
<p>Tips to improve soil fertility using natural and chemical methods.</p> | |
</div> | |
</div> | |
<!-- Card 6 --> | |
<div class="card"> | |
<iframe src="https://www.youtube.com/embed/TfiWMGrRU7w" allowfullscreen></iframe> | |
<div class="card-content"> | |
<h3>Modern Tractor Use</h3> | |
<p>Learn about the latest tractors and machinery for farming.</p> | |
</div> | |
</div> | |
<!-- Card 7 --> | |
<div class="card"> | |
<iframe src="https://www.youtube.com/embed/_tijHjup-gM" allowfullscreen></iframe> | |
<div class="card-content"> | |
<h3>Precision Agriculture</h3> | |
<p>Using technology to optimize farm production and reduce waste.</p> | |
</div> | |
</div> | |
<!-- Card 8 --> | |
<div class="card"> | |
<iframe src="https://www.youtube.com/embed/dmThw7TyutA" allowfullscreen></iframe> | |
<div class="card-content"> | |
<h3>Farm Safety Tips</h3> | |
<p>Essential safety guidelines to protect yourself on the farm.</p> | |
</div> | |
</div> | |
<!-- Card 9 --> | |
<div class="card"> | |
<iframe src="https://www.youtube.com/embed/eQSNKrigiOM" allowfullscreen></iframe> | |
<div class="card-content"> | |
<h3>Greenhouse Management</h3> | |
<p>Learn how to manage greenhouses for year-round farming.</p> | |
</div> | |
</div> | |
<!-- Card 10 --> | |
<div class="card"> | |
<iframe src="https://www.youtube.com/embed/xW50iMVzo2k" allowfullscreen></iframe> | |
<div class="card-content"> | |
<h3>Farm Equipment Maintenance</h3> | |
<p>Maintenance tips to keep your farm equipment running smoothly.</p> | |
</div> | |
</div> | |
<!-- Card 11 --> | |
<div class="card"> | |
<iframe src="https://www.youtube.com/embed/AzDWmpVOk5I" allowfullscreen></iframe> | |
<div class="card-content"> | |
<h3>Livestock Management</h3> | |
<p>Best practices for raising and caring for livestock.</p> | |
</div> | |
</div> | |
<!-- Card 12 --> | |
<div class="card"> | |
<iframe src="https://www.youtube.com/embed/CIVfSXoTsyk" allowfullscreen></iframe> | |
<div class="card-content"> | |
<h3>Organic Pesticides</h3> | |
<p>How to make and use organic pesticides for crop protection.</p> | |
</div> | |
</div> | |
<!-- Card 13 --> | |
<div class="card"> | |
<iframe src="https://www.youtube.com/embed/Ltc4ZzQN_vE" allowfullscreen></iframe> | |
<div class="card-content"> | |
<h3>Sustainable Farming</h3> | |
<p>Steps toward a sustainable and eco-friendly farm operation.</p> | |
</div> | |
</div> | |
<!-- Card 14 --> | |
<div class="card"> | |
<iframe src="https://www.youtube.com/embed/ttBywb7DwSo" allowfullscreen></iframe> | |
<div class="card-content"> | |
<h3>Farm Budgeting</h3> | |
<p>Managing finances and budgeting effectively on the farm.</p> | |
</div> | |
</div> | |
<!-- Card 15 --> | |
<div class="card"> | |
<iframe src="https://www.youtube.com/embed/Ov3tMgej808" allowfullscreen></iframe> | |
<div class="card-content"> | |
<h3>Advanced Farming Tools</h3> | |
<p>Explore the latest tools and technology transforming farming.</p> | |
</div> | |
</div> | |
</div> | |
</main> | |
<!-- Chat Interface --> | |
<div class="chat-container"> | |
<div class="chat-header">Farming Assistant</div> | |
<div class="chat-messages" id="chatMessages"></div> | |
<div class="chat-input"> | |
<input type="text" placeholder="Ask about farming..." id="chatInput"> | |
<button onclick="sendMessage()">Send</button> | |
</div> | |
</div> | |
<script src="chatbot.js"></script> | |
<script> | |
const searchInput = document.querySelector('.search-container input[type="text"]'); | |
const cards = document.querySelectorAll('.card'); | |
const chatInput = document.getElementById('chatInput'); | |
const chatMessages = document.getElementById('chatMessages'); | |
// Search functionality | |
searchInput.addEventListener('input', function() { | |
const searchTerm = searchInput.value.toLowerCase(); | |
cards.forEach(card => { | |
const title = card.querySelector('h3').textContent.toLowerCase(); | |
const description = card.querySelector('p').textContent.toLowerCase(); | |
if (title.includes(searchTerm) || description.includes(searchTerm)) { | |
card.style.display = 'block'; | |
} else { | |
card.style.display = 'none'; | |
} | |
}); | |
}); | |
// Chat functionality | |
function addMessage(message, isUser) { | |
const messageDiv = document.createElement('div'); | |
messageDiv.className = `chat-message ${isUser ? 'user-message' : 'bot-message'}`; | |
messageDiv.textContent = message; | |
chatMessages.appendChild(messageDiv); | |
chatMessages.scrollTop = chatMessages.scrollHeight; | |
} | |
function displayRecommendations(recommendations) { | |
recommendations.forEach(video => { | |
const messageDiv = document.createElement('div'); | |
messageDiv.className = 'chat-message bot-message'; | |
messageDiv.innerHTML = `<strong><a href="${video.url}" target="_blank">${video.title}</a></strong><br>${video.description}`; | |
chatMessages.appendChild(messageDiv); | |
}); | |
chatMessages.scrollTop = chatMessages.scrollHeight; | |
} | |
function sendMessage() { | |
const message = chatInput.value.trim(); | |
if (message) { | |
addMessage(message, true); | |
chatbot.addToHistory(message, true); | |
const response = chatbot.processInput(message); | |
addMessage(response.message, false); | |
chatbot.addToHistory(response.message, false); | |
if (response.recommendations.length > 0) { | |
displayRecommendations(response.recommendations); | |
} | |
chatInput.value = ''; | |
} | |
} | |
// Handle Enter key | |
chatInput.addEventListener('keypress', function(e) { | |
if (e.key === 'Enter') { | |
sendMessage(); | |
} | |
}); | |
</script> | |
</body> | |
</html> | |