| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <script> | 3 <script src="popup.js"></script> |
| 4 // Shows an updating list of process statistics. | |
| 5 function init() { | |
| 6 chrome.experimental.processes.onUpdated.addListener(function(processes) { | |
| 7 var table = "<table>\n" + | |
| 8 "<tr><td><b>Process</b></td>" + | |
| 9 "<td>Type</td>" + | |
| 10 "<td>CPU</td>" + | |
| 11 "<td>Network</td>" + | |
| 12 "<td>Shared Memory</td>" + | |
| 13 "<td>Private Memory</td>" + | |
| 14 "</tr>\n"; | |
| 15 for (pid in processes) { | |
| 16 table = displayProcessInfo(processes[pid], table); | |
| 17 } | |
| 18 table += "</table>\n"; | |
| 19 var div = document.getElementById("process-list"); | |
| 20 div.innerHTML = table; | |
| 21 }); | |
| 22 } | |
| 23 | |
| 24 function displayProcessInfo(process, table) { | |
| 25 // Format network string like task manager | |
| 26 var network = process.network; | |
| 27 if (network > 1024) { | |
| 28 network = (network / 1024).toFixed(1) + " kB/s"; | |
| 29 } else if (network > 0) { | |
| 30 network += " B/s"; | |
| 31 } else if (network == -1) { | |
| 32 network = "N/A"; | |
| 33 } | |
| 34 | |
| 35 table += | |
| 36 "<tr><td>" + process.id + "</td>" + | |
| 37 "<td>" + process.type + "</td>" + | |
| 38 "<td>" + process.cpu + "</td>" + | |
| 39 "<td>" + network + "</td>" + | |
| 40 "<td>" + (process.sharedMemory / 1024) + "K</td>" + | |
| 41 "<td>" + (process.privateMemory / 1024) + "K</td>" + | |
| 42 "</tr>\n"; | |
| 43 return table; | |
| 44 } | |
| 45 </script> | |
| 46 <style> | 4 <style> |
| 47 body { | 5 body { |
| 48 overflow: hidden; | 6 overflow: hidden; |
| 49 margin: 0px; | 7 margin: 0px; |
| 50 padding: 0px; | 8 padding: 0px; |
| 51 background: white; | 9 background: white; |
| 52 } | 10 } |
| 53 | 11 |
| 54 div:first-child { | 12 div:first-child { |
| 55 margin-top: 0px; | 13 margin-top: 0px; |
| 56 } | 14 } |
| 57 | 15 |
| 58 div, td { | 16 div, td { |
| 59 padding: 1px 3px; | 17 padding: 1px 3px; |
| 60 font-family: sans-serif; | 18 font-family: sans-serif; |
| 61 font-size: 10pt; | 19 font-size: 10pt; |
| 62 margin-top: 1px; | 20 margin-top: 1px; |
| 63 } | 21 } |
| 64 </style> | 22 </style> |
| 65 </head> | 23 </head> |
| 66 <body onload="init()"> | 24 <body> |
| 67 <div id="title"><b>Process Monitor</b></div> | 25 <div id="title"><b>Process Monitor</b></div> |
| 68 <div id="process-list"><i>Loading...</i></div> | 26 <div id="process-list"><i>Loading...</i></div> |
| 69 </body> | 27 </body> |
| 70 </html> | 28 </html> |
| OLD | NEW |