mirror of
https://github.com/fergalmoran/chrometophone.git
synced 2025-12-22 09:41:51 +00:00
Event pages, and other cleanup.
Credits: Aaron Boodman
This commit is contained in:
@@ -13,15 +13,6 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
<html>
|
|
||||||
|
|
||||||
|
|
||||||
<script src="channel.js"></script>
|
|
||||||
<script src="chrome_ex_oauthsimple.js"></script>
|
|
||||||
<script src="chrome_ex_oauth.js"></script>
|
|
||||||
<script src="send_logic.js"></script>
|
|
||||||
<script>
|
|
||||||
function onClickHandler(info, tab) {
|
function onClickHandler(info, tab) {
|
||||||
var url = info.srcUrl;
|
var url = info.srcUrl;
|
||||||
if (url == undefined) url = info.linkUrl;
|
if (url == undefined) url = info.linkUrl;
|
||||||
@@ -47,12 +38,9 @@ function onClickHandler(info, tab) {
|
|||||||
if (chrome.contextMenus) {
|
if (chrome.contextMenus) {
|
||||||
chrome.contextMenus.create({'title': chrome.i18n.getMessage('app_name_short'),
|
chrome.contextMenus.create({'title': chrome.i18n.getMessage('app_name_short'),
|
||||||
'documentUrlPatterns': [ 'http://*/*', 'https://*/*' ],
|
'documentUrlPatterns': [ 'http://*/*', 'https://*/*' ],
|
||||||
'onclick': onClickHandler,
|
'contexts': ['link', 'selection', 'image', 'video', 'audio'],
|
||||||
'contexts': ['link', 'selection', 'image', 'video', 'audio']});
|
'id': '0'});
|
||||||
|
chrome.contextMenus.onClicked.addListener(onClickHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
initializeBrowserChannel();
|
initializeBrowserChannel();
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
</html>
|
|
||||||
@@ -32,44 +32,27 @@ body, td {
|
|||||||
<script src="chrome_ex_oauthsimple.js"></script>
|
<script src="chrome_ex_oauthsimple.js"></script>
|
||||||
<script src="chrome_ex_oauth.js"></script>
|
<script src="chrome_ex_oauth.js"></script>
|
||||||
<script src="send_logic.js"></script>
|
<script src="send_logic.js"></script>
|
||||||
|
<script src="help.js"></script>
|
||||||
<script type="text/javascript">
|
|
||||||
function loadHandler() {
|
|
||||||
if (oauth.hasToken()) {
|
|
||||||
document.getElementById('sign_in_out_div').innerHTML =
|
|
||||||
'<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 {
|
|
||||||
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
|
|
||||||
document.getElementById('sign_in_out_div').innerHTML =
|
|
||||||
'<a href="oauth_interstitial.html">' + sign_in_message;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body onload="loadHandler()">
|
<body>
|
||||||
<div id="sign_in_out_div"></div>
|
<div id="sign_in_out_div"></div>
|
||||||
<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>
|
<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" i18n-message="about_title_message"></h2>
|
||||||
<p style="padding-left: 10px"><script>document.write(chrome.i18n.getMessage('about_message'));</script></p>
|
<p style="padding-left: 10px" i18n-message="about_message"></p>
|
||||||
|
|
||||||
<h2 style="padding-left: 10px"><script>document.write(chrome.i18n.getMessage('features_title_message'));</script></h2>
|
<h2 style="padding-left: 10px" i18n-message="features_title_message"></h2>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li><script>document.write(chrome.i18n.getMessage('features_message1'));</script></li>
|
<li i18n-message="features_message1"></li>
|
||||||
<li><script>document.write(chrome.i18n.getMessage('features_message2'));</script></li>
|
<li i18n-message="features_message2"></li>
|
||||||
<li><script>document.write(chrome.i18n.getMessage('features_message3'));</script></li>
|
<li i18n-message="features_message3"></li>
|
||||||
<li><script>document.write(chrome.i18n.getMessage('features_message4'));</script></li>
|
<li i18n-message="features_message4"></li>
|
||||||
<li><script>document.write(chrome.i18n.getMessage('features_message5'));</script></li>
|
<li i18n-message="features_message5"></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<table width="1131px">
|
<table width="1131px">
|
||||||
@@ -80,8 +63,8 @@ body, td {
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td style="padding-left: 10px"><script>document.write(chrome.i18n.getMessage('step2_message'));</script></td>
|
<td style="padding-left: 10px" i18n-message="step2_message"></td>
|
||||||
<td style="padding-left: 10px"><script>document.write(chrome.i18n.getMessage('step3_message'));</script></td>
|
<td style="padding-left: 10px" i18n-message="step3_message"></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td width="33%"><img id="comic4" src="comic4.png"></td>
|
<td width="33%"><img id="comic4" src="comic4.png"></td>
|
||||||
@@ -89,16 +72,15 @@ body, td {
|
|||||||
<td width="33%"><img src="comic6.png"></td>
|
<td width="33%"><img src="comic6.png"></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="padding-left: 10px"><script>document.write(chrome.i18n.getMessage('step4_message'));</script>
|
<td style="padding-left: 10px"><span i18n-message="step4_message"></span>
|
||||||
<b><a href="#" onmouseover="document.getElementById('comic4').src='qr_code.png'" onmouseout="document.getElementById('comic4').src='comic4.png'">(QR)</a></b>
|
<b><a href="#" onmouseover="document.getElementById('comic4').src='qr_code.png'" onmouseout="document.getElementById('comic4').src='comic4.png'">(QR)</a></b>
|
||||||
</td>
|
</td>
|
||||||
<td style="padding-left: 10px"><script>document.write(chrome.i18n.getMessage('step5_message'));</script></td>
|
<td style="padding-left: 10px" i18n-message="step5_message"></td>
|
||||||
<td style="padding-left: 10px"><script>document.write(chrome.i18n.getMessage('step6_message'));</script></td>
|
<td style="padding-left: 10px" i18n-message="step6_message"></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<br>
|
<br>
|
||||||
<div align="center">©2010 Google - <a href="http://www.google.com/intl/en/about.html"><script>document.write(chrome.i18n.getMessage('about_google_message'));</script></a> -
|
<div align="center">©2010 Google - <a href="http://www.google.com/intl/en/about.html" i18n-message="about_google_message"></a> -
|
||||||
<a href="http://www.google.com/privacy.html"><script>document.write(chrome.i18n.getMessage('privacy_message'));</script></a> -
|
<a href="http://www.google.com/privacy.html" i18n-message="privacy_message"></a> - <a id="gallery_tos_link" i18n-message="tos_message"></a></div>
|
||||||
<script>document.write('<a href="http://chrome.google.com/extensions/intl/' + window.navigator.language.substring(0, 2) + '/gallery_tos.html">' + chrome.i18n.getMessage('tos_message') + '</a>');</script></div>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
39
extension/help.js
Normal file
39
extension/help.js
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
document.addEventListener("DOMContentLoaded", function() {
|
||||||
|
// localize easy stuff
|
||||||
|
Array.prototype.forEach.call(document.querySelectorAll("*[i18n-message]"),
|
||||||
|
function(node) {
|
||||||
|
node.textContent = chrome.i18n.getMessage(node.getAttribute('i18n-message'));
|
||||||
|
});
|
||||||
|
|
||||||
|
// localize tos link
|
||||||
|
document.querySelector('#gallery_tos_link').href =
|
||||||
|
'http://chrome.google.com/extensions/intl/' +
|
||||||
|
navigator.language.substring(0, 2) + '/gallery_tos.html';
|
||||||
|
|
||||||
|
|
||||||
|
if (oauth.hasToken()) {
|
||||||
|
var link = document.createElement('a');
|
||||||
|
link.href = 'help.html';
|
||||||
|
link.onclick = function() {
|
||||||
|
chrome.extension.getBackgroundPage().closeBrowserChannel();
|
||||||
|
oauth.clearTokens();
|
||||||
|
};
|
||||||
|
link.text = chrome.i18n.getMessage('sign_out_message');
|
||||||
|
document.querySelector('#sign_in_out_div').appendChild(link);
|
||||||
|
|
||||||
|
if (document.location.hash == '#just_signed_in') {
|
||||||
|
var p = document.createElement('p');
|
||||||
|
p.style.fontWeight = 'bold';
|
||||||
|
p.style.color = '#0a0';
|
||||||
|
p.textContent = chrome.i18n.getMessage('signed_in_message');
|
||||||
|
document.querySelector('#just_signed_in_div').appendChild(p);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
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
|
||||||
|
var link = document.createElement('a');
|
||||||
|
link.href = 'oauth_interstitial.html';
|
||||||
|
link.textContent = sign_in_message;
|
||||||
|
document.querySelector('#sign_in_out_div').appendChild(link);
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
{
|
{
|
||||||
|
"update_url":"http://clients2.google.com/service/update2/crx",
|
||||||
|
"manifest_version": 2,
|
||||||
"name": "__MSG_app_name__",
|
"name": "__MSG_app_name__",
|
||||||
"description": "__MSG_app_desc__",
|
"description": "__MSG_app_desc__",
|
||||||
"version": "2.3.1",
|
"version": "2.3.2",
|
||||||
"default_locale": "en",
|
"default_locale": "en",
|
||||||
"icons": {
|
"icons": {
|
||||||
"16": "icon_16.png",
|
"16": "icon_16.png",
|
||||||
@@ -14,14 +16,18 @@
|
|||||||
"default_icon": "icon_19.png",
|
"default_icon": "icon_19.png",
|
||||||
"default_popup": "popup.html"
|
"default_popup": "popup.html"
|
||||||
},
|
},
|
||||||
"background_page": "background.html",
|
"background": {
|
||||||
|
"persistent": false,
|
||||||
|
"scripts": [
|
||||||
|
"channel.js",
|
||||||
|
"chrome_ex_oauthsimple.js",
|
||||||
|
"chrome_ex_oauth.js",
|
||||||
|
"send_logic.js",
|
||||||
|
"background.js"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"contextMenus", "tabs", "http://*/*", "https://*/*"
|
"contextMenus", "tabs", "http://*/*", "https://*/*"
|
||||||
],
|
]
|
||||||
"content_scripts": [
|
|
||||||
{
|
|
||||||
"matches": ["http://*/*", "https://*/*"],
|
|
||||||
"js": ["content_script.js"]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,29 +34,11 @@ body {
|
|||||||
<script src="chrome_ex_oauthsimple.js"></script>
|
<script src="chrome_ex_oauthsimple.js"></script>
|
||||||
<script src="chrome_ex_oauth.js"></script>
|
<script src="chrome_ex_oauth.js"></script>
|
||||||
<script src="send_logic.js"></script>
|
<script src="send_logic.js"></script>
|
||||||
|
<script src="oauth_interstitial.js"></script>
|
||||||
<script type="text/javascript">
|
|
||||||
function loadHandler() {
|
|
||||||
// We may be called directly, as options, or as result of a
|
|
||||||
// redirect from OAuth1 flow
|
|
||||||
var params = ChromeExOAuth.getQueryStringParams();
|
|
||||||
if (params['chromeexoauthcallback'] == 'true') {
|
|
||||||
// End of the oauth request flow, get access token
|
|
||||||
oauth.initOAuthFlow(function(token, secret) {
|
|
||||||
chrome.extension.getBackgroundPage().initializeBrowserChannel();
|
|
||||||
window.location = 'help.html#just_signed_in';
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
oauth.initOAuthFlow(function(token, secret) {
|
|
||||||
chrome.extension.getBackgroundPage().initializeBrowserChannel();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body onload="loadHandler();">
|
<body>
|
||||||
Redirecting...
|
Redirecting...
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|||||||
16
extension/oauth_interstitial.js
Normal file
16
extension/oauth_interstitial.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
window.onload = function() {
|
||||||
|
// We may be called directly, as options, or as result of a
|
||||||
|
// redirect from OAuth1 flow
|
||||||
|
var params = ChromeExOAuth.getQueryStringParams();
|
||||||
|
if (params['chromeexoauthcallback'] == 'true') {
|
||||||
|
// End of the oauth request flow, get access token
|
||||||
|
oauth.initOAuthFlow(function(token, secret) {
|
||||||
|
chrome.extension.getBackgroundPage().initializeBrowserChannel();
|
||||||
|
window.location = 'help.html#just_signed_in';
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
oauth.initOAuthFlow(function(token, secret) {
|
||||||
|
chrome.extension.getBackgroundPage().initializeBrowserChannel();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -28,97 +28,26 @@ td {
|
|||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
color: black;
|
color: black;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*:focus {
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script src="chrome_ex_oauthsimple.js"></script>
|
<script src="chrome_ex_oauthsimple.js"></script>
|
||||||
<script src="chrome_ex_oauth.js"></script>
|
<script src="chrome_ex_oauth.js"></script>
|
||||||
<script src="send_logic.js"></script>
|
<script src="send_logic.js"></script>
|
||||||
<script>
|
<script src="popup.js"></script>
|
||||||
function loadHandler() {
|
<body>
|
||||||
document.getElementById('help').innerHTML = chrome.i18n.getMessage('help_message');
|
|
||||||
|
|
||||||
if (oauth.hasToken()) {
|
|
||||||
document.getElementById('msg').innerHTML = chrome.i18n.getMessage('sending_message');
|
|
||||||
document.getElementById('signout').innerHTML = chrome.i18n.getMessage('sign_out_message');
|
|
||||||
|
|
||||||
chrome.tabs.getSelected(null, function(tab) {
|
|
||||||
if (tab.url.indexOf('http:') == 0 ||
|
|
||||||
tab.url.indexOf('https:') == 0) {
|
|
||||||
chrome.tabs.executeScript(null, {file: "content_script.js"});
|
|
||||||
} else {
|
|
||||||
document.getElementById('msg').innerHTML = chrome.i18n.getMessage('invalid_scheme_message');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
// we need the options page to show signin
|
|
||||||
activateSignInLink("chrome.tabs.create({url: 'oauth_interstitial.html'})");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function sendToPhoneListener(status, responseText) {
|
|
||||||
if (status == STATUS_SUCCESS) {
|
|
||||||
document.getElementById('msg').innerHTML = chrome.i18n.getMessage('sent_message');
|
|
||||||
activateSignOutLink();
|
|
||||||
} else if (status == STATUS_LOGIN_REQUIRED) {
|
|
||||||
activateSignInLink("chrome.tabs.create({url: 'help.html?fromPopup=1'})"); // token revoked
|
|
||||||
} else if (status == STATUS_DEVICE_NOT_REGISTERED) {
|
|
||||||
document.getElementById('msg').innerHTML = chrome.i18n.getMessage('device_not_registered_message');
|
|
||||||
activateSignOutLink();
|
|
||||||
} else {
|
|
||||||
document.getElementById('msg').innerHTML =
|
|
||||||
chrome.i18n.getMessage('error_sending_message', responseText);
|
|
||||||
activateSignOutLink();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
chrome.extension.onConnect.addListener(function(port) {
|
|
||||||
// This will get called by the content script. We go through
|
|
||||||
// these hoops to get the optional text selection.
|
|
||||||
port.onMessage.addListener(function(info) {
|
|
||||||
var msgType = (info.selection && info.selection.length > 0) ? 'selection' : 'page';
|
|
||||||
sendToPhone(info.title, info.url, msgType, info.selection, sendToPhoneListener);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
function setSignOutVisibility(visible) {
|
|
||||||
var signOutLink = document.getElementById('signout');
|
|
||||||
signOutLink.style.visibility = visible ? 'visible' : 'hidden';
|
|
||||||
var sep = document.getElementById('sep');
|
|
||||||
sep.style.visibility = visible ? 'visible' : 'hidden';
|
|
||||||
}
|
|
||||||
|
|
||||||
function activateSignOutLink() {
|
|
||||||
setSignOutVisibility(true);
|
|
||||||
var signOutLink = document.getElementById('signout');
|
|
||||||
signOutLink.innerHTML = chrome.i18n.getMessage('sign_out_message');
|
|
||||||
signOutLink.style.color = 'blue';
|
|
||||||
signOutLink.onclick = function() {
|
|
||||||
chrome.extension.getBackgroundPage().closeBrowserChannel();
|
|
||||||
oauth.clearTokens();
|
|
||||||
window.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function activateSignInLink(onclick) {
|
|
||||||
var link = '<a href="#" onclick="' + onclick + '">' +
|
|
||||||
chrome.i18n.getMessage('sign_in_message') + '</a>';
|
|
||||||
document.getElementById('msg').innerHTML =
|
|
||||||
chrome.i18n.getMessage('sign_in_required_message', link);
|
|
||||||
setSignOutVisibility(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<body onload="loadHandler()">
|
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td><img src="icon_48.png" style="margin-right: 4px;"/></td>
|
<td><img src="icon_48.png" style="margin-right: 4px;"/></td>
|
||||||
<td width="100%" valign="middle">
|
<td width="100%" valign="middle">
|
||||||
<b><div id="msg"></div></b>
|
<b><div id="msg"></div></b>
|
||||||
<p><a id="help" href="#" onclick="chrome.tabs.create({url: 'help.html'})"></a> <span id="sep">|</span>
|
<p><a id="help" href="#"></a> <span id="sep">|</span>
|
||||||
<a id="signout" href="#" style="color: gray;"></a></p>
|
<a id="signout" href="#" style="color: gray;"></a></p>
|
||||||
</td>
|
</td>
|
||||||
<td valign="top"><a href="#" onclick="window.close()"><img src="popup_close.png" style="margin: 2px;"></a></td>
|
<td valign="top"><a id="close" href="#"><img src="popup_close.png" style="margin: 2px;"></a></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
96
extension/popup.js
Normal file
96
extension/popup.js
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
window.onload = function() {
|
||||||
|
document.getElementById('help').textContent = chrome.i18n.getMessage('help_message');
|
||||||
|
|
||||||
|
if (oauth.hasToken()) {
|
||||||
|
document.getElementById('msg').textContent = chrome.i18n.getMessage('sending_message');
|
||||||
|
document.getElementById('signout').textContent = chrome.i18n.getMessage('sign_out_message');
|
||||||
|
|
||||||
|
chrome.tabs.getSelected(null, function(tab) {
|
||||||
|
if (tab.url.indexOf('http:') == 0 ||
|
||||||
|
tab.url.indexOf('https:') == 0) {
|
||||||
|
chrome.tabs.executeScript(null, {file: "content_script.js"});
|
||||||
|
} else {
|
||||||
|
document.getElementById('msg').textContent = chrome.i18n.getMessage('invalid_scheme_message');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// we need the options page to show signin
|
||||||
|
activateSignInLink(function() {
|
||||||
|
chrome.tabs.create({url: 'oauth_interstitial.html'})
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
document.querySelector("#help").onclick = function() {
|
||||||
|
chrome.tabs.create({url: 'help.html'});
|
||||||
|
};
|
||||||
|
|
||||||
|
document.querySelector("#close").onclick = function() {
|
||||||
|
window.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function sendToPhoneListener(status, responseText) {
|
||||||
|
if (status == STATUS_SUCCESS) {
|
||||||
|
document.getElementById('msg').textContent = chrome.i18n.getMessage('sent_message');
|
||||||
|
activateSignOutLink();
|
||||||
|
} else if (status == STATUS_LOGIN_REQUIRED) {
|
||||||
|
activateSignInLink(function() {
|
||||||
|
chrome.tabs.create({url: 'help.html?fromPopup=1'}); // token revoked
|
||||||
|
});
|
||||||
|
} else if (status == STATUS_DEVICE_NOT_REGISTERED) {
|
||||||
|
document.getElementById('msg').textContent = chrome.i18n.getMessage('device_not_registered_message');
|
||||||
|
activateSignOutLink();
|
||||||
|
} else {
|
||||||
|
document.getElementById('msg').textContent =
|
||||||
|
chrome.i18n.getMessage('error_sending_message', responseText);
|
||||||
|
activateSignOutLink();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
chrome.extension.onConnect.addListener(function(port) {
|
||||||
|
// This will get called by the content script. We go through
|
||||||
|
// these hoops to get the optional text selection.
|
||||||
|
port.onMessage.addListener(function(info) {
|
||||||
|
var msgType = (info.selection && info.selection.length > 0) ? 'selection' : 'page';
|
||||||
|
sendToPhone(info.title, info.url, msgType, info.selection, sendToPhoneListener);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function setSignOutVisibility(visible) {
|
||||||
|
var signOutLink = document.getElementById('signout');
|
||||||
|
signOutLink.style.visibility = visible ? 'visible' : 'hidden';
|
||||||
|
var sep = document.getElementById('sep');
|
||||||
|
sep.style.visibility = visible ? 'visible' : 'hidden';
|
||||||
|
}
|
||||||
|
|
||||||
|
function activateSignOutLink() {
|
||||||
|
setSignOutVisibility(true);
|
||||||
|
var signOutLink = document.getElementById('signout');
|
||||||
|
signOutLink.textContent = chrome.i18n.getMessage('sign_out_message');
|
||||||
|
signOutLink.style.color = 'blue';
|
||||||
|
signOutLink.onclick = function() {
|
||||||
|
chrome.extension.getBackgroundPage().closeBrowserChannel();
|
||||||
|
oauth.clearTokens();
|
||||||
|
window.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function activateSignInLink(onclick) {
|
||||||
|
var link = document.createElement("a");
|
||||||
|
link.href = "#";
|
||||||
|
link.onclick = onclick;
|
||||||
|
link.textContent = chrome.i18n.getMessage('sign_in_message');
|
||||||
|
var linkToken = '$link$';
|
||||||
|
var msg = chrome.i18n.getMessage('sign_in_required_message', linkToken);
|
||||||
|
var linkIndex = msg.indexOf(linkToken);
|
||||||
|
|
||||||
|
var parent = document.getElementById('msg');
|
||||||
|
parent.textContent = '';
|
||||||
|
parent.appendChild(document.createTextNode(msg.substring(0, linkIndex)));
|
||||||
|
parent.appendChild(link);
|
||||||
|
parent.appendChild(
|
||||||
|
document.createTextNode(msg.substring(linkIndex + linkToken.length)));
|
||||||
|
|
||||||
|
setSignOutVisibility(false);
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user