-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathdirectory.html
116 lines (107 loc) · 5.26 KB
/
directory.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MedPlant</title>
<meta name="description" content="MedPlant" />
<meta name="keywords" content="MedPlant" />
<meta property="og:title" content="MedPlant" />
<meta property="og:description" content="MedPlant" />
<meta property="og:image" content="#" />
<meta property="og:type" content="website" />
<meta property="og:url" content="#" />
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-9ndCyUaIbzAi2FUVXJi0CjmCapSmO7SnpJef0486qhLnuZ2cdeRhO02iuK6FUUVM" crossorigin="anonymous">
<link rel="icon" type="image/x-icon" href="./img/leaf.png">
<link rel="stylesheet" href="">
<style>
.card:hover {
transition: all ease-in 0.2s;
transform: scale(1.03);
cursor: pointer;
}
a {
text-decoration: none;
}
.card-text{
max-height: 70px;
overflow:hidden;
}
</style>
</head>
<body>
<nav class="navbar bg-dark">
<div class="container-fluid">
<a class="navbar-brand text-light" href="./home.html">
<img src="./img/leaf.png" alt="Logo" width="30" height="24" class="d-inline-block align-text-top"> MedPlant
</a>
</div>
</nav>
<section class="py-5 text-center container" style="background-image: url(./img/remove.png);">
<div class="row py-lg-5">
<div class="col-lg-6 col-md-8 mx-auto">
<h1 class="fw-light">Directory Page</h1>
<p class="lead text-body-secondary">Discover the Blooming Wellness Archive: Where Nature's Remedies and Serenity Unite</p>
</div>
</div>
</section>
<main class="bg-success">
<div class="album py-5 bg-body-tertiary">
<div class="container" style="background-image: url(./assets/asset\ 30.png)">
<div class="row row-cols-1 row-cols-sm-2 row-cols-md-3 g-3" id="plantCardsContainer" >
</div>
</div>
</div>
</div>
</main>
<script>
function createCard(plantName, imageUrl) {
// Create a new card element
const card = document.createElement('div');
card.className = 'col';
//remove space from the plant name
plantNameNoSpace = plantName.replace(/\s+/g, '')
// Fetch the "about" content from the corresponding HTML page
fetch(`./${plantNameNoSpace.toLowerCase()}.html`)
.then(response => response.text())
.then(htmlContent => {
// Extract the "about" content from the fetched HTML
const parser = new DOMParser();
const doc = parser.parseFromString(htmlContent, 'text/html');
const aboutContent = doc.querySelector('#about-plant').textContent;
// Build the card content
card.innerHTML = `
<a class="text-dark" href="./${plantName.replace(/\s+/g, '').toLowerCase()}.html">
<div class="card shadow-sm">
<img class="bd-placeholder-img card-img-top" width="100%" height="225" src="${imageUrl}" role="img" aria-label="Placeholder: Thumbnail" preserveAspectRatio="xMidYMid slice" focusable="false">
<rect width="100%" height="100%" fill="#55595c" />
</svg>
<div class="card-body">
<h3>${plantName}</h3>
<p class="card-text">${aboutContent}</p>
</div>
</div>
</a>
`;
// Append the card to the container
const container = document.getElementById("plantCardsContainer");
container.appendChild(card);
})
.catch(error => console.error('Error fetching plant content:', error));
}
// Call the function for each plant
createCard('Holy Basil', 'https://upload.wikimedia.org/wikipedia/commons/thumb/0/01/Tulsi_or_Tulasi_Holy_basil.jpg/640px-Tulsi_or_Tulasi_Holy_basil.jpg');
createCard('Neem', 'https://static.toiimg.com/photo/68670559.cms');
createCard('Aloevera', 'https://www.almanac.com/sites/default/files/styles/or/public/image_nodes/aloe-vera-white-pot_sunwand24-ss_edit.jpg?itok=BVzzldrw');
createCard('Black Cumin', 'https://cdn.britannica.com/37/197437-050-91B080A8/cumin-seeds.jpg');
createCard('Lavender', 'https://i0.wp.com/post.healthline.com/wp-content/uploads/2020/04/11450-Natures_9_Most_Powerful_Plants-body8_1296x728.jpg?h=1528');
createCard('Amla', 'img/amla.jpeg');
createCard('Babool', 'img/babool.jpeg');
createCard('Black Pepper', './img/blackpepper.jpg');
// Add similar calls to add more plants
// keep the plant name and html file name exactly similar
</script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-geWF76RCwLtnZ8qwWowPQNguL3RmwHVBC9FhGdlKrxdiJJigb/j/68SIy3Te4Bkz" crossorigin="anonymous"></script>
</body>
</html>