Skip to content

Commit 3f68cc4

Browse files
committed
Summary points are now ordered; Bad, Neutral, Good. (#2)
1 parent 93022e0 commit 3f68cc4

File tree

1 file changed

+31
-18
lines changed

1 file changed

+31
-18
lines changed

popup.js

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -976,25 +976,38 @@ function initPopup() {
976976
}
977977

978978
if (clonedSibling.tagName === 'UL' && clonedHeader.id.includes("implications")) {
979+
const badItems = [];
980+
const neutralItems = [];
981+
const goodItems = [];
982+
979983
Array.from(clonedSibling.children).forEach((li) => {
980-
let iconSrc;
981-
switch (li.className) {
982-
case 'good':
983-
iconSrc = "good.png";
984-
break;
985-
case 'bad':
986-
iconSrc = "bad.png";
987-
break;
988-
default:
989-
iconSrc = "neutral.png";
990-
break;
991-
}
992-
let iconImg = document.createElement('img');
993-
iconImg.src = iconSrc;
994-
iconImg.alt = li.className;
995-
iconImg.style.marginRight = "8px"; // Add some spacing between icon and text
996-
iconImg.classList.add('w-5', 'h-5', 'mb-auto'); // Add the classes to the icon
997-
li.insertBefore(iconImg, li.firstChild);
984+
let iconSrc;
985+
switch (li.className) {
986+
case 'good':
987+
iconSrc = "good.png";
988+
goodItems.push(li); // Add to good items
989+
break;
990+
case 'bad':
991+
iconSrc = "bad.png";
992+
badItems.push(li); // Add to bad items
993+
break;
994+
default:
995+
iconSrc = "neutral.png";
996+
neutralItems.push(li); // Add to neutral items
997+
break;
998+
}
999+
let iconImg = document.createElement('img');
1000+
iconImg.src = iconSrc;
1001+
iconImg.alt = li.className;
1002+
iconImg.style.marginRight = "8px"; // Add some spacing between icon and text
1003+
iconImg.classList.add('w-5', 'h-5', 'mb-auto'); // Add the classes to the icon
1004+
li.insertBefore(iconImg, li.firstChild);
1005+
});
1006+
1007+
clonedSibling.innerHTML = '';
1008+
1009+
[...badItems, ...neutralItems, ...goodItems].forEach(item => {
1010+
clonedSibling.appendChild(item);
9981011
});
9991012
}
10001013
policyDiv.appendChild(clonedSibling);

0 commit comments

Comments
 (0)