demo: Use Object.entries for simpler code

This commit is contained in:
Daniel Jacobs 2022-08-03 12:17:21 -04:00 committed by Mike Welsh
parent 9bd1a8c940
commit 86f0813a79
1 changed files with 12 additions and 14 deletions

View File

@ -96,29 +96,27 @@ function load(options) {
player.load(options); player.load(options);
player.addEventListener("loadedmetadata", function () { player.addEventListener("loadedmetadata", function () {
if (this.metadata) { if (this.metadata) {
Object.keys(this.metadata).forEach((el) => { for (const [key, value] of Object.entries(this.metadata)) {
const metadataElement = document.getElementById(el); const metadataElement = document.getElementById(key);
if (metadataElement) { if (metadataElement) {
if (el === "backgroundColor") { if (key === "backgroundColor") {
metadataElement.value = this.metadata[el] ?? "#FFFFFF"; metadataElement.value = value ?? "#FFFFFF";
} else { } else {
if (el === "swfVersion") { if (key === "swfVersion") {
document.getElementById( document.getElementById(
"flashVersion" "flashVersion"
).textContent = ).textContent = swfToFlashVersion[value];
swfToFlashVersion[this.metadata[el]];
} }
if (el === "uncompressedLength") { if (key === "uncompressedLength") {
metadataElement.textContent = metadataElement.textContent = `${Math.round(
`${Math.round(this.metadata[el] / 1024)}Kb` ?? value / 1024
"?"; )}Kb`;
} else { } else {
metadataElement.textContent = metadataElement.textContent = value;
this.metadata[el] ?? "?"; }
} }
} }
} }
});
} }
}); });
} }