Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Side by Side Diff: remoting/webapp/host_list.js

Issue 10703034: Remove 'Enable' button on unsupported platforms. Added 'No hosts' message. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Split 'no hosts' message into two sentences and display the second only if hosting is not supported. Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * Class representing the host-list portion of the home screen UI. 7 * Class representing the host-list portion of the home screen UI.
8 */ 8 */
9 9
10 'use strict'; 10 'use strict';
11 11
12 /** @suppress {duplicate} */ 12 /** @suppress {duplicate} */
13 var remoting = remoting || {}; 13 var remoting = remoting || {};
14 14
15 /** 15 /**
16 * Create a host list consisting of the specified HTML elements, which should 16 * Create a host list consisting of the specified HTML elements, which should
17 * have a common parent that contains only host-list UI as it will be hidden 17 * have a common parent that contains only host-list UI as it will be hidden
18 * if the host-list is empty. 18 * if the host-list is empty.
19 * 19 *
20 * @constructor 20 * @constructor
21 * @param {Element} table The HTML <table> to contain host-list. 21 * @param {Element} table The HTML <div> to contain host-list.
22 * @param {Element} noHosts The HTML <div> containing the "no hosts" message.
22 * @param {Element} errorMsg The HTML <div> to display error messages. 23 * @param {Element} errorMsg The HTML <div> to display error messages.
23 * @param {Element} errorButton The HTML <button> to display the error 24 * @param {Element} errorButton The HTML <button> to display the error
24 * resolution action. 25 * resolution action.
25 */ 26 */
26 remoting.HostList = function(table, errorMsg, errorButton) { 27 remoting.HostList = function(table, noHosts, errorMsg, errorButton) {
27 /** 28 /**
28 * @type {Element} 29 * @type {Element}
29 * @private 30 * @private
30 */ 31 */
31 this.table_ = table; 32 this.table_ = table;
32 /** 33 /**
33 * @type {Element} 34 * @type {Element}
34 * @private 35 * @private
36 * TODO(jamiewalch): This should be doable using CSS's sibling selector,
37 * but it doesn't work right now (crbug.com/135050).
38 */
39 this.noHosts_ = noHosts;
40 /**
41 * @type {Element}
42 * @private
35 */ 43 */
36 this.errorMsg_ = errorMsg; 44 this.errorMsg_ = errorMsg;
37 /** 45 /**
38 * @type {Element} 46 * @type {Element}
39 * @private 47 * @private
40 */ 48 */
41 this.errorButton_ = errorButton; 49 this.errorButton_ = errorButton;
42 /** 50 /**
43 * @type {Array.<remoting.HostTableEntry>} 51 * @type {Array.<remoting.HostTableEntry>}
44 * @private 52 * @private
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 * Display the list of hosts or error condition. 186 * Display the list of hosts or error condition.
179 * 187 *
180 * @param {string?} thisHostId The id of this host, or null if not registered. 188 * @param {string?} thisHostId The id of this host, or null if not registered.
181 * @return {void} Nothing. 189 * @return {void} Nothing.
182 */ 190 */
183 remoting.HostList.prototype.display = function(thisHostId) { 191 remoting.HostList.prototype.display = function(thisHostId) {
184 this.table_.innerText = ''; 192 this.table_.innerText = '';
185 this.errorMsg_.innerText = ''; 193 this.errorMsg_.innerText = '';
186 this.hostTableEntries_ = []; 194 this.hostTableEntries_ = [];
187 195
188 this.table_.hidden = (this.hosts_.length == 0); 196 var noHostsRegistered = (this.hosts_.length == 0);
197 this.table_.hidden = noHostsRegistered;
198 this.noHosts_.hidden = !noHostsRegistered;
189 199
190 for (var i = 0; i < this.hosts_.length; ++i) { 200 for (var i = 0; i < this.hosts_.length; ++i) {
191 /** @type {remoting.Host} */ 201 /** @type {remoting.Host} */
192 var host = this.hosts_[i]; 202 var host = this.hosts_[i];
193 // Validate the entry to make sure it has all the fields we expect and is 203 // Validate the entry to make sure it has all the fields we expect and is
194 // not the local host (which is displayed separately). NB: if the host has 204 // not the local host (which is displayed separately). NB: if the host has
195 // never sent a heartbeat, then there will be no jabberId. 205 // never sent a heartbeat, then there will be no jabberId.
196 if (host.hostName && host.hostId && host.status && host.publicKey && 206 if (host.hostName && host.hostId && host.status && host.publicKey &&
197 host.hostId != thisHostId) { 207 host.hostId != thisHostId) {
198 var hostTableEntry = new remoting.HostTableEntry(); 208 var hostTableEntry = new remoting.HostTableEntry();
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 } 327 }
318 } 328 }
319 329
320 /** 330 /**
321 * Key name under which Me2Me hosts are cached. 331 * Key name under which Me2Me hosts are cached.
322 */ 332 */
323 remoting.HostList.HOSTS_KEY = 'me2me-cached-hosts'; 333 remoting.HostList.HOSTS_KEY = 'me2me-cached-hosts';
324 334
325 /** @type {remoting.HostList} */ 335 /** @type {remoting.HostList} */
326 remoting.hostList = null; 336 remoting.hostList = null;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698