| <!DOCTYPE html> |
| <html> |
| <!-- |
| |
| Copyright (c) 2010 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. |
| |
| Central roster: hosting all Google Talk chats in ChromeOS. |
| |
| --> |
| <head> |
| <style> |
| .talk_roster { |
| position: fixed; |
| left: 0px; |
| top: 0px; |
| } |
| .talk_iframe { |
| width: 100%; |
| height: 100%; |
| border: none; |
| overflow: hidden; |
| } |
| body { |
| text-align: center; |
| } |
| </style> |
| <script> |
| var MIN_RETRY_MILLISECONDS = 1 * 1000; |
| var MAX_RETRY_MILLISECONDS = 4 * 60 * 1000; |
| var retryTime; |
| var retryTimer; |
| var chatClient = null; |
| |
| var args = { |
| 'protocol': 'https', |
| 'host': 'talkgadget.google.com', |
| 'jsmode': 'pre', |
| 'hl': chrome.i18n.getMessage('@@ui_locale'), |
| }; |
| |
| // Read args. |
| var urlParts = window.location.href.split(/[?&#]/); |
| for (var i = 1; i < urlParts.length; i++) { |
| var argParts = urlParts[i].split('='); |
| if (argParts.length == 2) { |
| args[argParts[0]] = argParts[1]; |
| } |
| } |
| var notifierScriptUrl = |
| args['protocol'] + '://' + args['host'] + |
| '/talkgadget/notifier-js?silent=true&host=' + |
| args['protocol'] + '://' + args['host'] + |
| '/talkgadget/notifier-js' + |
| (args['jsmode'] != '' ? ('&jsmode=' + args['jsmode']) : ''); |
| |
| function runGTalkScript() { |
| var script = document.createElement('script'); |
| script.src = notifierScriptUrl; |
| script.onload = loadGTalk; |
| script.onerror = loadGTalk; |
| document.body.appendChild(script); |
| } |
| function retryConnection() { |
| location.reload(); |
| } |
| function retryConnectionCountdown() { |
| var seconds = retryTime / 1000; |
| var minutes = Math.floor(seconds / 60); |
| seconds -= minutes * 60; |
| |
| document.getElementById('retryStatus').textContent = |
| chrome.i18n.getMessage('CHAT_MANAGER_RETRYING_IN', |
| [minutes, (seconds < 10 ? '0' : '') + seconds]); |
| |
| if (retryTime <= 0) { |
| retryConnection(); |
| } else { |
| retryTimer = setTimeout(retryConnectionCountdown, 1000); |
| retryTime -= 1000; |
| } |
| } |
| function loadGTalk() { |
| if (window.GTalkNotifier) { |
| document.getElementById('retryInfo').style.display = 'none'; |
| var baseUrl = args['protocol'] + '://' + args['host'] + '/talkgadget/'; |
| chatClient = new window.GTalkNotifier( |
| { |
| 'clientBaseUrl': baseUrl, |
| 'clientUrl': 'notifierclient' + |
| (args['jsmode'] != '' ? ('?jsmode=' + args['jsmode']) : ''), |
| 'propertyName': 'ChromeOS', |
| 'xpcRelay': baseUrl + 'xpc_relay', |
| 'xpcBlank': baseUrl + 'xpc_blank', |
| 'locale': args['hl'], |
| 'isCentralRoster': true, |
| 'hideProfileCard': true, |
| 'isFullFrame': true |
| } |
| ); |
| delete localStorage.retryStartTime; |
| } else { |
| if (!localStorage.retryStartTime) { |
| localStorage.retryStartTime = MIN_RETRY_MILLISECONDS; |
| } else if (localStorage.retryStartTime < MAX_RETRY_MILLISECONDS) { |
| localStorage.retryStartTime = Math.min(localStorage.retryStartTime * 2, |
| MAX_RETRY_MILLISECONDS); |
| } |
| retryTime = localStorage.retryStartTime; |
| document.getElementById('retryInfo').style.display = 'inline'; |
| retryConnectionCountdown(); |
| } |
| } |
| function onPageLoaded() { |
| // localize the page |
| document.getElementById('retryMessage').textContent = |
| chrome.i18n.getMessage('CHAT_MANAGER_COULD_NOT_CONNECT'); |
| document.getElementById('retryButton').value = |
| chrome.i18n.getMessage('CHAT_MANAGER_RETRY_NOW'); |
| |
| if (localStorage.hasOpenedInViewer) { |
| runGTalkScript(); |
| } |
| } |
| function onOpenedInViewer() { |
| if (!localStorage.hasOpenedInViewer) { |
| localStorage.hasOpenedInViewer = true; |
| runGTalkScript(); |
| } |
| } |
| </script> |
| </head> |
| <body onload='onPageLoaded()'> |
| <div id='retryInfo' style='display:none'> |
| <p id='retryMessage'></p> |
| <p id='retryStatus'></p> |
| <input id='retryButton' type='button' value='' onclick='retryConnection()'/> |
| </div> |
| </body> |
| </html> |