/*
========================================================================
The 2022 /r/place Atlas
An Atlas of Reddit's 2022 /r/place, with information to each
artwork of the canvas provided by the community.
Copyright (c) 2017 Roland Rytz
');
formattedDesc = formattedDesc.replace(/\n/g, '
');
descElement.innerHTML = '
' + formattedDesc + '
'; bodyElement.appendChild(descElement); } const linkListElement = document.createElement("div"); linkListElement.className = "d-flex flex-column gap-2"; bodyElement.appendChild(linkListElement); const listElement = document.createElement("ul"); listElement.className = "list-group list-group-flush"; element.appendChild(listElement); if (entry.diff) { let diffElement = createInfoListItem("Diff: ", entry.diff); if (entry.diff == "add") { diffElement.className = "list-group-item list-group-item-success"; } else if (entry.diff == "edit") { diffElement.className = "list-group-item list-group-item-warning"; } else if (entry.diff == "delete") { diffElement.className = "list-group-item list-group-item-danger"; } listElement.appendChild(diffElement); } const [x, y] = entry.center; listElement.appendChild(createInfoListItem("Position: ", `${Math.floor(x)}, ${Math.floor(y)}`)); if(entry.path){ const area = calcPolygonArea(entry.path); listElement.appendChild(createInfoListItem("Area: ", `${area} pixels`)); } if (entry.links.subreddit.length) { const subredditGroupElement = document.createElement("div"); subredditGroupElement.className = "btn-group-vertical"; linkListElement.appendChild(subredditGroupElement); entry.links.subreddit.forEach(subreddit => { if (subreddit) { subreddit = "r/" + subreddit; const subredditLinkElement = document.createElement("a"); subredditLinkElement.className = "btn btn-primary text-truncate"; subredditLinkElement.target = "_blank"; subredditLinkElement.rel = "noopener noreferrer"; subredditLinkElement.href = "https://reddit.com/" + subreddit; subredditLinkElement.textContent = subreddit; subredditGroupElement.appendChild(subredditLinkElement); } }); }; if (entry.links.website.length) { const websiteGroupElement = document.createElement("div"); websiteGroupElement.className = "btn-group-vertical"; linkListElement.appendChild(websiteGroupElement); entry.links.website.forEach(link => { if (link) { const websiteLinkElement = document.createElement("a"); websiteLinkElement.className = "btn btn-primary" websiteLinkElement.target = "_blank"; websiteLinkElement.rel = "noopener noreferrer"; websiteLinkElement.href = link; websiteLinkElement.textContent = "Website"; websiteGroupElement.appendChild(websiteLinkElement); } }); } if (entry.links.discord.length) { const discordGroupElement = document.createElement("div"); discordGroupElement.className = "btn-group-vertical"; linkListElement.appendChild(discordGroupElement); entry.links.discord.forEach(link => { if (link) { const discordLinkElement = document.createElement("a"); discordLinkElement.target = "_blank"; discordLinkElement.href = "https://discord.gg/" + link; discordLinkElement.textContent = "Discord"; discordGroupElement.appendChild(discordLinkElement); } }); } if (entry.links.wiki.length) { const wikiGroupElement = document.createElement("div"); wikiGroupElement.className = "btn-group-vertical"; linkListElement.appendChild(wikiGroupElement); entry.links.wiki.forEach(link => { if (link) { const wikiLinkElement = document.createElement("a"); wikiLinkElement.target = "_blank"; websiteLinkElement.rel = "noopener noreferrer"; wikiLinkElement.href = "https://place-wiki.stefanocoding.me/wiki/" + link.replace(/ /g, '_'); wikiLinkElement.textContent = "Wiki Article"; wikiGroupElement.appendChild(wikiLinkElement); } }); } const idElement = document.createElement("div"); idElement.className = "py-1"; createLabel("ID: ", entry.id, idElement); const idElementContainer = document.createElement("div"); idElementContainer.className = "card-footer d-flex justify-content-between align-items-center"; idElementContainer.appendChild(idElement); element.appendChild(idElementContainer); if (!entry.diff || entry.diff !== "delete") { const editElement = document.createElement("a"); editElement.textContent = "Edit"; editElement.className = "btn btn-sm btn-outline-primary"; editElement.href = "./?mode=draw&id=" + entry.id; editElement.title = "Edit " + entry.name; idElementContainer.appendChild(editElement); } if (!linkListElement.hasChildNodes()) { linkListElement.remove(); } if (!bodyElement.hasChildNodes()) { bodyElement.remove(); } return element; }