Merge pull request #365 from asivery/master

Removed XSS in infoblock creation, moved infoblock creation into a separate file, formatted atlas.json and made it distinct by description if it's longer than 10 characters
This commit is contained in:
Aeywoo 2022-04-05 20:23:38 +09:30 committed by GitHub
commit 445be39898
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 51 additions and 59 deletions

48
web/_js/infoblock.js Normal file
View file

@ -0,0 +1,48 @@
function createInfoBlock(entry) {
var element = document.createElement("div");
element.className = "object";
let headerElement = document.createElement("h2");
let linkElement = document.createElement("a");
linkElement.href = "?" + entry.id;
linkElement.innerText = entry.name;
headerElement.appendChild(linkElement);
element.appendChild(headerElement);
if (entry.description) {
let descElement = document.createElement("p");
descElement.innerText = entry.description;
element.appendChild(descElement);
}
if (entry.website) {
let websiteLinkElement = document.createElement("a");
websiteLinkElement.target = "_blank";
websiteLinkElement.href = entry.website;
websiteLinkElement.innerText = "Website";
element.appendChild(websiteLinkElement);
}
if (entry.subreddit) {
var subreddits = entry.subreddit.split(",");
for (var i in subreddits) {
var subreddit = subreddits[i].trim();
if (subreddit.substring(0, 2) == "r/") {
subreddit = "/" + subreddit;
} else if (subreddit.substring(0, 1) != "/") {
subreddit = "/r/" + subreddit;
}
let subredditLinkElement = document.createElement("a");
subredditLinkElement.target = "_blank";
subredditLinkElement.href = "https://reddit.com" + subreddit;
subredditLinkElement.innerText = subreddit;
element.appendChild(subredditLinkElement);
}
}
let idElement = document.createElement("p");
idElement.style.fontFamily = "Dejavu Sans Mono, sans, Sans-Serif;";
idElement.innerText = "id: " + entry.id;
element.appendChild(idElement);
return element;
}

View file

