{"id":208,"date":"2024-12-28T18:44:04","date_gmt":"2024-12-28T18:44:04","guid":{"rendered":"https:\/\/makulu.online\/?page_id=208"},"modified":"2024-12-28T18:44:07","modified_gmt":"2024-12-28T18:44:07","slug":"stocks","status":"publish","type":"page","link":"https:\/\/makulu.online\/index.php\/stocks\/","title":{"rendered":"Stocks"},"content":{"rendered":"\n<!DOCTYPE html>\n<html>\n<head>\n    <title>Electra AI &#8211; Stock Market News<\/title>\n    <style>\n        body {\n            font-family: 'Arial', sans-serif;\n            margin: 10px;\n            background-color: #e6f7ff;\n            color: #333;\n            position: relative;\n        }\n\n        h1 {\n            text-align: center;\n            margin-bottom: 10px;\n            color: #0056b3;\n            font-size: 2.2em;\n            text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.05);\n        }\n\n        h3 {\n            text-align: center;\n            margin-bottom: 15px;\n            color: #0056b3;\n            font-size: 1.0em;\n            text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.05);\n        }\n\n        #controls-container {\n            display: flex;\n            justify-content: space-between;\n            align-items: center;\n            margin-bottom: 10px;\n        }\n\n        #filter-sort-container {\n            display: flex;\n            gap: 10px;\n        }\n\n        #ticker-filter, #sort-by {\n            padding: 8px;\n            border-radius: 5px;\n            border: 1px solid #ccc;\n            font-size: 1em;\n            cursor: pointer;\n        }\n\n        #news-container {\n            display: grid;\n            grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));\n            gap: 20px;\n        }\n\n        .news-item {\n            background-color: #fff;\n            border-radius: 12px;\n            box-shadow: 0 5px 10px rgba(0, 0, 0, 0.15);\n            padding: 20px;\n            transition: transform 0.3s ease, box-shadow 0.3s ease;\n            border-top: 8px solid #007bff;\n            cursor: pointer;\n            display: flex;\n            flex-direction: column;\n            min-height: 150px;\n            position: relative; \/* For sentiment badge positioning *\/\n        }\n\n        .news-item:hover {\n            transform: scale(1.04);\n            box-shadow: 0 7px 14px rgba(0, 0, 0, 0.2);\n        }\n\n        .ticker {\n            font-size: 1.3em;\n            font-weight: bold;\n            color: #fff;\n            background-color: #007bff;\n            padding: 6px 12px;\n            border-radius: 6px;\n            display: inline-block;\n            margin-bottom: 12px;\n        }\n\n        .title {\n            font-size: 1.15em;\n            font-weight: 600;\n            margin-top: 0;\n            margin-bottom: 12px;\n            line-height: 1.5;\n            color: #2c3e50;\n        }\n\n        .summary {\n            font-size: 0.95em;\n            line-height: 1.6;\n            color: #555;\n            margin-bottom: 12px;\n            overflow: hidden;\n            max-height: 120px;\n            transition: max-height 0.3s ease-out;\n            flex-grow: 1;\n        }\n\n        .news-item.expanded .summary {\n            max-height: none;\n        }\n\n        .read-more-link {\n            display: inline-block;\n            padding: 10px 20px;\n            background-color: #28a745;\n            color: #fff;\n            text-decoration: none;\n            border-radius: 6px;\n            font-size: 0.9em;\n            transition: background-color 0.3s ease;\n            margin-top: auto;\n        }\n\n        .read-more-link:hover {\n            background-color: #218838;\n        }\n\n        #news-popup {\n            display: none;\n            position: fixed;\n            top: 50%;\n            left: 50%;\n            transform: translate(-50%, -50%);\n            background-color: #fff;\n            padding: 30px;\n            border-radius: 15px;\n            box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);\n            z-index: 1001;\n            width: 80%;\n            max-height: 90%;\n            overflow-y: auto;\n        }\n\n        #news-popup .popup-ticker {\n            font-size: 1.5em;\n            font-weight: bold;\n            color: #fff;\n            background-color: #007bff;\n            padding: 8px 15px;\n            border-radius: 8px;\n            display: inline-block;\n            margin-bottom: 15px;\n        }\n\n        #news-popup .popup-title {\n            font-size: 1.4em;\n            font-weight: 700;\n            margin-top: 0;\n            margin-bottom: 15px;\n            line-height: 1.6;\n            color: #2c3e50;\n        }\n\n        #news-popup .popup-summary {\n            font-size: 1.05em;\n            line-height: 1.8;\n            color: #444;\n            margin-bottom: 20px;\n        }\n\n        #news-popup .popup-read-more-link {\n            display: inline-block;\n            padding: 12px 25px;\n            background-color: #28a745;\n            color: #fff;\n            text-decoration: none;\n            border-radius: 8px;\n            font-size: 1em;\n            transition: background-color 0.3s ease;\n        }\n\n        #news-popup .popup-read-more-link:hover {\n            background-color: #218838;\n        }\n\n        #popup-backdrop {\n            display: none;\n            position: fixed;\n            top: 0;\n            left: 0;\n            width: 100%;\n            height: 100%;\n            background-color: rgba(0, 0, 0, 0.5);\n            z-index: 1000;\n        }\n\n        .close-button {\n            position: absolute;\n            top: 10px;\n            right: 15px;\n            font-size: 24px;\n            color: #aaa;\n            font-weight: bold;\n            cursor: pointer;\n        }\n\n        .sentiment-badge {\n            position: absolute;\n            top: 10px;\n            right: 10px;\n            padding: 5px 10px;\n            border-radius: 5px;\n            font-size: 0.8em;\n            font-weight: bold;\n            color: #fff;\n        }\n\n        .sentiment-badge.Positive {\n            background-color: #28a745;\n        }\n\n        .sentiment-badge.Negative {\n            background-color: #dc3545;\n        }\n\n        .sentiment-badge.Neutral {\n            background-color: #ffc107;\n            color: #000;\n        }\n\n        #loading-message {\n            text-align: center;\n            margin-top: 20px;\n            font-style: italic;\n            color: #777;\n        }\n\n        \/* Media Query for smaller screens *\/\n        @media (max-width: 768px) {\n            \/* ... (rest of the mobile styles remain the same) ... *\/\n        }\n    <\/style>\n<\/head>\n<body>\n    <h1>Electra AI &#8211; Stock Market News<\/h1>\n    <div id=\"controls-container\">\n        <div id=\"filter-sort-container\">\n            <select id=\"ticker-filter\">\n                <option value=\"All\">All<\/option>\n                <!-- Ticker options will be added here by JavaScript -->\n            <\/select>\n            <select id=\"sort-by\">\n                <option value=\"newest\">Newest<\/option>\n                <option value=\"oldest\">Oldest<\/option>\n            <\/select>\n        <\/div>\n    <\/div>\n    <h3>Updates Every 60 seconds<\/h3>\n    <div id=\"news-container\">\n        <p id=\"loading-message\">Loading news&#8230;<\/p>\n        <!-- News items will be added here by JavaScript -->\n    <\/div>\n\n    <div id=\"news-popup\">\n        <span class=\"close-button\">\u00d7<\/span>\n        <h3 class=\"popup-ticker\"><\/h3>\n        <h4 class=\"popup-title\"><\/h4>\n        <p class=\"popup-summary\"><\/p>\n        <a class=\"popup-read-more-link\" target=\"_blank\">Read More<\/a>\n    <\/div>\n    <div id=\"popup-backdrop\"><\/div>\n\n    <script>\n        const newsContainer = document.getElementById('news-container');\n        const newsPopup = document.getElementById('news-popup');\n        const popupBackdrop = document.getElementById('popup-backdrop');\n        const closeButton = newsPopup.querySelector('.close-button');\n        const popupTicker = newsPopup.querySelector('.popup-ticker');\n        const popupTitle = newsPopup.querySelector('.popup-title');\n        const popupSummary = newsPopup.querySelector('.popup-summary');\n        const popupReadMoreLink = newsPopup.querySelector('.popup-read-more-link');\n        const tickerFilter = document.getElementById('ticker-filter');\n        const sortBy = document.getElementById('sort-by');\n        const loadingMessage = document.getElementById('loading-message');\n\n        const tickerToCompany = {\n            \"AAPL\": \"Apple\", \"GOOGL\": \"Alphabet (Google)\", \"TSLA\": \"Tesla\", \"MSFT\": \"Microsoft\", \"AMZN\": \"Amazon\", \"META\": \"Meta Platforms\", \"NVDA\": \"NVIDIA\", \"BRK.B\": \"Berkshire Hathaway\", \"JPM\": \"JPMorgan Chase\", \"V\": \"Visa\", \"UNH\": \"UnitedHealth Group\", \"PG\": \"Procter & Gamble\", \"HD\": \"The Home Depot\", \"DIS\": \"The Walt Disney Company\", \"MA\": \"Mastercard\", \"PEP\": \"PepsiCo\", \"NFLX\": \"Netflix\", \"KO\": \"The Coca-Cola Company\", \"INTC\": \"Intel\", \"CSCO\": \"Cisco Systems\", \"ADBE\": \"Adobe\", \"CRM\": \"Salesforce\", \"CMCSA\": \"Comcast\", \"ORCL\": \"Oracle\", \"PFE\": \"Pfizer\", \"T\": \"AT&T\", \"XOM\": \"ExxonMobil\", \"WMT\": \"Walmart\", \"COST\": \"Costco\", \"BA\": \"Boeing\", \"MCD\": \"McDonald's\", \"NKE\": \"Nike\", \"MRK\": \"Merck\", \"IBM\": \"IBM\", \"AMGN\": \"Amgen\", \"HON\": \"Honeywell\", \"SBUX\": \"Starbucks\", \"MMM\": \"3M\", \"CAT\": \"Caterpillar\", \"GE\": \"General Electric\", \"BTC\": \"Bitcoin\"\n        };\n\n        let currentFilter = localStorage.getItem('selectedTicker') || 'All';\n        let currentSort = localStorage.getItem('selectedSort') || 'newest';\n        tickerFilter.value = currentFilter;\n        sortBy.value = currentSort;\n\n        Object.keys(tickerToCompany).sort().forEach(ticker => {\n            const option = document.createElement('option');\n            option.value = ticker;\n            option.textContent = `${ticker} - ${tickerToCompany[ticker]}`;\n            tickerFilter.appendChild(option);\n        });\n\n        async function fetchNews() {\n            loadingMessage.style.display = 'block';\n            newsContainer.innerHTML = ''; \/\/ Clear previous news\n            try {\n                const response = await fetch('https:\/\/makulu.online:8000\/api\/news');\n                if (!response.ok) {\n                    const message = `HTTP error! status: ${response.status}`;\n                    throw new Error(message);\n                }\n                const newsData = await response.json();\n                displayNews(newsData);\n            } catch (error) {\n                console.error(\"Error fetching news:\", error);\n                newsContainer.innerHTML = `<p>Error fetching news: ${error.message}. Please try again later.<\/p>`;\n            } finally {\n                loadingMessage.style.display = 'none';\n            }\n        }\n\nfunction displayNews(news) {\n            const filteredNews = currentFilter === 'All' ? news : news.filter(item => item.ticker === currentFilter);\n\n            filteredNews.sort((a, b) => {\n                const dateA = new Date(a.published_at);\n                const dateB = new Date(b.published_at);\n                return currentSort === 'newest' ? dateB - dateA : dateA - dateB;\n            });\n\n            newsContainer.innerHTML = '';\n            if (filteredNews.length === 0 && currentFilter !== 'All') {\n                newsContainer.innerHTML = `<p>No news found for ${tickerToCompany[currentFilter] || currentFilter}.<\/p>`;\n                return;\n            } else if (filteredNews.length === 0) {\n                newsContainer.innerHTML = `<p>No news available at this time.<\/p>`;\n                return;\n            }\n\n            filteredNews.forEach(item => {\n                if (item.title && (item.title.includes(\"Web search:\") || item.title.toLowerCase().includes(\"nothing found\") || item.title.toLowerCase().includes(\"i'm electra\") || item.title.toLowerCase().includes(\"To find relevant news about\"))) {\n                    return; \/\/ Skip this item\n                }\n\n                const newsDiv = document.createElement('div');\n                newsDiv.classList.add('news-item');\n                newsDiv.setAttribute('data-ticker', item.ticker);\n\n                const tickerElem = document.createElement('h3');\n                tickerElem.classList.add('ticker');\n                tickerElem.textContent = `${item.ticker} - ${tickerToCompany[item.ticker] || \"Unknown Company\"}`;\n\n                const titleElem = document.createElement('h4');\n                titleElem.classList.add('title');\n                titleElem.textContent = item.title;\n\n                const summaryElem = document.createElement('p');\n                summaryElem.classList.add('summary');\n                summaryElem.textContent = item.summary;\n\n                const sentimentBadge = document.createElement('span');\n                sentimentBadge.classList.add('sentiment-badge', item.sentiment);\n                sentimentBadge.textContent = item.sentiment;\n                newsDiv.appendChild(sentimentBadge);\n\n                newsDiv.appendChild(tickerElem);\n                newsDiv.appendChild(titleElem);\n                newsDiv.appendChild(summaryElem);\n\n                newsDiv.addEventListener('click', () => {\n                    popupTicker.textContent = `${item.ticker} - ${tickerToCompany[item.ticker] || \"Unknown Company\"}`;\n                    popupTitle.textContent = item.title;\n                    popupSummary.textContent = item.summary;\n                    \/\/ Removed link functionality\n                    newsPopup.style.display = 'block';\n                    popupBackdrop.style.display = 'block';\n                });\n\n                newsContainer.appendChild(newsDiv);\n            });\n        }\n\n        function closePopup() {\n            newsPopup.style.display = 'none';\n            popupBackdrop.style.display = 'none';\n        }\n\n        closeButton.addEventListener('click', closePopup);\n        popupBackdrop.addEventListener('click', closePopup);\n\n        newsPopup.addEventListener('click', (event) => {\n            event.stopPropagation();\n        });\n\n        tickerFilter.addEventListener('change', function() {\n            currentFilter = this.value;\n            localStorage.setItem('selectedTicker', currentFilter);\n            fetchNews();\n        });\n\n        sortBy.addEventListener('change', function() {\n            currentSort = this.value;\n            localStorage.setItem('selectedSort', currentSort);\n            fetchNews();\n        });\n\n        fetchNews();\n        setInterval(fetchNews, 60000);\n    <\/script>\n<\/body>\n<\/html>\n","protected":false},"excerpt":{"rendered":"<p>Electra AI &#8211; Stock Market News Electra AI &#8211; Stock Market News All NewestOldest Updates Every 60 seconds Loading news&#8230; \u00d7 Read More<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-208","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/makulu.online\/index.php\/wp-json\/wp\/v2\/pages\/208","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/makulu.online\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/makulu.online\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/makulu.online\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/makulu.online\/index.php\/wp-json\/wp\/v2\/comments?post=208"}],"version-history":[{"count":1,"href":"https:\/\/makulu.online\/index.php\/wp-json\/wp\/v2\/pages\/208\/revisions"}],"predecessor-version":[{"id":209,"href":"https:\/\/makulu.online\/index.php\/wp-json\/wp\/v2\/pages\/208\/revisions\/209"}],"wp:attachment":[{"href":"https:\/\/makulu.online\/index.php\/wp-json\/wp\/v2\/media?parent=208"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}