1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
<!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>
|