(function module() {

const URL = "https://wiai.stuve-bamberg.de/vc-customization/"
const LOGO_URL = "img/logos/"

const quickLinks = [
	{
		name_german: "Virtuelle Karte",
		name_english: "Virtual Map",
		url_german: "https://wiai.de/home",
		url_english: "https://wiai.de/home",
    		icon: "gamepad"
	},
	{
		name_german: "Teams",
		name_english: "Teams",
		url_german: "#",
		url_english: "#",
		icon: "headset"
	},
	{
                name_german: "Zeitplan",
                name_english: "Schedule",
                url_german: "#",
                url_english: "#",
                icon: "calendar-alt"
        },
	{
                name_german: "Hilfe & FAQ",
                name_english: "Help & FAQ",
                url_german: "https://vc.uni-bamberg.de/mod/page/view.php?id=1122808",
                url_english: "#",
                icon: "question-circle"
        },
	{
                name_german: "Glossar",
                name_english: "Glossary",
                url_german: "https://vc.uni-bamberg.de/mod/glossary/view.php?id=1122803",
                url_english: "https://vc.uni-bamberg.de/mod/glossary/view.php?id=1122803",
                icon: "book"
        }
]

window.addEventListener('load', init);
addStylesheetTags();
addScriptTags();

function init() {
	addQuickLinks();
}

/**
 * Add a link to all stylesheets.
 */
function addStylesheetTags() {
	[
    'eets-wiai.css',
    'lib/fontawesome/css/fontawesome.min.css',
    'lib/fontawesome/css/solid.min.css'
  ].forEach(function (link) {
	        let tag = document.createElement('link');
	        tag.rel = 'stylesheet';
	        tag.href = URL + link;
	        document.head.appendChild(tag);
	});
}

/**
 * Add a link to all scripts.
 */
function addScriptTags() {
	['lib/fontawesome/attribution.js'].forEach(function (link) {
		let tag = document.createElement('script');
		tag.src = URL + link;
		document.body.appendChild(tag);
	});
}

/**
 * Add quick link section.
 */
function addQuickLinks() {
	const firstSection = document.querySelector('.course-content');
	const quickLinkContainer = document.createElement('div');
	quickLinkContainer.classList.add('wiai-quick-link-container');
	firstSection.prepend(quickLinkContainer);

	const bgColor = '#FFDC33', color = '#1A171B';
	quickLinkContainer.style.setProperty('--bg-color', bgColor);
        quickLinkContainer.style.setProperty('--color', color);

	quickLinks.forEach(function(quickLink) {
		const element = document.createElement('a');
		element.href = quickLink.url_german
		element.classList.add('wiai-quick-link');
		element.classList.add('wiai-german');
		
    		if (quickLink.logo) {
      			element.style.setProperty('--bg-image', `url(${URL}${LOGO_URL}${quickLink.logo})`);
      			element.innerText = quickLink.name_german;
    		} else {
      			element.innerHTML = `<i class="fa fa-${quickLink.icon}"/>`
		}
		
    		element.title = quickLink.name_german;
		quickLinkContainer.appendChild(element);

		const elementEnglish = document.createElement('a');
                elementEnglish.href = quickLink.url_english
                elementEnglish.classList.add('wiai-quick-link');
		elementEnglish.classList.add('wiai-english');

                if (quickLink.logo) {
                        elementEnglish.style.setProperty('--bg-image', `url(${URL}${LOGO_URL}${quickLink.logo})`);
                        elementEnglish.innerText = quickLink.name_english;
                } else {
                        elementEnglish.innerHTML = `<i class="fa fa-${quickLink.icon}"/>`
                }

                elementEnglish.title = quickLink.name_english;
                quickLinkContainer.appendChild(elementEnglish);
	});
}

})();
