From 2416f461c748d1fc7f7dd8c0090d31e8d201750e Mon Sep 17 00:00:00 2001 From: Traboulsi <salam.traboulsi@hft-stuttgart.de> Date: Fri, 29 Dec 2023 07:42:49 +0000 Subject: [PATCH] Update public/js/add_content.js --- public/js/add_content.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/public/js/add_content.js b/public/js/add_content.js index 3ab8fb1..35f550d 100644 --- a/public/js/add_content.js +++ b/public/js/add_content.js @@ -79,7 +79,16 @@ function addcontent(item) { var sdgProjectLink = item.sdgImage; var customColor = '#8A2BE2'; - sdgProjectHTML = `<a class="sdg-button btn btn-sm btn-outline-" style="color: ${customColor}; border-color: ${customColor};" href="javascript:void(0);"onclick="toggleImage('${sdgProjectLink}');"onmouseover="hoverEffect(this, 'white', '#8A2BE2');" onmouseout="hoverEffect(this, '${customColor}', 'white');">SDG Projekt<img id="sdgImage" src="" alt="SDG Project Image" style="max-width: 100%; max-height: 100%; display: none;"> </a> `; + sdgProjectHTML = `<a class="sdg-button btn btn-sm btn-outline-" style="color: ${customColor}; border-color: ${customColor};" + href="javascript:void(0);" + onclick="toggleImage('${sdgProjectLink}'); changeColor(this, 'lilac');" + onmouseover="hoverEffect(this, 'white', 'lilac');" + onmouseout="hoverEffect(this, '${customColor}', 'white');"> + SDG Projekt + <img id="sdgImage" src="" alt="SDG Project Image" style="max-width: 100%; max-height: 100%; display: none;"> + </a> `; + } + /* var sdgProjectHTML = ''; if ('sdgImage' in item) { @@ -107,7 +116,7 @@ function addcontent(item) { window.open(sdgProjectLink, '_blank'); } </script>`;*/ - } + //} //-- fin (new idea) @@ -204,6 +213,7 @@ function addTeam(item) { new_row.innerHTML = new_row.innerHTML + html_team } } + function toggleImage(imageLink) { var imageElement = document.getElementById('sdgImage'); if (imageElement.src === imageLink) { @@ -219,3 +229,8 @@ function hoverEffect(element, color, textColor) { element.style.backgroundColor = color; element.style.color = textColor; } + +function changeColor(element, newColor) { + element.style.backgroundColor = newColor; + element.style.color = 'white'; +} -- GitLab