Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random Quote Generator Website #176

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,798 changes: 1,798 additions & 0 deletions Vanilla-JS-Projects/Basic/Random-Quote-Generator/Data/insparation.csv

Large diffs are not rendered by default.

56 changes: 56 additions & 0 deletions Vanilla-JS-Projects/Basic/Random-Quote-Generator/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<h1 align='center'><b>🎉 Random Quote Generator 🎉</b></h1>


<h3 align='center'>Tech Stack Used 🎮 🎮</h3>

<div align='center'>

![HTML5](https://img.shields.io/badge/html5-%23E34F26.svg?style=for-the-badge&logo=html5&logoColor=white)
![CSS3](https://img.shields.io/badge/css3-%231572B6.svg?style=for-the-badge&logo=css3&logoColor=white)
![JavaScript](https://img.shields.io/badge/javascript-%23323330.svg?style=for-the-badge&logo=javascript&logoColor=%23F7DF1E)

</div>

![Line](https://github.com/Avdhesh-Varshney/WebMasterLog/assets/114330097/4b78510f-a941-45f8-a9d5-80ed0705e847)


## :zap: Description 📃

<div>
<p>
This web application generates a random quote from a predefined dataset when a button is clicked. Perfect for a quick dose of inspiration or a thoughtful moment!
</p>
</div>




## :zap: How to run it? 🕹️


- Fork this repository.
- Clone the forked repository.
- Open index.html in your web browser.

## :zap: Screenshots 📸

![image](https://github.com/Avdhesh-Varshney/WebMasterLog/assets/103999924/b821df92-57ca-41fe-b75c-db48b9039e8f)

![image](https://github.com/Santhosh-Siddhardha/WebMasterLog/assets/103999924/9268e5ef-42ed-43bc-b248-0040ca9e233f)


![Line](https://github.com/Avdhesh-Varshney/WebMasterLog/assets/114330097/4b78510f-a941-45f8-a9d5-80ed0705e847)

<h4 align='center'>Developed By <b><i>Lingamuneni Santhosh Siddhardha</i></b> 👦</h4>
<p align='center'>
<a href='https://www.linkedin.com/in/santhosh-siddhardha-lingamuneni-94b87b214/'>
<img src='https://img.shields.io/badge/linkedin-%230077B5.svg?style=for-the-badge&logo=linkedin&logoColor=white' />
</a>
<a href='https://github.com/Santhosh-Siddhardha'>
<img src='https://img.shields.io/badge/github-%23121011.svg?style=for-the-badge&logo=github&logoColor=white' />
</a>
</p>

<h4 align='center'>Happy Coding 🧑‍💻</h4>

<h3 align="center">Show some &nbsp;❤️&nbsp; by &nbsp;🌟&nbsp; this repository!</h3>
36 changes: 36 additions & 0 deletions Vanilla-JS-Projects/Basic/Random-Quote-Generator/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Random Quote Generator</title>
<link rel="stylesheet" href="./style.css">
</head>
<body>
<div class="container">
<div class="heading">
<h1 class="main_heading">Random Quote Generator</h1>
</div>
<div class = "quote_gen">
<div class = "box">
<h3>Click "Generate" Button to generate a random Quote</h3>
</div>
<div class="btn">
<button class = "btn">Generate</button>
</div>
</div>
<div class="footer">
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this footer section from the project. No need of it for the project WebMasterLog.

<footer>
<p>Created by Lingamuneni Santhosh Siddhardha</p>
<div class = "end">
<a href = "[email protected]">E-mail</a>
<a href = "https://www.linkedin.com/in/santhosh-siddhardha-lingamuneni-94b87b214/">LinkedIn</a>
<a href = "https://github.com/Santhosh-Siddhardha">GitHub</a>
</div>
</footer>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script src="./style.js" charset="UTF-8"></script>
</body>
</html>
71 changes: 71 additions & 0 deletions Vanilla-JS-Projects/Basic/Random-Quote-Generator/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
.container{
display: grid;
grid-template-rows: 0.5fr 2fr auto;
gap: 5px;

}


.heading{
background-color: rgb(209, 247, 245);
border: 5px solid;
text-align: center;
}
h1{
font-size: 42px;
}
.quote_gen{
margin-top: 80px;
display: grid;
grid-template-rows: 2fr 1fr;
gap: 5px;
}
.box{
display: flex;
justify-content: center;
align-items: center;
height: 30vh;
width: 50%;
border: 5px solid;
margin-left: 25%;
}

.btn{
margin-top: 20px;
display: flex;
align-items: center;
justify-content: center;
}
button{
width: 25%;
height: 40%;
background-color: #04AA6D;
font-weight: bolder;
font-size: larger;
border-radius: 20px;
}
.footer{
position: fixed;
left: 0;
bottom: 0;
width: 100%;
background-color:rgb(209, 247, 245);
color: white;
text-align: center;

}
p{
color: black;
font-weight: bolder;
}
.end{
width: 20%;
margin-left: 40%;
display: flex;
justify-content: space-around;
align-items: center;
margin-bottom: 10px;
}
h3{
font-size: large;
}
48 changes: 48 additions & 0 deletions Vanilla-JS-Projects/Basic/Random-Quote-Generator/style.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
function random_num(){
return Math.floor(Math.random()*1746)+1
}

async function loadCSV(file) {
const response = await fetch(file);
const data = await response.text();
return data;
}

function parseCSV(csv) {
const quotes = [];

// Split CSV into rows
const rows = csv.split('\n');

// Parse each row
for (let i = 1; i < rows.length; i++) { // Start from index 1 to skip header row
const columns = rows[i].split(',');

if (columns.length >= 3) { // Ensure there's at least 3 columns (including quote)
const quote = columns[2].trim(); // Get the quote (third column, index 2)

if (quote) {
quotes.push(quote);
}
}
}

return quotes;
}

$(".btn").click(function(){
loadCSV('./Data/insparation.csv')
.then(csv => {
const quotes = parseCSV(csv);

if (quotes.length > 0) {
const randomIndex = Math.floor(Math.random() * quotes.length);
const randomQuote = quotes[randomIndex];

$("h3").text(randomQuote);
}
})
.catch(error => {
console.error('Error loading CSV:', error);
});
})
5 changes: 5 additions & 0 deletions database/vanilla.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,10 @@
"tag": "Basic",
"title": "Stopwatch",
"description": "The project is a sleek and efficient stopwatch application built using HTML, CSS, and JavaScript."
},
{
"tag": "Basic",
"title": "Random Quote Generator",
"description": "This web application generates a random quote from a predefined dataset, when a button is clicked."
}
]