This commit is contained in:
root 2020-07-15 20:32:42 +00:00
parent 666943d4f1
commit 51208cad8d
27 changed files with 1003 additions and 678 deletions

View file

@ -10,6 +10,11 @@ let navContent = document.getElementById('nav-content')
let mosaic = document.getElementById('mosaic')
let mosaicHeader = document.getElementById('mosaic-header')
organizations = organizations.map(org => {
org.tag = tags.filter(t => t._id === org.tag)[0]
return org
})
navEnabler.onclick = async () => {
if (!navOpened) {
// open the menu
@ -73,6 +78,14 @@ function renderNavItem(tag) {
return navItem
}
function setAttributes(node, attrs) {
for (var key in attrs) {
attr = document.createAttribute(key)
attr.value = attrs[key]
node.attributes.setNamedItem(attr)
}
}
function renderCard(organization) {
let card = createEl('card')
@ -92,13 +105,19 @@ function renderCard(organization) {
titleContainer.appendChild(title)
let icon = createEl('card-icon')
let iconTag = createEl(organization.tag.icon, 'i')
icon.appendChild(iconTag)
icon.innerHTML = `<svg
aria-hidden="true"
focusable="false"
role="img"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 ${organization.tag.icon.width} ${organization.tag.icon.height}">
<path fill="currentColor" d="${organization.tag.icon.path}"></path>
</svg>`
titleContainer.appendChild(icon)
upperContent.appendChild(titleContainer)
let description = createEl('card-description')
description.textContent = organization.descriptionShort
description.textContent = organization.description
upperContent.appendChild(description)
let link = createEl('card-link')
@ -109,6 +128,10 @@ function renderCard(organization) {
content.appendChild(upperContent)
content.appendChild(link)
card.appendChild(content)
card.onclick = () => {
window.location = aTag.href
}
return card
}
@ -129,7 +152,7 @@ function enableTag(node) {
if (!all) {
tagId = node.attributes['data-tag-id'].value
}
let data = organizations.filter(orga => orga.tag.id === tagId || all)
let data = organizations.filter(orga => orga.tag._id === tagId || all)
let cards = renderMosaic(data)
if (currentCardContainer !== null) {
mosaic.removeChild(currentCardContainer)