improve handling of removed data

This commit is contained in:
buzz-lightsnack-2007 2024-05-06 10:27:51 +08:00
parent ecde00943a
commit 6f0da62ad5

View file

@ -41,7 +41,7 @@ class Page_Results extends Page {
} }
// Set the data. // Set the data.
this[`data`] = (DATA[`data`]) ? DATA[`data`] : (this[`data`] ? this[`data`] : {}); this[`data`] = ((DATA[`data`] != null) && !((typeof DATA[`data`]).includes(`undef`))) ? (DATA[`data`]) : (this[`data`] ? this[`data`] : {});
} }
async content() { async content() {
@ -78,7 +78,7 @@ class Page_Results extends Page {
Populate the contents. Populate the contents.
*/ */
async fill() { async fill() {
(this.elements) (this.elements && !((typeof this.elements).includes(`undef`)))
? (Object.keys(this.elements)).forEach(async (SOURCE) => { ? (Object.keys(this.elements)).forEach(async (SOURCE) => {
if (SOURCE.indexOf(`*`) < SOURCE.length - 1) { if (SOURCE.indexOf(`*`) < SOURCE.length - 1) {
let DATA = (nested.dictionary.get(this[`data`][`analysis`], SOURCE)); let DATA = (nested.dictionary.get(this[`data`][`analysis`], SOURCE));
@ -100,7 +100,7 @@ class Page_Results extends Page {
"body": "p" "body": "p"
}; };
(Object.keys(DATA)).forEach((ITEM) => { (DATA) ? (Object.keys(DATA)).forEach((ITEM) => {
let ELEMENTS = {}; let ELEMENTS = {};
// Create the elements. // Create the elements.
@ -124,13 +124,16 @@ class Page_Results extends Page {
}); });
ELEMENTS[`container`].appendChild(ELEMENTS[`content`]); ELEMENTS[`container`].appendChild(ELEMENTS[`content`]);
this.elements[SOURCE].appendChild(ELEMENTS[`container`]); this.elements[SOURCE].appendChild(ELEMENTS[`container`]);
}) }) : false;
} }
}) })
: false; : false;
// Set the color. // Set the color.
(nested.dictionary.get(this[`data`][`analysis`], [`Rating`, `Trust`]) && document.querySelector(`summary`)) ? document.querySelector(`summary`).setAttribute(`result`, (nested.dictionary.get(this[`data`][`analysis`], [`Rating`, `Trust`]))) : false; (nested.dictionary.get(this[`data`][`analysis`], [`Rating`, `Trust`]) && document.querySelector(`summary`)) ? document.querySelector(`summary`).setAttribute(`result`, (nested.dictionary.get(this[`data`][`analysis`], [`Rating`, `Trust`]))) : false;
// Display the results in the console.
console.log(this[`data`][`analysis`])
}; };
} }