| Index: chrome/browser/resources/local_discovery/local_discovery.js
|
| diff --git a/chrome/browser/resources/local_discovery/local_discovery.js b/chrome/browser/resources/local_discovery/local_discovery.js
|
| index 1ef4eb18253a7a0b1935bf65acea6f9e38f663e4..01ac725ba3750faa4fbc7a1d4000adfff8473022 100644
|
| --- a/chrome/browser/resources/local_discovery/local_discovery.js
|
| +++ b/chrome/browser/resources/local_discovery/local_discovery.js
|
| @@ -14,7 +14,7 @@
|
| * Appends a row to the output table listing the new device.
|
| * @param {string} name of the device service.
|
| * @param {string} info - additional info of the device,
|
| - * if empty device need to be deleted
|
| + * if empty device need to be deleted.
|
| */
|
| function onServiceUpdate(name, info) {
|
| var table = $('devices-table');
|
| @@ -26,7 +26,6 @@ function onServiceUpdate(name, info) {
|
| params[2] = info.ip;
|
| params[3] = info.metadata;
|
| params[4] = info.lastSeen;
|
| - params[5] = info.registered;
|
| }
|
|
|
| for (var i = 0, row; row = table.rows[i]; i++) {
|
| @@ -60,5 +59,55 @@ function onServiceUpdate(name, info) {
|
| tr.appendChild(td);
|
| }
|
|
|
| + td = document.createElement('td');
|
| + if (!info.registered) {
|
| + var button = document.createElement('button');
|
| + button.textContent = 'Register';
|
| + button.addEventListener('click', sendRegisterDevice.bind(null, name));
|
| + td.appendChild(button);
|
| + } else {
|
| + td.textContent = 'Registered';
|
| + }
|
| + tr.appendChild(td);
|
| +
|
| table.appendChild(tr);
|
| }
|
| +
|
| +/**
|
| + * Adds a row to the logging console.
|
| + * @param {string} msg The message to log.
|
| + */
|
| +function logToInfoConsole(msg) {
|
| + var div = document.createElement('div');
|
| + div.textContent = msg;
|
| + $('infoConsole').appendChild(div);
|
| +}
|
| +
|
| +/**
|
| + * Register a device.
|
| + * @param {string} device The device to register.
|
| + */
|
| +function sendRegisterDevice(device) {
|
| + chrome.send('register', [device]);
|
| + logToInfoConsole('Registering ' + device + '...');
|
| +}
|
| +
|
| +/**
|
| + * Announce that a registration failed.
|
| + * @param {string} reason The error message.
|
| + */
|
| +function registrationFailed(reason) {
|
| + logToInfoConsole('Registration failed: ' + reason);
|
| +}
|
| +
|
| +/**
|
| + * Announce that a registration succeeeded.
|
| + * @param {string} id The id of the newly registered device.
|
| + */
|
| +function registrationSuccess(id) {
|
| + logToInfoConsole('Registered as ' + id);
|
| +}
|
| +
|
| +document.addEventListener('DOMContentLoaded', function() {
|
| + chrome.send('start');
|
| +});
|
|
|