openwebapps-photosite-conne.../index.html

100 строки
2.4 KiB
HTML

{% import config %}
<html>
<head>
<title>{{config.PHOTO_SITE}}</title>
<script type="text/javascript" src="/static/js/jquery-1.4.4.min.js"></script>
<link type="text/css" href="/static/css/style.css" rel="stylesheet" />
<link rel="application-manifest" href="/{{app_name}}.webapp"></link>
<script>
function disconnect() {
// window.localStorage.setItem("user_id", null);
// window.localStorage.setItem("full_name", null);
// window.localStorage.setItem("credentials", null);
window.localStorage.clear();
init();
}
function get_credentials() {
if (window.localStorage.getItem("user_id")) {
return {
'user_id': window.localStorage.getItem("user_id"),
'full_name': window.localStorage.getItem("full_name"),
'credentials': window.localStorage.getItem("credentials"),
}
} else {
return null;
}
}
function is_installed(cb) {
if (!get_credentials()) {
cb(false);
return;
}
// is the app installed
navigator.apps.amInstalled(cb);
}
function init() {
is_installed(function(installed_p) {
if (installed_p) {
$("#notinstalled").hide();
$("#installed").show();
} else {
$("#installed").hide();
$("#notinstalled").show();
}
});
}
$(document).ready(init);
</script>
</head>
<body>
<div class="container">
<p>This is the {{config.PHOTO_SITE}} application.</p>
<p>It is a product of Mozilla Labs, and is experimental code. It is intended
to show how a {{config.PHOTO_SITE}} integration with an Open Web Apps service framework
would work.</p>
<p>Eventually we would hope that {{config.PHOTO_SITE}} would host this code themselves;
for now, we ask users to authorize us to access their data on their behalf.
</p>
<div id="notinstalled">
<p>The {{config.PHOTO_SITE}} application is <em>not installed.</em> You will
need to install it into your browser before it can do anything interesting for you.</p>
<div style="text-align:center">
<a class="button" href="/connect/start">Connect to {{config.PHOTO_SITE}} and Install the App</a>
</div>
</div>
<div id="installed">
<p>
The {{config.PHOTO_SITE}} application is installed and configured.
</p>
<div style="text-align:center">
<a class="button" href="javascript:disconnect()">Disconnect</a>
</div>
</div>
</div>
</div> <!-- end info -->
<div id="kicker">A <a href="#">Mozilla Labs</a> Project &middot; <a href="http://mozilla.com/privacy">Privacy Policy</a></div>
</body>
</html>