Skip to content

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
32 changes: 32 additions & 0 deletions projects/Quote generqtor/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Ultimate Quote Generator

💬 Daily Motivation

Click the button below to get today's quote.



Saved Quotes


    107 changes: 107 additions & 0 deletions projects/Quote generqtor/script.js
    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 deletions projects/Quote generqtor/style.css
    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;
    }