-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
293 lines (283 loc) · 10.1 KB
/
script.js
File metadata and controls
293 lines (283 loc) · 10.1 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
document.addEventListener('DOMContentLoaded', function() {
// Elements
const searchInput = document.getElementById('waste-search');
const searchBtn = document.getElementById('search-btn');
const tagButtons = document.querySelectorAll('.tag-btn');
const craftIdeasSection = document.getElementById('craft-ideas');
const ideasContainer = document.getElementById('ideas-container');
// Craft ideas database
const craftIdeas = {
'plastic bottle': [
{
title: 'Plastic Bottle Planter',
image: 'pictures/plasticbottle-plantholder.jpg',
description: 'Transform your plastic bottle into a beautiful hanging planter for your home.',
difficulty: 'Easy',
timeRequired: '30 minutes',
materials: ['Plastic bottle', 'Scissors or craft knife', 'String or twine', 'Potting soil', 'Small plant or seeds', 'Paint (optional)'],
steps: [
'Clean the plastic bottle thoroughly and remove any labels.',
'Cut the bottle in half horizontally using scissors or a craft knife.',
'Make small drainage holes in the bottom of the top half of the bottle.',
'Optionally, paint the outside of the bottle with weather-resistant paint.',
'Punch 3-4 small holes around the top edge for hanging strings.',
'Thread string or twine through the holes and tie them together at the top.',
'Fill the bottle with potting soil and plant your chosen plant or seeds.',
'Hang your planter in a suitable location with adequate sunlight.'
],
estimatedValue: '₹150-250',
},
{
title: 'Plastic Bottle Pen Holder',
image: 'pictures/penholder.png',
difficulty: 'Easy',
time: '20 minutes',
materials: ['Plastic bottle', 'Scissors', 'Sandpaper (optional, for smoothing edges)', 'Paint or decorative materials (optional)', 'Glue or tape (if adding extra decorations)'],
steps: [
'Clean the bottle thoroughly and remove any labels.',
'Cut the bottle to the desired height using scissors or a craft knife.',
'Smooth the edges with sandpaper to prevent rough or sharp areas.',
'Optionally, decorate by painting the outside, wrapping it in fabric, or adding stickers.',
'Place it on your desk and fill it with pens, pencils, or stationery.'
],
estimatedValue: '₹50-100'
}
],
'newspaper': [
{
title: 'Woven Basket',
image: 'pictures/wovenbasket.png',
difficulty: 'Medium',
time: '2 hours',
materials: ['Old newspapers', 'Glue', 'Paint', 'Scissors'],
steps: [
'Roll newspapers into tight tubes',
'Create base with crossed tubes',
'Weave sides up',
'Secure with glue',
'Paint and seal'
],
estimatedValue: '₹100-130'
}
],
'tin can': [
{
title: 'Lantern',
image: 'pictures/lantern.png',
difficulty: 'Medium',
time: '45 minutes',
materials: ['Clean tin can', 'Hammer', 'Nail', 'Tea light', 'Wire for handle'],
steps: [
'Clean can thoroughly',
'Draw pattern',
'Create holes following pattern',
'Sand edges',
'Add wire handle',
'Insert tea light'
],
estimatedValue: '₹150-200'
}
],
'cardboard box': [
{
title: ' Mini drawer organizer',
image: 'pictures/papercabinet.png',
difficulty: 'Medium',
time: '1 hours',
materials: ['Thick paper or cardboard', 'Ruler and pencil', 'Scissors or craft knife', 'Glue or double-sided tape', 'Decorative paper or stickers', 'Small paper rolls or beads for handles'],
steps: [
'Measure and cut a rectangular piece for the outer covering (it should wrap around three drawers).',
'Fold the edges to form a box shape.',
'Cut three rectangular pieces to make the drawers.',
'Fold and glue the sides to create a box-like shape.',
'Use small rolled paper tubes or beads as handles.',
'Glue them to the front center of each drawer.',
'Cover the outer box and drawers with patterned paper.',
'Add stickers or drawings for a cute aesthetic.',
'Secure the edges of the outer covering to hold the drawers inside. Make sure the drawers can slide in and out smoothly.',
'If making a multi-level organizer, glue multiple drawer units together.'
],
estimatedValue: '₹200-300'
}
],
'glass jar': [
{
title: 'Terrarium',
image: 'https://images.unsplash.com/photo-1516992654410-9309d4587e94?ixlib=rb-1.2.1&auto=format&fit=crop&w=600&q=80',
difficulty: 'Easy',
time: '30 minutes',
materials: ['Glass jar', 'Small plants', 'Pebbles', 'Soil', 'Charcoal'],
steps: [
'Clean jar thoroughly',
'Add layer of pebbles',
'Add charcoal layer',
'Add soil',
'Plant succulents or moss',
'Add decorative elements'
],
estimatedValue: '₹150-250'
}
],
'wine bottle': [
{
title: 'Pendant Light',
image: 'https://images.unsplash.com/photo-1550171362-78c9a56511c3?ixlib=rb-1.2.1&auto=format&fit=crop&w=600&q=80',
difficulty: 'Hard',
time: '2 hours',
materials: ['Wine bottle', 'Glass cutter', 'Sandpaper', 'Light fixture kit'],
steps: [
'Clean bottle',
'Remove label',
'Score with glass cutter',
'Sand edges smooth',
'Install light fixture',
'Hang securely'
],
estimatedValue: '₹400-600'
}
],
'old clothes': [
{
title: 'Tote Bag',
image: 'https://images.unsplash.com/photo-1597696929736-6d13bed8e6a8?ixlib=rb-1.2.1&auto=format&fit=crop&w=600&q=80',
difficulty: 'Medium',
time: '1.5 hours',
materials: ['Old jeans/shirts', 'Scissors', 'Sewing machine', 'Thread'],
steps: [
'Cut fabric to size',
'Sew sides together',
'Create straps',
'Attach straps',
'Add pockets (optional)'
],
estimatedValue: '₹200-300'
}
],
'wooden pallet': [
{
title: 'Coffee Table',
image: 'https://images.unsplash.com/photo-1551503766-ac63dfa6401c?ixlib=rb-1.2.1&auto=format&fit=crop&w=600&q=80',
difficulty: 'Hard',
time: '3 hours',
materials: ['Wooden pallet', 'Sandpaper', 'Wood stain', 'Wheels (optional)'],
steps: [
'Clean pallet',
'Sand surfaces smooth',
'Apply wood stain',
'Add wheels if desired',
'Seal surface'
],
estimatedValue: '₹800-1200'
}
],
'tire': [
{
title: 'Garden Planter',
image: 'https://images.unsplash.com/photo-1541123437800-1bb1317badc2?ixlib=rb-1.2.1&auto=format&fit=crop&w=600&q=80',
difficulty: 'Medium',
time: '1 hour',
materials: ['Old tire', 'Paint', 'Drill', 'Potting soil'],
steps: [
'Clean tire thoroughly',
'Paint exterior',
'Drill drainage holes',
'Add soil',
'Plant flowers or vegetables'
],
estimatedValue: '₹300-400'
}
],
'egg carton': [
{
title: 'Seed Starter',
image: 'https://images.unsplash.com/photo-1523348837708-15d4a09cfac2?ixlib=rb-1.2.1&auto=format&fit=crop&w=600&q=80',
difficulty: 'Easy',
time: '15 minutes',
materials: ['Egg carton', 'Soil', 'Seeds', 'Spray bottle'],
steps: [
'Cut lid off carton',
'Poke drainage holes',
'Fill cups with soil',
'Plant seeds',
'Water gently',
'Place in sunny spot'
],
estimatedValue: '₹500-1000'
}
]
};
// Search functionality
function searchCraftIdeas(searchTerm) {
searchTerm = searchTerm.toLowerCase();
craftIdeasSection.classList.remove('hidden');
ideasContainer.innerHTML = '';
// Find matching ideas
let found = false;
for (const [item, ideas] of Object.entries(craftIdeas)) {
if (item.includes(searchTerm)) {
found = true;
ideas.forEach(idea => {
const ideaCard = createIdeaCard(idea);
ideasContainer.appendChild(ideaCard);
});
}
}
if (!found) {
ideasContainer.innerHTML = '<p class="no-results">No craft ideas found for this item. Try searching for something else!</p>';
}
}
// Create idea card
function createIdeaCard(idea) {
const card = document.createElement('div');
card.className = 'idea-card';
card.innerHTML = `
<img src="${idea.image}" alt="${idea.title}" class="idea-image">
<div class="idea-content">
<h3>${idea.title}</h3>
<div class="idea-meta">
<span>Difficulty: ${idea.difficulty}</span>
<span>Time: ${idea.time}</span>
</div>
<div class="idea-materials">
<h4>Materials Needed:</h4>
<ul>
${idea.materials.map(material => `<li>${material}</li>`).join('')}
</ul>
</div>
<div class="idea-steps">
<h4>Steps:</h4>
<ol>
${idea.steps.map(step => `<li>${step}</li>`).join('')}
</ol>
</div>
<div class="idea-value">
<p>Estimated Value: ${idea.estimatedValue}</p>
</div>
<a href="/marketplace.html" class="btn secondary-btn">Find Similar Items</a>
</div>
`;
return card;
}
// Event listeners
if (searchBtn) {
searchBtn.addEventListener('click', () => {
searchCraftIdeas(searchInput.value);
});
}
if (searchInput) {
searchInput.addEventListener('keypress', (e) => {
if (e.key === 'Enter') {
searchCraftIdeas(searchInput.value);
}
});
}
if (tagButtons) {
tagButtons.forEach(button => {
button.addEventListener('click', () => {
const searchTerm = button.getAttribute('data-item');
searchInput.value = searchTerm;
searchCraftIdeas(searchTerm);
});
});
}
});