WEBproject
WEBproject
Submitted by
Smriti Dandagi – 2GI21EC142
Guide
Prof. Veena Kangralkar
Institute Vision
Mission
Department Vision:
Mission:
Certificate of Completion
This is to certify that Ms. Smriti Dandagi of 5 th semester bearing USN 2GI21EC142 has
satisfactorily completed the course project in Web Programming (Course code: 21CS554) .
It can be considered as a bonafide work carried out in partial fulfillment for the academic
requirement of 5th Semester B.E. in Computer Science & Engineering prescribed by KLS
Gogte Institute of Technology, Belagavi during the academic year 2023- 2024.
The report has been approved as it satisfies the academic requirements in respect of Assignment
(Course activity) prescribed for the said Degree.
2GI21EC142
Table of Content:
2 Introduction 2
3 Code 3-6
4 Methodology/Implementation 7-8
5 Output 9
6 Conclusion 10
7 References 11
Abstract:
This project is a simple Random Quote Generator built using JavaScript. It displays a random
inspirational quote along with its author's name when a button is clicked. The Random Quote
Generator is designed to provide users with a source of motivation and inspiration by
displaying random quotes from various authors. With each button click, a new quote and its
author are displayed on the page. This application fetches a new random quote from an API,
upon the click of a button, and displays it in the browser.
1
Introduction:
A Random Quote Generator is capable of pulling quotes randomly from an API, a database, or
simply from an array. We will be designing a Random Quote Generator from scratch using
HTML, CSS, JavaScript, and type.fit API. The webpage displays a random quote from a
collection and upon the click of a button, it randomly generates a new quote. We will first
generate the basic HTML Template and style it using CSS before diving deeper into the
JavaScript Logic. Random Quote Generator is a user-friendly online tool designed to deliver a
wide range of quotes on various topics. From wisdom and love to success and perseverance,
our tool offers an eclectic mix of quotes from renowned thinkers, authors, philosophers, and
even some lesser-known sources. With each click, you’ll encounter a new gem of wisdom to
uplift your spirits and ignite your imagination.
2
Code:
//file.html ( HTML code)
<!DOCTYPE html>
<html>
<head>
<!--META information-->
<meta charset="UTF-8">
<meta name="description" content="Random Quote Generator">
<meta name="keywords" content="HTML,CSS,JavaScript, Quotes, API">
<meta name="author" content="Smriti Dandagi">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!--End of META information-->
<!--FONTAWESOME CDN-->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-
awesome/5.15.1/css/all.min.css" integrity="sha512-
+4zCK9k+qNFUR5X+cKL9EIR+ZOhtIloNl9GIKS57V1MyNsYpYcUrUeQc9vNfzsWfV28
IaLL3i96P9sdNyeRssA==" crossorigin="anonymous" />
</head>
<body>
<!-- Quote Container -->
<div class="container">
<!-- Quote to be Displayed Here -->
<h1>
<i class="fas fa-quote-left"></i>
<span class="quote" id="quote"></span>
<i class="fas fa-quote-right"></i>
</h1>
<!-- Author to be Displayed Here -->
<p class="author" id="author"></p>
<hr/>
<div class="buttons">
<!--Button to tweet the quote -->
<a class="twitter" id="tweet"
href="https://twitter.com/intent/tweet?text=Greetings" data-size="large" target="_blank"
rel="noopener noreferrer"><i class="fab fa-twitter"></i></a>
<!--Add an onclick event on 'next quote' button. Upon the click of a button, a new random
quote is generated-->
<button class="next" onclick="getNewQuote()">Next quote</button>
</div>
</div>
3
<script src="script.js"></script>
</body>
</html>
//style.css(CSS code)
*{
margin:0;
padding:0;
box-sizing: border-box;
}
body{
min-height:100vh;
transition: 0.5s;
transition-timing-function: ease-in;
background-image: linear-gradient(to right bottom, rgb(255, 128, 128), #ffedbca8);
display: flex;
align-items: center;
justify-content: center;
.container
{
display: flex;
flex-direction: column;
align-items: center;
padding: 30px;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.6);
border-radius: 15px;
width: 600px;
background-color: rgba(255, 255, 255, 0.3);
margin: 10px;
}
.fa-quote-left, .fa-quote-right {
font-size: 35px;
color: rgb(179, 0, 0);
}
.quote
{
text-align: center;
font-size: 40px;
font-weight: bold;
}
.author
{
4
margin:10px;
text-align: right;
font-size: 25px;
font-style: italic;
font-family: cursive;
}
hr {
margin: 10px 0;
width: 100%;
border: 1px solid black;
background-color: black;
}
.buttons {
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 9px;
}
.twitter
{
border:1px solid rgb(102, 179, 255);
border-radius: 4px;
background-color: rgb(102, 179, 255);
color: white;
text-align: center;
font-size: 1.8em;
width: 60px;
height: 35px;
line-height: 40px;
}
.next
{
font-size:18px;
border-radius: 5px;
cursor:pointer;
padding: 10px;
margin-top: 5px;
font-weight: bold;
color: white;
background-image: linear-gradient(to right bottom, rgb(230, 0, 0), #ffedbca8);
}
.container:hover
{
box-shadow: 0 10px 10px rgb(230, 0, 0);
}
5
//script.js(Javascript code)
const text=document.getElementById("quote");
const author=document.getElementById("author");
const tweetButton=document.getElementById("tweet");
// Generates a random number between 0 and the length of the quotes array
const indx = Math.floor(Math.random()*allQuotes.length);
if(auth==null)
{
author = "Anonymous";
}
6
Methodology & Implementation:
Making the Bare Bones Of Our Application: In this section, we will use only HTML and put
all the required CDN links.
Step 1 (Adding our Foundation): Link your stylesheet and add other resources required for the
project as desired, for instance, we have added additional bootstrap libraries and Google fonts
for styling purposes. Our next step is to add the main body tag, where the bare bones of the
Random Quote Generator Lie.
Step 2 (Holding the front part and the back part of the Quote Box): Now it’s time for adding
the main HTML Code of our application. Add a div tag that holds the front side and the
backside of the Quote Box.
Step 3 (Adding front part of the Quote Box): Add a div element that holds the text, author, and
the clickable button.
Step 4 (Allocating area for displaying the quote): Let’s add a span element that holds the left
font awesome quote icon and the quote to be displayed. A span tag is used as the quote icon
and the quote needs to be on the same line.
Step 5 (Allocating area for displaying the author): Use a div tag to hold the author of the quote.
Step 6 (Adding the button): Use an anchor tag to display the button.
Step 7(Adding the back part of the Quote Box): Repeat the above 5 steps and generate a replica
of the quote box which exists behind the current box. After performing the above steps, we
have a bare-bones application with no styling or logic.
Styling The Application: CSS is used to make the application attractive and visually appealing
to the end-user.
Center the quote box using the top and left properties.
Apply padding and margin to the necessary elements.
Use two font families, Primary for the quote and Secondary for the author.
7
Two classes namely rotateB and rotateF are added to rotate the backside and the front side
when the button is clicked.
JavaScript Part:
Now here comes the main and last part of our random quote generator app. The entire code for
the working of the app is written within the getNewQuote() function. In this function, we will
fetch the data from the API. Since fetching the data from API is an asynchronous process so
we will use the async function to fetch the data and store it in the array.
Learn more about JavaScript async function here.
8
OUTPUT:
9
Conclusion:
Our Random Quote Generator is a user-friendly online tool designed to deliver a wide range
of quotes on various topics. From wisdom and love to success and perseverance, our tool offers
an eclectic mix of quotes from renowned thinkers, authors, philosophers, and even some lesser-
known sources. With each click, you’ll encounter a new gem of wisdom to uplift your spirits
and ignite your imagination.
10
References:
Random Quote Generator Using HTML, CSS, and JavaScript - DEV Community
Random Quote Generator Using HTML, CSS and JavaScript - GeeksforGeeks
11