File: /var/www/html/Siyum_old/wp-content/themes/siyum-old/js/publications.js
//-------------------------------radio-----------------------------------------------
async function fetchMetadata() {
const streamUrl = "http://167.114.174.204:8018/7.html"; // Shoutcast metadata endpoint
try {
const response = await fetch(streamUrl);
const text = await response.text();
// Parse the metadata (Shoutcast metadata format)
const metadata = text.split(',');
const songData = metadata[6]?.split("'")[1]?.split(' - ');
if (songData && songData.length === 2) {
const artist = songData[0].trim();
const song = songData[1].trim();
// Update the UI with metadata
document.getElementById("song-title").textContent = song;
document.getElementById("artist-name").textContent = artist;
}
} catch (error) {
console.error("Error fetching metadata:", error);
}
}
setInterval(fetchMetadata, 10000);
fetchMetadata();
document.addEventListener('DOMContentLoaded', function () {
const modal = document.getElementById('customModal');
const modalTitle = modal.querySelector('.modal-title');
const modalSubtitle = modal.querySelector('.subtitle');
const modalcontent = modal.querySelector('.content');
const imgSlider = modal.querySelector('.img-slider');
document.querySelectorAll('.lg-play-btn').forEach(button => {
button.addEventListener('click', function () {
// Get data attributes from the clicked button
const volume = this.getAttribute('data-volume');
const title = this.getAttribute('data-title');
const subtitle = this.getAttribute('data-subtitle');
const thumbnail = JSON.parse(this.getAttribute('data-thumbnail'));
const pdf = JSON.parse(this.getAttribute('data-pdf'));
const description = JSON.parse(this.getAttribute('data-description'));
// Update modal content
modalTitle.textContent = title;
modalSubtitle.textContent = subtitle;
modalcontent.textContent = description;
// Clear existing images
imgSlider.innerHTML = '';
// Add new images to the slider
// images.forEach(image => {
// const imgDiv = document.createElement('div');
// imgDiv.classList.add('pdf-image');
// imgDiv.innerHTML = `<img src="${image}" alt="Popup Image">`;
// imgSlider.appendChild(imgDiv);
// });
document.querySelector('#customModal .img-slider').innerHTML = `
<div class="pdf-image">
<img src="${thumbnail}" alt="Thumbnail">
</div>
`;
const downloadButton = document.querySelector('#customModal .btn-primary');
document.querySelector('#customModal .btn-primary').innerHTML = `
<span class="ico"><img src="https://kedusha.spericorn.com/wp-content/themes/kedushas/img/pdf.svg" alt="pdf"></span>
<span><a href="${pdf}" target="_blank">Download PDF</a></span>
`;
});
downloadButton.setAttribute('href', pdf); // Set the PDF link
downloadButton.setAttribute('download', `${title}.pdf`); // Set the filename for download
});
});