@ -131,32 +131,6 @@ function initOverlap(){
updateLines();
});
function createInfoBlock(entry){
var element = document.createElement("div");
element.className = "object";
var html = '<h2><a href="?id='+entry.id+'">'+entry.name+'</a></h2>';
if(entry.description){
html += '<p>'+entry.description+'</p>';
}
if(entry.website){
html += '<a target="_blank" href='+entry.website+'>Website</a>';
}
if(entry.subreddit){
if(entry.subreddit.substring(0, 2) == "r/"){
entry.subreddit = "/" + entry.subreddit;
} else if(entry.subreddit.substring(0, 1) != "/"){
entry.subreddit = "/r/" + entry.subreddit;
}
html += '<a target="_blank" href=https://reddit.com'+entry.subreddit+'>'+entry.subreddit+'</a>';
}
html+="<p style='font-family: Dejavu Sans Mono, sans, Sans-Serif;'>id: "+entry.id+"</p>";
element.innerHTML += html;
return element;
}
function highlightEntryFromUrl(){
var objectsContainer = document.getElementById("objectsList");

View file

@ -257,37 +257,6 @@ function initView(){
}
}
function createInfoBlock(entry){
var element = document.createElement("div");
element.className = "object";
var html = "<h2><a href=\"?id="+entry.id+"\">"+entry.name+"</a></h2>";
if(entry.description){
html += "<p>"+entry.description+"</p>";
}
if(entry.website){
html += "<a target=\"_blank\" href="+entry.website+">Website</a>";
}
if(entry.subreddit){
var subreddits = entry.subreddit.split(",");
for(var i in subreddits){
var subreddit = subreddits[i].trim();
if(subreddit.substring(0, 2) == "r/"){
subreddit = "/" + subreddit;
} else if(subreddit.substring(0, 1) != "/"){
subreddit = "/r/" + subreddit;
}
html += "<a target=\"_blank\" href=https://reddit.com"+subreddit+">"+subreddit+"</a>";
}
}
html+="<p style='font-family: Dejavu Sans Mono, sans, Sans-Serif;'>id: "+entry.id+"</p>";
element.innerHTML += html;
return element;
}
function highlightEntryFromUrl(){
var objectsContainer = document.getElementById("objectsList");

View file

@ -1,4 +1,5 @@
[{"id": "000000", "name": "Pinewood Logo/Rubix cube (Destroyed)", "description": "Originally the logo for the Roblox group Pinewood Builders, the logo transformed into a game of tic tac toe, and then a Rubix cube. It was destroyed after being invaded by Iran", "website": "https://pinewoodbuilders.reddit.com/", "subreddit": "r/PinewoodBuilders", "center": [39.5, 279.5], "path": [[22.5, 295.5], [23.5, 274.5], [35.5, 262.5], [55.5, 262.5], [55.5, 283.5], [43.5, 295.5]]},
[
{"id": "000000", "name": "Pinewood Logo/Rubix cube (Destroyed)", "description": "Originally the logo for the Roblox group Pinewood Builders, the logo transformed into a game of tic tac toe, and then a Rubix cube. It was destroyed after being invaded by Iran", "website": "https://pinewoodbuilders.reddit.com/", "subreddit": "r/PinewoodBuilders", "center": [39.5, 279.5], "path": [[22.5, 295.5], [23.5, 274.5], [35.5, 262.5], [55.5, 262.5], [55.5, 283.5], [43.5, 295.5]]},
{"id": "000001", "name": "CCKUFI Robin", "description": "The icon of CcKuFi, the subreddit of users who made it to the highest tier in Reddit's 2016 April Fools Event, Robin.", "subreddit": "ccKufiPrFaShleWoli0", "center": [783.5, 669.5], "path": [[771.5, 661.5], [771.5, 680.5], [789.5, 680.5], [789.5, 664.5], [806.5, 664.5], [806.5, 660.5], [771.5, 660.5]]},
{"id": "000002", "name": "Narrator Nexus", "description": "The icon of Narrator Nexus, the group of users who coordinated the storyline in Reddit's 2019 April Fools Event, Sequence.", "website": "", "subreddit": "/r/NarraNexus/", "center": [763.5, 673.5], "path": [[755.5, 667.5], [755.5, 680.5], [771.5, 680.5], [771.5, 674.5], [772.5, 673.5], [772.5, 670.5], [767.5, 664.5], [762.5, 664.5], [759.5, 669.5], [755.5, 667.5]]},
{"id": "000003", "name": "April Knights", "description": "The Logo of the April Knights, a subreddit formed for Reddit's 2015 April Fools event 'The Button'.", "website": "", "subreddit": "/r/AprilKnights/", "center": [788.5, 677.5], "path": [[789.5, 664.5], [789.5, 679.5], [789.5, 680.5], [755.5, 680.5], [755.5, 684.5], [803.5, 684.5], [801.5, 679.5], [803.5, 676.5], [803.5, 664.5], [789.5, 664.5]]},
@ -1248,5 +1249,4 @@
{"id": "febcaa", "name": "Abby | Abigail Williams", "description": "A character from the mobile game Fate/Grand Order.\n \nA Foreigner-class Servant and a key character in the events of Salem", "website": "https://typemoon.fandom.com/wiki/Abigail_Williams", "subreddit": "/r/grandorder", "center": [946.5, 1426.5], "path": [[941.5, 1419.5], [941.5, 1433.5], [951.5, 1433.5], [951.5, 1419.5], [941.5, 1419.5]]},
{"id": "3cd3ce", "name": "Saber | Fate Route", "description": "Saber - a Main character in the Visual Novel Fate/Stay Night\n\nFate Route - One of the main routes in the visual novel where Saber is featured as the main heroine.", "website": "https://typemoon.fandom.com/wiki/Saber", "subreddit": "/r/fatestaynight/", "center": [18.5, 1046.5], "path": [[0.5, 1028.5], [35.5, 1028.5], [35.5, 1063.5], [0.5, 1063.5], [0.5, 1028.5]]},
{"id": "6448c5", "name": "EMIYA", "description": "A main character in the Fate/Stay Night series and also a summonable character in Fate/Grand Order", "website": "https://typemoon.fandom.com/wiki/EMIYA_(Archer)", "subreddit": "/r/grandorder", "center": [8.5, 957.5], "path": [[0.5, 942.5], [16.5, 942.5], [15.5, 972.5], [0.5, 972.5], [0.5, 942.5]]}
]

View file

@ -229,6 +229,7 @@ <h2>His Bitcoin Address</h2>
Code by <a href="https://draemm.li/various/place-atlas/" target="_blank" rel="author">Roland Rytz</a>. Source on <a target="_blank" href="https://github.com/RolandR/place-atlas">GitHub</a> (<a target="_blank" href="https://github.com/Codixer/place-atlas">2022 Version Github</a>). Images provided by <a target="_blank" href="https://place.thatguyalex.com/">Alex Tsernoh</a>.
</div>
</div>
<script type="text/javascript" src="./_js/infoblock.js?version=1.0"></script>
<script type="text/javascript" src="./_js/pointInPolygon.js?version=1.0"></script>
<script type="text/javascript" src="./_js/atlas.js?version=1.0.50"></script>
<script type="text/javascript" src="./_js/view.js?version=1.0.4"></script>