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

Side by Side Diff: remoting/webapp/me2mom/client_screen.js

Issue 8511077: Fixed css to make host list prettier. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 * Functions related to the 'client screen' for Chromoting. 7 * Functions related to the 'client screen' for Chromoting.
8 */ 8 */
9 9
10 'use strict'; 10 'use strict';
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 } else { 457 } else {
458 remoting.debug.log('Error response: ' + xhr.responseText); 458 remoting.debug.log('Error response: ' + xhr.responseText);
459 } 459 }
460 460
461 // If the error is unlikely to be recoverable then notify the user. 461 // If the error is unlikely to be recoverable then notify the user.
462 if (xhr.status >= 400 && xhr.status <= 499) { 462 if (xhr.status >= 400 && xhr.status <= 499) {
463 // TODO(wez): We need to replace this with a more general showError_(). 463 // TODO(wez): We need to replace this with a more general showError_().
464 showConnectError_(remoting.Error.GENERIC); 464 showConnectError_(remoting.Error.GENERIC);
465 } 465 }
466 } 466 }
467 } catch(er) { 467 } catch (er) {
468 // Error parsing response... 468 console.error('Error processing response: ', xhr);
Wez 2011/11/12 01:12:42 You don't want this showing in the debug log?
Jamie 2011/11/14 18:28:16 TBH, I'm doubting the value of the debug log. cons
469 remoting.debug.log('Error: Error processing response: "' +
470 xhr.status + ' ' + xhr.statusText);
471 remoting.debug.log(xhr.responseText);
472 } 469 }
473 } 470 }
474 471
475 /** 472 /**
476 * Cache of the latest host list and status information. 473 * Cache of the latest host list and status information.
477 * 474 *
478 * @type {Array.<{hostName: string, hostId: string, status: string, 475 * @type {Array.<{hostName: string, hostId: string, status: string,
479 * jabberId: string, publicKey: string}>} 476 * jabberId: string, publicKey: string}>}
480 * 477 *
481 */ 478 */
482 remoting.hostList_ = new Array(); 479 remoting.hostList_ = new Array();
483 480
484 /** 481 /**
485 * Refresh the host list display with up to date host details. 482 * Refresh the host list display with up to date host details.
486 * 483 *
487 * @param {Array.<{hostName: string, hostId: string, status: string, 484 * @param {Array.<{hostName: string, hostId: string, status: string,
488 * jabberId: string, publicKey: string}>} hostList 485 * jabberId: string, publicKey: string}>} hostList
489 * The new list of registered hosts. 486 * The new list of registered hosts.
490 * @return {void} Nothing. 487 * @return {void} Nothing.
491 */ 488 */
492 function replaceHostList_(hostList) { 489 function replaceHostList_(hostList) {
493 var hostListDiv = document.getElementById('host-list-div'); 490 var hostListDiv = document.getElementById('host-list-div');
494 var hostListTable = document.getElementById('host-list'); 491 var hostListTable = document.getElementById('host-list');
495 492
496 remoting.hostList_ = hostList; 493 remoting.hostList_ = hostList;
497 494
498 // Clear the table before adding the host info. 495 // Clear the table before adding the host info.
499 hostListTable.innerHTML = ''; 496 hostListTable.innerHTML = '';
500 497
501 // Show/hide the div depending on whether there are hosts to list.
502 hostListDiv.hidden = (hostList.length == 0);
503
504 for (var i = 0; i < hostList.length; ++i) { 498 for (var i = 0; i < hostList.length; ++i) {
505 var host = hostList[i]; 499 var host = hostList[i];
506 if (!host.hostName || !host.hostId || !host.status || !host.jabberId || 500 if (!host.hostName || !host.hostId || !host.status || !host.jabberId ||
507 !host.publicKey) 501 !host.publicKey)
508 continue; 502 continue;
509 var hostEntry = document.createElement('tr'); 503 var hostEntry = document.createElement('tr');
504 addClass(hostEntry, 'host-list-row');
505
506 var hostIcon = document.createElement('td');
507 var hostIconImage = document.createElement('img');
508 hostIconImage.src = 'icon_host.png';
509 hostIcon.className = 'host-list-row-start';
510 hostIcon.appendChild(hostIconImage);
511 hostEntry.appendChild(hostIcon);
510 512
511 var hostName = document.createElement('td'); 513 var hostName = document.createElement('td');
512 hostName.setAttribute('class', 'mode-select-label'); 514 hostName.setAttribute('class', 'mode-select-label');
513 hostName.appendChild(document.createTextNode(host.hostName)); 515 hostName.appendChild(document.createTextNode(host.hostName));
514 hostEntry.appendChild(hostName); 516 hostEntry.appendChild(hostName);
515 517
516 var hostStatus = document.createElement('td'); 518 var hostStatus = document.createElement('td');
517 if (host.status == 'ONLINE') { 519 if (host.status == 'ONLINE') {
518 var connectButton = document.createElement('button'); 520 var connectButton = document.createElement('button');
519 connectButton.setAttribute('class', 'mode-select-button'); 521 connectButton.setAttribute('class', 'mode-select-button');
520 connectButton.setAttribute('type', 'button'); 522 connectButton.setAttribute('type', 'button');
521 connectButton.setAttribute('onclick', 523 connectButton.setAttribute('onclick',
522 'remoting.connectHost("'+host.hostId+'")'); 524 'remoting.connectHost("'+host.hostId+'")');
523 connectButton.innerHTML = 525 connectButton.innerHTML =
524 chrome.i18n.getMessage(/*i18n-content*/'CONNECT_BUTTON'); 526 chrome.i18n.getMessage(/*i18n-content*/'CONNECT_BUTTON');
525 hostStatus.appendChild(connectButton); 527 hostStatus.appendChild(connectButton);
526 } else { 528 } else {
529 addClass(hostEntry, 'host-offline');
527 hostStatus.innerHTML = chrome.i18n.getMessage(/*i18n-content*/'OFFLINE'); 530 hostStatus.innerHTML = chrome.i18n.getMessage(/*i18n-content*/'OFFLINE');
528 } 531 }
532 hostStatus.className = 'host-list-row-end';
529 hostEntry.appendChild(hostStatus); 533 hostEntry.appendChild(hostStatus);
530 534
531 hostListTable.appendChild(hostEntry); 535 hostListTable.appendChild(hostEntry);
532 } 536 }
537
538 // Show/hide the div depending on whether there are hosts to list.
539 hostListDiv.hidden = (hostList.length == 0);
540 if (hostList.length == 0) {
541 addClass(hostListDiv, 'collapsed');
542 } else {
543 hostListDiv.style.height = hostListDiv.scrollHeight + 'px';
544 removeClass(hostListDiv, 'collapsed');
545 }
546
533 } 547 }
534 548
535 /** 549 /**
536 * Start a connection to the specified host, using the stored details. 550 * Start a connection to the specified host, using the stored details.
537 * 551 *
538 * @param {string} hostId The Id of the host to connect to. 552 * @param {string} hostId The Id of the host to connect to.
539 * @return {void} Nothing. 553 * @return {void} Nothing.
540 */ 554 */
541 remoting.connectHost = function(hostId) { 555 remoting.connectHost = function(hostId) {
542 var hostList = remoting.hostList_; 556 var hostList = remoting.hostList_;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 var createPluginAndConnect = function(token) { 597 var createPluginAndConnect = function(token) {
584 remoting.clientSession.createPluginAndConnect( 598 remoting.clientSession.createPluginAndConnect(
585 document.getElementById('session-mode'), 599 document.getElementById('session-mode'),
586 token); 600 token);
587 }; 601 };
588 602
589 remoting.setMode(remoting.AppMode.CLIENT_CONNECTING); 603 remoting.setMode(remoting.AppMode.CLIENT_CONNECTING);
590 remoting.oauth2.callWithToken(createPluginAndConnect); 604 remoting.oauth2.callWithToken(createPluginAndConnect);
591 } 605 }
592 606
593 // Don't delete this!
594 }()); 607 }());
OLDNEW
« remoting/webapp/me2mom/choice.html ('K') | « remoting/webapp/me2mom/choice.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698