update with map
This commit is contained in:
parent
d7e5eb3994
commit
b959a6b047
|
|
@ -12,26 +12,31 @@ for (let elementName in elements) {
|
||||||
}
|
}
|
||||||
|
|
||||||
runAfterLoad(function() {
|
runAfterLoad(function() {
|
||||||
for (let i = 0; i < enabledMods.length; i++) {
|
let modDescriptions = {};
|
||||||
let mod = enabledMods[i];
|
|
||||||
|
|
||||||
fetch(mod)
|
let fetchPromises = enabledMods.map(mod => {
|
||||||
|
return fetch(mod)
|
||||||
.then(response => response.text())
|
.then(response => response.text())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
console.log(`Loaded mod: ${mod}`);
|
console.log(`Loaded mod: ${mod}`);
|
||||||
|
modDescriptions[mod] = data;
|
||||||
Object.keys(elements).forEach(function(elementName) {
|
|
||||||
let element = elements[elementName];
|
|
||||||
|
|
||||||
if (element.desc && typeof element.desc === 'string' && element.desc.trim() !== '') {
|
|
||||||
if (!element.desc.includes("This Element is from")) {
|
|
||||||
element.desc += `\nThis Element is from ${mod}`;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
element.desc = `This Element is from ${mod}`;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})
|
})
|
||||||
.catch(error => console.error('Error fetching the mod file: ', error));
|
.catch(error => console.error('Error fetching the mod file: ', error));
|
||||||
}
|
});
|
||||||
|
|
||||||
|
Promise.all(fetchPromises).then(() => {
|
||||||
|
Object.keys(elements).forEach(function(elementName) {
|
||||||
|
let element = elements[elementName];
|
||||||
|
|
||||||
|
for (let mod of enabledMods) {
|
||||||
|
if (element.desc && typeof element.desc === 'string' && element.desc.trim() !== '') {
|
||||||
|
if (!element.desc.includes("This Element is from")) {
|
||||||
|
element.desc += `\nThis Element is from ${mod}`;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
element.desc = `This Element is from ${mod}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue