Display the aspects and do not rely on removed data
This commit is contained in:
parent
8fb4e3189d
commit
ce0a50837d
1 changed files with 56 additions and 7 deletions
|
@ -52,36 +52,85 @@ class Page_Results extends Page {
|
||||||
let PROPERTY = ELEMENT.getAttribute(`data-active-result`).trim();
|
let PROPERTY = ELEMENT.getAttribute(`data-active-result`).trim();
|
||||||
this.elements[PROPERTY] = ELEMENT;
|
this.elements[PROPERTY] = ELEMENT;
|
||||||
|
|
||||||
|
// Copy the expected type of sub-elements, if any.
|
||||||
|
if (ELEMENT.getAttribute(`data-active-result-type`)) {
|
||||||
|
this.elements[PROPERTY][`target element type`] = ELEMENT.getAttribute(`data-active-result-type`).trim();
|
||||||
|
ELEMENT.removeAttribute(`data-active-result-type`);
|
||||||
|
};
|
||||||
|
|
||||||
// Remove the construction data active result.
|
// Remove the construction data active result.
|
||||||
ELEMENT.removeAttribute(`data-active-result`);
|
ELEMENT.removeAttribute(`data-active-result`);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.update();
|
await this.update();
|
||||||
this.fill();
|
this.fill();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Resize the window to fit the content.
|
||||||
|
*/
|
||||||
|
async resize() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Populate the contents.
|
Populate the contents.
|
||||||
*/
|
*/
|
||||||
async fill() {
|
async fill() {
|
||||||
(this.elements)
|
(this.elements)
|
||||||
? (Object.keys(this.elements)).forEach(async (SOURCE) => {
|
? (Object.keys(this.elements)).forEach(async (SOURCE) => {
|
||||||
if (SOURCE.includes(`*`)) {
|
if (SOURCE.indexOf(`*`) < SOURCE.length - 1) {
|
||||||
let DATA = (nested.dictionary.get(this[`data`][`analysis`], SOURCE));
|
let DATA = (nested.dictionary.get(this[`data`][`analysis`], SOURCE));
|
||||||
|
|
||||||
this.elements[SOURCE][(this.elements[SOURCE].nodeName.toLowerCase().includes(`input`) || this.elements[SOURCE].nodeName.toLowerCase().includes(`progress`)) ? `value` : `innerHTML`] = (DATA)
|
this.elements[SOURCE][(this.elements[SOURCE].nodeName.toLowerCase().includes(`input`) || this.elements[SOURCE].nodeName.toLowerCase().includes(`progress`)) ? `value` : `innerHTML`] = (DATA)
|
||||||
? (((typeof DATA).includes(`obj`) && !Array.isArray(DATA))
|
? (((typeof DATA).includes(`obj`) && !Array.isArray(DATA))
|
||||||
? JSON.stringify(DATA)
|
? JSON.stringify(DATA)
|
||||||
: String(DATA))
|
: String(DATA))
|
||||||
: null;
|
: null;
|
||||||
} else {
|
} else if (SOURCE.indexOf(`*`) >= SOURCE.length - 1) {
|
||||||
|
let DATA = (nested.dictionary.get(this[`data`][`analysis`], SOURCE.split(`,`).slice(0, -1)));
|
||||||
}
|
|
||||||
|
|
||||||
|
(!Array.isArray(DATA) && (typeof DATA).includes(`obj`) && DATA != null)
|
||||||
|
|
||||||
|
let ELEMENT_TYPES = {
|
||||||
|
"container": "section",
|
||||||
|
"content": "article",
|
||||||
|
"title": "p",
|
||||||
|
"body": "p"
|
||||||
|
};
|
||||||
|
|
||||||
|
(Object.keys(DATA)).forEach((ITEM) => {
|
||||||
|
let ELEMENTS = {};
|
||||||
|
|
||||||
|
// Create the elements.
|
||||||
|
(Object.keys(ELEMENT_TYPES)).forEach((TYPE) => {
|
||||||
|
ELEMENTS[TYPE] = document.createElement(ELEMENT_TYPES[TYPE]);
|
||||||
|
|
||||||
|
(([`content`, `action`, `title`].includes(TYPE) || TYPE.includes(`container`)) && this.elements[SOURCE][`target element type`])
|
||||||
|
? ELEMENTS[TYPE].classList.add(this.elements[SOURCE][`target element type`].concat((!TYPE.includes(`container`))
|
||||||
|
? `-${TYPE}`
|
||||||
|
: ``))
|
||||||
|
: false;
|
||||||
|
});
|
||||||
|
|
||||||
|
ELEMENTS[`title`].innerText = String(ITEM).trim();
|
||||||
|
ELEMENTS[`title`].classList.add(`flow-text`);
|
||||||
|
ELEMENTS[`body`].innerText = String(DATA[ITEM]).trim();
|
||||||
|
|
||||||
|
// Inject the elements.
|
||||||
|
[`title`, `body`].forEach((CONTENT) => {
|
||||||
|
ELEMENTS[`content`].appendChild(ELEMENTS[CONTENT]);
|
||||||
|
});
|
||||||
|
ELEMENTS[`container`].appendChild(ELEMENTS[`content`]);
|
||||||
|
this.elements[SOURCE].appendChild(ELEMENTS[`container`]);
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
: false;
|
: false;
|
||||||
|
|
||||||
|
// 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;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue