Български | Català | Deutsche | Hrvatski | Čeština | Dansk | Nederlandse | English | Eesti keel | Français | Ελληνικά | Magyar | Italiano | Latviski | Norsk | Polski | Português | Română | Русский | Српски | Slovenský | Slovenščina | Español | Svenska | Türkçe | 汉语 | 日本語 |
B

book1.ru

Registriran

Davanje web stranice je dar za svakoga Ova stranica posvećena je umjetnosti odabira darova, gdje svaka knjiga nije samo publikacija, već punopravno kulturno iskustvo preneseno u prekrasni...

Datum ažuriranja analize stranice: 2026/06/01 15:04:51
Zadnji datum ažuriranja Whois: 2026/03/27 15:49:03
Status domene
Registriran
Plaćeno do
07.11.2026
Dostupno od
09.12.2026

Opis web stranice

📝

Davanje web stranice je dar za svakoga

Ova stranica posvećena je umjetnosti odabira darova, gdje svaka knjiga nije samo publikacija, već punopravno kulturno iskustvo preneseno u prekrasnim naslovnicama.

Tema stranice: Poklon izdanja i kolekcionarske knjige

Glavna tema stranice je izbor visokokvalitetnih poklon knjiga i publikacija različitih žanrova, namijenjenih različitim dobnim skupinama i interesima. Ovo nije samo katalog, to je pravi vodič u svijet estetike, kulture i fikcije, predstavljen u obliku prezentiranih, često ograničenih izdanja.

Ključne kategorije i upute

  • Poklon albumi - vizualni vodiči kroz arhitekturu, palače, muzeje i velike gradove svijeta. Serije “Veliki gradovi svijeta”, “Velike palače svijeta” i druge stvaraju atmosferu putovanja kroz slike i tekstove.
  • Poklon atlasi - i za globalne studije (svjetski atlasi) i za proučavanje Rusije, oni kombiniraju kartografsku točnost s pristupom dizajnu.
  • Poslovna literatura na dar - sofisticirana izdanja za one koji cijene profesionalizam i stil u poslovnom okruženju.
  • Knjige za djecu - pažljivo odabrane, šarene, često s interaktivnim elementima, idealne za mlade čitatelje.
  • Knjige za žene - teme domaćinstva, gastronomije, mode i ljepote, dizajnirane u ženstvenom, udobnom stilu.
  • Knjige za muškarce - uključuju teme moći, poslovanja, lova, ribolova, proizvodnje vina i cigara, naglašavajući mušku estetiku i zanimanje za rijetke kolekcionarske predmete.
  • Knjige sa suvenirima - jedinstveni format u kojem je publikacija dopunjena elementima koji postaju dio poklona: razglednice, privjesci za ključeve, mini-foto albumi.
  • Poklon izdanja beletristike - u izdanju poznatih izdavačkih kuća kao što su Vita Nova, Pan Press, Slovo/Slovo, Yantarny Skaz. Serija Portret posebna je pažnja posvećena figurativnom i kulturnom kontekstu svakog autora.
  • Sabrana djela i višesveščana djela - za poznavatelje cjelovitog ciklusa stvaralačke baštine pisaca, pjesnika i mislilaca.

Što stranica nudi ne samo za kupnju, već i za osjetiti

Svaka knjiga ovdje je umjetničko djelo. Stranica stvara svečanu atmosferu, prenoseći osjećaje kroz predmet. Namijenjen je onima koji dar ne biraju iz nužde, već iz želje da zadive, dirnu, inspiriraju.

Ovo je mjesto gdje književnost postaje simbol pažnje, poštovanja i dubokog razumijevanja primatelja.

Tema stranice je kultura darova i kolekcionarskih knjiga. Kombinira estetiku, povijest, umjetnost i osobna iskustva, ne nudeći samo proizvod, već priliku da prenesete djelić sebe drugoj osobi.

SEO rezultat
50%
73
Postignut rezultat
146
Maksimalni rezultat

Glavne informacije

ℹ️
Titula: - Книги в подарок - подарочные и коллекционные книги"><title>
Opis: nepoznato
Ključne riječi: интернет,Книга подарок, подарочные книги,интернет-магазин книги, книжный интернет магазин,подарочные издания, книга подарочная,книги подарочные, подарочная книга, подарочное издание, подарки, подарок, элитная книга, книга в коже,кожаный переплет, дорогоя книга, коллекционная книга, коллекционное издание, эксклюзивная книга, подарок, книга в подарок, альбом, магазин, интернет-магазин
Kodiranje stranice: windows-1251
Veličina datoteke stranice: 34 KB

Informacije o poslužitelju

🖥️
IP: 90.156.201.21
Mjesto: Russia,RU,,,55.7386,37.6068,Europe/Moscow
Kodiranje: windows-1251

Whois informacije

📄
domain_name: book1.ru
update_date: on
update_time:
creation_date: 2005-11-07T21:00:00Z
creation_time: 1131397200
expiration_date: 2026-11-07T21:00:00Z

Whois neobrađeni podaci

📋
            domain:        BOOK1.RU
nserver: ns1.masterhost.ru.
nserver: ns2.masterhost.ru.
nserver: ns.masterhost.ru.
state: REGISTERED, DELEGATED, UNVERIFIED
person: Private Person
registrar: RD-RU
admin-contact: https://cp.mastername.ru/domain_feedback/
created: 2005-11-07T21:00:00Z
paid-till: 2026-11-07T21:00:00Z
free-date: 2026-12-09
source: TCI
Last updated on 2026-03-27T15:48:01Z

Robots.txt

🤖
			# robots.txt for http://a-shop.ru
User-Agent: *
Disallow: /advanced_search_result
Disallow: /shopping_cart
Disallow: /pollbooth
Disallow: /login
Disallow: /create_account
Disallow: /create_account_process
Disallow: /popup_image
Disallow: /checkout_shipping
Disallow: /password_forgotten
Disallow: /product_reviews
Disallow: /reviews
Disallow: /default.php?manufacturers_id





        

SEO revizija

🔍

Tehnički SEO

Šifra odgovora
HTTP/1.1 200 OK
Status 200 OK - stranica se ispravno učitava.
Kodiranje znakova
Page: windows-1251, Header: windows-1251
Konzistentno kodiranje znakova između HTML-a i zaglavlja.
Veličina stranice
35428 bytes
Veličina stranice prihvatljiva za brzo učitavanje.
Resursi
0 total
Optimalan broj resursa.
Hreflang oznake
hreflang tags
Dodajte hreflang oznake ako imate višejezični sadržaj.
Robots.txt
Exists
Datoteka robots.txt pronađena.
!
Sitemap
Not found
Dodajte sitemap.xml i referencirajte ga u robots.txt.
HTTPS
Yes
Sigurna HTTPS veza omogućena.
Kompresija
gzip
Gzip ili Zstd kompresija omogućena za brže učitavanje.
Predmemoriranje
no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Zaglavlja kontrole predmemorije pravilno postavljena.
Brzina stranice
0.33 ms
Izvrsna brzina učitavanja.

On-Page SEO

