{"id":24,"date":"2026-03-30T08:13:38","date_gmt":"2026-03-30T06:13:38","guid":{"rendered":"https:\/\/gradnja.shop\/?page_id=24"},"modified":"2026-03-30T08:13:38","modified_gmt":"2026-03-30T06:13:38","slug":"news","status":"publish","type":"page","link":"https:\/\/gradnja.shop\/index.php\/news\/","title":{"rendered":"news"},"content":{"rendered":"\n<!DOCTYPE html>\n<html lang=\"hr\">\n<head>\n    <meta charset=\"UTF-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    <title>Live News Portal &#8211; Pro\u0161irena Baza<\/title>\n    <style>\n        :root {\n            --bg-color: #f4f7f6;\n            --card-bg: #ffffff;\n            --text-main: #333333;\n            --text-muted: #777777;\n            --accent: #0056b3;\n            --accent-hover: #004494;\n        }\n\n        body {\n            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;\n            background-color: var(--bg-color);\n            color: var(--text-main);\n            margin: 0;\n            padding: 20px;\n        }\n\n        header {\n            text-align: center;\n            margin-bottom: 20px;\n        }\n\n        h1 {\n            color: var(--accent);\n            text-transform: uppercase;\n            letter-spacing: 1px;\n            margin-bottom: 5px;\n        }\n\n        .status-text {\n            font-size: 0.85rem;\n            color: var(--text-muted);\n            margin-top: 5px;\n            display: block;\n        }\n\n        \/* Navigacija za rubrike *\/\n        .category-nav {\n            display: flex;\n            justify-content: center;\n            gap: 10px;\n            flex-wrap: wrap;\n            margin-bottom: 30px;\n            padding: 10px 0;\n        }\n\n        .cat-btn {\n            background-color: #e0e0e0;\n            color: var(--text-main);\n            border: none;\n            padding: 8px 16px;\n            font-size: 0.95rem;\n            border-radius: 20px;\n            cursor: pointer;\n            font-weight: bold;\n            transition: all 0.2s;\n        }\n\n        .cat-btn:hover { background-color: #d0d0d0; }\n        \n        .cat-btn.active {\n            background-color: var(--accent);\n            color: white;\n            box-shadow: 0 2px 5px rgba(0,0,0,0.2);\n        }\n\n        \/* Grid sustav za to\u010dno 10 ku\u0107ica *\/\n        .news-grid {\n            display: grid;\n            grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));\n            gap: 20px;\n            max-width: 1200px;\n            margin: 0 auto;\n        }\n\n        .news-card {\n            background: var(--card-bg);\n            border-radius: 8px;\n            box-shadow: 0 4px 6px rgba(0,0,0,0.05);\n            overflow: hidden;\n            transition: transform 0.2s ease, box-shadow 0.2s ease;\n            display: flex;\n            flex-direction: column;\n            position: relative;\n        }\n\n        .news-card:hover {\n            transform: translateY(-5px);\n            box-shadow: 0 8px 15px rgba(0,0,0,0.1);\n        }\n\n        .source-badge {\n            position: absolute;\n            top: 10px;\n            left: 10px;\n            background-color: rgba(0, 0, 0, 0.8);\n            color: #fff;\n            padding: 4px 8px;\n            border-radius: 4px;\n            font-size: 0.75rem;\n            font-weight: bold;\n            text-transform: uppercase;\n            letter-spacing: 0.5px;\n            z-index: 10;\n        }\n\n        .news-image {\n            width: 100%;\n            height: 180px;\n            object-fit: cover;\n            background-color: #eaeaea;\n        }\n\n        .news-content {\n            padding: 15px;\n            display: flex;\n            flex-direction: column;\n            flex-grow: 1;\n        }\n\n        .news-title {\n            font-size: 1.1rem;\n            font-weight: bold;\n            margin: 0 0 10px 0;\n            line-height: 1.4;\n        }\n\n        .news-title a {\n            text-decoration: none;\n            color: var(--text-main);\n        }\n\n        .news-title a:hover { color: var(--accent); }\n\n        .news-date {\n            font-size: 0.8rem;\n            color: var(--text-muted);\n            margin-top: auto;\n            padding-top: 10px;\n        }\n\n        .loading {\n            text-align: center;\n            font-size: 1.1rem;\n            grid-column: 1 \/ -1;\n            color: var(--text-muted);\n            padding: 40px;\n        }\n    <\/style>\n<\/head>\n<body>\n\n    <header>\n        <h1>Live Vijesti<\/h1>\n        <span class=\"status-text\" id=\"last-update\">Inicijalizacija baze&#8230;<\/span>\n    <\/header>\n\n    <nav class=\"category-nav\" id=\"category-nav\">\n        <button class=\"cat-btn active\" onclick=\"changeCategory('najnovije', this)\">Najnovije<\/button>\n        <button class=\"cat-btn\" onclick=\"changeCategory('tehnologija', this)\">Tehnologija<\/button>\n        <button class=\"cat-btn\" onclick=\"changeCategory('ekonomija', this)\">Ekonomija<\/button>\n        <button class=\"cat-btn\" onclick=\"changeCategory('auto', this)\">Auto-Moto<\/button>\n        <button class=\"cat-btn\" onclick=\"changeCategory('sport', this)\">Sport<\/button>\n    <\/nav>\n\n    <main id=\"news-container\" class=\"news-grid\">\n        <div class=\"loading\">Prikupljam i filtriram podatke s portala&#8230;<\/div>\n    <\/main>\n\n    <script>\n        \/\/ Pro\u0161irena arhiva izvora s novim Tech portalima\n        const feedSources = {\n            'najnovije': [\n                { name: '24sata', url: 'https:\/\/www.24sata.hr\/feeds\/najnovije.xml' },\n                { name: 'Index', url: 'https:\/\/www.index.hr\/rss' },\n                { name: 'N1', url: 'https:\/\/n1info.hr\/feed\/' },\n                { name: 'Jutarnji', url: 'https:\/\/www.jutarnji.hr\/rss' },\n                { name: 'Telegram', url: 'https:\/\/www.telegram.hr\/feed\/' },\n                { name: 'Ve\u010dernji', url: 'https:\/\/www.vecernji.hr\/feeds\/najnovije.xml' },\n                { name: 'Tportal', url: 'https:\/\/www.tportal.hr\/rss' },\n                { name: 'HRT', url: 'https:\/\/vijesti.hrt.hr\/rss' },\n                { name: 'Bug', url: 'https:\/\/www.bug.hr\/rss' },\n                { name: 'PC Chip', url: 'https:\/\/pcchip.hr\/feed\/' },\n                { name: 'Vidi', url: 'https:\/\/www.vidi.hr\/rss' }\n            ],\n            'tehnologija': [\n                { name: 'Bug', url: 'https:\/\/www.bug.hr\/rss' },\n                { name: 'PC Chip', url: 'https:\/\/pcchip.hr\/feed\/' },\n                { name: 'Vidi', url: 'https:\/\/www.vidi.hr\/rss' },\n                { name: '24Tech', url: 'https:\/\/www.24sata.hr\/feeds\/tech.xml' },\n                { name: 'Index Tech', url: 'https:\/\/www.index.hr\/rss\/scitech' },\n                { name: 'Net.hr Tech', url: 'https:\/\/net.hr\/tehnoklik\/feed' }\n            ],\n            'ekonomija': [\n                { name: 'Poslovni', url: 'https:\/\/www.poslovni.hr\/feed' },\n                { name: 'Lider', url: 'https:\/\/lider.media\/feed' },\n                { name: 'Tportal Biz', url: 'https:\/\/www.tportal.hr\/biznis\/rss' }\n            ],\n            'auto': [\n                { name: '24Auto', url: 'https:\/\/www.24sata.hr\/feeds\/auti.xml' },\n                { name: 'Index Auto', url: 'https:\/\/www.index.hr\/rss\/auto' },\n                { name: 'Net Auto', url: 'https:\/\/net.hr\/auto\/feed' }\n            ],\n            'sport': [\n                { name: '24Sport', url: 'https:\/\/www.24sata.hr\/feeds\/sport.xml' },\n                { name: 'Index Sport', url: 'https:\/\/www.index.hr\/rss\/sport' },\n                { name: 'Telegram Sport', url: 'https:\/\/telesport.telegram.hr\/feed\/' },\n                { name: 'HRT Sport', url: 'https:\/\/sport.hrt.hr\/rss' }\n            ]\n        };\n\n        let currentCategory = 'najnovije';\n        const container = document.getElementById('news-container');\n        const updateText = document.getElementById('last-update');\n        let refreshTimer;\n\n        function changeCategory(categoryName, buttonElement) {\n            const buttons = document.querySelectorAll('.cat-btn');\n            buttons.forEach(btn => btn.classList.remove('active'));\n            buttonElement.classList.add('active');\n\n            currentCategory = categoryName;\n            fetchNews();\n\n            clearInterval(refreshTimer);\n            refreshTimer = setInterval(fetchNews, 180000); \n        }\n\n        async function fetchNews() {\n            container.innerHTML = `<div class=\"loading\">U\u010ditavam i skeniram izvore za: ${currentCategory.toUpperCase()}...<br><small>(Ovo mo\u017ee potrajati par sekundi zbog velikog broja portala)<\/small><\/div>`;\n            \n            try {\n                let allArticles = [];\n                const timestamp = new Date().getTime();\n                const activePortals = feedSources[currentCategory];\n\n                const fetchPromises = activePortals.map(async (portal) => {\n                    const apiUrl = `https:\/\/api.rss2json.com\/v1\/api.json?rss_url=${encodeURIComponent(portal.url)}&t=${timestamp}`;\n                    try {\n                        const fetchTimeout = new Promise((_, reject) => setTimeout(() => reject(new Error(\"Timeout\")), 6000));\n                        const response = await Promise.race([fetch(apiUrl), fetchTimeout]);\n                        \n                        const data = await response.json();\n                        if (data.status === 'ok') {\n                            return data.items.map(article => ({ ...article, sourceName: portal.name }));\n                        }\n                    } catch (error) {\n                        console.warn(`Portal ${portal.name} trenutno nedostupan ili spor.`);\n                    }\n                    return [];\n                });\n\n                const results = await Promise.all(fetchPromises);\n                \n                results.forEach(articles => {\n                    allArticles = allArticles.concat(articles);\n                });\n\n                \/\/ Strogo sortiranje po vremenu objave\n                allArticles.sort((a, b) => new Date(b.pubDate) - new Date(a.pubDate));\n                \n                \/\/ Uvijek izvla\u010dimo to\u010dno 10 najnovijih\n                const top10Articles = allArticles.slice(0, 10);\n                \n                renderNews(top10Articles);\n\n                const now = new Date();\n                updateText.innerText = `Zadnja sinkronizacija: ${now.toLocaleTimeString('hr-HR')} | Automatsko osvje\u017eavanje za 3 min.`;\n\n            } catch (error) {\n                container.innerHTML = '<div class=\"loading\">Do\u0161lo je do gre\u0161ke pri obradi podataka. Sustav \u0107e poku\u0161ati ponovno.<\/div>';\n            }\n        }\n\n        function renderNews(articles) {\n            container.innerHTML = ''; \n\n            if (articles.length === 0) {\n                container.innerHTML = '<div class=\"loading\">Trenutno nema dostupnih podataka u ovoj rubrici.<\/div>';\n                return;\n            }\n\n            articles.forEach(article => {\n                let imageUrl = '';\n                \n                if (article.enclosure && article.enclosure.link) {\n                    imageUrl = article.enclosure.link;\n                } else if (article.thumbnail && article.thumbnail !== \"\") {\n                    imageUrl = article.thumbnail;\n                } else {\n                    const imgRegex = \/<img[^>]+src=['\"]([^'\"]+)['\"]\/i;\n                    const contentToSearch = article.content || article.description || '';\n                    const match = contentToSearch.match(imgRegex);\n                    if (match) {\n                        imageUrl = match[1];\n                    }\n                }\n\n                if (!imageUrl || imageUrl === \"\") {\n                    imageUrl = `https:\/\/via.placeholder.com\/300x180\/e0e0e0\/555555?text=${article.sourceName.toUpperCase()}`;\n                }\n\n                const dateObj = new Date(article.pubDate);\n                const formattedDate = dateObj.toLocaleString('hr-HR', { \n                    day: '2-digit', month: '2-digit', year: 'numeric', \n                    hour: '2-digit', minute: '2-digit' \n                });\n\n                const card = document.createElement('div');\n                card.className = 'news-card';\n                card.innerHTML = `\n                    <div class=\"source-badge\">${article.sourceName}<\/div>\n                    <img decoding=\"async\" src=\"${imageUrl}\" alt=\"Slika vijesti\" class=\"news-image\" onerror=\"this.src='https:\/\/via.placeholder.com\/300x180\/e0e0e0\/ff0000?text=GRE\u0160KA+SLIKE'\">\n                    <div class=\"news-content\">\n                        <h2 class=\"news-title\">\n                            <a href=\"${article.link}\" target=\"_blank\">${article.title}<\/a>\n                        <\/h2>\n                        <div class=\"news-date\">${formattedDate}<\/div>\n                    <\/div>\n                `;\n                container.appendChild(card);\n            });\n        }\n\n        fetchNews();\n        refreshTimer = setInterval(fetchNews, 180000);\n    <\/script>\n\n<\/body>\n<\/html>\n","protected":false},"excerpt":{"rendered":"<p>Live News Portal &#8211; Pro\u0161irena Baza Live Vijesti Inicijalizacija baze&#8230; Najnovije Tehnologija Ekonomija Auto-Moto Sport Prikupljam i filtriram podatke s\u2026<\/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-24","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/gradnja.shop\/index.php\/wp-json\/wp\/v2\/pages\/24","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gradnja.shop\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/gradnja.shop\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/gradnja.shop\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gradnja.shop\/index.php\/wp-json\/wp\/v2\/comments?post=24"}],"version-history":[{"count":1,"href":"https:\/\/gradnja.shop\/index.php\/wp-json\/wp\/v2\/pages\/24\/revisions"}],"predecessor-version":[{"id":25,"href":"https:\/\/gradnja.shop\/index.php\/wp-json\/wp\/v2\/pages\/24\/revisions\/25"}],"wp:attachment":[{"href":"https:\/\/gradnja.shop\/index.php\/wp-json\/wp\/v2\/media?parent=24"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}