Chromium Code Reviews| OLD | NEW |
|---|---|
| 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'; |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 193 hostTableEntry.init(host, onRename, onDelete); | 193 hostTableEntry.init(host, onRename, onDelete); |
| 194 this.hostTableEntries_[i] = hostTableEntry; | 194 this.hostTableEntries_[i] = hostTableEntry; |
| 195 this.table_.appendChild(hostTableEntry.tableRow); | 195 this.table_.appendChild(hostTableEntry.tableRow); |
| 196 } | 196 } |
| 197 } | 197 } |
| 198 | 198 |
| 199 if (this.lastError_ != '') { | 199 if (this.lastError_ != '') { |
| 200 l10n.localizeElementFromTag(this.errorDiv_, this.lastError_); | 200 l10n.localizeElementFromTag(this.errorDiv_, this.lastError_); |
| 201 } | 201 } |
| 202 this.errorDiv_.hidden = (this.lastError_ == ''); | 202 this.errorDiv_.hidden = (this.lastError_ == ''); |
| 203 | |
| 204 this.showOrHide_(this.hosts_.length != 0 || this.lastError_ != ''); | |
| 205 }; | 203 }; |
| 206 | 204 |
| 207 /** | 205 /** |
| 208 * Show or hide the host-list UI. | |
|
Jamie
2012/03/29 01:38:13
This method was used to hide the Me2Me section if
| |
| 209 * | |
| 210 * @param {boolean} show True to show the UI, or false to hide it. | |
| 211 * @return {void} Nothing. | |
| 212 * @private | |
| 213 */ | |
| 214 remoting.HostList.prototype.showOrHide_ = function(show) { | |
| 215 var parent = /** @type {Element} */ (this.table_.parentNode); | |
| 216 parent.hidden = !show; | |
| 217 }; | |
| 218 | |
| 219 /** | |
| 220 * Remove a host from the list, and deregister it. | 206 * Remove a host from the list, and deregister it. |
| 221 * @param {remoting.HostTableEntry} hostTableEntry The host to be removed. | 207 * @param {remoting.HostTableEntry} hostTableEntry The host to be removed. |
| 222 * @return {void} Nothing. | 208 * @return {void} Nothing. |
| 223 * @private | 209 * @private |
| 224 */ | 210 */ |
| 225 remoting.HostList.prototype.deleteHost_ = function(hostTableEntry) { | 211 remoting.HostList.prototype.deleteHost_ = function(hostTableEntry) { |
| 226 this.table_.removeChild(hostTableEntry.tableRow); | 212 this.table_.removeChild(hostTableEntry.tableRow); |
| 227 var index = this.hostTableEntries_.indexOf(hostTableEntry); | 213 var index = this.hostTableEntries_.indexOf(hostTableEntry); |
| 228 if (index != -1) { | 214 if (index != -1) { |
| 229 this.hostTableEntries_.splice(index, 1); | 215 this.hostTableEntries_.splice(index, 1); |
| 230 } | 216 } |
| 231 | 217 |
| 232 /** @param {string} token The OAuth2 token. */ | 218 /** @param {string} token The OAuth2 token. */ |
| 233 var deleteHost = function(token) { | 219 var deleteHost = function(token) { |
| 234 var headers = { 'Authorization': 'OAuth ' + token }; | 220 var headers = { 'Authorization': 'OAuth ' + token }; |
| 235 remoting.xhr.remove( | 221 remoting.xhr.remove( |
| 236 'https://www.googleapis.com/chromoting/v1/@me/hosts/' + | 222 'https://www.googleapis.com/chromoting/v1/@me/hosts/' + |
| 237 hostTableEntry.host.hostId, | 223 hostTableEntry.host.hostId, |
| 238 function() {}, '', headers); | 224 function() {}, '', headers); |
| 239 } | 225 } |
| 240 remoting.oauth2.callWithToken(deleteHost); | 226 remoting.oauth2.callWithToken(deleteHost); |
| 241 | |
| 242 this.showOrHide_(this.hostTableEntries_.length != 0); | |
| 243 }; | 227 }; |
| 244 | 228 |
| 245 /** | 229 /** |
| 246 * Prepare a host for renaming by replacing its name with an edit box. | 230 * Prepare a host for renaming by replacing its name with an edit box. |
| 247 * @param {remoting.HostTableEntry} hostTableEntry The host to be renamed. | 231 * @param {remoting.HostTableEntry} hostTableEntry The host to be renamed. |
| 248 * @return {void} Nothing. | 232 * @return {void} Nothing. |
| 249 * @private | 233 * @private |
| 250 */ | 234 */ |
| 251 remoting.HostList.prototype.renameHost_ = function(hostTableEntry) { | 235 remoting.HostList.prototype.renameHost_ = function(hostTableEntry) { |
| 252 for (var i = 0; i < this.hosts_.length; ++i) { | 236 for (var i = 0; i < this.hosts_.length; ++i) { |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 279 remoting.oauth2.callWithToken(renameHost); | 263 remoting.oauth2.callWithToken(renameHost); |
| 280 }; | 264 }; |
| 281 | 265 |
| 282 /** | 266 /** |
| 283 * Key name under which Me2Me hosts are cached. | 267 * Key name under which Me2Me hosts are cached. |
| 284 */ | 268 */ |
| 285 remoting.HostList.HOSTS_KEY = 'me2me-cached-hosts'; | 269 remoting.HostList.HOSTS_KEY = 'me2me-cached-hosts'; |
| 286 | 270 |
| 287 /** @type {remoting.HostList} */ | 271 /** @type {remoting.HostList} */ |
| 288 remoting.hostList = null; | 272 remoting.hostList = null; |
| OLD | NEW |