!
Titula
- Книги в подарок - подарочные и коллекционные книги"></div><div class="audit-recommendation">Naslov je predug. Smanjite na 30-60 znakova kako biste izbjegli skraćivanje.</div></div></div><div class="audit-item"><div class="audit-status status-fail">!</div><div class="audit-info"><div class="audit-name">Meta opis</div><div class="audit-value"> Lenght:0</div><div class="audit-recommendation">Dodajte meta opis (preporučuje se 100-160 znakova).</div></div></div><div class="audit-item"><div class="audit-status status-fail">!</div><div class="audit-info"><div class="audit-name">H1 naslov</div><div class="audit-value">0 found - ""</div><div class="audit-recommendation">Dodajte točno jedan H1 naslov s primarnim ključnim riječima.</div></div></div><div class="audit-item"><div class="audit-status status-fail">!</div><div class="audit-info"><div class="audit-name">Broj riječi</div><div class="audit-value"></div><div class="audit-recommendation">Sadržaj vrlo kratak. Ciljajte na najmanje 500 riječi za bolji SEO.</div></div></div><div class="audit-item"><div class="audit-status status-fail">!</div><div class="audit-info"><div class="audit-name">Kanonska oznaka</div><div class="audit-value"></div><div class="audit-recommendation">Dodajte kanonsku oznaku kako biste spriječili probleme s dvostrukim sadržajem.</div></div></div><div class="audit-item"><div class="audit-status status-pass">✓</div><div class="audit-info"><div class="audit-name">Duplikat Meta</div><div class="audit-value">[]</div><div class="audit-recommendation">Nisu pronađene duple meta oznake.</div></div></div><div class="audit-item"><div class="audit-status status-pass">✓</div><div class="audit-info"><div class="audit-name">Ključne riječi</div><div class="audit-value">интернет,Книга подарок, подарочные книги,интернет-магазин книги, книжный интернет магазин,подарочные издания, книга подарочная,книги подарочные, подарочная книга, подарочное издание, подарки, подарок, элитная книга, книга в коже,кожаный переплет, дорогоя книга, коллекционная книга, коллекционное издание, эксклюзивная книга, подарок, книга в подарок, альбом, магазин, интернет-магазин</div><div class="audit-recommendation">Postavljene meta ključne riječi (napomena: ne koriste ih glavne tražilice).</div></div></div><h3 class="category-title" style="margin-top: 1.5rem;">Sadržaj i UX</h3><div class="audit-item"><div class="audit-status status-fail">!</div><div class="audit-info"><div class="audit-name">Jezik</div><div class="audit-value"></div><div class="audit-recommendation">Dodajte atribut lang <html> oznaci za pristupačnost i SEO.</div></div></div><div class="audit-item"><div class="audit-status status-pass">✓</div><div class="audit-info"><div class="audit-name">Slike</div><div class="audit-value">0 total, 0 missing ALT</div><div class="audit-recommendation">Sve slike imaju ispravan ALT tekst.</div></div></div><div class="audit-item"><div class="audit-status status-fail">!</div><div class="audit-info"><div class="audit-name">Viewport</div><div class="audit-value"></div><div class="audit-recommendation">Dodajte meta oznaku okvira za prikaz za mobilni odziv.</div></div></div><div class="audit-item"><div class="audit-status status-fail">!</div><div class="audit-info"><div class="audit-name">Otvori grafikon</div><div class="audit-value">Missing: og:title, og:description, og:image, og:url</div><div class="audit-recommendation">Dodajte OpenGraph oznake koje nedostaju za dijeljenje na društvenim mrežama:og:title, og:description, og:image, og:url</div></div></div><div class="audit-item"><div class="audit-status status-fail">!</div><div class="audit-info"><div class="audit-name">Strukturirani podaci</div><div class="audit-value"> JSON-LD scripts</div><div class="audit-recommendation">Dodajte strukturirane podatke (JSON-LD) za bogate isječke i bolji SEO.</div></div></div></div></div> <!-- Load Google Charts at the top of the search engine section --> <script> // Load Google Charts google.charts.load('current', {'packages':['corechart', 'line']}); </script> <!-- Google Positions --> <div class="chart-container"> <h2 class="chart-title">Pozicije u Google</h2> <div id="chart_div_google" style="width: 100%; height: 400px;"></div> </div> <!-- Google Search Phrases --> <div class="card"> <div class="card-header"> <h2 class="card-title">Fraze za pretraživanje - Google</h2> <div class="card-icon">🔍</div> </div> <div class="card-content"> <div class="filters"> <div class="filter-group"> <label class="filter-label" for="googlePhraseFilter">Fraza:</label> <input type="text" id="googlePhraseFilter" class="filter-input" placeholder="Filtriraj po izrazu"> </div> <div class="filter-group"> <label class="filter-label" for="googlePageFilter">Stranica:</label> <input type="text" id="googlePageFilter" class="filter-input" placeholder="Filtriraj po stranici"> </div> <div class="filter-group"> <label class="filter-label"> </label> <button class="cta-button" onclick="applyFilters('google')">Primijeni filtar</button> </div> </div> <div class="table-responsive"> <table class="data-table" id="googlePhrasesTable"> <thead> <tr> <th>Položaj</th> <th>Fraza</th> <th>Stranica</th> <th>Isječak</th> </tr> </thead> <tbody id="googlePhrasesBody"> <tr><td><span class="badge badge-success">1</span></td><td><noindex><a href="/hr/phrase/%D1%81%D0%B5%D1%80%D0%B8%D1%8F-%D0%B2%D0%B5%D0%BB%D0%B8%D0%BA%D0%B8%D0%B5-%D0%BC%D1%83%D0%B7%D0%B5%D0%B8-%D0%BC%D0%B8%D1%80%D0%B0/" rel="nofollow">серия великие музеи мира</a></noindex></td><td>/</td><td></td></tr><tr><td><span class="badge badge-warning">4</span></td><td><noindex><a href="/hr/phrase/%D0%BA%D0%BE%D0%BB%D0%BB%D0%B5%D0%BA%D1%86%D0%B8%D0%BE%D0%BD%D0%BD%D1%8B%D0%B5-%D0%BA%D0%BD%D0%B8%D0%B3%D0%B8/" rel="nofollow">коллекционные книги</a></noindex></td><td>/</td><td></td></tr><tr><td><span class="badge badge-warning">5</span></td><td><noindex><a href="/hr/phrase/%D0%B1%D0%BE%D0%BB%D1%8C%D1%88%D0%BE%D0%B9-%D0%B0%D1%82%D0%BB%D0%B0%D1%81-%D0%BC%D0%B8%D1%80%D0%B0/" rel="nofollow">большой атлас мира</a></noindex></td><td>/</td><td></td></tr><tr><td><span class="badge badge-warning">9</span></td><td><noindex><a href="/hr/phrase/%D0%B2%D0%B5%D0%BB%D0%B8%D0%BA%D0%B8%D0%B5-%D0%BA%D0%BD%D0%B8%D0%B3%D0%B8-%D0%BC%D0%B8%D1%80%D0%B0/" rel="nofollow">великие книги мира</a></noindex></td><td>/default.php?cPath=5...</td><td><button class="show-snippet-btn" onclick="toggleSnippet(this)">Prikaži isječak</button><div class="snippet" style="display: none;"><noindex><a href="https://book1.ru//default.php?cPath=5_49" rel="nofollow" target="_blank">Серия "Великие книги мира" - book1.ru</a></noindex><br>АЛЬБОМЫ ПОДАРОЧНЫЕ > Серия "Великие книги мира · Артур Конан Дойль Шерлок Холмс · СЛОВО/SLOVO · Артур Конан Дойль Шерлок Холмс · Заказать 'Артур Конан Дойль ...</div></td></tr><tr><td><span class="badge badge-danger">11</span></td><td><noindex><a href="/hr/phrase/%D1%8D%D0%BA%D0%BE-%D0%B8%D1%81%D1%82%D0%BE%D1%80%D0%B8%D1%8F-%D0%BA%D1%80%D0%B0%D1%81%D0%BE%D1%82%D1%8B/" rel="nofollow">эко история красоты</a></noindex></td><td>/</td><td></td></tr><tr><td><span class="badge badge-danger">12</span></td><td><noindex><a href="/hr/phrase/%D0%B4%D0%BE%D0%BD-%D0%BA%D0%B8%D1%85%D0%BE%D1%82-%D1%81%D0%B5%D1%80%D0%B2%D0%B0%D0%BD%D1%82%D0%B5%D1%81-%D0%B0%D0%BD%D0%B0%D0%BB%D0%B8%D0%B7/" rel="nofollow">дон кихот сервантес анализ</a></noindex></td><td>/</td><td></td></tr><tr><td><span class="badge badge-danger">13</span></td><td><noindex><a href="/hr/phrase/%D0%B0%D0%BB%D1%8C%D0%B1%D0%BE%D0%BC-%D0%B4%D1%80%D0%B5%D0%B7%D0%B4%D0%B5%D0%BD%D1%81%D0%BA%D0%B0%D1%8F-%D0%B3%D0%B0%D0%BB%D0%B5%D1%80%D0%B5%D1%8F/" rel="nofollow">альбом дрезденская галерея</a></noindex></td><td>/</td><td></td></tr><tr><td><span class="badge badge-danger">14</span></td><td><noindex><a href="/hr/phrase/%D0%BA%D0%B0%D1%84%D0%B5-%D1%81%D1%82%D1%80%D0%B0%D1%81%D0%B1%D1%83%D1%80%D0%B3/" rel="nofollow">кафе страсбург</a></noindex></td><td>/</td><td></td></tr><tr><td><span class="badge badge-danger">15</span></td><td><noindex><a href="/hr/phrase/%D0%B8%D1%81%D1%82%D0%BE%D1%80%D0%B8%D1%8F-%D1%80%D1%83%D1%81%D1%81%D0%BA%D0%BE%D0%B9-%D0%BC%D0%BE%D0%B4%D1%8B/" rel="nofollow">история русской моды</a></noindex></td><td>/</td><td></td></tr><tr><td><span class="badge badge-danger">15</span></td><td><noindex><a href="/hr/phrase/%D0%BE%D0%B2%D0%B8%D0%B4%D0%B8%D0%B9-%D0%BC%D0%B5%D1%82%D0%B0%D0%BC%D0%BE%D1%80%D1%84%D0%BE%D0%B7%D1%8B-%D0%BA%D1%80%D0%B0%D1%82%D0%BA%D0%BE%D0%B5-%D1%81%D0%BE%D0%B4%D0%B5%D1%80%D0%B6%D0%B0%D0%BD%D0%B8%D0%B5/" rel="nofollow">овидий метаморфозы краткое содержание</a></noindex></td><td>/</td><td></td></tr> </tbody> </table> </div> <div class="pagination" id="googlePagination"> <button disabled onclick="loadSearchPhrases('google', 0)">«</button> <button class="active" onclick="loadSearchPhrases('google', 1)">1</button> <button class="" onclick="loadSearchPhrases('google', 2)">2</button> <button class="" onclick="loadSearchPhrases('google', 3)">3</button> <button disabled="">...</button> <button class="" onclick="loadSearchPhrases('google', 5)">5</button> <button class="" onclick="loadSearchPhrases('google', 6)">6</button> <button onclick="loadSearchPhrases('google', 2)">»</button> </div> </div> </div> <script> // Google Charts for google google.charts.setOnLoadCallback(drawChart_google); function drawChart_google() { var data = new google.visualization.DataTable(); data.addColumn('date', 'Dan'); data.addColumn("number", "серия великие музеи мира");data.addColumn("number", "коллекционные книги");data.addColumn("number", "большой атлас мира");data.addColumn("number", "великие книги мира");data.addColumn("number", "эко история красоты");data.addColumn("number", "дон кихот сервантес анализ");data.addColumn("number", "альбом дрезденская галерея");data.addColumn("number", "кафе страсбург");data.addColumn("number", "история русской моды");data.addColumn("number", "овидий метаморфозы краткое содержание"); data.addRows([ [new Date(2011, 1, 11),null,null,null,null,null,null,null,14,null,null,],[new Date(2011, 1, 13),null,null,5,null,null,null,null,null,null,null,],[new Date(2011, 1, 14),null,null,null,null,11,12,null,null,null,15,],[new Date(2011, 1, 26),null,null,null,null,null,null,13,null,null,null,],[new Date(2011, 1, 5),1,null,null,null,null,null,null,null,null,null,],[new Date(2011, 1, 8),null,null,null,null,null,null,null,null,15,null,],[new Date(2011, 1, 9),null,4,null,null,null,null,null,null,null,null,],[new Date(2025, 10, 6),null,null,null,9,null,null,null,null,null,null,], ]); var options = { chart: { title: 'Fraze za pretraživanje za koje je domena na vrhu google tražilica: "book1.ru"', subtitle: 'Povijest položaja fraze' }, width: '100%', height: 400, curveType: 'function', legend: { position: 'bottom' }, pointSize: 5, pointsVisible: true, interpolateNulls: true, selectionMode: 'multiple', vAxis: { direction: '-1', title: 'Položaj', }, hAxis: { title: 'Datum', }, }; var chart = new google.visualization.LineChart(document.getElementById("chart_div_google")); chart.draw(data, options); } </script> <!-- Yandex Positions --> <div class="chart-container"> <h2 class="chart-title">Pozicije u Yandex</h2> <div id="chart_div_yandex" style="width: 100%; height: 400px;"></div> </div> <!-- Yandex Search Phrases --> <div class="card"> <div class="card-header"> <h2 class="card-title">Fraze za pretraživanje - Yandex</h2> <div class="card-icon">🔍</div> </div> <div class="card-content"> <div class="filters"> <div class="filter-group"> <label class="filter-label" for="yandexPhraseFilter">Fraza:</label> <input type="text" id="yandexPhraseFilter" class="filter-input" placeholder="Filtriraj po izrazu"> </div> <div class="filter-group"> <label class="filter-label" for="yandexPageFilter">Stranica:</label> <input type="text" id="yandexPageFilter" class="filter-input" placeholder="Filtriraj po stranici"> </div> <div class="filter-group"> <label class="filter-label"> </label> <button class="cta-button" onclick="applyFilters('yandex')">Primijeni filtar</button> </div> </div> <div class="table-responsive"> <table class="data-table" id="yandexPhrasesTable"> <thead> <tr> <th>Položaj</th> <th>Fraza</th> <th>Stranica</th> <th>Isječak</th> </tr> </thead> <tbody id="yandexPhrasesBody"> <tr><td><span class="badge badge-success">1</span></td><td><noindex><a href="/hr/phrase/book-1/" rel="nofollow">book 1</a></noindex></td><td>/about_shop.php</td><td><button class="show-snippet-btn" onclick="toggleSnippet(this)">Prikaži isječak</button><div class="snippet" style="display: none;"><noindex><a href="https://book1.ru//about_shop.php" rel="nofollow" target="_blank">book 1 .ru/about_shop.php</a></noindex><br>Режим работы операторов интернет-магазина " Книги в подарок" с понедельника по пятницу с 9 до 19 часов, в субботу с 9 до 15 часов.</div></td></tr><tr><td><span class="badge badge-danger">22</span></td><td><noindex><a href="/hr/phrase/%D0%B0%D1%82%D0%BB%D0%B0%D1%81-%D1%80%D0%BE%D1%81%D1%81%D0%B8%D0%B8/" rel="nofollow">атлас россии</a></noindex></td><td>/</td><td></td></tr><tr><td><span class="badge badge-danger">23</span></td><td><noindex><a href="/hr/phrase/%D0%B8%D0%B7%D0%B4%D0%B0%D1%82%D0%B5%D0%BB%D1%8C%D1%81%D1%82%D0%B2%D0%BE-%D1%81%D0%BB%D0%BE%D0%B2%D0%BE-%D0%B2%D0%B5%D0%BB%D0%B8%D0%BA%D0%B8%D0%B5-%D0%BC%D1%83%D0%B7%D0%B5%D0%B8-%D0%BC%D0%B8%D1%80%D0%B0/" rel="nofollow">издательство слово великие музеи мира</a></noindex></td><td>/</td><td></td></tr><tr><td><span class="badge badge-danger">25</span></td><td><noindex><a href="/hr/phrase/%D0%B8%D0%BD%D1%82%D0%B5%D1%80%D1%8C%D0%B5%D1%80%D1%8B-%D0%B0%D0%BB%D0%B5%D0%BA%D1%81%D0%B0%D0%BD%D0%B4%D1%80%D0%B0-%D0%B2%D0%B0%D1%81%D0%B8%D0%BB%D1%8C%D0%B5%D0%B2%D0%B0/" rel="nofollow">интерьеры александра васильева</a></noindex></td><td>/</td><td></td></tr> </tbody> </table> </div> <div class="pagination" id="yandexPagination"> <button disabled onclick="loadSearchPhrases('yandex', 0)">«</button> <button class="active" onclick="loadSearchPhrases('yandex', 1)">1</button> <button disabled onclick="loadSearchPhrases('yandex', 2)">»</button> </div> </div> </div> <script> // Google Charts for yandex google.charts.setOnLoadCallback(drawChart_yandex); function drawChart_yandex() { var data = new google.visualization.DataTable(); data.addColumn('date', 'Dan'); data.addColumn("number", "book 1");data.addColumn("number", "атлас россии");data.addColumn("number", "издательство слово великие музеи мира");data.addColumn("number", "интерьеры александра васильева"); data.addRows([ [new Date(2011, 2, 2),null,null,23,null,],[new Date(2011, 2, 4),null,null,null,25,],[new Date(2012, 0, 29),null,22,null,null,],[new Date(2025, 2, 20),1,null,null,null,],[new Date(2025, 5, 13),1,null,null,null,], ]); var options = { chart: { title: 'Fraze za pretraživanje za koje je domena na vrhu yandex tražilica: "book1.ru"', subtitle: 'Povijest položaja fraze' }, width: '100%', height: 400, curveType: 'function', legend: { position: 'bottom' }, pointSize: 5, pointsVisible: true, interpolateNulls: true, selectionMode: 'multiple', vAxis: { direction: '-1', title: 'Položaj', }, hAxis: { title: 'Datum', }, }; var chart = new google.visualization.LineChart(document.getElementById("chart_div_yandex")); chart.draw(data, options); } </script> <!-- Additional Services --> <div class="card" id="domain-additional-services"> <div class="card-header"> <h2 class="card-title">Dodatne usluge</h2> <div class="card-icon">💎</div> </div> <div class="card-content"> <div class="info-grid"> <div class="info-item"> <span class="popup-trigger" alt="Potpuni SEO audit s detaljnim preporukama"> <button class="cta-button" data-modal="paymentModal" data-payment-type="domain_seo_pay" data-payment-item-id="21746" data-title="Kompletna SEO revizija book1.ru" data-text="Kompletan SEO audit s detaljnim preporukama za poboljšanje pozicija na tražilicama." data-price="99.99"> Kompletna SEO revizija </button> <span class="popup-text"></span> </span> </div> <div class="info-item"> <span class="popup-trigger" alt="Mjesečno praćenje položaja za 100 ključnih izraza"> <button class="cta-button" data-modal="paymentModal" data-payment-type="domain_position_pay" data-payment-item-id="21746" data-title="Praćenje položaja book1.ru" data-text="Mjesečno praćenje pozicije za 100 ključnih izraza u Google i Yandex." data-price="49.99"> Praćenje položaja </button> <span class="popup-text"></span> </span> </div> <div class="info-item"> <span class="popup-trigger" alt="Analiza konkurenata i identifikacija njihovih strategija promocije"> <button class="cta-button" data-modal="paymentModal" data-payment-type="domain_analiz_pay" data-payment-item-id="21746" data-title="Analiza konkurenta book1.ru" data-text="Analiza konkurenata i identifikacija njihovih strategija promocije." data-price="79.99"> Analiza konkurenta </button> <span class="popup-text"></span> </span> </div> </div> </div> </div> <!-- Search Engine Positions --> <!-- Load Google Charts --> <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <script> // Load Google Charts google.charts.load('current', {'packages':['corechart', 'line']}); </script> <script> // Google Charts loader (already in your HTML) google.charts.load('current', {'packages':['corechart', 'line']}); // Global variable to store chart instances let chartInstances = {}; // AJAX function for loading search phrases with pagination/filtering function loadSearchPhrases(engine, page) { const phraseFilterEl = document.getElementById(`${engine}PhraseFilter`); const pageFilterEl = document.getElementById(`${engine}PageFilter`); const phraseFilter = phraseFilterEl ? phraseFilterEl.value : ''; const pageFilter = pageFilterEl ? pageFilterEl.value : ''; const domain = document.getElementById('domain_name').value; const data = { type: 'search_phrases', engine: engine, page: page, domain: domain, phrase_filter: phraseFilter, page_filter: pageFilter }; // Show loading state for table const tbody = document.getElementById(`${engine}PhrasesBody`); if (tbody) { tbody.innerHTML = ` <tr> <td colspan="4" style="text-align: center; padding: 2rem;"> <div class="loading-spinner"></div> <p>Loading data...</p> </td> </tr> `; } // Show loading state for chart const chartContainer = document.getElementById(`chart_div_${engine}`); if (chartContainer) { chartContainer.innerHTML = ` <div style="text-align: center; padding: 4rem;"> <div class="loading-spinner"></div> <p>Updating chart...</p> </div> `; } sendRequest('/ajax/', data, function(response) { if (response.status === 'ok') { updateTableContent(engine, response.data); updatePagination(engine, response.pagination); // Generate and update chart with new data if (response.data && response.data.length > 0) { const chartData = generateChartData(response.data, engine); updateChart(engine, chartData); } else { // Hide chart if no data const chartContainerDiv = document.getElementById(`chart_container_${engine}`); if (chartContainerDiv) { chartContainerDiv.style.display = 'none'; } } } else { showErrorInTable(engine, response.error); } }); } // Generate chart data from API response function generateChartData(phrasesData, engine) { const chartData = { js_addColumn_str: '', js_dataRows_str: '' }; if (!phrasesData || phrasesData.length === 0) { return chartData; } // Parse all phrases and their history const allPhrases = []; const allHistory = []; phrasesData.forEach(item => { const pages = parsePageData(item.page_data); const titles = parseContentData(item.title_data); const snippets = parseContentData(item.snippet_data); const history = parsePositionHistory(item.position_history, pages, titles, snippets); if (history.length > 0) { allPhrases.push(item.phrase); allHistory.push({ phrase: item.phrase, history: history }); } }); if (allHistory.length === 0) { return chartData; } // Collect all unique days const allDays = new Set(); allHistory.forEach(item => { item.history.forEach(h => { allDays.add(h.day); }); }); // Sort days in ascending order const sortedDays = Array.from(allDays).sort((a, b) => a - b); // Generate columns chartData.js_addColumn_str = 'data.addColumn("date", "Day")\n'; allPhrases.forEach(phrase => { const label = phrase.length > 30 ? phrase.substring(0, 27) + '...' : phrase; chartData.js_addColumn_str += `data.addColumn("number", "${label}")\n`; }); // Count how many columns we should have const expectedColumnCount = 1 + allPhrases.length; // Generate data rows const dataRows = []; sortedDays.forEach(day => { // Convert day number to Date object const date = new Date(day * 86400 * 1000); // Create row array const row = [date]; // Add position for EACH phrase on this day allHistory.forEach(item => { const history = item.history; const entry = history.find(h => h.day === day); row.push(entry ? entry.position : null); }); // Adjust row length if needed if (row.length !== expectedColumnCount) { while (row.length < expectedColumnCount) { row.push(null); } while (row.length > expectedColumnCount) { row.pop(); } } dataRows.push(row); }); // Format rows for Google Charts if (dataRows.length > 0) { const rowStrings = dataRows.map(row => { const formattedRow = row.map((value, index) => { if (index === 0 && value instanceof Date) { const year = value.getFullYear(); const month = value.getMonth(); const day = value.getDate(); return `new Date(${year}, ${month}, ${day})`; } return value; }); return JSON.stringify(formattedRow); }); chartData.js_dataRows_str = rowStrings.join(',\n'); chartData.js_dataRows_str = chartData.js_dataRows_str.replace(/"new Date\((\d+), (\d+), (\d+)\)"/g, 'new Date($1, $2, $3)'); } return chartData; } // Update chart with new data function updateChart(engine, chartData) { if (!chartData || !chartData.js_dataRows_str || !chartData.js_addColumn_str) { console.warn(`No chart data for ${engine}`); const chartContainerDiv = document.getElementById(`chart_container_${engine}`); if (chartContainerDiv) { chartContainerDiv.style.display = 'none'; } return; } // Show chart container const chartContainerDiv = document.getElementById(`chart_container_${engine}`); if (chartContainerDiv) { chartContainerDiv.style.display = 'block'; } // Check if Google Charts is loaded if (typeof google === 'undefined' || typeof google.visualization === 'undefined') { console.warn('Google Charts not loaded yet'); google.charts.load('current', {'packages':['corechart', 'line']}); google.charts.setOnLoadCallback(function() { setTimeout(() => { drawChart(engine, chartData); }, 100); }); } else { setTimeout(() => { drawChart(engine, chartData); }, 100); } } // Draw chart function function drawChart(engine, chartData) { try { const chartContainer = document.getElementById(`chart_div_${engine}`); // Check if chart container exists if (!chartContainer) { console.warn(`Chart container for ${engine} not found`); return; } var data = new google.visualization.DataTable(); // Add date column data.addColumn('date', 'Day'); // Parse and add data columns const columns = chartData.js_addColumn_str.split('\n').filter(line => line.trim() !== ''); columns.forEach(col => { const match = col.match(/data\.addColumn\("(\w+)",\s*"([^"]+)"\)/); if (match) { const type = match[1]; const label = match[2]; if (type === 'date' && label === 'Day') { return; } data.addColumn(type, label); } }); // Parse data rows const rowsStr = chartData.js_dataRows_str.trim(); if (rowsStr && rowsStr !== '[]') { try { const rows = eval(`[${rowsStr}]`); // Adjust rows if needed const adjustedRows = rows.map(row => { if (!Array.isArray(row)) { return new Array(data.getNumberOfColumns()).fill(null); } if (row.length === data.getNumberOfColumns()) { return row; } const adjusted = new Array(data.getNumberOfColumns()).fill(null); // Copy available values const copyCount = Math.min(row.length, data.getNumberOfColumns()); for (let i = 0; i < copyCount; i++) { adjusted[i] = row[i]; } return adjusted; }); data.addRows(adjustedRows); } catch (e) { console.error(`Error parsing data rows:`, e); return; } } const domainName = document.getElementById('domain_name').value; const engineName = engine.charAt(0).toUpperCase() + engine.slice(1); var options = { chart: { title: `Search phrases for which the domain is at the top of the ${engine} search engine: "${domainName}"`, subtitle: 'Phrase position history' }, width: '100%', height: 400, curveType: 'function', legend: { position: 'bottom', maxLines: 3 }, pointSize: 3, pointsVisible: true, interpolateNulls: true, selectionMode: 'multiple', vAxis: { direction: -1, title: 'Position', viewWindow: { min: 1, max: 100 }, ticks: [ {v: 1, f: '1'}, {v: 10, f: '10'}, {v: 20, f: '20'}, {v: 30, f: '30'}, {v: 50, f: '50'}, {v: 100, f: '100'} ] }, hAxis: { title: 'Date', format: 'MMM yyyy' }, }; // Store chart instance for potential future updates const chart = new google.visualization.LineChart(chartContainer); chartInstances[engine] = chart; chart.draw(data, options); } catch (error) { console.error(`Error drawing chart for ${engine}:`, error); } } // Parse functions (same as before) function parsePageData(pageDataStr) { const pages = {}; if (!pageDataStr || pageDataStr.trim() === '') return pages; try { const pageItems = pageDataStr.split(';'); pageItems.forEach(item => { if (item.trim()) { const parts = item.split(':'); if (parts.length >= 2) { const id = parts[0].trim(); const page = parts.slice(1).join(':'); if (id) { pages[id] = decodeURIComponent(page).replace(/\+/g, ' '); } } } }); } catch (e) { console.error('Error parsing page data:', e); } return pages; } function parseContentData(contentDataStr) { const content = {}; if (!contentDataStr || contentDataStr.trim() === '') return content; try { const items = contentDataStr.split(';'); items.forEach(item => { if (item.trim()) { const parts = item.split(':'); if (parts.length >= 2) { const id = parts[0].trim(); const value = parts.slice(1).join(':'); if (id) { let decodedValue; try { decodedValue = decodeURIComponent(value); decodedValue = decodedValue.replace(/\\x([0-9A-Fa-f]{2})/g, (match, hex) => String.fromCharCode(parseInt(hex, 16)) ); } catch (e) { decodedValue = value; } content[id] = decodedValue; } } } }); } catch (e) { console.error('Error parsing content data:', e); } return content; } function parsePositionHistory(historyStr, pages, titles, snippets) { const history = []; if (!historyStr || historyStr.trim() === '') return history; try { const entries = historyStr.split(';'); entries.forEach(entry => { if (entry.trim()) { const parts = entry.split(':'); if (parts.length >= 3) { const day = parseInt(parts[0]); const position = parseInt(parts[1]); const pageId = parts[2]; const titleId = parts[3] || ''; const snippetId = parts[4] || ''; if (!isNaN(day) && !isNaN(position)) { history.push({ day: day, position: position, page: pages[pageId] || '', title: titles[titleId] || '', snippet: snippets[snippetId] || '' }); } } } }); history.sort((a, b) => a.day - b.day); } catch (e) { console.error('Error parsing position history:', e); } return history; } // Update table content with AJAX response function updateTableContent(engine, data) { const tbody = document.getElementById(`${engine}PhrasesBody`); if (!tbody) return; let tableRows = ''; const domain = document.getElementById('domain_name').value; data.forEach(item => { const pages = parsePageData(item.page_data); const titles = parseContentData(item.title_data); const snippets = parseContentData(item.snippet_data); const history = parsePositionHistory(item.position_history, pages, titles, snippets); const latestEntry = history.length > 0 ? history[history.length - 1] : null; const position = latestEntry ? latestEntry.position : null; const page = latestEntry ? latestEntry.page : ''; const title = latestEntry ? latestEntry.title : ''; const snippet = latestEntry ? latestEntry.snippet : ''; let change = null; if (history.length >= 2) { const previousEntry = history[history.length - 2]; if (previousEntry && position !== null && previousEntry.position !== null) { change = previousEntry.position - position; } } const badgeClass = getPositionBadgeClass(position); const positionHtml = position ? `<span class="badge ${badgeClass}">${position}</span>` : '<span class="badge">N/A</span>'; const changeHtml = change !== null && change !== 0 ? `<span class="position-change ${change > 0 ? 'positive' : 'negative'}">(${change > 0 ? '+' : ''}${change})</span>` : ''; const hasTitle = title && title.trim() !== ''; const hasSnippet = snippet && snippet.trim() !== ''; const showSnippet = hasTitle || hasSnippet; let snippetHtml = ''; if (showSnippet) { snippetHtml = ` <button class="show-snippet-btn" onclick="toggleSnippet(this)">Show snippet</button> <div class="snippet" style="display: none;"> <noindex><a href="https://${domain}${escapeHtml(page)}" rel="nofollow" target="_blank"> ${hasTitle ? `<strong>${escapeHtml(title)}</strong><br>` : ''} </a></noindex> ${hasSnippet ? escapeHtml(snippet) : ''} </div> `; } else { snippetHtml = '<span style="color: var(--gray);">-</span>'; } tableRows += ` <tr> <td>${positionHtml}${changeHtml}</td> <td><noindex><a href="/en/phrase/${encodeURIComponent(item.phrase)}/" rel="nofollow">${escapeHtml(item.phrase)}</a></noindex></td> <td>${escapeHtml(page)}</td> <td>${snippetHtml}</td> </tr> `; }); tbody.innerHTML = tableRows; } // Update pagination with AJAX response function updatePagination(engine, pagination) { const paginationContainer = document.getElementById(`${engine}Pagination`); if (!paginationContainer) return; const { current_page, total_pages, has_previous, has_next } = pagination; let paginationButtons = ''; if (total_pages > 1) { // Previous button paginationButtons += `<button ${!has_previous ? 'disabled' : ''} onclick="loadSearchPhrases('${engine}', ${current_page - 1})">«</button>`; // First page paginationButtons += `<button class="${current_page === 1 ? 'active' : ''}" ${current_page === 1 ? 'disabled' : ''} onclick="loadSearchPhrases('${engine}', 1)">1</button>`; // Calculate range let startPage = Math.max(2, current_page - 2); let endPage = Math.min(total_pages - 1, current_page + 2); if (current_page <= 3) { endPage = Math.min(total_pages - 1, 5); } if (current_page >= total_pages - 2) { startPage = Math.max(2, total_pages - 4); } if (startPage > 2) { paginationButtons += `<button disabled>...</button>`; } for (let i = startPage; i <= endPage; i++) { const activeClass = i === current_page ? 'active' : ''; const disabledAttr = i === current_page ? 'disabled' : ''; paginationButtons += `<button class="${activeClass}" ${disabledAttr} onclick="loadSearchPhrases('${engine}', ${i})">${i}</button>`; } if (endPage < total_pages - 1) { paginationButtons += `<button disabled>...</button>`; } if (total_pages > 1) { paginationButtons += `<button class="${current_page === total_pages ? 'active' : ''}" ${current_page === total_pages ? 'disabled' : ''} onclick="loadSearchPhrases('${engine}', ${total_pages})">${total_pages}</button>`; } // Next button paginationButtons += `<button ${!has_next ? 'disabled' : ''} onclick="loadSearchPhrases('${engine}', ${current_page + 1})">»</button>`; } paginationContainer.innerHTML = paginationButtons; } // Show error in table function showErrorInTable(engine, errorMessage) { const tbody = document.getElementById(`${engine}PhrasesBody`); if (tbody) { tbody.innerHTML = ` <tr> <td colspan="4" style="text-align: center; padding: 2rem; color: var(--danger);"> <div style="margin-bottom: 1rem;"> <span style="font-size: 2rem;">❌</span> </div> <p><strong>Error loading data:</strong></p> <p>${escapeHtml(errorMessage)}</p> <button class="toggle-btn" onclick="loadSearchPhrases('${engine}', 1)" style="margin-top: 1rem;"> Retry </button> </td> </tr> `; } } // Helper functions function escapeHtml(text) { if (!text) return ''; const div = document.createElement('div'); div.textContent = text; return div.innerHTML; } function getPositionBadgeClass(position) { if (!position) return 'badge'; if (position <= 3) return 'badge-success'; if (position <= 10) return 'badge-warning'; return 'badge-danger'; } function toggleSnippet(button) { const snippet = button.nextElementSibling; const isVisible = snippet.style.display === 'block'; snippet.style.display = isVisible ? 'none' : 'block'; button.textContent = isVisible ? 'Show snippet' : 'Hide snippet'; } // Filter functions function applyFilters(engine) { loadSearchPhrases(engine, 1); } function clearFilters(engine) { const phraseFilterEl = document.getElementById(`${engine}PhraseFilter`); const pageFilterEl = document.getElementById(`${engine}PageFilter`); if (phraseFilterEl) phraseFilterEl.value = ''; if (pageFilterEl) pageFilterEl.value = ''; loadSearchPhrases(engine, 1); } // Initialize filter events on page load document.addEventListener('DOMContentLoaded', function() { // Initialize enter key for filter inputs ['google', 'yandex'].forEach(engine => { const phraseFilter = document.getElementById(`${engine}PhraseFilter`); const pageFilter = document.getElementById(`${engine}PageFilter`); if (phraseFilter) { phraseFilter.addEventListener('keypress', function(e) { if (e.key === 'Enter') { applyFilters(engine); } }); } if (pageFilter) { pageFilter.addEventListener('keypress', function(e) { if (e.key === 'Enter') { applyFilters(engine); } }); } }); // Load Google Charts google.charts.load('current', {'packages':['corechart', 'line']}); // Initial chart drawing for server-side data google.charts.setOnLoadCallback(function() { // You might want to extract chart data from initial server-side render // or make an initial AJAX call to get chart data for page 1 }); }); // AJAX request function function sendRequest(url, data, callback) { const xhr = new XMLHttpRequest(); xhr.open('POST', url, true); xhr.setRequestHeader('Content-Type', 'application/json'); xhr.onreadystatechange = function() { if (xhr.readyState === 4) { if (xhr.status === 200) { try { const response = JSON.parse(xhr.responseText); callback(response); } catch (e) { console.error("JSON parse error:", e); callback({status: 'error', error: 'Invalid response from server'}); } } else { callback({status: 'error', error: 'Server error: ' + xhr.status}); } } }; xhr.send(JSON.stringify(data)); } </script> <script> (function() { 'use strict'; // --- Configuration --- const STORAGE_KEY = 'serpuls_domain_sections_state'; const SECTIONS_TO_COLLAPSE = [ { id: 'domain-main-info', title: 'Glavne informacije', btnText: 'Info' }, { id: 'domain-server-info', title: 'Informacije o poslužitelju', btnText: 'poslužitelj' }, { id: 'domain-meta-tags', title: 'Popis meta oznaka', btnText: 'Meta' }, { id: 'domain-internal-links', title: 'Interne veze', btnText: 'Interni' }, { id: 'domain-external-links', title: 'Vanjske veze', btnText: 'Vanjski' }, { id: 'domain-whois-info', title: 'Whois informacije', btnText: 'Whois' }, { id: 'domain-seo-audit', title: 'SEO revizija', btnText: 'SEO revizija' } ]; // --- Helper Functions --- function saveSectionState(sectionId, isCollapsed) { const savedState = localStorage.getItem(STORAGE_KEY); const state = savedState ? JSON.parse(savedState) : {}; state[sectionId] = isCollapsed; localStorage.setItem(STORAGE_KEY, JSON.stringify(state)); } function loadSectionState(sectionId) { const savedState = localStorage.getItem(STORAGE_KEY); if (!savedState) return false; const state = JSON.parse(savedState); return state[sectionId] || false; } // --- Create Floating TOC --- function createFloatingTOC() { // Find all major sections const sections = []; // Add main sections from the page const sectionSelectors = [ { id: 'domain-header', title: 'Informacije o domeni', selector: '.domain-header' }, { id: 'domain-description', title: 'Opis web stranice', selector: '.card:has(.card-title:contains("Opis web stranice"))' }, { id: 'domain-backup', title: 'Sigurnosna kopija domene', selector: '.card:has(.card-title:contains("Sigurnosna kopija domene"))' }, { id: 'domain-seo-score', title: 'SEO rezultat', selector: '.seo-score' }, { id: 'domain-main-info', title: 'Glavne informacije', selector: '.card:has(.card-title:contains("Glavne informacije"))' }, { id: 'domain-server-info', title: 'Informacije o poslužitelju', selector: '.card:has(.card-title:contains("Informacije o poslužitelju"))' }, { id: 'domain-meta-tags', title: 'Popis meta oznaka', selector: '.card:has(.card-title:contains("Popis meta oznaka"))' }, { id: 'domain-internal-links', title: 'Interne veze', selector: '.card:has(.card-title:contains("Interne veze"))' }, { id: 'domain-external-links', title: 'Vanjske veze', selector: '.card:has(.card-title:contains("Vanjske veze"))' }, { id: 'domain-whois-info', title: 'Whois informacije', selector: '.card:has(.card-title:contains("Whois informacije"))' }, { id: 'domain-whois-raw', title: 'Whois neobrađeni podaci', selector: '.card:has(.card-title:contains("Whois neobrađeni podaci"))' }, { id: 'domain-robots', title: 'Robots.txt', selector: '.card:has(.card-title:contains("Robots.txt"))' }, { id: 'domain-seo-audit', title: 'SEO revizija', selector: '.card:has(.card-title:contains("SEO revizija"))' }, { id: 'domain-google-positions', title: 'Pozicije u Google', selector: '.chart-container:has(h2:contains("Google"))' }, { id: 'domain-google-phrases', title: 'Fraze za pretraživanje - Google', selector: '.card:has(.card-title:contains("Google"))' }, { id: 'domain-yandex-positions', title: 'Pozicije u Yandex', selector: '.chart-container:has(h2:contains("Yandex"))' }, { id: 'domain-yandex-phrases', title: 'Fraze za pretraživanje - Yandex', selector: '.card:has(.card-title:contains("Yandex"))' }, { id: 'domain-additional-services', title: 'Dodatne usluge', selector: '.card:has(.card-title:contains("Dodatne usluge"))' } ]; sectionSelectors.forEach(section => { let element = null; // Try to find by selector if (section.selector) { if (section.selector.includes(':contains')) { // Simple contains selector const containsText = section.selector.match(/:contains\("([^"]+)"\)/); if (containsText) { const searchText = containsText[1]; const cards = document.querySelectorAll('.card, .chart-container, .seo-score, .domain-header'); for (const card of cards) { if (card.textContent.includes(searchText) && !card.id) { element = card; break; } } } } else { element = document.querySelector(section.selector); } } if (element && !element.id) { element.id = section.id; sections.push({ id: section.id, title: section.title, element: element }); } else if (element && element.id) { sections.push({ id: element.id, title: section.title, element: element }); } }); // Also add any card with an ID that wasn't captured document.querySelectorAll('.card[id], .chart-container[id], .seo-score[id]').forEach(el => { if (!sections.find(s => s.id === el.id)) { const titleEl = el.querySelector('.card-title, h2'); if (titleEl) { sections.push({ id: el.id, title: titleEl.innerText.trim(), element: el }); } } }); if (sections.length < 2) return; // Create TOC container const tocContainer = document.createElement('div'); tocContainer.id = 'floating-toc'; tocContainer.className = 'floating-toc'; tocContainer.innerHTML = ` <div class="floating-toc-header"> <span>📑 Sadržaj</span> <button id="toc-toggle-btn" class="toc-toggle-btn" aria-label="Sažmi sadržaj">−</button> </div> <div id="toc-links-container" class="toc-links-container"> ${sections.map(section => `<a href="#${section.id}" class="toc-link" data-id="${section.id}">${escapeHtml(section.title)}</a>`).join('')} </div> `; document.body.appendChild(tocContainer); // Toggle TOC visibility const toggleBtn = document.getElementById('toc-toggle-btn'); const linksContainer = document.getElementById('toc-links-container'); let isTocExpanded = true; toggleBtn.addEventListener('click', () => { if (isTocExpanded) { linksContainer.style.display = 'none'; toggleBtn.textContent = '+'; tocContainer.classList.add('collapsed'); } else { linksContainer.style.display = 'block'; toggleBtn.textContent = '−'; tocContainer.classList.remove('collapsed'); } isTocExpanded = !isTocExpanded; }); // Highlight active section on scroll const tocLinks = document.querySelectorAll('.toc-link'); const sectionElements = sections.map(s => s.element); function updateActiveLink() { let current = ''; const scrollPosition = window.scrollY + 100; for (const section of sectionElements) { if (!section) continue; const sectionTop = section.offsetTop; const sectionBottom = sectionTop + section.offsetHeight; if (scrollPosition >= sectionTop && scrollPosition < sectionBottom) { current = section.id; break; } } tocLinks.forEach(link => { link.classList.remove('active'); if (link.getAttribute('data-id') === current) { link.classList.add('active'); } }); } window.addEventListener('scroll', updateActiveLink); updateActiveLink(); // Smooth scroll tocLinks.forEach(link => { link.addEventListener('click', (e) => { e.preventDefault(); const targetId = link.getAttribute('data-id'); const targetElement = document.getElementById(targetId); if (targetElement) { targetElement.scrollIntoView({ behavior: 'smooth', block: 'start' }); } }); }); } // --- Add Collapsible Buttons to Sections --- function addCollapsibleButtons() { SECTIONS_TO_COLLAPSE.forEach(section => { // Find the card by ID or by title let targetCard = document.getElementById(section.id); if (!targetCard) { const cards = document.querySelectorAll('.card'); for (const card of cards) { const titleEl = card.querySelector('.card-title'); if (titleEl && titleEl.innerText.trim() === section.title) { targetCard = card; break; } } } if (!targetCard) return; // Set ID if not exists if (!targetCard.id) targetCard.id = section.id; // Create button const button = document.createElement('button'); button.className = 'collapse-section-btn'; button.setAttribute('data-section-id', section.id); button.setAttribute('aria-label', 'Sažmi/proširi odjeljak'); // Get initial state const isCollapsed = loadSectionState(section.id); if (isCollapsed) { button.innerHTML = '➕'; targetCard.classList.add('section-collapsed'); const content = targetCard.querySelector('.card-content'); if (content) content.style.display = 'none'; } else { button.innerHTML = '➖'; targetCard.classList.remove('section-collapsed'); const content = targetCard.querySelector('.card-content'); if (content) content.style.display = ''; } // Insert button into card-header const cardHeader = targetCard.querySelector('.card-header'); if (cardHeader) { const iconDiv = cardHeader.querySelector('.card-icon'); if (iconDiv) { cardHeader.insertBefore(button, iconDiv); } else { cardHeader.appendChild(button); } // Add click handler button.addEventListener('click', (e) => { e.stopPropagation(); const sectionId = button.getAttribute('data-section-id'); const card = document.getElementById(sectionId); if (!card) return; const content = card.querySelector('.card-content'); if (!content) return; if (card.classList.contains('section-collapsed')) { content.style.display = ''; card.classList.remove('section-collapsed'); button.innerHTML = '➖'; saveSectionState(sectionId, false); } else { content.style.display = 'none'; card.classList.add('section-collapsed'); button.innerHTML = '➕'; saveSectionState(sectionId, true); } }); } }); } // --- Create Back to Top Button --- function createBackToTopButton() { const btn = document.createElement('button'); btn.id = 'back-to-top'; btn.innerHTML = '↑'; btn.setAttribute('aria-label', 'Povratak na vrh'); btn.className = 'back-to-top-btn'; document.body.appendChild(btn); window.addEventListener('scroll', () => { if (window.scrollY > 500) { btn.classList.add('visible'); } else { btn.classList.remove('visible'); } }); btn.addEventListener('click', () => { window.scrollTo({ top: 0, behavior: 'smooth' }); }); } // --- Improve Table Responsiveness --- function improveTables() { const tables = document.querySelectorAll('.data-table, .tasks-table'); tables.forEach(table => { const container = table.closest('.table-responsive') || table.parentElement; if (container && !container.querySelector('.scroll-hint')) { const hint = document.createElement('div'); hint.className = 'scroll-hint'; hint.innerHTML = '← → Prijeđite prstom da vidite više'; hint.style.cssText = ` display: none; text-align: center; font-size: 0.7rem; color: var(--gray); margin-top: 0.5rem; padding: 0.25rem; background: rgba(67, 97, 238, 0.05); border-radius: 12px; `; container.style.position = 'relative'; container.appendChild(hint); function checkScroll() { if (container.scrollWidth > container.clientWidth) { hint.style.display = 'block'; } else { hint.style.display = 'none'; } } checkScroll(); window.addEventListener('resize', checkScroll); container.addEventListener('scroll', () => { hint.style.opacity = '0.5'; setTimeout(() => { hint.style.opacity = '1'; }, 300); }); } }); } // --- Escape HTML helper --- function escapeHtml(text) { const div = document.createElement('div'); div.textContent = text; return div.innerHTML; } // --- Add custom styles --- function addCustomStyles() { const style = document.createElement('style'); style.textContent = ` .floating-toc { position: fixed; top: 80px; right: 20px; z-index: 1000; background: white; border-radius: 12px; box-shadow: 0 4px 20px rgba(0,0,0,0.15); border: 1px solid #e9ecef; width: 260px; max-width: calc(100% - 40px); transition: all 0.3s ease; backdrop-filter: blur(8px); background: rgba(255,255,255,0.95); } .floating-toc-header { display: flex; justify-content: space-between; align-items: center; padding: 10px 15px; background: linear-gradient(135deg, var(--primary), var(--secondary)); color: white; border-radius: 12px 12px 0 0; font-weight: 600; font-size: 0.9rem; cursor: pointer; } .toc-toggle-btn { background: none; border: none; color: white; font-size: 1.2rem; cursor: pointer; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; border-radius: 50%; transition: background 0.2s; } .toc-toggle-btn:hover { background: rgba(255,255,255,0.2); } .floating-toc.collapsed { width: auto; } .floating-toc.collapsed .floating-toc-header { border-radius: 12px; } .toc-links-container { max-height: 400px; overflow-y: auto; padding: 8px 0; } .toc-link { display: block; padding: 8px 15px; color: var(--dark); text-decoration: none; font-size: 0.85rem; transition: all 0.2s; border-left: 3px solid transparent; } .toc-link:hover { background: rgba(67, 97, 238, 0.05); color: var(--primary); padding-left: 20px; } .toc-link.active { background: rgba(67, 97, 238, 0.1); border-left-color: var(--primary); color: var(--primary); font-weight: 500; } .collapse-section-btn { background: none; border: none; font-size: 1.1rem; cursor: pointer; width: 28px; height: 28px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; transition: all 0.2s; color: var(--gray); margin-right: 8px; } .collapse-section-btn:hover { background: rgba(67, 97, 238, 0.1); color: var(--primary); } .card.section-collapsed .card-header { border-bottom: none; } .back-to-top-btn { position: fixed; bottom: 30px; right: 30px; width: 48px; height: 48px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--secondary)); color: white; border: none; cursor: pointer; font-size: 1.5rem; display: flex; align-items: center; justify-content: center; opacity: 0; visibility: hidden; transition: all 0.3s ease; z-index: 999; box-shadow: 0 4px 12px rgba(67, 97, 238, 0.4); } .back-to-top-btn.visible { opacity: 1; visibility: visible; } .back-to-top-btn:hover { transform: translateY(-3px); box-shadow: 0 6px 16px rgba(67, 97, 238, 0.5); } @media (max-width: 768px) { .floating-toc { top: auto; bottom: 20px; right: 20px; left: auto; width: 48px; overflow: hidden; } .floating-toc .floating-toc-header span { display: none; } .floating-toc .floating-toc-header { justify-content: center; padding: 12px; } .floating-toc .toc-toggle-btn { margin: 0; } .floating-toc:not(.collapsed) { width: 260px; left: auto; right: 20px; bottom: 20px; top: auto; } .floating-toc:not(.collapsed) .floating-toc-header span { display: inline; } .floating-toc:not(.collapsed) .floating-toc-header { justify-content: space-between; } .back-to-top-btn { bottom: 80px; right: 20px; width: 40px; height: 40px; font-size: 1.2rem; } .scroll-hint { display: block !important; font-size: 0.65rem; } } html { scroll-behavior: smooth; } .card .card-content { transition: display 0.2s ease; } [dir="rtl"] .floating-toc { right: auto; left: 20px; } [dir="rtl"] .back-to-top-btn { right: auto; left: 30px; } [dir="rtl"] .collapse-section-btn { margin-right: 0; margin-left: 8px; } `; document.head.appendChild(style); } // --- Initialize --- function init() { addCustomStyles(); createFloatingTOC(); addCollapsibleButtons(); createBackToTopButton(); improveTables(); } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', init); } else { init(); } })(); </script></div> <!-- Footer --> <footer> <div class="footer-container"> <div class="footer-content"> <div class="footer-section"> <h3>About serpuls.com</h3> <div class="footer-info"> <p>Profesionalni alat za analizu tražilica, praćenje pozicije i SEO optimizaciju.</p> <p style="margin-top: 1rem;"><strong>Skynet360 LP.</strong></p> <p><strong>Tvrtka br:</strong> SL027564</p> <p><strong>Adresa:</strong> Suite 1 4 Queen Street, Edinburgh, Scotland, EH2 1JE</p> </div> </div> <div class="footer-section"> <h3>Brze veze</h3> <ul class="footer-links"> <li><a href="/hr/">Dom</a></li> <li><a href="/hr/profile/">Profil</a></li> <li><a href="/hr/tasks/">Zadaci praćenja</a></li> <li><a href="/hr/api_docs/">API dokumentacija</a></li> <li><a href="/hr/team/">Naš tim</a></li> </ul> </div> <div class="footer-section"> <h3>Resursi</h3> <ul class="footer-links"> <li><a href="/hr/blogs/">Blog</a></li> <li><a href="/hr/faq/">FAQ</a></li> <li><a href="/hr/support/">podrška</a></li> </ul> </div> <div class="footer-section"> <h3>Kontakti</h3> <div class="footer-info"> <p>E-mail: <a href="mailto:info@serpuls.com">info@serpuls.com</a></p> <p>Telegram: <a href="https://t.me/serpulse_support">@serpulse_support</a></p> <div class="social-links"> <a href="#" class="social-link" title="Telegram">📱</a> <a href="https://github.com/SkyNetJose/serpuls" class="social-link" title="GitHub">💻</a> <a href="#" class="social-link" title="Cvrkut">🐦</a> </div> </div> </div> </div> <div class="footer-bottom"> <p class="copyright">© 2026 serpuls.com. Sva prava pridržana. Skynet360 LP.</p> <div class="footer-bottom-links"> <a href="/hr/privacy/">Politika privatnosti</a> <a href="/hr/terms/">Uvjeti korištenja</a> <a href="/hr/agreement/">Korisnički ugovor</a> <a href="/hr/cookie/">Politika kolačića</a> </div> </div> </div> </footer> <!-- Updated Payment Modal HTML --> <div class="modal" id="paymentModal"> <div class="modal-content"> <span class="close-btn">×</span> <div class="modal-success" id="paymentSuccess"> <div class="success-icon">✓</div> <h3>Plaćanje uspješno!</h3> <p>Hvala vam na narudžbi. Uskoro ćemo Vas kontaktirati.</p> <button class="cta-button" onclick="closeModal('paymentModal')">Zatvoriti</button> </div> <form id="paymentForm" onsubmit="return processPayment(event)"> <h2 class="modal-title" id="modalTitle">Plaćanje usluge</h2> <p class="modal-text" id="modalText">Opis usluge</p> <!-- Hidden fields for payment type and ID --> <input type="hidden" id="paymentType" name="payment_type" value=""> <input type="hidden" id="paymentItemId" name="payment_item_id" value=""> <!-- Payment Options --> <div class="payment-options" id="paymentOptions"> <!-- Options will be dynamically generated here --> </div> <!-- Manual Price Input (Optional) - Now dynamically shown based on config --> <div class="form-group" id="manualPriceGroup" style="display: none;"> <label for="manualPrice">Unesite iznos (USD):</label> <input type="number" id="manualPrice" class="form-control" placeholder="Unesite iznos" min="1" max="10000" step="0.01" oninput="updateManualPrice(this.value)"> <div class="error-message" id="manualPriceError"></div> </div> <!-- Custom Price Option Toggle - Now dynamically shown --> <div class="form-group" id="customPriceToggle" style="display: none; margin-bottom: 1rem;"> <label style="display: flex; align-items: center; gap: 0.5rem; cursor: pointer;"> <input type="radio" id="customPriceRadio" name="paymentOption" value="custom" onchange="toggleCustomPriceSelection(this.checked)"> Unesite prilagođeni iznos </label> </div> <div class="form-group"> <label for="modalName">Ime:</label> <input type="text" id="modalName" class="form-control" placeholder="Unesite svoje ime" required> <div class="error-message" id="modalNameError"></div> </div> <div class="form-group"> <label for="modalEmail">Email:</label> <input type="email" id="modalEmail" class="form-control" placeholder="Unesite svoju e-poštu" required> <div class="error-message" id="modalEmailError"></div> </div> <p class="modal-price" id="modalPrice">Cijena: $0.00</p> <button type="submit" class="cta-button" id="payButton">Platiti $0.00</button> </form> </div> </div> <!-- Redirect Modal (for iframe) --> <div class="modal" id="redirectModal"> <div class="modal-content modal-large"> <span class="close-btn">×</span> <h2 class="modal-title">Plaćanje</h2> <iframe id="redirectIframe" class="modal-iframe" src=""></iframe> </div> </div> <!-- Auth Modal --> <div class="modal" id="authModal"> <div class="modal-content"> <span class="close-btn">×</span> <div class="auth-tabs"> <div class="auth-tab active" data-tab="login">Prijava</div> <div class="auth-tab" data-tab="register">Registar</div> </div> <div class="auth-form active" id="loginForm"> <h2 class="modal-title">Prijavite se na svoj račun</h2> <!-- Regular Login --> <div class="form-group"> <label for="loginEmail">Email:</label> <input type="email" id="loginEmail" class="form-control" placeholder="Unesite svoju e-poštu"> <div class="error-message" id="loginEmailError"></div> </div> <div class="form-group"> <label for="loginPassword">Lozinka:</label> <input type="password" id="loginPassword" class="form-control" placeholder="Unesite svoju lozinku"> <div class="error-message" id="loginPasswordError"></div> </div> <button class="cta-button" style="width: 100%;" onclick="processLogin()">Prijava</button> <!-- Telegram Login Option --> <div style="text-align: center; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid #e9ecef;"> <p style="margin-bottom: 1rem; color: var(--gray);">Ili se prijavite putem Telegrama</p> <button class="cta-button" style="background: #0088cc; width: 100%;" onclick="loginWithTelegram()"> <span style="margin-right: 0.5rem;">📱</span> Prijavite se putem Telegrama </button> </div> </div> <div class="auth-form" id="registerForm"> <h2 class="modal-title">Registrirajte se putem Telegrama</h2> <!-- Registration Form --> <div class="form-group"> <label for="registerName">Ime:</label> <input type="text" id="registerName" class="form-control" placeholder="Unesite svoje ime" required> <div class="error-message" id="registerNameError"></div> </div> <div class="form-group"> <label for="registerEmail">Email:</label> <input type="email" id="registerEmail" class="form-control" placeholder="Unesite svoju e-poštu" required> <div class="error-message" id="registerEmailError"></div> </div> <button class="cta-button" style="background: #0088cc; width: 100%; padding: 1rem; font-size: 1.1rem;" onclick="startTelegramRegistration()"> <span style="margin-right: 0.5rem;">🚀</span> Nastavite s registracijom u Telegramu </button> <div class="how-it-works"> <h4 class="how-it-works-title">Kako radi:</h4> <ol class="how-it-works-list"> <li>Unesite ime i e-mail iznad</li> <li>Pritisnite gumb za otvaranje Telegrama</li> <li>Završite registraciju na botu (potreban broj telefona)</li> <li>Primite vjerodajnice za prijavu putem e-pošte</li> </ol> </div> </div> </div> </div> <!-- Telegram Code Input Modal --> <div class="modal" id="telegramCodeModal"> <div class="modal-content"> <span class="close-btn" onclick="closeModal('telegramCodeModal')">×</span> <div class="centered-content"> <div class="success-icon">🔐</div> <h2 class="modal-title">Kontrolni kod</h2> <p class="modal-text">Šifra je poslana na Telegram. Unesite ga ispod:</p> <div class="form-group"> <input type="text" id="telegramLoginCode" class="form-control verify-code-input" placeholder="0000000" maxlength="7" style="font-size: 1.5rem; letter-spacing: 0.5rem;"> <div class="error-message" id="telegramLoginCodeError"></div> </div> <button class="cta-button" style="width: 100%; margin-top: 1rem;" onclick="verifyTelegramLoginCode()"> Potvrdite prijavu </button> <div class="timer-container" id="loginCodeTimer"> Kod vrijedi za: <span id="loginTimer">05:00</span> </div> </div> </div> </div> <!-- Updated Telegram Verification Modal --> <div class="modal" id="telegramVerifyModal"> <div class="modal-content"> <span class="close-btn" onclick="closeTelegramVerifyModal()">×</span> <div class="centered-content"> <div class="success-icon">📱</div> <h2 class="modal-title">Završite registraciju u Telegramu</h2> <p class="modal-text" id="telegramModalText"> Telegram je otvoren u novoj kartici.<br> Ako se bot nije otvorio automatski, upotrijebite gumb ispod ili skenirajte QR kod. </p> <!-- QR Code Container --> <div id="qrCodeContainer" style="margin: 1.5rem 0; text-align: center;"> <div id="qrcode" style="display: inline-block;"></div> <p style="font-size: 0.9rem; color: var(--gray); margin-top: 0.5rem;"> Skenirajte QR kod da otvorite bot </p> </div> <!-- Timer and Status --> <div id="telegramTimer" class="timer-container"> Čeka se potvrda... <span id="timer">05:00</span> </div> <!-- Action Buttons --> <div style="display: flex; gap: 1rem; margin-top: 1.5rem; flex-wrap: wrap; justify-content: center;"> <button class="cta-button" style="background: #0088cc;" onclick="openTelegramBot()" id="openTelegramBtn"> 📱 Ponovno otvorite Telegram </button> <button class="cta-button secondary" onclick="refreshTelegramQR()" id="refreshQRBtn"> 🔄 Osvježi QR kod </button> </div> <!-- Status Info --> <div class="info-box" style="margin-top: 1.5rem;"> <p style="margin: 0; font-size: 0.9rem;"> <strong>Kako radi:</strong><br> 1. Pritisnite Otvori Telegram ili skenirajte QR kod<br> 2. U botu kliknite START i podijelite svoj broj telefona<br> 3. Status potvrde ažurirat će se automatski </p> </div> </div> </div> </div> <!-- Email Verification Modal --> <div class="modal" id="emailVerifyModal"> <div class="modal-content"> <span class="close-btn" onclick="closeEmailVerifyModal()">×</span> <div class="centered-content"> <div class="success-icon">📧</div> <h2 class="modal-title">Potvrda e-pošte</h2> <p class="modal-text">Poslali smo e-poruku za potvrdu na vašu adresu</p> <!-- Email Verification Input --> <div class="form-group"> <label for="emailVerifyToken">Kontrolni kod:</label> <input type="text" id="emailVerifyToken" class="form-control" placeholder="Unesite kod iz e-maila" style="text-align: center; font-size: 1.1rem;"> <div class="error-message" id="emailVerifyTokenError"></div> </div> <button class="cta-button" style="width: 100%; margin-bottom: 1rem;" onclick="verifyEmailToken()"> Potvrdi e-poštu </button> <button id="resendEmailBtn" class="cta-button secondary" style="width: 100%;" onclick="resendEmailVerification()" disabled> Ponovno pošalji kod (<span id="resendTimer">300</span>) </button> <!-- Auto-check status --> <div id="emailCheckStatus" style="margin-top: 1rem; display: none;"> <p style="color: var(--gray); font-size: 0.9rem;"> 🔍 Provjera statusa provjere... </p> </div> </div> </div> </div> <!-- Image reusable Modal --> <div class="modal" id="imgModal"> <div class="modal-content"> <span class="close-btn">×</span> <img id="modalImg" src="" style="max-width:90%; max-height:90%; margin-top:40px; border-radius:8px;"> </div> </div> <!--Loading overlay --> <div class="loading-overlay" id="loadingOverlay"> <div class="loading-spinner"></div> </div> <div class="toast" id="toast"></div> <script> // Get language from URL path like /en/about or /ru/products function getLangFromUrl() { const path = window.location.pathname; const match = path.match(/^\/([a-z]{2})(\/|$)/i); return match ? match[1] : 'en'; // default to 'en' if no language code found } // Store in global variable window.currentLang = getLangFromUrl(); // Show loading overlay function showLoading() { document.getElementById('loadingOverlay').classList.add('active'); } // Hide loading overlay function hideLoading() { document.getElementById('loadingOverlay').classList.remove('active'); } // Show toast notification function showToast(message, type = 'info') { const toast = document.getElementById('toast'); toast.textContent = message; toast.className = 'toast ' + type; toast.classList.add('show'); setTimeout(() => { toast.classList.remove('show'); }, 3000); } // Check user login status on page load document.addEventListener('DOMContentLoaded', function() { checkUserLoginStatus(); }); // Function to check if user is logged in function checkUserLoginStatus() { const userInfoElement = document.getElementById('userInfo'); const guestButtonsElement = document.getElementById('guestButtons'); const userNameElement = document.getElementById('userName'); // Show loading state or keep defaults while checking if (guestButtonsElement) { guestButtonsElement.style.display = 'flex'; } if (userInfoElement) { userInfoElement.style.display = 'none'; } const data = { type: 'check_user_logined' }; sendRequest('/ajax/', data, function(response) { if (response.status === 'ok') { if (response.user_logined === 1) { // User is logged in if (userInfoElement) { userInfoElement.style.display = 'block'; } if (guestButtonsElement) { guestButtonsElement.style.display = 'none'; } if (userNameElement) { // Use logined_user_name if available, otherwise show default userNameElement.textContent = response.logined_user_name || 'Profil'; } // Optionally store minimal info in localStorage for quick access // but don't rely on it for auth state if (response.logined_user_id) { localStorage.setItem('user_id', response.logined_user_id); } if (response.logined_user_name) { localStorage.setItem('user_name', response.logined_user_name); } } else { // User is not logged in if (userInfoElement) { userInfoElement.style.display = 'none'; } if (guestButtonsElement) { guestButtonsElement.style.display = 'flex'; } // Clear any previously stored user data localStorage.removeItem('user_id'); localStorage.removeItem('user_name'); localStorage.removeItem('user_info'); } } else { console.error('Pogreška pri provjeri statusa prijave:', response.error); // On error, default to guest view if (userInfoElement) { userInfoElement.style.display = 'none'; } if (guestButtonsElement) { guestButtonsElement.style.display = 'flex'; } } }, false); // Don't show loading overlay for this quick check } // Logout function function logout() { // Send logout request to server const data = { type: 'logout' }; sendRequest('/ajax/', data, function(response) { // Clear all user data from localStorage regardless of response localStorage.removeItem('user_info'); localStorage.removeItem('user_id'); localStorage.removeItem('user_name'); localStorage.removeItem('current_user_token'); // Update UI checkUserLoginStatus(); // Redirect to main page window.location.href = '/'; }); } </script> <script> // Mobile menu toggle - Combined approach document.getElementById('hamburger').addEventListener('click', function() { const mobileMenu = document.getElementById('mobileMenu'); mobileMenu.classList.toggle('active'); }); // Close mobile menu when clicking on links or buttons document.querySelectorAll('.nav-links a, .auth-buttons button').forEach(element => { element.addEventListener('click', function() { document.getElementById('mobileMenu').classList.remove('active'); }); }); // Close mobile menu when clicking outside document.addEventListener('click', function(event) { const mobileMenu = document.getElementById('mobileMenu'); const hamburger = document.getElementById('hamburger'); const navContainer = document.querySelector('.nav-container'); if (!navContainer.contains(event.target) && mobileMenu.classList.contains('active')) { mobileMenu.classList.remove('active'); } }); // Simple animation on scroll document.addEventListener('DOMContentLoaded', function() { const cards = document.querySelectorAll('.card, .domain-header, .chart-container, .lemma-card'); const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.style.opacity = '1'; entry.target.style.transform = 'translateY(0)'; } }); }, { threshold: 0.0001, // Optional: keep small percentage rootMargin: '350px 0px 350px 0px' // Trigger 100px before element enters }); cards.forEach(card => { card.style.opacity = '0'; card.style.transform = 'translateY(20px)'; card.style.transition = 'opacity 0.5s ease, transform 0.5s ease'; observer.observe(card); }); }); // Toggle links visibility function toggleLinks(className, btn, max_count = 5) { const list = document.getElementById(className); const items = list.querySelectorAll('li'); const hiddenItems = list.querySelectorAll('li.hidden'); if (hiddenItems.length > 0) { // Show all list.querySelectorAll('li.hidden').forEach(el => el.classList.remove('hidden')); btn.textContent = 'Sakriti'; } else { // Hide all beyond the first 5 items.forEach((el, index) => { if (index >= max_count) el.classList.add('hidden'); }); btn.textContent = 'Prikaži više'; } } // Toggle raw data visibility function toggleRawData(elementId, btn) { const element = document.getElementById(elementId); if (element.style.maxHeight === '200px') { element.style.maxHeight = 'none'; btn.textContent = 'Sakrij sve podatke'; } else { element.style.maxHeight = '200px'; btn.textContent = 'Prikaži sve podatke'; } } </script> <script> // Payment Modal // Global variable to store payment config let paymentConfig = { allowCustomAmount: false, minAmount: 1, maxAmount: 1000 }; // Payment options functionality document.addEventListener('DOMContentLoaded', function() { // Replace the entire payment options event listener with this: document.addEventListener('change', function(e) { if (e.target && e.target.name === 'paymentOption') { // Update selected state for regular options document.querySelectorAll('.payment-option').forEach(opt => { opt.classList.remove('selected'); }); // Handle custom price radio separately if (e.target.id === 'customPriceRadio') { // For custom price, we don't have a .payment-option wrapper // Just update the custom price toggle UI document.querySelectorAll('.payment-option').forEach(opt => { opt.classList.remove('selected'); }); // You might want to add visual feedback for custom price selection const customPriceToggle = document.getElementById('customPriceToggle'); if (customPriceToggle) { customPriceToggle.style.backgroundColor = 'rgba(67, 97, 238, 0.1)'; customPriceToggle.style.borderLeft = '3px solid var(--primary)'; customPriceToggle.style.padding = '0.5rem'; customPriceToggle.style.borderRadius = 'var(--border-radius)'; } } else { // For regular options, highlight the .payment-option container const paymentOption = e.target.closest('.payment-option'); if (paymentOption) { paymentOption.classList.add('selected'); // Reset custom price toggle styling if it was highlighted const customPriceToggle = document.getElementById('customPriceToggle'); if (customPriceToggle) { customPriceToggle.style.backgroundColor = ''; customPriceToggle.style.borderLeft = ''; customPriceToggle.style.padding = ''; } } } // Update price (this should work for all options) updatePaymentPrice(e.target.value); } }); }); // Update the updatePaymentPrice function to handle custom price: function updatePaymentPrice(price) { const modalPrice = document.getElementById('modalPrice'); const payButton = document.getElementById('payButton'); const customPriceRadio = document.getElementById('customPriceRadio'); // Uncheck custom price radio if regular option is selected if (customPriceRadio && customPriceRadio.checked === false) { document.getElementById('manualPriceGroup').style.display = 'none'; // Reset custom price toggle styling const customPriceToggle = document.getElementById('customPriceToggle'); if (customPriceToggle) { customPriceToggle.style.backgroundColor = ''; customPriceToggle.style.borderLeft = ''; customPriceToggle.style.padding = ''; } } modalPrice.textContent = 'Cijena: $' + parseFloat(price).toFixed(2); payButton.textContent = 'Platiti $' + parseFloat(price).toFixed(2); payButton.disabled = false; payButton.style.opacity = '1'; } // Generate payment options based on config function generatePaymentOptions(optionsData, paymentType = 'balance', paymentItemId = '', config = {}) { const paymentOptionsContainer = document.getElementById('paymentOptions'); const paymentTypeInput = document.getElementById('paymentType'); const paymentItemIdInput = document.getElementById('paymentItemId'); const customPriceToggle = document.getElementById('customPriceToggle'); const manualPriceGroup = document.getElementById('manualPriceGroup'); // Set hidden fields paymentTypeInput.value = paymentType; paymentItemIdInput.value = paymentItemId; // Store config globally paymentConfig = { allowCustomAmount: config.allowCustomAmount || false, minAmount: config.minAmount || 1, maxAmount: config.maxAmount || 1000 }; // Clear container paymentOptionsContainer.innerHTML = ''; // Generate regular options if (optionsData && optionsData.length > 0) { optionsData.forEach((option, index) => { const optionElement = document.createElement('div'); optionElement.className = 'payment-option'; optionElement.innerHTML = ` <input type="radio" id="option${index}" name="paymentOption" value="${option.price}" data-label="${option.label}" ${option.default ? 'checked' : ''} onchange="updatePaymentPrice('${option.price}')"> <label for="option${index}">${option.label} - $${option.price}</label> `; paymentOptionsContainer.appendChild(optionElement); }); paymentOptionsContainer.style.display = 'block'; } else { paymentOptionsContainer.style.display = 'none'; } // Show/hide custom amount option based on config if (paymentConfig.allowCustomAmount) { customPriceToggle.style.display = 'block'; // Update manual price input constraints document.getElementById('manualPrice').min = paymentConfig.minAmount; document.getElementById('manualPrice').max = paymentConfig.maxAmount; document.getElementById('manualPrice').placeholder = 'Iz $${paymentConfig.minAmount} do $${paymentConfig.maxAmount}'; } else { customPriceToggle.style.display = 'none'; manualPriceGroup.style.display = 'none'; } // Select first option by default if none is marked as default if (optionsData && optionsData.length > 0) { const defaultOption = paymentOptionsContainer.querySelector('input[type="radio"][checked]') || paymentOptionsContainer.querySelector('input[type="radio"]'); if (defaultOption) { defaultOption.checked = true; defaultOption.closest('.payment-option').classList.add('selected'); updatePaymentPrice(defaultOption.value); } } else if (paymentConfig.allowCustomAmount) { // If no options but custom amount is allowed, show custom by default document.getElementById('customPriceRadio').checked = true; toggleCustomPriceSelection(true); } } // Also update the toggleCustomPriceSelection function: function toggleCustomPriceSelection(isSelected) { const manualPriceGroup = document.getElementById('manualPriceGroup'); const paymentOptions = document.getElementById('paymentOptions'); const customPriceRadio = document.getElementById('customPriceRadio'); if (isSelected) { manualPriceGroup.style.display = 'block'; // Deselect all regular options document.querySelectorAll('input[name="paymentOption"]').forEach(radio => { if (radio.id !== 'customPriceRadio') { radio.checked = false; const paymentOption = radio.closest('.payment-option'); if (paymentOption) { paymentOption.classList.remove('selected'); } } }); // Visual feedback for custom price selection const customPriceToggle = document.getElementById('customPriceToggle'); if (customPriceToggle) { customPriceToggle.style.backgroundColor = 'rgba(67, 97, 238, 0.1)'; customPriceToggle.style.borderLeft = '3px solid var(--primary)'; customPriceToggle.style.padding = '0.5rem'; customPriceToggle.style.borderRadius = 'var(--border-radius)'; customPriceToggle.style.transition = 'var(--transition)'; } // Focus on manual price input setTimeout(() => { const manualInput = document.getElementById('manualPrice'); manualInput.focus(); // Update price if there's already a value if (manualInput.value) { updateManualPrice(manualInput.value); } else { // Set default to min amount updateManualPrice(paymentConfig.minAmount); manualInput.value = paymentConfig.minAmount; } }, 100); } else { manualPriceGroup.style.display = 'none'; // Reset custom price toggle styling const customPriceToggle = document.getElementById('customPriceToggle'); if (customPriceToggle) { customPriceToggle.style.backgroundColor = ''; customPriceToggle.style.borderLeft = ''; customPriceToggle.style.padding = ''; } } } // Update price from manual input in real-time function updateManualPrice(price) { if (!price || price < paymentConfig.minAmount || price > paymentConfig.maxAmount) { const modalPrice = document.getElementById('modalPrice'); const payButton = document.getElementById('payButton'); if (price && (price < paymentConfig.minAmount || price > paymentConfig.maxAmount)) { modalPrice.textContent = 'Cijena: iz $${paymentConfig.minAmount} do $${paymentConfig.maxAmount}'; payButton.textContent = 'Nevažeći iznos'; payButton.disabled = true; payButton.style.opacity = '0.6'; } else { modalPrice.textContent = 'Cijena: $0.00'; payButton.textContent = 'Platiti $0.00'; payButton.disabled = true; payButton.style.opacity = '0.6'; } return; } const modalPrice = document.getElementById('modalPrice'); const payButton = document.getElementById('payButton'); modalPrice.textContent = 'Cijena: $' + parseFloat(price).toFixed(2); payButton.textContent = 'Platiti $' + parseFloat(price).toFixed(2); payButton.disabled = false; payButton.style.opacity = '1'; } const paymentModal = document.getElementById('paymentModal'); const paymentCloseBtn = paymentModal.querySelector('.close-btn'); // Elements inside modal const modalTitle = document.getElementById('modalTitle'); const modalText = document.getElementById('modalText'); const modalPrice = document.getElementById('modalPrice'); const payButton = document.getElementById('payButton'); const paymentForm = document.getElementById('paymentForm'); const paymentSuccess = document.getElementById('paymentSuccess'); // Updated modal opening handler document.querySelectorAll('[data-modal="paymentModal"]').forEach(trigger => { trigger.addEventListener('click', function(e) { e.preventDefault(); // Get data attributes const title = this.getAttribute('data-title'); const text = this.getAttribute('data-text'); const price = this.getAttribute('data-price'); const paymentType = this.getAttribute('data-payment-type') || 'balance'; const paymentItemId = this.getAttribute('data-payment-item-id') || ''; // Get payment config from data attributes const allowCustomAmount = this.getAttribute('data-allow-custom') === 'true'; const minAmount = parseFloat(this.getAttribute('data-min-amount')) || 1; const maxAmount = parseFloat(this.getAttribute('data-max-amount')) || 1000; // Get payment options from data attribute const optionsData = this.getAttribute('data-options'); let paymentOptions = []; if (optionsData) { try { paymentOptions = JSON.parse(optionsData); } catch (e) { console.error('Pogreška prilikom analize opcija plaćanja:', e); } } // Fill modal content document.getElementById('modalTitle').textContent = title; document.getElementById('modalText').textContent = text; // Generate payment options with config const config = { allowCustomAmount: allowCustomAmount, minAmount: minAmount, maxAmount: maxAmount }; generatePaymentOptions(paymentOptions, paymentType, paymentItemId, config); // If no options and custom amount not allowed, use default price if (paymentOptions.length === 0 && !allowCustomAmount) { updatePaymentPrice(price); } // Reset form resetForm('paymentModal'); document.getElementById('paymentForm').style.display = 'block'; document.getElementById('paymentSuccess').style.display = 'none'; // Show modal document.getElementById('paymentModal').style.display = 'flex'; }); }); // Helper function to reset form function resetPaymentForm() { document.getElementById('modalName').value = ''; document.getElementById('modalEmail').value = ''; document.getElementById('manualPrice').value = ''; if (document.getElementById('customPriceRadio')) { document.getElementById('customPriceRadio').checked = false; } clearErrors(['nameError', 'emailError', 'manualPriceError']); } // Close payment modal paymentCloseBtn.addEventListener('click', function() { paymentModal.style.display = 'none'; }); // Close on outside click window.addEventListener('click', function(e) { if (e.target === paymentModal) { paymentModal.style.display = 'none'; } }); // Fill tooltip with alt text automatically document.querySelectorAll('.popup-trigger').forEach(trigger => { const altText = trigger.getAttribute('alt'); const popupText = trigger.querySelector('.popup-text'); if (popupText && altText) { popupText.textContent = altText; } }); </script> <script> // Fill tooltip with alt text automatically document.querySelectorAll('.popup-trigger').forEach(trigger => { const altText = trigger.getAttribute('alt'); const popupText = trigger.querySelector('.popup-text'); if (popupText && altText) { popupText.textContent = altText; } }); // Auth Modal const authModal = document.getElementById('authModal'); const authCloseBtn = authModal.querySelector('.close-btn'); const loginBtn = document.getElementById('loginBtn'); const registerBtn = document.getElementById('registerBtn'); const authTabs = document.querySelectorAll('.auth-tab'); const authForms = document.querySelectorAll('.auth-form'); // Open auth modal loginBtn.addEventListener('click', function() { authModal.style.display = 'flex'; switchAuthTab('login'); resetForm('authModal'); }); registerBtn.addEventListener('click', function() { authModal.style.display = 'flex'; switchAuthTab('register'); resetForm('authModal'); }); // Close auth modal authCloseBtn.addEventListener('click', function() { authModal.style.display = 'none'; }); // Close on outside click window.addEventListener('click', function(e) { if (e.target === authModal) { authModal.style.display = 'none'; } }); // Switch auth tabs function switchAuthTab(tabName) { authTabs.forEach(tab => { if (tab.getAttribute('data-tab') === tabName) { tab.classList.add('active'); } else { tab.classList.remove('active'); } }); authForms.forEach(form => { if (form.id === tabName + 'Form') { form.classList.add('active'); } else { form.classList.remove('active'); } }); } // Add click events to auth tabs authTabs.forEach(tab => { tab.addEventListener('click', function() { const tabName = this.getAttribute('data-tab'); switchAuthTab(tabName); resetForm('authModal'); }); }); // Reset form and errors function resetForm(modalType) { if (modalType === 'paymentModal') { document.getElementById('modalName').value = ''; document.getElementById('modalEmail').value = ''; clearErrors(['nameError', 'emailError']); } else if (modalType === 'authModal') { document.getElementById('loginEmail').value = ''; document.getElementById('loginPassword').value = ''; document.getElementById('registerName').value = ''; document.getElementById('registerEmail').value = ''; if(document.getElementById('registerPassword'))document.getElementById('registerPassword').value = ''; if(document.getElementById('registerConfirmPassword'))document.getElementById('registerConfirmPassword').value = ''; clearErrors(['loginEmailError', 'loginPasswordError', 'registerNameError', 'registerEmailError', 'registerPasswordError', 'registerConfirmPasswordError']); } } // Clear error messages function clearErrors(errorIds) { errorIds.forEach(id => { const errorElement = document.getElementById(id); if (errorElement) { errorElement.textContent = ''; errorElement.classList.remove('show'); const inputElement = document.getElementById(id.replace('Error', '')); if (inputElement) { inputElement.classList.remove('error'); } } }); } // Show error message function showError(fieldId, message) { const errorElement = document.getElementById(fieldId + 'Error'); const inputElement = document.getElementById(fieldId); if (errorElement) { errorElement.textContent = message; errorElement.classList.add('show'); } if (inputElement) { inputElement.classList.add('error'); } } // Enhanced close modal function for general use function closeModal(modalId) { // Clear timers based on which modal is being closed switch(modalId) { case 'telegramVerifyModal': clearTelegramTimers(); break; case 'emailVerifyModal': clearEmailTimers(); break; case 'authModal': // Clear any potential timers in auth modal break; } document.getElementById(modalId).style.display = 'none'; } // Enhanced processPayment function function processPayment(event) { if (event) event.preventDefault(); const name = document.getElementById('modalName').value; const email = document.getElementById('modalEmail').value; const paymentType = document.getElementById('paymentType').value; const paymentItemId = document.getElementById('paymentItemId').value; // Get price - check if using custom amount or selected option let price; let optionLabel = ''; const customPriceRadio = document.getElementById('customPriceRadio'); if (customPriceRadio && customPriceRadio.checked) { // Custom amount price = document.getElementById('manualPrice').value; optionLabel = 'custom_amount'; // Validate custom amount if (!price || price < paymentConfig.minAmount || price > paymentConfig.maxAmount) { showError('manualPrice', 'Iznos mora biti između $${paymentConfig.minAmount} i $${paymentConfig.maxAmount}'); return false; } } else { // Regular option const selectedOption = document.querySelector('input[name="paymentOption"]:checked'); if (selectedOption) { price = selectedOption.value; optionLabel = selectedOption.getAttribute('data-label') || 'selected_option'; } else { // Fallback to default price price = document.getElementById('modalPrice').textContent.match(/\d+\.\d+/)?.[0] || '0'; optionLabel = 'default'; } } const service = document.getElementById('modalTitle').textContent; // Clear previous errors clearErrors(['nameError', 'emailError', 'manualPriceError']); // Validate form let hasErrors = false; if (!name) { showError('modalName', 'Molimo unesite svoje ime'); hasErrors = true; } if (!email) { showError('modalEmail', 'Molimo unesite svoju email adresu'); hasErrors = true; } else if (!/\S+@\S+\.\S+/.test(email)) { showError('modalEmail', 'Unesite važeću adresu e-pošte'); hasErrors = true; } if (hasErrors) return false; // Prepare data for API request const data = { type: 'payment', name: name, email: email, price: parseFloat(price).toFixed(2), service: service, payment_type: paymentType, payment_item_id: paymentItemId, option: optionLabel, is_custom_amount: (customPriceRadio && customPriceRadio.checked) ? 1 : 0 }; // Send request to API sendRequest('/ajax/', data, function(response) { if (response.status === 'ok') { if (response.redirect_url) { handlePaymentRedirect(response.redirect_url, response.redirect_type); } else { // Show success message document.getElementById('paymentForm').style.display = 'none'; document.getElementById('paymentSuccess').style.display = 'block'; } } else { // Show error message alert('Greška: ' + response.error); } }); return false; } // Handle payment redirect function handlePaymentRedirect(redirectUrl, redirectType) { switch (redirectType) { case 'new_window': window.open(redirectUrl, '_blank'); closeModal('paymentModal'); break; case 'iframe': document.getElementById('redirectIframe').src = redirectUrl; closeModal('paymentModal'); document.getElementById('redirectModal').style.display = 'flex'; break; case 'default': default: window.location.href = redirectUrl; break; } } // Process login function processLogin() { const email = document.getElementById('loginEmail').value; const password = document.getElementById('loginPassword').value; // Clear previous errors clearErrors(['loginEmail', 'loginPassword']); // Validate form let hasErrors = false; if (!email) { showError('loginEmail', 'Molimo unesite svoju e-poštu'); hasErrors = true; } else if (!/\S+@\S+\.\S+/.test(email)) { showError('loginEmail', 'Unesite valjanu e-poštu'); hasErrors = true; } if (!password) { showError('loginPassword', 'Molimo unesite svoju lozinku'); hasErrors = true; } if (hasErrors) return; // Prepare data for API request const data = { type: 'login', email: email, password: password }; // Send request to API sendRequest('/ajax/', data, function(response) { if (response.status === 'ok') { // Close modal and redirect or show success closeModal('authModal'); alert('Prijava uspješna!'); // Redirect to profile window.location.href = '/' + window.currentLang + '/profile/'; } else { // Show error message alert('Greška: ' + response.error); } }); } // Process registration function processRegistration() { const name = document.getElementById('registerName').value; const email = document.getElementById('registerEmail').value; const password = document.getElementById('registerPassword').value; const confirmPassword = document.getElementById('registerConfirmPassword').value; // Clear previous errors clearErrors(['registerName', 'registerEmail', 'registerPassword', 'registerConfirmPassword']); // Validate form let hasErrors = false; if (!name) { showError('registerName', 'Molimo unesite svoje ime'); hasErrors = true; } if (!email) { showError('registerEmail', 'Molimo unesite svoju e-poštu'); hasErrors = true; } else if (!/\S+@\S+\.\S+/.test(email)) { showError('registerEmail', 'Unesite valjanu e-poštu'); hasErrors = true; } if (!password) { showError('registerPassword', 'Molimo kreirajte lozinku'); hasErrors = true; } else if (password.length < 6) { showError('registerPassword', 'Lozinka mora imati najmanje 6 znakova'); hasErrors = true; } if (!confirmPassword) { showError('registerConfirmPassword', 'Molimo potvrdite svoju lozinku'); hasErrors = true; } else if (password !== confirmPassword) { showError('registerConfirmPassword', 'Lozinke se ne podudaraju'); hasErrors = true; } if (hasErrors) return; // Prepare data for API request const data = { type: 'registration', name: name, email: email, password: password }; // Send request to API sendRequest('/ajax/', data, function(response) { if (response.status === 'ok') { // Close modal and redirect or show success closeModal('authModal'); alert('Registracija uspjela!'); // Here you would typically redirect or update UI } else { // Show error message alert('Greška: ' + response.error); } }); } // Send AJAX request function sendRequest(url, data, callback,need_loading_overlay=true) { // Show loading overlay when request starts if(need_loading_overlay)showLoading(); //console.log("XMLHttpRequest started"); const xhr = new XMLHttpRequest(); xhr.open('POST', url, true); xhr.setRequestHeader('Content-Type', 'application/json'); xhr.onreadystatechange = function() { //console.log("XMLHttpRequest onready fired, readyState:", xhr.readyState); if (xhr.readyState === 4) { // Hide loading overlay when request completes if(need_loading_overlay)hideLoading(); //console.log("Request complete, status:", xhr.status); //console.log("responseText:", xhr.responseText); if (xhr.status === 200) { let is_good = true; let response; // Declare response variable outside try block try { response = JSON.parse(xhr.responseText); } catch (e) { is_good=false; console.error("JSON parse error:", e); callback({status: 'error', error: 'Neispravan odgovor poslužitelja'}); } if(is_good) callback(response); } else { callback({status: 'error', error: 'Greška poslužitelja: ' + xhr.status}); } } }; xhr.send(JSON.stringify(data)); } // Close redirect modal document.getElementById('redirectModal').querySelector('.close-btn').addEventListener('click', function() { document.getElementById('redirectModal').style.display = 'none'; }); // Mock chart data (in a real implementation, you would use Google Charts) function initCharts() { // This is a placeholder for actual chart implementation //console.log('Charts would be initialized here with Google Charts API'); } // Image modal functionality document.addEventListener('DOMContentLoaded', function() { // Image modal const imgModal = document.getElementById('imgModal'); const modalImg = document.getElementById('modalImg'); const imgCloseBtn = imgModal.querySelector('.close-btn'); // Open image modal document.querySelectorAll('[data-modal="imgModal"]').forEach(img => { img.addEventListener('click', function() { modalImg.src = this.src; imgModal.style.display = 'flex'; }); }); // Close image modal imgCloseBtn.addEventListener('click', function() { imgModal.style.display = 'none'; }); // Close on outside click window.addEventListener('click', function(e) { if (e.target === imgModal) { imgModal.style.display = 'none'; } }); }); </script> <script> //console.log("herei"); // Analysis functionality document.addEventListener('DOMContentLoaded', function() { //console.log("DOMContentLoaded"); const analyzeBtn = document.getElementById('analyzeNowBtn'); const analysisStatus = document.getElementById('analysisStatus'); if (analyzeBtn) { analyzeBtn.addEventListener('click', function() { //console.log("click"); // Show captcha modal showCaptchaModal(); }); } }); function showCaptchaModal() { //console.log("showCaptchaModal"); // Create modal for captcha const modal = document.createElement('div'); modal.className = 'modal'; modal.id = 'captchaModal'; modal.style.display = 'flex'; modal.innerHTML = ` <div class="modal-content"> <span class="close-btn" onclick="closeCaptchaModal()">×</span> <h2 class="modal-title">Potvrdite da niste robot</h2> <p class="modal-text">Unesite tekst sa slike:</p> <div class="captcha-container"> <img src="/captcha.php?t=` + new Date().getTime() + `" alt="CAPTCHA" class="captcha-image" id="captchaImage"> <button type="button" class="refresh-captcha" onclick="refreshCaptcha()">Osvježi kôd</button> <input type="text" class="captcha-input" id="captchaInput" placeholder="Unesite kod" maxlength="6"> </div> <button class="cta-button" onclick="submitAnalysis()" style="margin-top: 1rem;">Pošaljite na analizu</button> </div> `; document.body.appendChild(modal); } function closeCaptchaModal() { const modal = document.getElementById('captchaModal'); if (modal) { modal.remove(); } } function refreshCaptcha() { const captchaImage = document.getElementById('captchaImage'); if (captchaImage) { // Add timestamp to prevent caching captchaImage.src = '/captcha.php?t=' + new Date().getTime(); } } function submitAnalysis() { const captchaInput = document.getElementById('captchaInput'); const captchaCode = captchaInput ? captchaInput.value.trim() : ''; const analysisStatus = document.getElementById('analysisStatus'); if (!captchaCode) { alert('Molimo unesite kod sa slike'); return; } // Show loading state analysisStatus.textContent = 'Slanje zahtjeva...'; analysisStatus.className = 'analysis-status'; analysisStatus.style.display = 'block'; // Prepare data for API request type = "none"; if(document.getElementById('domain_name')){ type = "domain_analysis"; sendData = document.getElementById('domain_name').value; } if(document.getElementById('phrase')){ type = "phrase_analysis"; sendData = document.getElementById('phrase').value; } if(type=="none"){ // Show error message closeCaptchaModal(); analysisStatus.textContent = 'Greška: tip je nijedan'; analysisStatus.className = 'analysis-status error'; analysisStatus.style.display = 'block'; return false; } const data = { type: type, data: sendData, captcha_code: captchaCode }; // Send request to API sendRequest('/ajax/', data, function(response) { // Close captcha modal closeCaptchaModal(); if (response.status === 'ok') { // Show success message analysisStatus.textContent = 'Vaš zahtjev je poslan, pričekajte potvrdu domene'; analysisStatus.className = 'analysis-status success'; } else { // Show error message analysisStatus.textContent = 'Greška: ' + response.error; analysisStatus.className = 'analysis-status error'; // Refresh captcha on error if (response.refresh_captcha) { setTimeout(refreshCaptcha, 500); } } analysisStatus.style.display = 'block'; // Clear captcha input if (captchaInput) { captchaInput.value = ''; } }); } </script> <script> // Full screenshot functionality function openFullScreenshot(src) { const modal = document.getElementById('fullScreenshotModal'); const img = document.getElementById('fullScreenshotImg'); img.src = src; modal.style.display = 'flex'; // Prevent body scroll when modal is open document.body.style.overflow = 'hidden'; } function closeFullScreenshot() { const modal = document.getElementById('fullScreenshotModal'); modal.style.display = 'none'; // Restore body scroll document.body.style.overflow = 'auto'; } function downloadScreenshot() { const img = document.getElementById('fullScreenshotImg'); const link = document.createElement('a'); link.download = `screenshot-${document.getElementById('domain_name').value}-${new Date().getTime()}.jpg`; link.href = img.src; link.click(); } // Close modal on outside click document.addEventListener('click', function(e) { const modal = document.getElementById('fullScreenshotModal'); if (e.target === modal) { closeFullScreenshot(); } }); // Close modal on Escape key document.addEventListener('keydown', function(e) { if (e.key === 'Escape') { closeFullScreenshot(); } }); </script> <script> // Global variables to track intervals let telegramStatusInterval = null; let telegramTimerInterval = null; let resendTimerInterval = null; let emailCheckInterval = null; // Global variable to store QR code instance let qrcodeInstance = null; function startTelegramRegistration(name=false,email=false) { if(!name)name = document.getElementById('registerName').value.trim(); if(!email)email = document.getElementById('registerEmail').value.trim(); // Clear previous errors clearErrors(['registerName', 'registerEmail']); // Validate form let hasErrors = false; if (!name) { showError('registerName', 'Molimo unesite svoje ime'); hasErrors = true; } if (!email) { showError('registerEmail', 'Molimo unesite svoju e-poštu'); hasErrors = true; } else if (!/\S+@\S+\.\S+/.test(email)) { showError('registerEmail', 'Unesite važeću adresu e-pošte'); hasErrors = true; } if (hasErrors) return; // Prepare data for API request const data = { type: 'telegram_registration_start', name: name, email: email }; //console.log("telegram_registration_start request"); // Send request to API sendRequest('/ajax/', data, function(response) { //console.log("telegram_registration_start callback"); if (response.status === 'ok') { // Store user token localStorage.setItem('current_user_token', response.user_token); // Immediately open Telegram bot in new tab if (response.deep_link) { window.open(response.deep_link, '_blank'); } // Show Telegram verification modal with deep link and QR code showTelegramVerifyModal(response.bot_username, response.telegram_token, response.deep_link,response.telegram_token_expires_remaining); // Clear form clearRegistrationForm(); // Close auth modal closeModal('authModal'); //YM reach goal send ym(109200701,'reachGoal','registration_start'); } else if (response.status === 'continue_email_verification') { //!! // User exists, Telegram verified, but email not verified localStorage.setItem('current_user_token', response.user_token); // Auto-resend email and show verification modal autoResendEmailAndShowModal(response.user_token); // Clear form clearRegistrationForm(); // Close auth modal closeModal('authModal'); } else { alert('Greška1: ' + response.error); } }); } // Auto-resend email and show verification modal function autoResendEmailAndShowModal(userToken) { // First, try to resend the email const data = { type: 'resend_email_verification', user_token: userToken }; sendRequest('/ajax/', data, function(response) { if (response.status === 'ok') { // Email sent successfully, show verification modal with full timer //showEmailVerifyModal(); safeShowEmailVerifyModal(); } else { // Handle resend error - use cooldown_remaining from response if (response.cooldown_remaining !== undefined) { // Use the exact remaining seconds from the response const remainingSeconds = Math.max(1, Math.floor(response.cooldown_remaining)); // Show verification modal with synchronized timer showEmailVerifyModalWithCooldown(remainingSeconds); } else { // Other error - show modal with default timer //showEmailVerifyModal(); safeShowEmailVerifyModal(); alert('Greška: ' + response.error); } } }); } // Enhanced resend email verification function function resendEmailVerification() { const userToken = localStorage.getItem('current_user_token'); const resendBtn = document.getElementById('resendEmailBtn'); if (!resendBtn) { alert('Greška: Gumb nije pronađen. Molimo osvježite stranicu.'); return; } // Prevent multiple clicks if (resendBtn.disabled) { return; } // Immediately disable button and show loading state resendBtn.disabled = true; resendBtn.style.opacity = '0.7'; resendBtn.innerHTML = 'Slanje...'; const data = { type: 'resend_email_verification', user_token: userToken }; sendRequest('/ajax/', data, function(response) { if (response.status === 'ok') { // Success - restart timer AND restart email check interval setupResendButtonForTimer(); startResendTimer(300); // CRITICAL FIX: Restart the email check interval restartEmailCheckInterval(); // Update status message const statusElement = document.getElementById('emailCheckStatus'); if (statusElement) { statusElement.innerHTML = '<p style="color: var(--primary);">🔍 Novi kod poslan. Provjera potvrde...</p>'; statusElement.className = 'email-check-status status-checking'; statusElement.style.display = 'block'; } alert('Novi kontrolni kod poslan je na vašu e-poštu'); } else { // Handle different error cases if (response.cooldown_remaining !== undefined) { const remainingSeconds = Math.max(1, Math.floor(response.cooldown_remaining)); setupResendButtonForTimer(); startResendTimer(remainingSeconds); // CRITICAL FIX: Even on cooldown, restart the email check interval restartEmailCheckInterval(); const remainingMinutes = Math.ceil(remainingSeconds / 60); // Update status message const statusElement = document.getElementById('emailCheckStatus'); if (statusElement) { statusElement.innerHTML = `<p style="color: #856404;">⏰ Novi kod se može ponovno poslati ${remainingMinutes} minuta. Provjera prethodne potvrde koda...</p>`; statusElement.style.display = 'block'; } alert('Novi kod se može ponovno poslati ' + remainingMinutes + ' minuta.'); } else { alert('Greška: ' + response.error); // Re-enable button on other errors resendBtn.disabled = false; resendBtn.style.opacity = '1'; resendBtn.innerHTML = 'Ponovno pošalji kod'; } } }); } function restartEmailCheckInterval() { const userToken = localStorage.getItem('current_user_token'); let attempts = 0; const maxAttempts = 30; // Clear existing interval if any if (emailCheckInterval) { clearInterval(emailCheckInterval); emailCheckInterval = null; } // Update status to show checking updateEmailCheckStatus('checking', 'Provjera statusa provjere...'); // Start new interval emailCheckInterval = setInterval(function() { if (attempts >= maxAttempts) { if (emailCheckInterval) { clearInterval(emailCheckInterval); emailCheckInterval = null; } updateEmailCheckStatus('timeout', 'Provjerite timeout. Molimo osvježite stranicu.'); return; } checkEmailVerificationStatus(userToken); attempts++; }, 10000); } // Setup resend button for timer display function setupResendButtonForTimer() { const resendBtn = document.getElementById('resendEmailBtn'); if (!resendBtn) return; resendBtn.disabled = true; resendBtn.style.opacity = '0.7'; // Ensure timer element exists let timerElement = document.getElementById('resendTimer'); if (!timerElement) { timerElement = document.createElement('span'); timerElement.id = 'resendTimer'; resendBtn.appendChild(timerElement); } // Set initial timer display resendBtn.innerHTML = 'Ponovno pošalji kod (<span id="resendTimer">5:00</span>)'; } function showEmailVerifyModalWithCooldown(remainingSeconds) { // Clear previous input const emailVerifyToken = document.getElementById('emailVerifyToken'); if (emailVerifyToken) { emailVerifyToken.value = ''; } clearErrors(['emailVerifyToken']); // Setup button for timer setupResendButtonForTimer(); // Start timer with remaining time startResendTimer(remainingSeconds); // Start email check interval startEmailCheckInterval(); // Show modal document.getElementById('emailVerifyModal').style.display = 'flex'; // Show info message const statusElement = document.getElementById('emailCheckStatus'); if (statusElement) { const remainingMinutes = Math.ceil(remainingSeconds / 60); statusElement.innerHTML = `<p style="color: #856404;">⏰ Novi kod se može ponovno poslati ${remainingMinutes} minuta</p>`; statusElement.className = 'email-check-status status-checking'; statusElement.style.display = 'block'; } } // Safe function to show email verification modal function safeShowEmailVerifyModal() { // Clear previous input const emailVerifyToken = document.getElementById('emailVerifyToken'); if (emailVerifyToken) { emailVerifyToken.value = ''; } clearErrors(['emailVerifyToken']); // Setup button for timer setupResendButtonForTimer(); // Start fresh timer startResendTimer(300); // Start email check interval startEmailCheckInterval(); // Show modal document.getElementById('emailVerifyModal').style.display = 'flex'; } // Safe function to clear registration form function clearRegistrationForm() { const nameField = document.getElementById('registerName'); const emailField = document.getElementById('registerEmail'); if (nameField) nameField.value = ''; if (emailField) emailField.value = ''; // Only clear password fields if they exist (for traditional registration) const passwordField = document.getElementById('registerPassword'); const confirmPasswordField = document.getElementById('registerConfirmPassword'); if (passwordField) passwordField.value = ''; if (confirmPasswordField) confirmPasswordField.value = ''; // Clear any status messages const statusElement = document.getElementById('registrationStatus'); if (statusElement) { statusElement.innerHTML = ''; statusElement.style.display = 'none'; } } // Enhanced showTelegramVerifyModal function function showTelegramVerifyModal(botUsername, telegramToken, deepLink,telegram_token_expires_remaining) { // Set Telegram bot deep link const telegramUrl = deepLink || `https://t.me/${botUsername}?start=${telegramToken}`; window.telegramBotUrl = telegramUrl; // Generate QR code generateQRCode(telegramUrl); // Update the "Open Telegram" button const openTelegramBtn = document.getElementById('openTelegramBtn'); if (openTelegramBtn) { openTelegramBtn.onclick = function() { window.open(telegramUrl, '_blank'); }; } // Update modal text const modalText = document.getElementById('telegramModalText'); if (modalText) { modalText.innerHTML = ` Telegram je otvoren u novoj kartici.<br> Ako se bot nije otvorio automatski, upotrijebite gumb ispod ili skenirajte QR kod. `; } // Start timer //console.log("start timer:"+telegram_token_expires_remaining); startTelegramTimer(telegram_token_expires_remaining); // Start status checking startTelegramStatusCheck(); // Show modal document.getElementById('telegramVerifyModal').style.display = 'flex'; } // Generate QR code using qrcodejs library function generateQRCode(url) { const qrcodeElement = document.getElementById('qrcode'); // Clear previous QR code if exists if (qrcodeInstance) { qrcodeInstance.clear(); qrcodeElement.innerHTML = ''; } try { // Create new QR code instance qrcodeInstance = new QRCode(qrcodeElement, { text: url, width: 200, height: 200, colorDark: "#000000", colorLight: "#ffffff", correctLevel: QRCode.CorrectLevel.H }); //console.log('QR code generated successfully'); } catch (error) { console.error('Generiranje QR koda nije uspjelo:', error); // Fallback: show message to use the button instead qrcodeElement.innerHTML = ` <div style="color: var(--warning); font-size: 0.9rem; padding: 1rem;"> <p>QR kod nije dostupan. Koristite gumb Otvori Telegram.</p> </div> `; } } // Refresh QR code function refreshTelegramQR() { if (window.telegramBotUrl) { const refreshBtn = document.getElementById('refreshQRBtn'); const originalText = refreshBtn.innerHTML; refreshBtn.innerHTML = '🔄 Osvježavajući...'; refreshBtn.disabled = true; // Regenerate QR code generateQRCode(window.telegramBotUrl); setTimeout(() => { refreshBtn.innerHTML = originalText; refreshBtn.disabled = false; }, 500); } } // Open Telegram bot in new tab function openTelegramBot() { if (window.telegramBotUrl) { window.open(window.telegramBotUrl, '_blank'); } } function startTelegramStatusCheck() { const userToken = localStorage.getItem('current_user_token'); // Clear existing interval if any if (telegramStatusInterval) { clearInterval(telegramStatusInterval); } // Check status every 5 seconds telegramStatusInterval = setInterval(function() { checkTelegramVerificationStatus(userToken); }, 5000); } // Update the checkTelegramVerificationStatus to clear timers on success function checkTelegramVerificationStatus(userToken) { const data = { type: 'check_telegram_verification', user_token: userToken }; sendRequest('/ajax/', data, function(response) { if (response.status === 'ok') { if (response.telegram_verified) { // Telegram verified successfully clearTelegramTimers(); // Show success message const timerContainer = document.getElementById('telegramTimer'); timerContainer.innerHTML = '✅ Telegram je uspješno potvrđen!'; timerContainer.className = 'timer-container'; timerContainer.style.background = '#d4edda'; timerContainer.style.color = '#155724'; //YM reach goal send ym(109200701,'reachGoal','registration_tg_success'); // Auto-proceed to email verification after 2 seconds setTimeout(function() { closeTelegramVerifyModal(); safeShowEmailVerifyModal(); }, 2000); } } },false); } // Enhanced timer functions that store interval IDs function startTelegramTimer(duration) { let timerContainer = document.getElementById('telegramTimer'); let timerElement = document.getElementById('timer'); // Check if timer was expired and reset if needed if (timerContainer && timerContainer.classList.contains('timer-expired')) { //console.log('Timer has expired - resetting UI'); timerContainer.classList.remove('timer-expired'); timerContainer.innerHTML = 'Čeka se potvrda... <span id="timer">05:00</span>'; // Update timerElement reference after resetting HTML timerElement = document.getElementById('timer'); } let timer = duration; // Clear existing timer if any if (telegramTimerInterval) { clearInterval(telegramTimerInterval); } telegramTimerInterval = setInterval(function() { const minutes = parseInt(timer / 60, 10); const seconds = parseInt(timer % 60, 10); if (timerElement) { timerElement.textContent = minutes + ":" + (seconds < 10 ? "0" + seconds : seconds); } if (--timer < 0) { clearTelegramTimers(); if (timerElement) { timerElement.textContent = "00:00"; } if (timerContainer) { timerContainer.classList.add('timer-expired'); timerContainer.innerHTML = 'Vrijeme je isteklo. Molim te počni ispočetka.'; } // Auto-close after 3 seconds setTimeout(function() { closeTelegramVerifyModal(); }, 3000); } }, 1000); } // Enhanced close function to clean up QR code function closeTelegramVerifyModal() { // Clear QR code instance if (qrcodeInstance) { qrcodeInstance.clear(); qrcodeInstance = null; } // Clear container const qrcodeElement = document.getElementById('qrcode'); if (qrcodeElement) { qrcodeElement.innerHTML = ''; } // Clear timers clearTelegramTimers(); // Hide modal document.getElementById('telegramVerifyModal').style.display = 'none'; } // Verify Telegram code function verifyTelegramCode() { const code = document.getElementById('telegramVerifyCode').value.trim(); const userToken = localStorage.getItem('current_user_token'); // Clear previous errors clearErrors(['telegramVerifyCode']); if (!code) { showError('telegramVerifyCode', 'Molimo unesite kod za provjeru'); return; } if (code.length !== 7) { showError('telegramVerifyCode', 'Šifra mora sadržavati 7 znamenki'); return; } // Prepare data for API request const data = { type: 'verify_telegram_code', user_token: userToken, verify_code: code }; // Send request to API sendRequest('/ajax/', data, function(response) { if (response.status === 'ok') { // Stop timer clearInterval(telegramTimer); // Close Telegram modal closeTelegramVerifyModal(); // Show email verification modal //showEmailVerifyModal(); safeShowEmailVerifyModal(); } else { showError('telegramVerifyCode', response.error); } }); } // Update the modal opening calls function showEmailVerifyModal() { safeShowEmailVerifyModal(); } // Enhanced start resend timer function function startResendTimer(duration) { let timer = duration; // Clear existing timer if any if (resendTimerInterval) { clearInterval(resendTimerInterval); } // Update timer display immediately updateResendTimerDisplay(timer); resendTimerInterval = setInterval(function() { timer--; updateResendTimerDisplay(timer); if (timer <= 0) { if (resendTimerInterval) { clearInterval(resendTimerInterval); resendTimerInterval = null; } enableResendButton(); } }, 1000); } // Safe function to update timer display function updateResendTimerDisplay(timer) { const timerElement = document.getElementById('resendTimer'); const resendBtn = document.getElementById('resendEmailBtn'); if (!timerElement || !resendBtn) { console.warn('Elementi mjerača vremena nisu pronađeni tijekom ažuriranja'); return; } const minutes = Math.floor(timer / 60); const seconds = timer % 60; const timeString = minutes + ":" + (seconds < 10 ? "0" + seconds : seconds); timerElement.textContent = timeString; // Update button text while preserving the timer element resendBtn.innerHTML = 'Ponovno pošalji kod (<span id="resendTimer">' + timeString + '</span>)'; } // Helper function to update timer display function updateTimerDisplay(timerElement, timer) { if (!timerElement) return; const minutes = Math.floor(timer / 60); const seconds = timer % 60; timerElement.textContent = minutes + ":" + (seconds < 10 ? "0" + seconds : seconds); } // Enable resend button when timer expires function enableResendButton() { const resendBtn = document.getElementById('resendEmailBtn'); if (!resendBtn) { console.error('Gumb za ponovno slanje nije pronađen'); return; } resendBtn.disabled = false; resendBtn.style.opacity = '1'; // Set final state without timer resendBtn.innerHTML = 'Ponovno pošalji kod'; // Re-create the timer element for future use const timerSpan = document.createElement('span'); timerSpan.id = 'resendTimer'; timerSpan.style.display = 'none'; // Hide when not active resendBtn.appendChild(timerSpan); } // Enhanced email check interval function startEmailCheckInterval() { restartEmailCheckInterval(); // Just call the new function } // Update the checkEmailVerificationStatus to clear interval on success function checkEmailVerificationStatus(userToken) { const data = { type: 'check_email_verification', user_token: userToken }; sendRequest('/ajax/', data, function(response) { const statusElement = document.getElementById('emailCheckStatus'); if (response.status === 'ok') { if (response.email_verified) { // Email verified successfully if (emailCheckInterval) { clearInterval(emailCheckInterval); emailCheckInterval = null; } if (statusElement) { statusElement.innerHTML = '<p style="color: #155724;">✅ Email je uspješno potvrđen!</p>'; statusElement.className = 'email-check-status status-success'; } //YM reach goal send ym(109200701,'reachGoal','registration_email_success'); // Auto-redirect after 2 seconds setTimeout(function() { completeRegistration(); }, 2000); } else { if (statusElement) { statusElement.style.display = 'block'; statusElement.innerHTML = '<p style="color: var(--primary);">🔍 Provjera statusa provjere...</p>'; statusElement.className = 'email-check-status status-checking'; } } } else { // Handle error response if (statusElement) { statusElement.innerHTML = `<p style="color: #721c24;">❌ Pogreška provjere provjere: ${response.error}</p>`; statusElement.className = 'email-check-status status-error'; } } },false); } // Verify email token manually function verifyEmailToken() { const token = document.getElementById('emailVerifyToken').value.trim(); const userToken = localStorage.getItem('current_user_token'); // Clear previous errors clearErrors(['emailVerifyToken']); if (!token) { showError('emailVerifyToken', 'Molimo unesite kod za provjeru'); return; } const data = { type: 'verify_email_token', user_token: userToken, email_token: token }; sendRequest('/ajax/', data, function(response) { if (response.status === 'ok') { completeRegistration(); } else { showError('emailVerifyToken', response.error); } }); } // Complete registration and login function completeRegistration() { const userToken = localStorage.getItem('current_user_token'); const data = { type: 'complete_registration', user_token: userToken }; sendRequest('/ajax/', data, function(response) { if (response.status === 'ok') { // Store user info localStorage.setItem('user_info', JSON.stringify(response.user)); // Close modal closeEmailVerifyModal(); //YM send reachGoal ym(109200701,'reachGoal','registration_complete'); // Redirect to profile window.location.href = '/' + window.currentLang + '/profile/'; } else { alert('Greška: ' + response.error); } }); } function closeEmailVerifyModal() { // Clear all email-related intervals if (resendTimerInterval) { clearInterval(resendTimerInterval); resendTimerInterval = null; } if (emailCheckInterval) { clearInterval(emailCheckInterval); emailCheckInterval = null; } document.getElementById('emailVerifyModal').style.display = 'none'; } // Add this to check registration status when email is entered document.getElementById('registerEmail').addEventListener('blur', function() { const email = this.value.trim(); if(statusElement = document.getElementById('registrationStatus')){ statusElement.innerHTML = ''; } if (email && /\S+@\S+\.\S+/.test(email)) { checkRegistrationStatus(email); } }); function checkRegistrationStatus(email) { const data = { type: 'check_registration_status', email: email }; sendRequest('/ajax/', data, function(response) { if (response.status === 'ok') { const status = response.registration_status; let statusElement = document.getElementById('registrationStatus'); // Remove 'const' declaration if (!statusElement) { // Create status element if it doesn't exist statusElement = document.createElement('div'); // Now we're assigning to the existing variable statusElement.id = 'registrationStatus'; statusElement.style.marginTop = '1rem'; statusElement.style.padding = '0.75rem'; statusElement.style.borderRadius = 'var(--border-radius)'; statusElement.style.fontSize = '0.9rem'; const registerForm = document.getElementById('registerForm'); const submitButton = registerForm.querySelector('button[onclick="startTelegramRegistration()"]'); registerForm.insertBefore(statusElement, submitButton.nextSibling); } // Remove the duplicate declaration of statusElement here // const statusElement = document.getElementById('registrationStatus'); // ← This line is removed switch(status) { case 'completed': statusElement.innerHTML = '✅ Ovaj email je već registriran. <a href="#" onclick="switchAuthTab(\'login\')">Prijava</a>'; statusElement.style.background = '#d4edda'; statusElement.style.color = '#155724'; break; case 'email_pending': statusElement.innerHTML = '📧 Registracija skoro gotova! Potrebna je potvrda e-pošte.'; statusElement.style.background = '#fff3cd'; statusElement.style.color = '#856404'; break; case 'telegram_pending': statusElement.innerHTML = '📱 Nastavite s registracijom u Telegramu.'; statusElement.style.background = '#cce5ff'; statusElement.style.color = '#004085'; break; case 'incomplete': statusElement.innerHTML = '🔄 Nastavi registraciju.'; statusElement.style.background = '#e2e3e5'; statusElement.style.color = '#383d41'; break; default: statusElement.innerHTML = ''; } } },false); } // Enhanced email check status function function updateEmailCheckStatus(type, message) { const statusElement = document.getElementById('emailCheckStatus'); if (!statusElement) return; statusElement.style.display = 'block'; switch(type) { case 'checking': statusElement.innerHTML = '<p style="color: var(--primary);">🔍 Provjera statusa provjere...</p>'; statusElement.className = 'email-check-status status-checking'; break; case 'success': statusElement.innerHTML = '<p style="color: #155724;">✅ ' + message + '</p>'; statusElement.className = 'email-check-status status-success'; break; case 'error': statusElement.innerHTML = '<p style="color: #721c24;">❌ ' + message + '</p>'; statusElement.className = 'email-check-status status-error'; break; case 'timeout': statusElement.innerHTML = '<p style="color: #856404;">⏰ ' + message + '</p>'; statusElement.className = 'email-check-status status-error'; break; } } // Helper function to clear all Telegram timers function clearTelegramTimers() { if (telegramTimerInterval) { clearInterval(telegramTimerInterval); telegramTimerInterval = null; } if (telegramStatusInterval) { clearInterval(telegramStatusInterval); telegramStatusInterval = null; } } // Helper function to clear all email timers function clearEmailTimers() { if (resendTimerInterval) { clearInterval(resendTimerInterval); resendTimerInterval = null; } if (emailCheckInterval) { clearInterval(emailCheckInterval); emailCheckInterval = null; } } </script> <script> // Login with Telegram function function loginWithTelegram() { const email = document.getElementById('loginEmail').value.trim(); // Clear previous errors clearErrors(['loginEmail']); // Validate email if (!email) { showError('loginEmail', 'Molimo unesite svoju e-poštu'); return; } else if (!/\S+@\S+\.\S+/.test(email)) { showError('loginEmail', 'Unesite važeću adresu e-pošte'); return; } // Check if user exists and is verified checkUserForTelegramLogin(email); } // Check if user exists and is verified for Telegram login function checkUserForTelegramLogin(email) { const data = { type: 'check_user_for_telegram_login', email: email }; sendRequest('/ajax/', data, function(response) { if (response.status === 'ok') { if(response.user_exists && response.telegram_verified && response.email_verified){ // User exists and Telegram verified and email verifed- generate login link generateTelegramLoginLink(email); }else if (response.user_exists && response.telegram_verified) { // User exists and Telegram verified //alert('Для входа через Telegram необходимо сначала завершить регистрацию подтвердите email'); startTelegramRegistration("noneedname",email); } else if (response.user_exists && !response.telegram_verified) { // User exists but Telegram not verified //alert('Для входа через Telegram необходимо сначала завершить регистрацию в Telegram'); startTelegramRegistration("noneedname",email); } else { // User doesn't exist alert('Korisnik s ovom e-poštom nije pronađen. Molimo registrirajte se.'); } } else { alert('Greška: ' + response.error); } }); } // Generate Telegram login code function generateTelegramLoginLink(email) { const data = { type: 'generate_telegram_login_link', email: email }; sendRequest('/ajax/', data, function(response) { if (response.status === 'ok') { // Store user token localStorage.setItem('current_user_token', response.user_token); // Show Telegram verification modal for login showTelegramLoginModal(response.bot_username, response.deep_link, response.telegram_token_expires_remaining); // Close auth modal closeModal('authModal'); } else { alert('Greška: ' + response.error); } }); } // Show Telegram login modal function showTelegramLoginModal(botUsername, deepLink, expiresRemaining) { // Set Telegram bot deep link const telegramUrl = deepLink || `https://t.me/${botUsername}?start=login_${Date.now()}`; window.telegramBotUrl = telegramUrl; //open forced window.open(telegramUrl, '_blank'); // Generate QR code generateQRCode(telegramUrl); // Update modal text for login const modalText = document.getElementById('telegramModalText'); if (modalText) { modalText.innerHTML = ` Telegram otvoren za prijavu.<br> Ako se bot nije otvorio automatski, upotrijebite gumb ispod ili skenirajte QR kod. `; } // Update modal title const modalTitle = document.querySelector('#telegramVerifyModal .modal-title'); if (modalTitle) { modalTitle.textContent = 'Prijavite se putem Telegrama'; } // Start timer startTelegramTimer(expiresRemaining || 300); // Start status checking for login startTelegramLoginStatusCheck(); // Show modal document.getElementById('telegramVerifyModal').style.display = 'flex'; } // Start Telegram login status check function startTelegramLoginStatusCheck() { const userToken = localStorage.getItem('current_user_token'); // Clear existing interval if any if (telegramStatusInterval) { clearInterval(telegramStatusInterval); } // Check status every 5 seconds telegramStatusInterval = setInterval(function() { checkTelegramLoginStatus(userToken); }, 5000); } // Check Telegram login status function checkTelegramLoginStatus(userToken) { const data = { type: 'check_telegram_login_status', user_token: userToken }; sendRequest('/ajax/', data, function(response) { if (response.status === 'ok') { if (response.login_code_sended ) { // Login code received - show code input modal clearTelegramTimers(); showTelegramCodeInputModal(response.verify_code); } else if (response.login_completed) { // Login completed successfully clearTelegramTimers(); completeTelegramLogin(); } } }); } // Show Telegram code input modal function showTelegramCodeInputModal(verifyCode) { // Close Telegram verify modal closeTelegramVerifyModal(); // Create or show code input modal let codeModal = document.getElementById('telegramCodeModal'); // Start code timer startLoginCodeTimer(300); // Show modal codeModal.style.display = 'flex'; } // Start login code timer function startLoginCodeTimer(duration) { let timer = duration; const timerElement = document.getElementById('loginTimer'); if (!timerElement) return; // Clear existing timer if any if (window.loginCodeTimer) { clearInterval(window.loginCodeTimer); } window.loginCodeTimer = setInterval(function() { const minutes = parseInt(timer / 60, 10); const seconds = parseInt(timer % 60, 10); timerElement.textContent = minutes + ":" + (seconds < 10 ? "0" + seconds : seconds); if (--timer < 0) { clearInterval(window.loginCodeTimer); timerElement.textContent = "00:00"; // Show expired message const timerContainer = document.getElementById('loginCodeTimer'); if (timerContainer) { timerContainer.classList.add('timer-expired'); timerContainer.innerHTML = 'Kod je istekao. Molim te počni ispočetka.'; } } }, 1000); } // Verify Telegram login code function verifyTelegramLoginCode() { const userToken = localStorage.getItem('current_user_token'); const codeInput = document.getElementById('telegramLoginCode'); const code = codeInput ? codeInput.value.trim() : ''; // Clear previous errors clearErrors(['telegramLoginCode']); if (!code) { showError('telegramLoginCode', 'Molimo unesite kod za provjeru'); return; } if (code.length !== 7) { showError('telegramLoginCode', 'Šifra mora sadržavati 7 znamenki'); return; } const data = { type: 'verify_telegram_login_code', user_token: userToken, verify_code: code }; sendRequest('/ajax/', data, function(response) { if (response.status === 'ok') { // Clear timer if (window.loginCodeTimer) { clearInterval(window.loginCodeTimer); } localStorage.setItem('user_info', JSON.stringify(response.user)); // Close any open modals closeModal('telegramCodeModal'); closeModal('telegramVerifyModal'); // Show success message and redirect alert('Prijava uspješna!'); window.location.href = '/' + window.currentLang + '/profile/'; } else { showError('telegramLoginCode', response.error); } }); } </script> <!-- Add this JavaScript before closing body tag --> <script> // Animation on scroll document.addEventListener('DOMContentLoaded', function() { const fadeElements = document.querySelectorAll('.fade-in'); const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.classList.add('visible'); } }); }, { threshold: 0.1 }); fadeElements.forEach(element => { observer.observe(element); }); // Add click handlers for project CTAs document.querySelectorAll('.project-cta').forEach(button => { button.addEventListener('click', function() { const projectTitle = this.closest('.project-card').querySelector('.project-title').textContent; // alert(`Exploring: ${projectTitle}`); // In production, this would navigate to the appropriate page }); }); }); </script> <script> // Cookie consent management (function() { // Configuration const COOKIE_CONSENT_KEY = 'serpuls_cookie_consent'; const COOKIE_EXPIRY_DAYS = 365; // Create cookie consent banner if not already accepted function initCookieConsent() { // Check if user has already made a choice const consent = getCookieConsent(); if (consent !== null) { // User already made a choice, apply preferences applyCookiePreferences(consent); return; } // Create banner createCookieBanner(); } // Create the cookie banner HTML function createCookieBanner() { const banner = document.createElement('div'); banner.id = 'cookie-consent-banner'; banner.style.cssText = ` position: fixed; bottom: 0; left: 0; right: 0; background: white; box-shadow: 0 -4px 20px rgba(0,0,0,0.15); padding: 1.5rem; z-index: 9999; border-top: 3px solid var(--primary, #4361ee); animation: slideUp 0.5s ease; `; // Add animation style if not exists if (!document.getElementById('cookie-animation-style')) { const style = document.createElement('style'); style.id = 'cookie-animation-style'; style.textContent = ` @keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } } `; document.head.appendChild(style); } banner.innerHTML = ` <div style="max-width: 1200px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 2rem; align-items: center; justify-content: space-between;"> <div style="flex: 2; min-width: 280px;"> <h3 style="margin: 0 0 0.5rem 0; color: var(--dark, #212529); font-size: 1.25rem;">🍪 Suglasnost za kolačiće</h3> <p style="margin: 0; color: var(--gray, #6c757d); line-height: 1.5;"> Koristimo kolačiće za poboljšanje vašeg iskustva pregledavanja, posluživanje personaliziranog sadržaja i analizu našeg prometa. Klikom na Prihvati sve pristajete na našu upotrebu kolačića. Pročitajte naše <a href="/en/cookie/" style="color: var(--primary, #4361ee); text-decoration: underline;">Politika kolačića</a> i <a href="/en/privacy/" style="color: var(--primary, #4361ee); text-decoration: underline;">Politika privatnosti</a>. </p> </div> <div style="display: flex; gap: 1rem; flex-wrap: wrap; align-items: center;"> <button id="cookie-accept-all" style="padding: 0.75rem 1.5rem; background: linear-gradient(135deg, var(--primary, #4361ee), var(--secondary, #7209b7)); color: white; border: none; border-radius: var(--border-radius, 8px); font-weight: 600; cursor: pointer; transition: all 0.3s ease; box-shadow: 0 4px 6px rgba(67,97,238,0.3);"> Prihvati sve </button> <button id="cookie-accept-essential" style="padding: 0.75rem 1.5rem; background: white; color: var(--dark, #212529); border: 1px solid var(--gray, #6c757d); border-radius: var(--border-radius, 8px); font-weight: 600; cursor: pointer; transition: all 0.3s ease;"> Samo neophodno </button> <button id="cookie-settings" style="padding: 0.75rem 1.5rem; background: transparent; color: var(--primary, #4361ee); border: none; font-weight: 600; cursor: pointer; text-decoration: underline;"> Prilagodite </button> </div> </div> `; document.body.appendChild(banner); // Add event listeners document.getElementById('cookie-accept-all').addEventListener('click', function() { acceptAllCookies(); }); document.getElementById('cookie-accept-essential').addEventListener('click', function() { acceptEssentialCookies(); }); document.getElementById('cookie-settings').addEventListener('click', function() { showCookieSettings(); }); } // Show cookie settings modal function showCookieSettings() { // Remove existing modal if any const existingModal = document.getElementById('cookie-settings-modal'); if (existingModal) existingModal.remove(); const modal = document.createElement('div'); modal.id = 'cookie-settings-modal'; modal.style.cssText = ` position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 10000; animation: fadeIn 0.3s ease; `; modal.innerHTML = ` <div style="background: white; border-radius: var(--border-radius, 8px); max-width: 500px; width: 90%; max-height: 80vh; overflow-y: auto; box-shadow: 0 10px 25px rgba(0,0,0,0.2);"> <div style="padding: 1.5rem; border-bottom: 1px solid #e9ecef;"> <h3 style="margin: 0; color: var(--dark, #212529);">Postavke kolačića</h3> </div> <div style="padding: 1.5rem;"> <p style="color: var(--gray, #6c757d); margin-bottom: 1.5rem;">Odaberite koje kolačiće dopuštate. Ove postavke možete promijeniti u bilo kojem trenutku.</p> <div style="margin-bottom: 1rem; padding: 1rem; background: #f8f9fa; border-radius: var(--border-radius, 8px);"> <label style="display: flex; align-items: center; gap: 0.75rem; cursor: not-allowed;"> <input type="checkbox" checked disabled style="width: 18px; height: 18px;"> <div> <strong style="color: var(--dark, #212529);">Osnovni kolačići</strong> <p style="margin: 0.25rem 0 0; font-size: 0.9rem; color: var(--gray, #6c757d);">Potrebno za funkcioniranje web stranice. Ne može se onemogućiti.</p> </div> </label> </div> <div style="margin-bottom: 1rem; padding: 1rem; background: #f8f9fa; border-radius: var(--border-radius, 8px);"> <label style="display: flex; align-items: center; gap: 0.75rem; cursor: pointer;"> <input type="checkbox" id="cookie-pref-analytics" checked style="width: 18px; height: 18px;"> <div> <strong style="color: var(--dark, #212529);">Kolačići analitike</strong> <p style="margin: 0.25rem 0 0; font-size: 0.9rem; color: var(--gray, #6c757d);">Pomozite nam da shvatimo kako posjetitelji stupaju u interakciju s našom stranicom.</p> </div> </label> </div> <div style="margin-bottom: 1rem; padding: 1rem; background: #f8f9fa; border-radius: var(--border-radius, 8px);"> <label style="display: flex; align-items: center; gap: 0.75rem; cursor: pointer;"> <input type="checkbox" id="cookie-pref-functional" checked style="width: 18px; height: 18px;"> <div> <strong style="color: var(--dark, #212529);">Funkcionalni kolačići</strong> <p style="margin: 0.25rem 0 0; font-size: 0.9rem; color: var(--gray, #6c757d);">Zapamtite svoje postavke i postavke.</p> </div> </label> </div> <div style="margin-bottom: 1rem; padding: 1rem; background: #f8f9fa; border-radius: var(--border-radius, 8px);"> <label style="display: flex; align-items: center; gap: 0.75rem; cursor: pointer;"> <input type="checkbox" id="cookie-pref-targeting" checked style="width: 18px; height: 18px;"> <div> <strong style="color: var(--dark, #212529);">Ciljanje kolačića</strong> <p style="margin: 0.25rem 0 0; font-size: 0.9rem; color: var(--gray, #6c757d);">Koristi se za isporuku relevantnog sadržaja i oglasa.</p> </div> </label> </div> </div> <div style="padding: 1.5rem; border-top: 1px solid #e9ecef; display: flex; gap: 1rem; justify-content: flex-end;"> <button id="cookie-save-preferences" style="padding: 0.75rem 1.5rem; background: linear-gradient(135deg, var(--primary, #4361ee), var(--secondary, #7209b7)); color: white; border: none; border-radius: var(--border-radius, 8px); font-weight: 600; cursor: pointer;"> Spremi postavke </button> <button id="cookie-close-modal" style="padding: 0.75rem 1.5rem; background: white; color: var(--dark, #212529); border: 1px solid var(--gray, #6c757d); border-radius: var(--border-radius, 8px); font-weight: 600; cursor: pointer;"> Otkazati </button> </div> </div> `; document.body.appendChild(modal); // Close modal handlers document.getElementById('cookie-close-modal').addEventListener('click', function() { modal.remove(); }); document.getElementById('cookie-save-preferences').addEventListener('click', function() { const preferences = { essential: true, // Always true analytics: document.getElementById('cookie-pref-analytics').checked, functional: document.getElementById('cookie-pref-functional').checked, targeting: document.getElementById('cookie-pref-targeting').checked }; saveCookiePreferences(preferences); modal.remove(); removeCookieBanner(); }); // Click outside to close modal.addEventListener('click', function(e) { if (e.target === modal) { modal.remove(); } }); } // Accept all cookies function acceptAllCookies() { const preferences = { essential: true, analytics: true, functional: true, targeting: true }; saveCookiePreferences(preferences); removeCookieBanner(); } // Accept only essential cookies function acceptEssentialCookies() { const preferences = { essential: true, analytics: false, functional: false, targeting: false }; saveCookiePreferences(preferences); removeCookieBanner(); } // Save cookie preferences function saveCookiePreferences(preferences) { // Save to cookie const expiryDate = new Date(); expiryDate.setDate(expiryDate.getDate() + COOKIE_EXPIRY_DAYS); const cookieValue = JSON.stringify(preferences); document.cookie = `${COOKIE_CONSENT_KEY}=${encodeURIComponent(cookieValue)}; expires=${expiryDate.toUTCString()}; path=/; SameSite=Lax`; // Apply preferences applyCookiePreferences(preferences); // Store in localStorage for quick access localStorage.setItem(COOKIE_CONSENT_KEY, cookieValue); // Optional: send event to analytics if (typeof window.gtag !== 'undefined' && preferences.analytics) { window.gtag('consent', 'update', { 'analytics_storage': 'granted' }); } } // Get cookie consent from cookie or localStorage function getCookieConsent() { // Try to get from cookie first const match = document.cookie.match(new RegExp('(^| )' + COOKIE_CONSENT_KEY + '=([^;]+)')); if (match) { try { return JSON.parse(decodeURIComponent(match[2])); } catch (e) { console.error('Pogreška pri analizi suglasnosti za kolačiće:', e); } } // Try localStorage const stored = localStorage.getItem(COOKIE_CONSENT_KEY); if (stored) { try { return JSON.parse(stored); } catch (e) { console.error('Pogreška prilikom analize pristanka za lokalnu pohranu:', e); } } return null; } // Apply cookie preferences (enable/disable features) function applyCookiePreferences(preferences) { if (!preferences) return; // Example: Disable analytics if not consented if (!preferences.analytics) { // Disable Google Analytics if present if (typeof window.gtag !== 'undefined') { window.gtag('consent', 'default', { 'analytics_storage': 'denied' }); } // Optionally remove existing analytics cookies // This is handled by the analytics script itself usually } // Disable targeting cookies if (!preferences.targeting) { // Disable ad-related tracking // Remove Facebook pixel, etc. } // Store preferences in data attribute for other scripts to check document.documentElement.setAttribute('data-cookie-consent', JSON.stringify(preferences)); // Dispatch event for other scripts to react window.dispatchEvent(new CustomEvent('cookieConsentChanged', { detail: preferences })); } // Remove cookie banner function removeCookieBanner() { const banner = document.getElementById('cookie-consent-banner'); if (banner) { banner.style.animation = 'slideDown 0.5s ease forwards'; setTimeout(() => { if (banner.parentNode) banner.remove(); }, 500); // Add slideDown animation if not exists if (!document.getElementById('cookie-animation-slidedown')) { const style = document.createElement('style'); style.id = 'cookie-animation-slidedown'; style.textContent = ` @keyframes slideDown { from { transform: translateY(0); } to { transform: translateY(100%); } } `; document.head.appendChild(style); } } } // Add a floating button to reopen cookie settings (optional) function addCookieSettingsButton() { const btn = document.createElement('button'); btn.id = 'cookie-settings-button'; btn.innerHTML = '🍪'; btn.setAttribute('aria-label', 'Postavke kolačića'); btn.style.cssText = ` position: fixed; bottom: 20px; left: 20px; width: 48px; height: 48px; border-radius: 50%; background: white; border: 1px solid var(--gray, #6c757d); box-shadow: var(--box-shadow, 0 4px 6px rgba(0,0,0,0.1)); cursor: pointer; font-size: 1.2rem; display: flex; align-items: center; justify-content: center; z-index: 9998; transition: var(--transition, all 0.3s ease); opacity: 0.8; `; btn.addEventListener('mouseenter', function() { this.style.opacity = '1'; this.style.transform = 'scale(1.1)'; }); btn.addEventListener('mouseleave', function() { this.style.opacity = '0.8'; this.style.transform = 'scale(1)'; }); btn.addEventListener('click', function() { showCookieSettings(); }); document.body.appendChild(btn); } // Initialize on DOM ready if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', initCookieConsent); } else { initCookieConsent(); } // Optional: Add settings button after consent is given window.addEventListener('cookieConsentChanged', function() { // Only show settings button if not already present if (!document.getElementById('cookie-settings-button')) { //addCookieSettingsButton(); } }); // If consent already exists, add settings button const existingConsent = getCookieConsent(); if (existingConsent && !document.getElementById('cookie-settings-button')) { document.addEventListener('DOMContentLoaded', function() { //addCookieSettingsButton(); }); } })(); </script> </body> </html>