-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Adding send message and on message functions * moving table displaying into a new function * updating rootCertStats from var to let * updating comments * Apply Linter change, unused const Co-authored-by: Rob Wu <[email protected]> --------- Co-authored-by: Rob Wu <[email protected]> Co-authored-by: rebloor <[email protected]>
- Loading branch information
1 parent
d5fee36
commit faadfca
Showing
2 changed files
with
38 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,37 @@ | ||
"use strict"; | ||
|
||
/* | ||
Get the background page to access the rootCertStats object | ||
Send message to the background page to get the rootCertStats object | ||
*/ | ||
const backgroundPage = browser.extension.getBackgroundPage(); | ||
browser.runtime.sendMessage({ action: "getRootCertStats" }, response => { | ||
displayTable(response.rootCertStats); | ||
}); | ||
|
||
let entries = Object.keys(backgroundPage.rootCertStats); | ||
|
||
/* | ||
If there are any stats, show the table, and append one row for each entry. | ||
Each row contains the name of the CA and the number of times it has been | ||
used as a trust root. | ||
*/ | ||
if (entries.length > 0) { | ||
|
||
let noData = document.querySelector(".no-data"); | ||
noData.classList.add("hidden"); | ||
let entryTable = document.querySelector(".root-cert-table"); | ||
entryTable.classList.remove("hidden"); | ||
|
||
for (let entry of entries) { | ||
let entryTR = document.createElement("tr"); | ||
let entryName = document.createElement("td"); | ||
let entryValue = document.createElement("td"); | ||
entryName.textContent = entry; | ||
entryValue.textContent = backgroundPage.rootCertStats[entry]; | ||
function displayTable(rootCertStats) { | ||
/* | ||
If there are any stats, show the table, and append one row for each entry. | ||
Each row contains the name of the CA and the number of times it has been | ||
used as a trust root. | ||
*/ | ||
let entries = Object.keys(rootCertStats); | ||
|
||
entryTR.appendChild(entryName); | ||
entryTR.appendChild(entryValue); | ||
entryTable.appendChild(entryTR); | ||
if (entries.length > 0) { | ||
let noData = document.querySelector(".no-data"); | ||
noData.classList.add("hidden"); | ||
let entryTable = document.querySelector(".root-cert-table"); | ||
entryTable.classList.remove("hidden"); | ||
|
||
for (let entry of entries) { | ||
let entryTR = document.createElement("tr"); | ||
let entryName = document.createElement("td"); | ||
let entryValue = document.createElement("td"); | ||
entryName.textContent = entry; | ||
entryValue.textContent = rootCertStats[entry]; | ||
|
||
entryTR.appendChild(entryName); | ||
entryTR.appendChild(entryValue); | ||
entryTable.appendChild(entryTR); | ||
} | ||
} | ||
} |