mirror of
https://github.com/fergalmoran/chrometophone.git
synced 2026-01-03 07:25:50 +00:00
Reinstate signed in message.
Fix multiple attempted reconnects issue.
This commit is contained in:
@@ -38,6 +38,10 @@ body, td {
|
|||||||
if (oauth.hasToken()) {
|
if (oauth.hasToken()) {
|
||||||
document.getElementById('sign_in_out_div').innerHTML =
|
document.getElementById('sign_in_out_div').innerHTML =
|
||||||
'<a href="help.html" onclick="chrome.extension.getBackgroundPage().closeBrowserChannel(); oauth.clearTokens()">' + chrome.i18n.getMessage('sign_out_message');
|
'<a href="help.html" onclick="chrome.extension.getBackgroundPage().closeBrowserChannel(); oauth.clearTokens()">' + chrome.i18n.getMessage('sign_out_message');
|
||||||
|
if (document.location.hash == '#just_signed_in') {
|
||||||
|
document.getElementById('just_signed_in_div').innerHTML = '<p><b><font color="#00A000">' +
|
||||||
|
chrome.i18n.getMessage('signed_in_message') + '</font></b></p>';
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
var sign_in_message = chrome.i18n.getMessage('sign_in_message');
|
var sign_in_message = chrome.i18n.getMessage('sign_in_message');
|
||||||
sign_in_message = sign_in_message.substring(0, 1).toUpperCase() + sign_in_message.substring(1); // TODO: Get a new title case string translated
|
sign_in_message = sign_in_message.substring(0, 1).toUpperCase() + sign_in_message.substring(1); // TODO: Get a new title case string translated
|
||||||
@@ -53,6 +57,8 @@ body, td {
|
|||||||
<b><div id="msg"></div></b><a id="signout" href="#" style="color: gray;"></a></p>
|
<b><div id="msg"></div></b><a id="signout" href="#" style="color: gray;"></a></p>
|
||||||
<h1><img src="icon_128.png" width="64" height="64" valign="bottom"> Google Chrome to Phone Extension</h1>
|
<h1><img src="icon_128.png" width="64" height="64" valign="bottom"> Google Chrome to Phone Extension</h1>
|
||||||
|
|
||||||
|
<div id="just_signed_in_div"></div>
|
||||||
|
|
||||||
<h2 style="padding-left: 10px"><script>document.write(chrome.i18n.getMessage('about_title_message'));</script></h2>
|
<h2 style="padding-left: 10px"><script>document.write(chrome.i18n.getMessage('about_title_message'));</script></h2>
|
||||||
<p style="padding-left: 10px"><script>document.write(chrome.i18n.getMessage('about_message'));</script></p>
|
<p style="padding-left: 10px"><script>document.write(chrome.i18n.getMessage('about_message'));</script></p>
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ body {
|
|||||||
// End of the oauth request flow, get access token
|
// End of the oauth request flow, get access token
|
||||||
oauth.initOAuthFlow(function(token, secret) {
|
oauth.initOAuthFlow(function(token, secret) {
|
||||||
chrome.extension.getBackgroundPage().initializeBrowserChannel();
|
chrome.extension.getBackgroundPage().initializeBrowserChannel();
|
||||||
window.location = 'help.html';
|
window.location = 'help.html#just_signed_in';
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
oauth.initOAuthFlow(function(token, secret) {
|
oauth.initOAuthFlow(function(token, secret) {
|
||||||
|
|||||||
@@ -119,6 +119,7 @@ function initializeBrowserChannel() {
|
|||||||
if (req.status == 200) {
|
if (req.status == 200) {
|
||||||
var channelId = req.responseText.substring(3).trim(); // expect 'OK <id>';
|
var channelId = req.responseText.substring(3).trim(); // expect 'OK <id>';
|
||||||
channel = new goog.appengine.Channel(channelId);
|
channel = new goog.appengine.Channel(channelId);
|
||||||
|
console.log(new Date().toTimeString() + ' Opening channel...');
|
||||||
socket = channel.open();
|
socket = channel.open();
|
||||||
socket.onopen = function() {
|
socket.onopen = function() {
|
||||||
console.log(new Date().toTimeString() + ' Browser channel initialized');
|
console.log(new Date().toTimeString() + ' Browser channel initialized');
|
||||||
@@ -126,17 +127,18 @@ function initializeBrowserChannel() {
|
|||||||
socket.onclose = function() {
|
socket.onclose = function() {
|
||||||
console.log(new Date().toTimeString() + ' Browser channel closed');
|
console.log(new Date().toTimeString() + ' Browser channel closed');
|
||||||
if (!socketCloseRequested) {
|
if (!socketCloseRequested) {
|
||||||
|
console.log(new Date().toTimeString() + ' Reconnecting...');
|
||||||
setTimeout('initializeBrowserChannel()', 0);
|
setTimeout('initializeBrowserChannel()', 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
socket.onerror = function(error) {
|
socket.onerror = function(error) {
|
||||||
if (error.code == 401) { // token expiry
|
if (error.code == 401) { // token expiry
|
||||||
console.log(new Date().toTimeString() + ' Browser channel token expired - reconnecting');
|
console.log(new Date().toTimeString() + ' Browser channel token expired');
|
||||||
// Reconnects in onclose()
|
|
||||||
} else {
|
} else {
|
||||||
console.log(new Date().toTimeString() + ' Browser channel error - reconnecting');
|
console.log(new Date().toTimeString() + ' Browser channel error');
|
||||||
setTimeout('initializeBrowserChannel()', 0);
|
socket.close();
|
||||||
}
|
}
|
||||||
|
// Reconnects in onclose()
|
||||||
}
|
}
|
||||||
socket.onmessage = function(evt) {
|
socket.onmessage = function(evt) {
|
||||||
console.log("Onmessage " + evt.data);
|
console.log("Onmessage " + evt.data);
|
||||||
|
|||||||
Reference in New Issue
Block a user