forked from GoogleChrome/chrome-extensions-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
42 lines (37 loc) · 1.48 KB
/
popup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
function dumpDevices(devices) {
$('#deviceinfos').empty();
$('#deviceinfos').append(outputDevicesToList(devices));
}
function outputDevicesToList(devices) {
var table = $('<table border="1">');
table.append($("<tr>" +
"<th>" + "Name" + "</th>" +
"<th>" + "OS" + "</th>" +
"<th>" + "Id" + "</th>" +
"<th>" + "Type" + "</th>" +
"<th>" + "Chrome Version" + "</th>" +
"</tr>"));
for (i = 0; i < devices.length; i++) {
table.append($("<tr>" +
"<td>" + devices[i].name + "</td>" +
"<td>" + devices[i].os + "</td>" +
"<td>" + devices[i].id + "</td>" +
"<td>" + devices[i].type + "</td>" +
"<td>" + devices[i].chromeVersion + "</td>" +
"</tr>"));
}
return table;
}
// Add an event listener to listen for changes to device info. The
// callback would redisplay the list of devices.
chrome.signedInDevices.onDeviceInfoChange.addListener(dumpDevices);
function populateDevices() {
// Get the list of devices and display it.
chrome.signedInDevices.get(false, dumpDevices);
}
document.addEventListener('DOMContentLoaded', function () {
populateDevices();
});