-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
61 lines (57 loc) · 1.87 KB
/
Copy pathscript.js
File metadata and controls
61 lines (57 loc) · 1.87 KB
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
// Simple SPA navigation for steps
const steps = ['login', 'soil', 'crops', 'tasks', 'market'];
function nextStep(nextId) {
steps.forEach(id => {
const el = document.getElementById(id);
if (el) el.classList.remove('active');
});
const nextEl = document.getElementById(nextId);
if (nextEl) nextEl.classList.add('active');
// Highlight active tab
const navLinks = document.querySelectorAll('nav a');
navLinks.forEach(link => {
link.classList.remove('active');
if (link.getAttribute('href') === '#' + nextId) {
link.classList.add('active');
}
});
}
// Login/Registration
const loginForm = document.getElementById('loginForm');
if (loginForm) {
loginForm.addEventListener('submit', function(e) {
e.preventDefault();
nextStep('soil');
});
}
// Task Upload
const taskUploadForm = document.getElementById('taskUploadForm');
let points = 0;
let level = 1;
let gifts = [];
if (taskUploadForm) {
taskUploadForm.addEventListener('submit', function(e) {
e.preventDefault();
points += 10;
if (points % 50 === 0) {
level++;
gifts.push('Gift ' + level);
}
document.getElementById('pointsDisplay').textContent = `Points: ${points} | Level: ${level} | Gifts: ${gifts.join(', ') || 'None'}`;
alert('Task picture uploaded! Notification sent to authorities.');
});
}
// Market Listing
const marketForm = document.getElementById('marketForm');
const marketList = document.getElementById('marketList');
if (marketForm && marketList) {
marketForm.addEventListener('submit', function(e) {
e.preventDefault();
const crop = document.getElementById('cropType').value;
const qty = document.getElementById('quantity').value;
const entry = document.createElement('div');
entry.textContent = `${crop} - ${qty} kg listed for bulk buying.`;
marketList.appendChild(entry);
alert('Crop listed for bulk buying!');
});
}