demo: Use switch statement instead of branches
This commit is contained in:
parent
7343acf65b
commit
a2968e6ecb
|
@ -99,19 +99,21 @@ function load(options) {
|
||||||
for (const [key, value] of Object.entries(this.metadata)) {
|
for (const [key, value] of Object.entries(this.metadata)) {
|
||||||
const metadataElement = document.getElementById(key);
|
const metadataElement = document.getElementById(key);
|
||||||
if (metadataElement) {
|
if (metadataElement) {
|
||||||
if (key === "backgroundColor") {
|
switch (key) {
|
||||||
metadataElement.value = value ?? "#FFFFFF";
|
case "backgroundColor":
|
||||||
} else {
|
metadataElement.value = value ?? "#FFFFFF";
|
||||||
if (key === "swfVersion") {
|
break;
|
||||||
|
case "uncompressedLength":
|
||||||
|
metadataElement.textContent = `${value >> 10}Kb`;
|
||||||
|
break;
|
||||||
|
case "swfVersion":
|
||||||
document.getElementById(
|
document.getElementById(
|
||||||
"flashVersion"
|
"flashVersion"
|
||||||
).textContent = swfToFlashVersion[value];
|
).textContent = swfToFlashVersion[value];
|
||||||
}
|
// falls through and executes the default case as well
|
||||||
if (key === "uncompressedLength") {
|
default:
|
||||||
metadataElement.textContent = `${value >> 10}Kb`;
|
|
||||||
} else {
|
|
||||||
metadataElement.textContent = value;
|
metadataElement.textContent = value;
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue