Files
chrometophone/third_party/operatophone/popup.html
2011-01-25 14:27:18 +00:00

106 lines
2.9 KiB
HTML

<html>
<head>
<style type="text/css">
body {
padding: 0px;
margin: 1px;
min-width: 320px;
overflow: hidden;
}
a, a:visited, a:active {
color: blue;
}
td {
font-family: Verdana, Arial;
font-size: 12px;
color: black;
}
</style>
<script type="text/javascript" src="constants.js"></script>
<script>
function loadHandler() {
var msg = document.getElementById('msg'),
helpLink = document.getElementById('help'),
signOutLink = document.getElementById('signout');
helpLink.addEventListener( 'click', function() {
opera.extension.postMessage({
action: ACTION_OPEN_TAB,
data: {
url: '/o2p_help.html?' + Math.floor(Math.random()*1e10) // to prevent caching issue
}
});
}, false );
signOutLink.href = signOutUrl;
// Callback from the background process
opera.extension.addEventListener( 'message', function( message ) {
var msgRcvd = false;
switch(message.data.action) {
case STATUS_SUCCESS:
msg.innerHTML = "Sent to phone."
setSignoutVisibility(true);
msgRcvd = true;
break;
case STATUS_LOGIN_REQUIRED:
var signinLink = '<a href="' + signInUrl + '" target="_o2pTab_ext">sign in</a>';
msg.innerHTML = "Please " + signinLink + " to Opera to Phone.";
setSignoutVisibility(false);
msgRcvd = true;
break;
case STATUS_DEVICE_NOT_REGISTERED:
opera.extension.postMessage({
action: ACTION_OPEN_URL,
data: {
url: apkUrl
}
});
msg.innerHTML = "Device not registered for user.";
setSignoutVisibility(true);
msgRcvd = true;
break;
case STATUS_NO_TAB_ACCESS:
msg.innerHTML = "Cannot access the current tab.";
msgRcvd = true;
break;
case STATUS_GENERAL_ERROR:
msg.innerHTML = "Error sending to phone: " + message.data.action;
setSignoutVisibility(false);
msgRcvd = true;
break;
}
if(msgRcvd) {
window.setTimeout(function() {
window.close();
}, 3000);
}
}, false);
function setSignoutVisibility(visible) {
signOutLink.style.visibility = visible ? 'visible' : 'hidden';
signOutLink.style.color = visible ? 'blue' : 'gray';
document.getElementById('sep').style.visibility = visible ? 'visible' : 'hidden';
}
opera.extension.postMessage({
action: ACTION_START_SEND
});
}
window.addEventListener("load", loadHandler, false);
</script>
</head>
<body>
<table>
<tr>
<td valign="top" width="48px"><img src="/icon_64x64.png" width="48px" height="48px" style="margin-right: 4px;"/></td>
<td valign="middle">
<b><div id="msg">Sending to phone...</div></b>
<p><a id="help" href="#">Help</a> <span id="sep" style="visibility:hidden;">|</span>
<a id="signout" href="#" target="_o2ptab_ext" style="color: gray; visibility: hidden;">Sign out</a></p>
</td>
</tr>
</table>
</body>
</html>