2022-04-09 04:45:47 +02:00
|
|
|
/*
|
|
|
|
========================================================================
|
|
|
|
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 <roland@draemm.li>
|
|
|
|
Copyright (c) 2022 r/placeAtlas2 contributors
|
|
|
|
|
|
|
|
Licensed under the GNU Affero General Public License Version 3
|
|
|
|
https://place-atlas.stefanocoding.me/license.txt
|
|
|
|
========================================================================
|
|
|
|
*/
|
|
|
|
|
2022-04-05 12:32:59 +02:00
|
|
|
function createInfoBlock(entry) {
|
2022-04-15 05:46:27 +02:00
|
|
|
// console.log(entry)
|
2022-04-06 15:29:40 +02:00
|
|
|
function createInfoParagraph(name, value){
|
|
|
|
let entryParagraphPositionElement = document.createElement("p");
|
|
|
|
let nameElement = document.createElement("span");
|
|
|
|
nameElement.style.fontWeight = "bold";
|
|
|
|
nameElement.innerText = name;
|
|
|
|
let valueElement = document.createElement("span");
|
|
|
|
valueElement.innerText = value;
|
|
|
|
entryParagraphPositionElement.appendChild(nameElement);
|
|
|
|
entryParagraphPositionElement.appendChild(valueElement);
|
|
|
|
return entryParagraphPositionElement;
|
|
|
|
}
|
|
|
|
|
2022-04-05 12:32:59 +02:00
|
|
|
var element = document.createElement("div");
|
|
|
|
element.className = "object";
|
|
|
|
|
|
|
|
let headerElement = document.createElement("h2");
|
|
|
|
let linkElement = document.createElement("a");
|
2022-04-11 04:50:39 +02:00
|
|
|
linkElement.href = "#" + entry.id;
|
2022-04-05 12:32:59 +02:00
|
|
|
linkElement.innerText = entry.name;
|
|
|
|
headerElement.appendChild(linkElement);
|
|
|
|
|
|
|
|
element.appendChild(headerElement);
|
|
|
|
|
2022-04-08 22:02:14 +02:00
|
|
|
if (entry.diff) {
|
|
|
|
let diffElement = createInfoParagraph("Diff: ", entry.diff);
|
|
|
|
diffElement.className = entry.diff;
|
|
|
|
element.appendChild(diffElement);
|
|
|
|
}
|
|
|
|
|
2022-04-05 12:32:59 +02:00
|
|
|
if (entry.description) {
|
|
|
|
let descElement = document.createElement("p");
|
|
|
|
descElement.innerText = entry.description;
|
|
|
|
element.appendChild(descElement);
|
|
|
|
}
|
2022-04-06 15:29:40 +02:00
|
|
|
|
|
|
|
let [x, y] = entry.center;
|
2022-04-09 06:34:13 +02:00
|
|
|
element.appendChild(createInfoParagraph("Position: ", `${Math.floor(x)}, ${Math.floor(y)}`));
|
2022-04-06 15:29:40 +02:00
|
|
|
|
|
|
|
if(entry.path){
|
|
|
|
let area = calcPolygonArea(entry.path);
|
|
|
|
element.appendChild(createInfoParagraph("Area: ", `${area} pixels`));
|
|
|
|
}
|
2022-04-15 05:46:27 +02:00
|
|
|
|
|
|
|
entry.links.subreddit.forEach(subreddit => {
|
|
|
|
subreddit = "/r/" + subreddit;
|
|
|
|
let subredditLinkElement = document.createElement("a");
|
|
|
|
subredditLinkElement.target = "_blank";
|
|
|
|
subredditLinkElement.href = "https://reddit.com" + subreddit;
|
|
|
|
subredditLinkElement.innerText = subreddit;
|
|
|
|
element.appendChild(subredditLinkElement);
|
|
|
|
})
|
|
|
|
|
|
|
|
entry.links.website.forEach(link => {
|
2022-04-05 12:32:59 +02:00
|
|
|
let websiteLinkElement = document.createElement("a");
|
|
|
|
websiteLinkElement.target = "_blank";
|
2022-04-15 05:46:27 +02:00
|
|
|
websiteLinkElement.href = link;
|
2022-04-05 12:32:59 +02:00
|
|
|
websiteLinkElement.innerText = "Website";
|
|
|
|
element.appendChild(websiteLinkElement);
|
2022-04-15 05:46:27 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
entry.links.discord.forEach(link => {
|
|
|
|
let websiteLinkElement = document.createElement("a");
|
|
|
|
websiteLinkElement.target = "_blank";
|
2022-04-15 09:24:08 +02:00
|
|
|
websiteLinkElement.href = "https://discord.gg/" + link;
|
2022-04-15 05:46:27 +02:00
|
|
|
websiteLinkElement.innerText = "Discord";
|
|
|
|
element.appendChild(websiteLinkElement);
|
|
|
|
})
|
|
|
|
|
|
|
|
entry.links.wiki.forEach(link => {
|
|
|
|
let websiteLinkElement = document.createElement("a");
|
|
|
|
websiteLinkElement.target = "_blank";
|
2022-04-15 09:24:08 +02:00
|
|
|
websiteLinkElement.href = "https://place-wiki.stefanocoding.me/wiki/" + link.replace(/ /g, '_');
|
2022-04-15 05:46:27 +02:00
|
|
|
websiteLinkElement.innerText = "Wiki Article";
|
|
|
|
element.appendChild(websiteLinkElement);
|
|
|
|
})
|
|
|
|
|
2022-04-06 15:29:40 +02:00
|
|
|
let idElement = createInfoParagraph("ID: ", entry.id);
|
2022-04-05 12:32:59 +02:00
|
|
|
element.appendChild(idElement);
|
|
|
|
|
2022-04-10 11:28:27 +02:00
|
|
|
if (!entry.diff || entry.diff !== "delete") {
|
|
|
|
let editElement = document.createElement("a");
|
|
|
|
editElement.innerText = "Edit"
|
|
|
|
editElement.className = "objectEdit"
|
|
|
|
editElement.href = "./?mode=draw&id=" + entry.id
|
|
|
|
element.appendChild(editElement);
|
|
|
|
}
|
2022-04-09 16:07:01 +02:00
|
|
|
|
2022-04-05 12:32:59 +02:00
|
|
|
return element;
|
|
|
|
}
|