viewer: switch to modern fetch API, do not cache metadata and entity files

This commit is contained in:
Matthias Schiffer 2024-01-07 20:49:36 +01:00
parent 3d024c6cd8
commit 643035eaed
Signed by: neocturne
GPG key ID: 16EF3F64CB201D9C

View file

@ -284,10 +284,10 @@ function createSign(sign, back) {
return wrapper;
}
function loadSigns(signLayer) {
const xhr = new XMLHttpRequest();
xhr.onload = function () {
const res = JSON.parse(this.responseText);
async function loadSigns(signLayer) {
const response = await fetch('data/entities.json', {cache: 'no-store'});
const res = await response.json();
const groups = {};
// Group signs by x,z coordinates
@ -343,17 +343,12 @@ function loadSigns(signLayer) {
}
}
xhr.open('GET', 'data/entities.json', true);
xhr.send();
}
window.createMap = function () {
const xhr = new XMLHttpRequest();
xhr.onload = function () {
const res = JSON.parse(this.responseText),
mipmaps = res.mipmaps,
spawn = res.spawn,
features = res.features || {};
(async function () {
const response = await fetch('data/info.json', {cache: 'no-store'});
const res = await response.json();
const {mipmaps, spawn} = res;
const features = res.features || {};
const updateParams = function () {
const args = parseHash();
@ -489,8 +484,5 @@ window.createMap = function () {
updateHash();
};
};
xhr.open('GET', 'data/info.json', true);
xhr.send();
})();
}