@keyframes rotate { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } @-webkit-keyframes rotate { from { -webkit-transform: rotate(0deg); } to { -webkit-transform: rotate(360deg); } } .load { width: 100px; height: 100px; margin: 110px auto 0; border:solid 10px#e5ae2f; border-radius: 50%; border-right-color: transparent; border-bottom-color: transparent; -webkit-transition: all 0.5s ease-in; -webkit-animation-name: rotate; -webkit-animation-duration: 1.0s; -webkit-animation-iteration-count: infinite; -webkit-animation-timing-function: linear; transition: all 0.5s ease-in; animation-name: rotate; animation-duration: 1.0s; animation-iteration-count: infinite; animation-timing-function: linear; }
// Import the functions you need from the SDKs you need import { initializeApp } from "https://www.gstatic.com/firebasejs/10.8.1/firebase-app.js"; import { getDatabase, ref, get, child, update } from "https://www.gstatic.com/firebasejs/10.8.1/firebase-database.js"; // TODO: Add SDKs for Firebase products that you want to use // https://firebase.google.com/docs/web/setup#available-libraries // Your web app's Firebase configuration // For Firebase JS SDK v7.20.0 and later, measurementId is optional const firebaseConfig = { apiKey: "AIzaSyC2PJundzrEpgGKh-d38AvX1qUQEV4iZu8", authDomain: "e-minima.firebaseapp.com", databaseURL: "https://e-minima-default-rtdb.europe-west1.firebasedatabase.app", projectId: "e-minima", storageBucket: "e-minima.appspot.com", messagingSenderId: "626480156746", appId: "1:626480156746:web:b4e7a2d9126c3308cad6b3", measurementId: "G-TWS5W2LGNT" }; // Initialize Firebase const app = initializeApp(firebaseConfig); const db = getDatabase(app); const title = document.getElementById('dbTitle').querySelector('h1'); const subtitle = document.getElementById('dbSubtitle').querySelector('strong'); const image = document.getElementById('dbImage').querySelector('img'); const story = document.getElementById('dbStory').querySelector('span'); const dateNameElement = document.getElementById('dbDate').querySelector('h2'); const headContainer = document.getElementById('dbContainerHead'); const storyContainer = document.getElementById('dbContainerStory'); const prevButton = document.getElementById('dbPrevButton'); const nextButton = document.getElementById('dbNextButton'); const loadCircle = document.getElementById('dbLoadCircle'); const dbErrorMessage = document.getElementById('dbErrorMessage'); const urlParams = new URLSearchParams(window.location.search); const date = urlParams.get('date'); const dateSplit = date.split('-'); if(dateSplit[0].length === 1){ dateSplit[0] = '0' + dateSplit[0]; } if(dateSplit[1].length === 1){ dateSplit[1] = '0' + dateSplit[1]; } const dateFormatted = dateSplit[0] + '-' + dateSplit[1]; const index = parseInt(urlParams.get('index')); const dateObj = new Date(); dateObj.setDate(dateFormatted.split('-')[0]); dateObj.setMonth(dateFormatted.split('-')[1] - 1); const myRef = child(ref(db), 'agiologio/' + dateFormatted + '/' + index); const lengthRef = child(ref(db), 'agiologio/' + dateFormatted + '/length'); Promise.all([ get(myRef), get(lengthRef) ]).then((snapshots) => { const snapshot = snapshots[0]; if (snapshot.exists()) { const data = snapshot.val(); const months = [ 'Ιανουαρίου', 'Φεβρουαρίου', 'Μαρτίου', 'Απριλίου', 'Μαΐου', 'Ιουνίου', 'Ιουλίου', 'Αυγούστου', 'Σεπτεμβρίου', 'Οκτωβρίου', 'Νοεμβρίου', 'Δεκεμβρίου' ]; loadCircle.classList.add('hidden'); const dateName = dateObj.getDate() + ' ' + months[dateObj.getMonth()]; const nextDate = new Date(dateObj); nextDate.setDate(nextDate.getDate() + 1); const prevDate = new Date(dateObj); prevDate.setDate(prevDate.getDate() - 1); dateNameElement.innerHTML = dateName; title.innerHTML = data.title; subtitle.innerHTML = data.subtitle; image.src = data.imageSrc; story.innerHTML = data.story; if(snapshots[1].val() - 1 <= index){ nextButton.href = '?date=' + nextDate.getDate() + '-' + (nextDate.getMonth() + 1) + '&index=0'; } else { nextButton.href = '?date=' + dateFormatted + '&index=' + (parseInt(index) + 1); } if(index === 0){ prevButton.href = '?date=' + prevDate.getDate() + '-' + (prevDate.getMonth() + 1) + '&index=0'; } else { prevButton.href = '?date=' + dateFormatted + '&index=' + (parseInt(index) - 1); } nextButton.classList.remove('hidden'); prevButton.classList.remove('hidden'); headContainer.classList.remove('hidden'); storyContainer.classList.remove('hidden'); } else { loadCircle.classList.add('hidden'); dbErrorMessage.querySelector('.et_pb_text_inner').innerHTML = '

Δεν βρέθηκαν δεδομένα.

'; dbErrorMessage.classList.remove('hidden'); } }).catch((error) => { loadCircle.classList.add('hidden'); dbErrorMessage.classList.remove('hidden'); });