atlas/web/_js/time.js

127 lines
3 KiB
JavaScript
Raw Normal View History

/*
========================================================================
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 20:17:39 +02:00
const timeConfig = [
{
2022-04-06 19:04:07 +02:00
timestamp: 1648822500,
2022-04-08 06:47:59 +02:00
url: "./_img/place/1648822500.png",
2022-04-05 20:17:39 +02:00
image: null
},
{
2022-04-06 19:04:07 +02:00
timestamp: 1648847036,
2022-04-08 06:47:59 +02:00
url: "./_img/place/1648847036.png",
2022-04-05 20:17:39 +02:00
image: null
},
{
2022-04-06 19:04:07 +02:00
timestamp: 1648870452,
2022-04-08 06:47:59 +02:00
url: "./_img/place/1648870452.png",
2022-04-06 19:04:07 +02:00
image: null
},
{
timestamp: 1648893666,
2022-04-08 06:47:59 +02:00
url: "./_img/place/1648893666.png",
2022-04-06 19:04:07 +02:00
image: null
},
{
timestamp: 1648917500,
2022-04-08 06:47:59 +02:00
url: "./_img/place/1648917500.png",
2022-04-06 19:04:07 +02:00
image: null
},
{
timestamp: 1648942113,
2022-04-08 06:47:59 +02:00
url: "./_img/place/1648942113.png",
2022-04-06 19:04:07 +02:00
image: null
},
{
timestamp: 1648956234,
2022-04-08 06:47:59 +02:00
url: "./_img/place/1648956234.png",
2022-04-06 19:04:07 +02:00
image: null
},
{
timestamp: 1648968061,
2022-04-08 06:47:59 +02:00
url: "./_img/place/1648968061.png",
2022-04-06 19:04:07 +02:00
image: null
},
{
timestamp: 1648979987,
2022-04-08 06:47:59 +02:00
url: "./_img/place/1648979987.png",
2022-04-06 19:04:07 +02:00
image: null
},
{
timestamp: 1648992274,
2022-04-08 06:47:59 +02:00
url: "./_img/place/1648992274.png",
2022-04-06 19:04:07 +02:00
image: null
},
{
timestamp: 1649012915,
2022-04-08 06:47:59 +02:00
url: "./_img/place/1649012915.png",
2022-04-06 19:04:07 +02:00
image: null
},
{
timestamp: 1649037182,
2022-04-08 06:47:59 +02:00
url: "./_img/place/1649037182.png",
2022-04-06 19:04:07 +02:00
image: null
},
{
timestamp: 1649060793,
2022-04-08 06:47:59 +02:00
url: "./_img/place/1649060793.png",
2022-04-06 19:04:07 +02:00
image: null
},
{
timestamp: 1649084741,
2022-04-08 06:47:59 +02:00
url: "./_img/place/1649084741.png",
2022-04-05 20:17:39 +02:00
image: null
},
2022-04-08 00:06:24 +02:00
{
timestamp: 1649113199,
2022-04-08 06:47:59 +02:00
url: "./_img/place/final.png",
2022-04-08 01:11:29 +02:00
image: null,
showAtlas: true,
2022-04-08 00:06:24 +02:00
},
2022-04-05 20:17:39 +02:00
];
let slider = document.getElementById("timeControlsSlider");
let image = document.getElementById("image");
2022-04-08 01:11:29 +02:00
let timeCallback = (a) => {};
let atlasBackup = [];
2022-04-05 20:17:39 +02:00
// SETUP
slider.max = timeConfig.length;
slider.value = timeConfig.length;
updateTime(timeConfig.length)
slider.oninput = (event) => {
updateTime(parseInt(event.target.value))
};
async function updateTime(index) {
let configObject = timeConfig[index-1];
if (!configObject.image) {
console.log("fetching");
let fetchResult = await fetch(configObject.url);
let imageBlob = await fetchResult.blob();
configObject.image = URL.createObjectURL(imageBlob);
}
image.src = configObject.image;
2022-04-08 01:11:29 +02:00
// TEMP ATLAS ONLY ON LAST TIMESTAMP
if (configObject.showAtlas) {
atlas = atlasBackup
} else {
atlas = []
}
timeCallback(atlas)
2022-04-05 20:17:39 +02:00
}