Oferta

Ofertă Panouri Publicitare Stradale

Oras:

Judet:

Adresa:

Format:

Cod:

Marime:

Suprafata:

GPS:

Tip strada:

document.getElementById(‘export-btn’).addEventListener(‘click’, function () {
const allPosts = document.querySelectorAll(‘.brz-posts__item’); // Correctly select all posts
const selectedPosts = [];

// Collect data from selected posts
allPosts.forEach((post) => {
const checkbox = post.querySelector(‘input[name=”select-post”]’); // Select the checkbox inside the post
if (checkbox && checkbox.checked) {
const titleElement = post.querySelector(‘.brz-wp-title-content’); // Find the title element
const title = titleElement ? titleElement.innerText.trim() : ‘No Title Found’; // Safely get the title
const spans = post.querySelectorAll(“span.text-population”);
const orasElement = spans[1];
const adresaElement = spans[3];
const pictureEl = post.querySelector(“picture img”);
const formatElement = spans[4];
const codElement = spans[5];
const sizeElement = spans[6];
const surfaceElement = spans[7];
const gpsElement = spans[8];

const oras = orasElement ? orasElement.innerText.trim() : ‘No Oras Found’;
const adresa = adresaElement ? adresaElement.innerText.trim() : ‘No Adresa Found’;
const pic = pictureEl ? pictureEl.src : “No Image Found”;
const format = formatElement ? formatElement.innerText.trim() : ‘No Format Found’;
const cod = codElement ? codElement.innerText.trim() : ‘No Cod Found’;
const size = sizeElement ? sizeElement.innerText.trim() : ‘No Size Found’;
const surface = surfaceElement ? surfaceElement.innerText.trim() : ‘No Surface Found’;
const gps = gpsElement ? gpsElement.innerText.trim() : ‘No GPS Found’;

selectedPosts.push({
title: title,
oras: oras,
adresa: adresa,
picture: pic,
format: format,
cod: cod,
size: size,
surface: surface,
gps: gps
});
}
});

if (selectedPosts.length === 0) {
alert(‘Please select at least one post to export.’);
return;
}

// Convert data to CSV
let csvContent = ‘Title,City,Adress,Picture,Format,Cod,Size,Surface,GPSn’; // Add CSV headers
selectedPosts.forEach((post) => {
const row = `”${post.title}”,”${post.oras}”,”${post.adresa}”,”${post.picture}”,”${post.format}”,”${post.cod}”,”${post.size}”,”${post.surface}”,”${post.gps}”`; // Escape commas
csvContent += row + ‘n’; // Add a new line
});

// Create and download CSV file
const blob = new Blob([csvContent], { type: ‘text/csv;charset=utf-8;’ });
const url = URL.createObjectURL(blob);

const a = document.createElement(‘a’);
a.href = url;
a.download = ‘exported_posts.csv’;
a.style.display = ‘none’;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);

URL.revokeObjectURL(url);
});

© Copyright 2025. Toate drepturile rezervate VAN BERRY HIGHWAY MEDIA

web development www.addvices.ro