mirror of
https://github.com/placeAtlas/atlas.git
synced 2024-09-28 21:49:06 +02:00
Fix prefer-const problems (ESLint)
This commit is contained in:
parent
48f7361306
commit
4be8a36839
6 changed files with 69 additions and 69 deletions
|
@ -24,7 +24,7 @@ window.addEventListener("error", function (e) {
|
||||||
|
|
||||||
function getPositionOfEntry(entry){
|
function getPositionOfEntry(entry){
|
||||||
let startX = 2000, startY = 2000;
|
let startX = 2000, startY = 2000;
|
||||||
for(let [x, y] of entry.path){
|
for(const [x, y] of entry.path){
|
||||||
startX = Math.min(x, startX);
|
startX = Math.min(x, startX);
|
||||||
startY = Math.min(y, startY)
|
startY = Math.min(y, startY)
|
||||||
}
|
}
|
||||||
|
|
|
@ -263,8 +263,8 @@ function initDraw(){
|
||||||
exportObject.center[key] = calculateCenter(value)
|
exportObject.center[key] = calculateCenter(value)
|
||||||
})
|
})
|
||||||
|
|
||||||
let inputWebsite = document.getElementById("websiteField").value.split('\n').map(line => line.trim()).filter(line => line)
|
const inputWebsite = document.getElementById("websiteField").value.split('\n').map(line => line.trim()).filter(line => line)
|
||||||
let inputSubreddit = document.getElementById("subredditField").value.split('\n').map(line => line.trim().replace(/^\/?r\//, '')).filter(line => line)
|
const inputSubreddit = document.getElementById("subredditField").value.split('\n').map(line => line.trim().replace(/^\/?r\//, '')).filter(line => line)
|
||||||
|
|
||||||
if (inputWebsite.length) exportObject.links.website = inputWebsite
|
if (inputWebsite.length) exportObject.links.website = inputWebsite
|
||||||
if (inputSubreddit.length) exportObject.links.subreddit = inputSubreddit
|
if (inputSubreddit.length) exportObject.links.subreddit = inputSubreddit
|
||||||
|
@ -425,7 +425,7 @@ function initDraw(){
|
||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
|
|
||||||
let params = new URLSearchParams(document.location.search)
|
const params = new URLSearchParams(document.location.search)
|
||||||
|
|
||||||
if (params.has('id')) {
|
if (params.has('id')) {
|
||||||
entry = getEntry(params.get('id'))
|
entry = getEntry(params.get('id'))
|
||||||
|
@ -508,18 +508,18 @@ function initPeriodGroups() {
|
||||||
// console.log(pathWithPeriods)
|
// console.log(pathWithPeriods)
|
||||||
|
|
||||||
pathWithPeriods.forEach(([period, path], index) => {
|
pathWithPeriods.forEach(([period, path], index) => {
|
||||||
let periodGroupEl = periodGroupTemplate.cloneNode(true)
|
const periodGroupEl = periodGroupTemplate.cloneNode(true)
|
||||||
periodGroupEl.id = "periodGroup" + index
|
periodGroupEl.id = "periodGroup" + index
|
||||||
|
|
||||||
let startPeriodEl = periodGroupEl.querySelector('.period-start')
|
const startPeriodEl = periodGroupEl.querySelector('.period-start')
|
||||||
let endPeriodEl = periodGroupEl.querySelector('.period-end')
|
const endPeriodEl = periodGroupEl.querySelector('.period-end')
|
||||||
let periodVisibilityEl = periodGroupEl.querySelector('.period-visible')
|
const periodVisibilityEl = periodGroupEl.querySelector('.period-visible')
|
||||||
let periodDeleteEl = periodGroupEl.querySelector('.period-delete')
|
const periodDeleteEl = periodGroupEl.querySelector('.period-delete')
|
||||||
let periodDuplicateEl = periodGroupEl.querySelector('.period-duplicate')
|
const periodDuplicateEl = periodGroupEl.querySelector('.period-duplicate')
|
||||||
let periodVariationEl = periodGroupEl.querySelector('.period-variation')
|
const periodVariationEl = periodGroupEl.querySelector('.period-variation')
|
||||||
let periodCopyEl = periodGroupEl.querySelector('.period-copy')
|
const periodCopyEl = periodGroupEl.querySelector('.period-copy')
|
||||||
|
|
||||||
let [start, end, variation] = parsePeriod(period)
|
const [start, end, variation] = parsePeriod(period)
|
||||||
// console.log(period, start, end, variation)
|
// console.log(period, start, end, variation)
|
||||||
|
|
||||||
startPeriodEl.id = "periodStart" + index
|
startPeriodEl.id = "periodStart" + index
|
||||||
|
@ -555,8 +555,8 @@ function initPeriodGroups() {
|
||||||
initPeriodGroups()
|
initPeriodGroups()
|
||||||
})
|
})
|
||||||
periodVariationEl.addEventListener('input', event => {
|
periodVariationEl.addEventListener('input', event => {
|
||||||
let newVariation = event.target.value
|
const newVariation = event.target.value
|
||||||
let newVariationConfig = variationsConfig[newVariation]
|
const newVariationConfig = variationsConfig[newVariation]
|
||||||
startPeriodEl.value = newVariationConfig.default
|
startPeriodEl.value = newVariationConfig.default
|
||||||
startPeriodEl.max = newVariationConfig.versions.length - 1
|
startPeriodEl.max = newVariationConfig.versions.length - 1
|
||||||
endPeriodEl.value = newVariationConfig.default
|
endPeriodEl.value = newVariationConfig.default
|
||||||
|
@ -587,7 +587,7 @@ function initPeriodGroups() {
|
||||||
|
|
||||||
periodGroups.appendChild(periodGroupEl)
|
periodGroups.appendChild(periodGroupEl)
|
||||||
|
|
||||||
for (let variation in variationsConfig) {
|
for (const variation in variationsConfig) {
|
||||||
const optionEl = document.createElement('option')
|
const optionEl = document.createElement('option')
|
||||||
optionEl.value = variation
|
optionEl.value = variation
|
||||||
optionEl.textContent = variationsConfig[variation].name
|
optionEl.textContent = variationsConfig[variation].name
|
||||||
|
@ -619,7 +619,7 @@ function updatePeriodGroups() {
|
||||||
var currentActivePathIndexes = []
|
var currentActivePathIndexes = []
|
||||||
|
|
||||||
periodGroupElements.forEach((elements, index) => {
|
periodGroupElements.forEach((elements, index) => {
|
||||||
let {
|
const {
|
||||||
periodGroupEl,
|
periodGroupEl,
|
||||||
startPeriodEl,
|
startPeriodEl,
|
||||||
endPeriodEl,
|
endPeriodEl,
|
||||||
|
@ -686,7 +686,7 @@ function updatePeriodGroups() {
|
||||||
if (lastActivePathIndex !== undefined) {
|
if (lastActivePathIndex !== undefined) {
|
||||||
if (lastActivePathIndex === currentActivePathIndex) {
|
if (lastActivePathIndex === currentActivePathIndex) {
|
||||||
// just update the path
|
// just update the path
|
||||||
let {
|
const {
|
||||||
startPeriodEl,
|
startPeriodEl,
|
||||||
endPeriodEl,
|
endPeriodEl,
|
||||||
periodVariationEl
|
periodVariationEl
|
||||||
|
@ -743,7 +743,7 @@ function updateErrors() {
|
||||||
periodsStatus.textContent = "No paths available on this period!"
|
periodsStatus.textContent = "No paths available on this period!"
|
||||||
}
|
}
|
||||||
|
|
||||||
let [conflicts, invalidPaths, allErrors] = getErrors()
|
const [conflicts, invalidPaths, allErrors] = getErrors()
|
||||||
|
|
||||||
if (allErrors.length > 0) {
|
if (allErrors.length > 0) {
|
||||||
periodsStatus.textContent = `Problems detected. Please check the groups indicated by red.`
|
periodsStatus.textContent = `Problems detected. Please check the groups indicated by red.`
|
||||||
|
@ -760,7 +760,7 @@ function updateErrors() {
|
||||||
periodsStatus.textContent = ``
|
periodsStatus.textContent = ``
|
||||||
finishButton.disabled = false
|
finishButton.disabled = false
|
||||||
periodGroupElements.forEach((elements, index) => {
|
periodGroupElements.forEach((elements, index) => {
|
||||||
let { periodGroupEl } = elements
|
const { periodGroupEl } = elements
|
||||||
if (periodGroupEl.dataset.active === "true") periodGroupEl.dataset.status = "active"
|
if (periodGroupEl.dataset.active === "true") periodGroupEl.dataset.status = "active"
|
||||||
else periodGroupEl.dataset.status = ""
|
else periodGroupEl.dataset.status = ""
|
||||||
})
|
})
|
||||||
|
@ -772,9 +772,9 @@ function getConflicts() {
|
||||||
let conflicts = new Set()
|
let conflicts = new Set()
|
||||||
|
|
||||||
for (let i = pathWithPeriods.length - 1; i > 0; i--) {
|
for (let i = pathWithPeriods.length - 1; i > 0; i--) {
|
||||||
let [start1, end1, period1] = parsePeriod(pathWithPeriods[i][0])
|
const [start1, end1, period1] = parsePeriod(pathWithPeriods[i][0])
|
||||||
for (let j = 0; j < i; j++) {
|
for (let j = 0; j < i; j++) {
|
||||||
let [start2, end2, period2] = parsePeriod(pathWithPeriods[j][0])
|
const [start2, end2, period2] = parsePeriod(pathWithPeriods[j][0])
|
||||||
if (period1 !== period2) continue
|
if (period1 !== period2) continue
|
||||||
if (
|
if (
|
||||||
(start2 <= start1 && start1 <= end2) ||
|
(start2 <= start1 && start1 <= end2) ||
|
||||||
|
@ -795,8 +795,8 @@ function getConflicts() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getErrors() {
|
function getErrors() {
|
||||||
let conflicts = getConflicts()
|
const conflicts = getConflicts()
|
||||||
let invalidPaths = []
|
const invalidPaths = []
|
||||||
|
|
||||||
pathWithPeriods.forEach(([period, path], i) => {
|
pathWithPeriods.forEach(([period, path], i) => {
|
||||||
if (path.length < 3) invalidPaths.push(i)
|
if (path.length < 3) invalidPaths.push(i)
|
||||||
|
|
|
@ -16,11 +16,11 @@
|
||||||
function createInfoBlock(entry) {
|
function createInfoBlock(entry) {
|
||||||
// console.log(entry)
|
// console.log(entry)
|
||||||
function createInfoParagraph(name, value){
|
function createInfoParagraph(name, value){
|
||||||
let entryParagraphPositionElement = document.createElement("p");
|
const entryParagraphPositionElement = document.createElement("p");
|
||||||
let nameElement = document.createElement("span");
|
const nameElement = document.createElement("span");
|
||||||
nameElement.style.fontWeight = "bold";
|
nameElement.style.fontWeight = "bold";
|
||||||
nameElement.innerText = name;
|
nameElement.innerText = name;
|
||||||
let valueElement = document.createElement("span");
|
const valueElement = document.createElement("span");
|
||||||
valueElement.innerText = value;
|
valueElement.innerText = value;
|
||||||
entryParagraphPositionElement.appendChild(nameElement);
|
entryParagraphPositionElement.appendChild(nameElement);
|
||||||
entryParagraphPositionElement.appendChild(valueElement);
|
entryParagraphPositionElement.appendChild(valueElement);
|
||||||
|
@ -30,8 +30,8 @@ function createInfoBlock(entry) {
|
||||||
var element = document.createElement("div");
|
var element = document.createElement("div");
|
||||||
element.className = "object";
|
element.className = "object";
|
||||||
|
|
||||||
let headerElement = document.createElement("h2");
|
const headerElement = document.createElement("h2");
|
||||||
let linkElement = document.createElement("a");
|
const linkElement = document.createElement("a");
|
||||||
linkElement.href = "#" + entry.id;
|
linkElement.href = "#" + entry.id;
|
||||||
linkElement.innerText = entry.name;
|
linkElement.innerText = entry.name;
|
||||||
headerElement.appendChild(linkElement);
|
headerElement.appendChild(linkElement);
|
||||||
|
@ -39,28 +39,28 @@ function createInfoBlock(entry) {
|
||||||
element.appendChild(headerElement);
|
element.appendChild(headerElement);
|
||||||
|
|
||||||
if (entry.diff) {
|
if (entry.diff) {
|
||||||
let diffElement = createInfoParagraph("Diff: ", entry.diff);
|
const diffElement = createInfoParagraph("Diff: ", entry.diff);
|
||||||
diffElement.className = entry.diff;
|
diffElement.className = entry.diff;
|
||||||
element.appendChild(diffElement);
|
element.appendChild(diffElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry.description) {
|
if (entry.description) {
|
||||||
let descElement = document.createElement("p");
|
const descElement = document.createElement("p");
|
||||||
descElement.innerText = entry.description;
|
descElement.innerText = entry.description;
|
||||||
element.appendChild(descElement);
|
element.appendChild(descElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
let [x, y] = entry.center;
|
const [x, y] = entry.center;
|
||||||
element.appendChild(createInfoParagraph("Position: ", `${Math.floor(x)}, ${Math.floor(y)}`));
|
element.appendChild(createInfoParagraph("Position: ", `${Math.floor(x)}, ${Math.floor(y)}`));
|
||||||
|
|
||||||
if(entry.path){
|
if(entry.path){
|
||||||
let area = calcPolygonArea(entry.path);
|
const area = calcPolygonArea(entry.path);
|
||||||
element.appendChild(createInfoParagraph("Area: ", `${area} pixels`));
|
element.appendChild(createInfoParagraph("Area: ", `${area} pixels`));
|
||||||
}
|
}
|
||||||
|
|
||||||
entry.links.subreddit.forEach(subreddit => {
|
entry.links.subreddit.forEach(subreddit => {
|
||||||
subreddit = "/r/" + subreddit;
|
subreddit = "/r/" + subreddit;
|
||||||
let subredditLinkElement = document.createElement("a");
|
const subredditLinkElement = document.createElement("a");
|
||||||
subredditLinkElement.target = "_blank";
|
subredditLinkElement.target = "_blank";
|
||||||
subredditLinkElement.href = "https://reddit.com" + subreddit;
|
subredditLinkElement.href = "https://reddit.com" + subreddit;
|
||||||
subredditLinkElement.innerText = subreddit;
|
subredditLinkElement.innerText = subreddit;
|
||||||
|
@ -68,7 +68,7 @@ function createInfoBlock(entry) {
|
||||||
})
|
})
|
||||||
|
|
||||||
entry.links.website.forEach(link => {
|
entry.links.website.forEach(link => {
|
||||||
let websiteLinkElement = document.createElement("a");
|
const websiteLinkElement = document.createElement("a");
|
||||||
websiteLinkElement.target = "_blank";
|
websiteLinkElement.target = "_blank";
|
||||||
websiteLinkElement.href = link;
|
websiteLinkElement.href = link;
|
||||||
websiteLinkElement.innerText = "Website";
|
websiteLinkElement.innerText = "Website";
|
||||||
|
@ -76,7 +76,7 @@ function createInfoBlock(entry) {
|
||||||
})
|
})
|
||||||
|
|
||||||
entry.links.discord.forEach(link => {
|
entry.links.discord.forEach(link => {
|
||||||
let websiteLinkElement = document.createElement("a");
|
const websiteLinkElement = document.createElement("a");
|
||||||
websiteLinkElement.target = "_blank";
|
websiteLinkElement.target = "_blank";
|
||||||
websiteLinkElement.href = "https://discord.gg/" + link;
|
websiteLinkElement.href = "https://discord.gg/" + link;
|
||||||
websiteLinkElement.innerText = "Discord";
|
websiteLinkElement.innerText = "Discord";
|
||||||
|
@ -84,18 +84,18 @@ function createInfoBlock(entry) {
|
||||||
})
|
})
|
||||||
|
|
||||||
entry.links.wiki.forEach(link => {
|
entry.links.wiki.forEach(link => {
|
||||||
let websiteLinkElement = document.createElement("a");
|
const websiteLinkElement = document.createElement("a");
|
||||||
websiteLinkElement.target = "_blank";
|
websiteLinkElement.target = "_blank";
|
||||||
websiteLinkElement.href = "https://place-wiki.stefanocoding.me/wiki/" + link.replace(/ /g, '_');
|
websiteLinkElement.href = "https://place-wiki.stefanocoding.me/wiki/" + link.replace(/ /g, '_');
|
||||||
websiteLinkElement.innerText = "Wiki Article";
|
websiteLinkElement.innerText = "Wiki Article";
|
||||||
element.appendChild(websiteLinkElement);
|
element.appendChild(websiteLinkElement);
|
||||||
})
|
})
|
||||||
|
|
||||||
let idElement = createInfoParagraph("ID: ", entry.id);
|
const idElement = createInfoParagraph("ID: ", entry.id);
|
||||||
element.appendChild(idElement);
|
element.appendChild(idElement);
|
||||||
|
|
||||||
if (!entry.diff || entry.diff !== "delete") {
|
if (!entry.diff || entry.diff !== "delete") {
|
||||||
let editElement = document.createElement("a");
|
const editElement = document.createElement("a");
|
||||||
editElement.innerText = "Edit"
|
editElement.innerText = "Edit"
|
||||||
editElement.className = "objectEdit"
|
editElement.className = "objectEdit"
|
||||||
editElement.href = "./?mode=draw&id=" + entry.id
|
editElement.href = "./?mode=draw&id=" + entry.id
|
||||||
|
|
|
@ -75,7 +75,7 @@ init();
|
||||||
async function init(){
|
async function init(){
|
||||||
// For Reviewing Reddit Changes
|
// For Reviewing Reddit Changes
|
||||||
//let resp = await fetch("../tools/temp_atlas.json");
|
//let resp = await fetch("../tools/temp_atlas.json");
|
||||||
let resp = await fetch("./atlas.json");
|
const resp = await fetch("./atlas.json");
|
||||||
atlas = await resp.json();
|
atlas = await resp.json();
|
||||||
atlas.sort(function (a, b) {
|
atlas.sort(function (a, b) {
|
||||||
if (a.center[1] < b.center[1]) {
|
if (a.center[1] < b.center[1]) {
|
||||||
|
@ -116,9 +116,9 @@ async function init(){
|
||||||
|
|
||||||
// Backwards compatibility for old links using "search" id arg
|
// Backwards compatibility for old links using "search" id arg
|
||||||
if (params.has('id') && params.get('mode') !== 'draw') {
|
if (params.has('id') && params.get('mode') !== 'draw') {
|
||||||
let id = params.get('id')
|
const id = params.get('id')
|
||||||
params.delete('id')
|
params.delete('id')
|
||||||
let newLocation = new URL(window.location)
|
const newLocation = new URL(window.location)
|
||||||
newLocation.hash = id
|
newLocation.hash = id
|
||||||
newLocation.search = params
|
newLocation.search = params
|
||||||
window.history.replaceState({}, '', newLocation)
|
window.history.replaceState({}, '', newLocation)
|
||||||
|
@ -140,12 +140,12 @@ async function init(){
|
||||||
}
|
}
|
||||||
} else if(mode.startsWith("diff")){
|
} else if(mode.startsWith("diff")){
|
||||||
try {
|
try {
|
||||||
let liveResp = await fetch("https://place-atlas.stefanocoding.me/atlas.json");
|
const liveResp = await fetch("https://place-atlas.stefanocoding.me/atlas.json");
|
||||||
let liveJson = await liveResp.json();
|
let liveJson = await liveResp.json();
|
||||||
liveJson = updateAtlasAll(liveJson)
|
liveJson = updateAtlasAll(liveJson)
|
||||||
// console.log(liveJson)
|
// console.log(liveJson)
|
||||||
|
|
||||||
let liveAtlasReduced = liveJson.reduce(function(a, c) {
|
const liveAtlasReduced = liveJson.reduce(function(a, c) {
|
||||||
a[c.id] = c;
|
a[c.id] = c;
|
||||||
return a;
|
return a;
|
||||||
},{});
|
},{});
|
||||||
|
@ -160,11 +160,11 @@ async function init(){
|
||||||
});
|
});
|
||||||
|
|
||||||
// Mark removed entries
|
// Mark removed entries
|
||||||
let atlasReduced = atlasAll.reduce(function(a, c) {
|
const atlasReduced = atlasAll.reduce(function(a, c) {
|
||||||
a[c.id] = c;
|
a[c.id] = c;
|
||||||
return a;
|
return a;
|
||||||
},{});
|
},{});
|
||||||
let removedEntries = liveJson.filter(entry =>
|
const removedEntries = liveJson.filter(entry =>
|
||||||
atlasReduced[entry.id] === undefined
|
atlasReduced[entry.id] === undefined
|
||||||
).map(entry => {
|
).map(entry => {
|
||||||
entry.diff = "delete"
|
entry.diff = "delete"
|
||||||
|
@ -508,19 +508,19 @@ async function init(){
|
||||||
|
|
||||||
function updateAtlasAll(atlas) {
|
function updateAtlasAll(atlas) {
|
||||||
if (!atlas) atlas = atlasAll
|
if (!atlas) atlas = atlasAll
|
||||||
for (let atlasIndex in atlas) {
|
for (const atlasIndex in atlas) {
|
||||||
if (Array.isArray(atlas[atlasIndex].path)) {
|
if (Array.isArray(atlas[atlasIndex].path)) {
|
||||||
let currentPath = atlas[atlasIndex].path
|
const currentPath = atlas[atlasIndex].path
|
||||||
atlas[atlasIndex].path = {}
|
atlas[atlasIndex].path = {}
|
||||||
atlas[atlasIndex].path[defaultPeriod] = currentPath
|
atlas[atlasIndex].path[defaultPeriod] = currentPath
|
||||||
}
|
}
|
||||||
if (Array.isArray(atlas[atlasIndex].center)) {
|
if (Array.isArray(atlas[atlasIndex].center)) {
|
||||||
let currentCenter = atlas[atlasIndex].center
|
const currentCenter = atlas[atlasIndex].center
|
||||||
atlas[atlasIndex].center = {}
|
atlas[atlasIndex].center = {}
|
||||||
atlas[atlasIndex].center[defaultPeriod] = currentCenter
|
atlas[atlasIndex].center[defaultPeriod] = currentCenter
|
||||||
}
|
}
|
||||||
if (atlas[atlasIndex].links) {
|
if (atlas[atlasIndex].links) {
|
||||||
let currentLinks = atlas[atlasIndex].links
|
const currentLinks = atlas[atlasIndex].links
|
||||||
atlas[atlasIndex].links = {
|
atlas[atlasIndex].links = {
|
||||||
website: [],
|
website: [],
|
||||||
subreddit: [],
|
subreddit: [],
|
||||||
|
|
|
@ -88,7 +88,7 @@ const imageCache = {}
|
||||||
|
|
||||||
const variantsEl = document.getElementById("variants")
|
const variantsEl = document.getElementById("variants")
|
||||||
|
|
||||||
for (let variation in variationsConfig) {
|
for (const variation in variationsConfig) {
|
||||||
codeReference[variationsConfig[variation].code] = variation
|
codeReference[variationsConfig[variation].code] = variation
|
||||||
const optionEl = document.createElement('option')
|
const optionEl = document.createElement('option')
|
||||||
optionEl.value = variation
|
optionEl.value = variation
|
||||||
|
@ -104,7 +104,7 @@ let currentUpdateIndex = 0
|
||||||
let updateTimeout = setTimeout(null, 0)
|
let updateTimeout = setTimeout(null, 0)
|
||||||
|
|
||||||
let currentVariation = "default"
|
let currentVariation = "default"
|
||||||
let defaultPeriod = variationsConfig[currentVariation].default
|
const defaultPeriod = variationsConfig[currentVariation].default
|
||||||
let currentPeriod = defaultPeriod
|
let currentPeriod = defaultPeriod
|
||||||
window.currentPeriod = currentPeriod
|
window.currentPeriod = currentPeriod
|
||||||
window.currentVariation = currentVariation
|
window.currentVariation = currentVariation
|
||||||
|
@ -150,7 +150,7 @@ async function updateBackground(newPeriod = currentPeriod, newVariation = curren
|
||||||
abortController.abort()
|
abortController.abort()
|
||||||
abortController = new AbortController()
|
abortController = new AbortController()
|
||||||
currentUpdateIndex++
|
currentUpdateIndex++
|
||||||
let myUpdateIndex = currentUpdateIndex
|
const myUpdateIndex = currentUpdateIndex
|
||||||
currentPeriod = newPeriod
|
currentPeriod = newPeriod
|
||||||
// console.log(newPeriod, newVariation)
|
// console.log(newPeriod, newVariation)
|
||||||
const variationConfig = variationsConfig[newVariation]
|
const variationConfig = variationsConfig[newVariation]
|
||||||
|
@ -165,14 +165,14 @@ async function updateBackground(newPeriod = currentPeriod, newVariation = curren
|
||||||
const configObject = variationConfig.versions[currentPeriod];
|
const configObject = variationConfig.versions[currentPeriod];
|
||||||
if (typeof configObject.url === "string") {
|
if (typeof configObject.url === "string") {
|
||||||
if (imageCache[configObject.url] === undefined) {
|
if (imageCache[configObject.url] === undefined) {
|
||||||
let fetchResult = await fetch(configObject.url, {
|
const fetchResult = await fetch(configObject.url, {
|
||||||
signal: abortController.signal
|
signal: abortController.signal
|
||||||
});
|
});
|
||||||
if (currentUpdateIndex !== myUpdateIndex) {
|
if (currentUpdateIndex !== myUpdateIndex) {
|
||||||
hideLoading()
|
hideLoading()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let imageBlob = await fetchResult.blob()
|
const imageBlob = await fetchResult.blob()
|
||||||
imageCache[configObject.url] = URL.createObjectURL(imageBlob)
|
imageCache[configObject.url] = URL.createObjectURL(imageBlob)
|
||||||
}
|
}
|
||||||
image.src = imageCache[configObject.url]
|
image.src = imageCache[configObject.url]
|
||||||
|
@ -181,16 +181,16 @@ async function updateBackground(newPeriod = currentPeriod, newVariation = curren
|
||||||
const context = canvas.getContext('2d')
|
const context = canvas.getContext('2d')
|
||||||
context.canvas.width = 2000
|
context.canvas.width = 2000
|
||||||
context.canvas.height = 2000
|
context.canvas.height = 2000
|
||||||
for await (let url of configObject.url) {
|
for await (const url of configObject.url) {
|
||||||
if (imageCache[url] === undefined) {
|
if (imageCache[url] === undefined) {
|
||||||
let fetchResult = await fetch(url, {
|
const fetchResult = await fetch(url, {
|
||||||
signal: abortController.signal
|
signal: abortController.signal
|
||||||
});
|
});
|
||||||
if (currentUpdateIndex !== myUpdateIndex) {
|
if (currentUpdateIndex !== myUpdateIndex) {
|
||||||
hideLoading()
|
hideLoading()
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
let imageBlob = await fetchResult.blob()
|
const imageBlob = await fetchResult.blob()
|
||||||
imageCache[url] = URL.createObjectURL(imageBlob)
|
imageCache[url] = URL.createObjectURL(imageBlob)
|
||||||
}
|
}
|
||||||
const imageLayer = new Image()
|
const imageLayer = new Image()
|
||||||
|
@ -224,14 +224,14 @@ async function updateTime(newPeriod = currentPeriod, newVariation = currentVaria
|
||||||
for ( var atlasIndex in atlasAll ) {
|
for ( var atlasIndex in atlasAll ) {
|
||||||
let pathChosen, centerChosen, chosenIndex
|
let pathChosen, centerChosen, chosenIndex
|
||||||
|
|
||||||
let validPeriods2 = Object.keys(atlasAll[atlasIndex].path)
|
const validPeriods2 = Object.keys(atlasAll[atlasIndex].path)
|
||||||
|
|
||||||
// console.log(chosenIndex)
|
// console.log(chosenIndex)
|
||||||
|
|
||||||
for (let i in validPeriods2) {
|
for (const i in validPeriods2) {
|
||||||
let validPeriods = validPeriods2[i].split(', ')
|
const validPeriods = validPeriods2[i].split(', ')
|
||||||
for (let j in validPeriods) {
|
for (const j in validPeriods) {
|
||||||
let [start, end, variation] = parsePeriod(validPeriods[j])
|
const [start, end, variation] = parsePeriod(validPeriods[j])
|
||||||
// console.log(start, end, variation, newPeriod, newVariation)
|
// console.log(start, end, variation, newPeriod, newVariation)
|
||||||
if (isOnPeriod(start, end, variation, newPeriod, newVariation)) {
|
if (isOnPeriod(start, end, variation, newPeriod, newVariation)) {
|
||||||
// console.log("match", start, end, variation, newPeriod, newVariation, i)
|
// console.log("match", start, end, variation, newPeriod, newVariation, i)
|
||||||
|
@ -285,7 +285,7 @@ function parsePeriod(periodString) {
|
||||||
let variation = "default"
|
let variation = "default"
|
||||||
periodString = periodString + ""
|
periodString = periodString + ""
|
||||||
if (periodString.split(':').length > 1) {
|
if (periodString.split(':').length > 1) {
|
||||||
let split = periodString.split(':')
|
const split = periodString.split(':')
|
||||||
variation = codeReference[split[0]]
|
variation = codeReference[split[0]]
|
||||||
periodString = split[1]
|
periodString = split[1]
|
||||||
}
|
}
|
||||||
|
@ -293,7 +293,7 @@ function parsePeriod(periodString) {
|
||||||
var [start, end] = periodString.split('-').map(i => parseInt(i))
|
var [start, end] = periodString.split('-').map(i => parseInt(i))
|
||||||
return [start, end, variation]
|
return [start, end, variation]
|
||||||
} else {
|
} else {
|
||||||
let periodNew = parseInt(periodString)
|
const periodNew = parseInt(periodString)
|
||||||
return [periodNew, periodNew, variation]
|
return [periodNew, periodNew, variation]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -558,12 +558,12 @@ async function render(){
|
||||||
context.drawImage(backgroundCanvas, 0, 0);
|
context.drawImage(backgroundCanvas, 0, 0);
|
||||||
|
|
||||||
if(hovered.length === 1 && hovered[0].path.length && hovered[0].overrideImage){
|
if(hovered.length === 1 && hovered[0].path.length && hovered[0].overrideImage){
|
||||||
let undisputableHovered = hovered[0];
|
const undisputableHovered = hovered[0];
|
||||||
// Find the left-topmost point of all the paths
|
// Find the left-topmost point of all the paths
|
||||||
let entryPosition = getPositionOfEntry(undisputableHovered);
|
const entryPosition = getPositionOfEntry(undisputableHovered);
|
||||||
if(entryPosition){
|
if(entryPosition){
|
||||||
const [startX, startY] = entryPosition;
|
const [startX, startY] = entryPosition;
|
||||||
let overrideImage = new Image();
|
const overrideImage = new Image();
|
||||||
const loadingPromise = new Promise((res, rej) => {
|
const loadingPromise = new Promise((res, rej) => {
|
||||||
overrideImage.onerror = rej;
|
overrideImage.onerror = rej;
|
||||||
overrideImage.onload = res;
|
overrideImage.onload = res;
|
||||||
|
@ -691,7 +691,7 @@ function highlightEntryFromUrl(){
|
||||||
});
|
});
|
||||||
|
|
||||||
if (entries.length === 1){
|
if (entries.length === 1){
|
||||||
let entry = entries[0];
|
const entry = entries[0];
|
||||||
|
|
||||||
document.title = entry.name + " on the 2022 /r/place Atlas";
|
document.title = entry.name + " on the 2022 /r/place Atlas";
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue