attempt: fixed trash data being loaded anyway

This commit is contained in:
buzz-lightsnack-2007 2024-05-07 11:50:53 +08:00
parent 2a4e60420d
commit 44f0bf9420

View file

@ -35,13 +35,15 @@ class Page_Results extends Page {
// Set the reference website when overriding or unset. // Set the reference website when overriding or unset.
if (override || !this[`ref`]) {this[`ref`] = await global.read([`last`])}; if (override || !this[`ref`]) {this[`ref`] = await global.read([`last`])};
if (this[`ref`]) {
// Get all the data. // Get all the data.
let DATA = { let DATA = {
"data": await global.read([`sites`, this[`ref`]]) "data": await global.read([`sites`, this[`ref`]])
} }
// Set the data. // Set the data.
this[`data`] = (DATA[`data`]) ? DATA[`data`] : (this[`data`] ? this[`data`] : {}); this[`data`] = (DATA[`data`] && (typeof DATA[`data`]).includes(`obj`)) ? DATA[`data`] : (this[`data`] ? this[`data`] : {});
}
} }
async content() { async content() {
@ -78,6 +80,7 @@ class Page_Results extends Page {
Populate the contents. Populate the contents.
*/ */
async fill() { async fill() {
if (this.data) {
(this.elements) (this.elements)
? (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) {
@ -100,7 +103,8 @@ 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.
@ -125,12 +129,14 @@ 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;
}
}; };
} }