- Notifications
You must be signed in to change notification settings - Fork760
Quote generator#66
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Open
SuhaniKaushal wants to merge1 commit intosahandghavidel:mainChoose a base branch fromSuhaniKaushal:principle
base:main
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
Uh oh!
There was an error while loading.Please reload this page.
Open
Changes fromall commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
32 changes: 32 additions & 0 deletionsprojects/Quote generqtor/index.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> | ||
<title>Ultimate Quote Generator</title> | ||
<link rel="stylesheet" href="style.css" /> | ||
</head> | ||
<body> | ||
<div class="quote-box"> | ||
<h1>💬 Daily Motivation</h1> | ||
<p id="quote">Click the button below to get today's quote.</p> | ||
<p id="author" class="author"></p> | ||
<div class="buttons"> | ||
<button onclick="generateQuote()">🔁 New Quote</button> | ||
<button onclick="copyQuote()">📋 Copy</button> | ||
<button onclick="shareQuote()">🐦 Share</button> | ||
<button onclick="saveFavorite()">💖 Save</button> | ||
<button onclick="viewFavorites()">📚 View Saved</button> | ||
<button onclick="toggleDarkMode()">🌙 Dark Mode</button> | ||
</div> | ||
<div id="favoritesContainer" class="hidden"> | ||
<h3>Saved Quotes</h3> | ||
<ul id="favoritesList"></ul> | ||
</div> | ||
</div> | ||
<script src="script.js"></script> | ||
</body> | ||
</html> |
107 changes: 107 additions & 0 deletionsprojects/Quote generqtor/script.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
let currentQuote = ""; | ||
let currentAuthor = ""; | ||
document.addEventListener("DOMContentLoaded", () => { | ||
autoDarkMode(); | ||
showDailyQuote(); | ||
}); | ||
const localQuotes = [ | ||
{ text: "Be yourself; everyone else is already taken.", author: "Oscar Wilde" }, | ||
{ text: "Success is not final, failure is not fatal: It is the courage to continue that counts.", author: "Winston Churchill" }, | ||
{ text: "Do not dwell in the past, do not dream of the future, concentrate the mind on the present moment.", author: "Buddha" }, | ||
{ text: "The only way to do great work is to love what you do.", author: "Steve Jobs" }, | ||
{ text: "Life is what happens when you're busy making other plans.", author: "John Lennon" } | ||
]; | ||
function generateQuote() { | ||
const randomIndex = Math.floor(Math.random() * localQuotes.length); | ||
const quote = localQuotes[randomIndex]; | ||
currentQuote = quote.text; | ||
currentAuthor = quote.author; | ||
displayQuote(currentQuote, currentAuthor); | ||
saveDailyQuote(currentQuote, currentAuthor); | ||
} | ||
function displayQuote(text, author) { | ||
const quoteEl = document.getElementById("quote"); | ||
const authorEl = document.getElementById("author"); | ||
quoteEl.innerHTML = ""; | ||
authorEl.innerHTML = ""; | ||
let i = 0; | ||
function typeWriter() { | ||
if (i < text.length) { | ||
quoteEl.innerHTML += text.charAt(i); | ||
i++; | ||
setTimeout(typeWriter, 30); | ||
} else { | ||
authorEl.innerText = `— ${author}`; | ||
} | ||
} | ||
typeWriter(); | ||
} | ||
function copyQuote() { | ||
const fullQuote = `"${currentQuote}" — ${currentAuthor}`; | ||
navigator.clipboard.writeText(fullQuote).then(() => { | ||
alert("Quote copied to clipboard!"); | ||
}); | ||
} | ||
function shareQuote() { | ||
const tweetURL = `https://twitter.com/intent/tweet?text=${encodeURIComponent( | ||
`"${currentQuote}" — ${currentAuthor}` | ||
)}`; | ||
window.open(tweetURL, "_blank"); | ||
} | ||
function saveFavorite() { | ||
const favorites = JSON.parse(localStorage.getItem("favorites")) || []; | ||
favorites.push({ text: currentQuote, author: currentAuthor }); | ||
localStorage.setItem("favorites", JSON.stringify(favorites)); | ||
alert("Quote saved!"); | ||
} | ||
function viewFavorites() { | ||
const container = document.getElementById("favoritesContainer"); | ||
const list = document.getElementById("favoritesList"); | ||
const favorites = JSON.parse(localStorage.getItem("favorites")) || []; | ||
list.innerHTML = ""; | ||
favorites.forEach(q => { | ||
const li = document.createElement("li"); | ||
li.textContent = `"${q.text}" — ${q.author}`; | ||
list.appendChild(li); | ||
}); | ||
container.classList.toggle("hidden"); | ||
} | ||
function toggleDarkMode() { | ||
document.body.classList.toggle("dark"); | ||
} | ||
function autoDarkMode() { | ||
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) { | ||
document.body.classList.add("dark"); | ||
} | ||
} | ||
function showDailyQuote() { | ||
const stored = JSON.parse(localStorage.getItem("dailyQuote")); | ||
const today = new Date().toDateString(); | ||
if (stored && stored.date === today) { | ||
currentQuote = stored.text; | ||
currentAuthor = stored.author; | ||
displayQuote(currentQuote, currentAuthor); | ||
} else { | ||
generateQuote(); | ||
} | ||
} | ||
function saveDailyQuote(text, author) { | ||
const today = new Date().toDateString(); | ||
localStorage.setItem("dailyQuote", JSON.stringify({ text, author, date: today })); | ||
} |
112 changes: 112 additions & 0 deletionsprojects/Quote generqtor/style.css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
body { | ||
font-family: 'Segoe UI', sans-serif; | ||
background: linear-gradient(-45deg, #f0f8ff, #e1f5fe, #f3e5f5, #ede7f6); | ||
background-size: 400% 400%; | ||
animation: gradient 15s ease infinite; | ||
margin: 0; | ||
display: flex; | ||
justify-content: center; | ||
align-items: flex-start; | ||
min-height: 100vh; | ||
padding: 40px; | ||
transition: background-color 1s ease, color 0.3s; | ||
} | ||
@keyframes gradient { | ||
0% { background-position: 0% 50% } | ||
50% { background-position: 100% 50% } | ||
100% { background-position: 0% 50% } | ||
} | ||
.quote-box { | ||
background-color: white; | ||
padding: 30px; | ||
border-radius: 12px; | ||
box-shadow: 0 10px 25px rgba(0,0,0,0.1); | ||
width: 100%; | ||
max-width: 500px; | ||
text-align: center; | ||
} | ||
h1 { | ||
margin-bottom: 20px; | ||
color: #333; | ||
} | ||
#quote { | ||
font-size: 20px; | ||
min-height: 60px; | ||
color: #444; | ||
} | ||
.author { | ||
margin-top: 10px; | ||
font-style: italic; | ||
color: #777; | ||
} | ||
.buttons { | ||
margin-top: 20px; | ||
display: flex; | ||
flex-wrap: wrap; | ||
justify-content: center; | ||
gap: 10px; | ||
} | ||
button { | ||
padding: 10px 14px; | ||
background-color: #007bff; | ||
color: white; | ||
border: none; | ||
border-radius: 6px; | ||
font-size: 14px; | ||
cursor: pointer; | ||
transition: 0.3s ease; | ||
} | ||
button:hover { | ||
background-color: #0056b3; | ||
} | ||
.dark { | ||
background-color: #121212; | ||
color: white; | ||
} | ||
.dark .quote-box { | ||
background-color: #1e1e1e; | ||
color: white; | ||
} | ||
.dark #quote, | ||
.dark .author { | ||
color: #ddd; | ||
} | ||
.dark button { | ||
background-color: #444; | ||
} | ||
.dark button:hover { | ||
background-color: #666; | ||
} | ||
.hidden { | ||
display: none; | ||
} | ||
#favoritesContainer { | ||
margin-top: 30px; | ||
text-align: left; | ||
} | ||
#favoritesList { | ||
list-style: none; | ||
padding: 0; | ||
} | ||
#favoritesList li { | ||
margin: 5px 0; | ||
border-bottom: 1px solid #ccc; | ||
padding-bottom: 5px; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.