const baseUrl12 = 'https://www.pl.weber/paleta-polnoc-';
const baseUrl3 = 'https://www.pl.weber/paleta-wschod-';
const baseUrl45 = 'https://www.pl.weber/paleta-poludnie-';
const baseUrl6 = 'https://www.pl.weber/paleta-zachod-';
colors.forEach((color, index) => {
const colorDiv = document.createElement('div');
colorDiv.className = 'matching-color';
colorDiv.style.backgroundColor = color;
const link = document.createElement('a');
let colorCode = names[index];
const firstDigit = colorCode.charAt(0);
let baseUrl;
if (firstDigit === '1' || firstDigit === '2') {
baseUrl = baseUrl12;
} else if (firstDigit === '3') {
baseUrl = baseUrl3;
} else if (firstDigit === '4' || firstDigit === '5') {
baseUrl = baseUrl45;
} else if (firstDigit === '6') {
baseUrl = baseUrl6;
} else {
baseUrl = 'https://www.pl.weber/paleta-poludnie-'; // Domyślny link, jeśli pierwsza cyfra nie pasuje
}
const urlPart = colorCode;
const lowerCaseUrlPart = urlPart.toLowerCase();
colorCode = lowerCaseUrlPart;
link.href = baseUrl + colorCode;
link.textContent = names[index];
colorDiv.appendChild(link);
matchingColorsContainer.appendChild(colorDiv);