Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
Code still very beta and raw, but seems to be working without many bugs
  • Loading branch information
cclaan committed Oct 1, 2011
0 parents commit 8012b0f
Show file tree
Hide file tree
Showing 108 changed files with 33,937 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
Binary file added app engine/.DS_Store
Binary file not shown.
Binary file added app engine/lockerino/.DS_Store
Binary file not shown.
3 changes: 3 additions & 0 deletions app engine/lockerino/about.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
If you're an app developer and you use a WiFi sharing feature in your app, you might be familiar with

<div> </div>
29 changes: 29 additions & 0 deletions app engine/lockerino/app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
application: mylockerino
version: 1
runtime: python
api_version: 1

handlers:
- url: /static
static_dir: static
secure: always

- url: /favicon.ico
static_files: static/images/favicon.ico
upload: static/images/favicon.ico

- url: /howto
script: lock-main.py
secure: always

- url: /set_lock
script: lock-main.py
login: required
secure: always

- url: /api/
script: lock-main.py
secure: always

- url: /.*
script: lock-main.py
38 changes: 38 additions & 0 deletions app engine/lockerino/basic-page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Lockerino - {{ page_title }}</title>
<link type="text/css" rel="stylesheet" href="/static/main.css" />

</head>

<body>

<div id="logo">Lockerino</div>
<!-- <div id="user-info">{{ logout_link }}</div> -->

<div id="main-content">

<div id="nav-bar">
<a href='/'><div class="nav-item">HOME</div></a>
<a href='/howto'><div class="nav-item">HOW TO</div></a>
{% if g_user %}
<a href='{{logout_url}}'><div class="nav-item">LOGOUT</div></a><div style="font-size:12px;">Logged in as:<br/>{{g_user.nickname}}</div>
{% else %}
<a href='{{login_url}}'><div class="nav-item">LOGIN</div></a>
{% endif %}
<!-- <div class="nav-item" style="float: right; width: 200px;">{{ logout_link }}</div> -->
</div>

<!-- <div class="page-title">
{{ page_title }}
</div> -->

{{ page_content }}

</div>

<div id="footer">Disclaimer</div>

</body>
</html>

175 changes: 175 additions & 0 deletions app engine/lockerino/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Lockerino</title>
<link type="text/css" rel="stylesheet" href="/static/main.css" />

{% if g_user %}
<script src="http://www.google.com/jsapi"></script>
<script>
google.load("jquery", "1.4.1");
</script>
<script src="static/datef.js"></script>


<script type="text/javascript" language="javascript">

var myData = {recentJson: ""};

$(document).ready(function(){

setInterval("getStatus()", 2000);
setInterval("updateDate()", 1000);

});


function setRecent(data) {
myData.recentJson = data;
}

function setStatus(status) {
$.ajax({
data: {"status": status },
type: "POST",
url: "/set_lock",
context: document.body,
success: function(data){
//alert(data);
//$('lock-status-div').text(data);
}
});
return false;
};

function updateDate() {

if ( !myData.recentJson ) {
$('#lock-status-div').html( " ?? " );
return;
}

var d = new Date();
var d2 = new Date(Date.parse(myData.recentJson.last_updated));

d2.setHours(d2.getHours()-4);

var diff = d.getTime() - d2.getTime();

var secsOld = (diff/1000);

var tsDate= new Date(myData.recentJson.last_updated_ts * 1000);
//tsDate.setHours(tsDate.getHours()-4);
var diff2 = d.getTime() - tsDate.getTime();

secsOld = (diff2/1000.0);

if ( secsOld < 0 ) secsOld = 0.0;

var dateFormatted = tsDate.format('M jS, g\\:i\\:s a');

if ( myData.recentJson ) {
$('#lock-status-div').html( "Status: " + myData.recentJson.observed_status + "<br/>Updated: " + prettyDate(secsOld) + "<br/> ( " + dateFormatted + ")" + "<br/> Angle: " + myData.recentJson.lock_angle );

} else {

}

}


function getStatus(status) {
$.ajax({
data: {"status": status},
dataType: "json",
type: "GET",
url: "/api/get_observed_status",
context: document.body,
success: function(data){
setRecent(data);
updateDate();
}
});
return false;
};


/*
* JavaScript Pretty Date
* Copyright (c) 2008 John Resig (jquery.com)
* Licensed under the MIT license.
*/

// Takes an ISO time and returns a string representing how
// long ago the date represents.
function prettyDate(diff){
//var date = new Date((time || "").replace(/-/g,"/").replace(/[TZ]/g," ")),
//diff = (((new Date()).getTime() - date.getTime()) / 1000),

day_diff = Math.floor(diff / 86400);

if ( isNaN(day_diff) || day_diff < 0 || day_diff >= 31 )
return;

return day_diff == 0 && (
diff < 60 && "just now" ||
diff < 120 && "1 minute ago" ||
diff < 3600 && Math.floor( diff / 60 ) + " minutes ago" ||
diff < 7200 && "1 hour ago" ||
diff < 86400 && Math.floor( diff / 3600 ) + " hours ago") ||
day_diff == 1 && "Yesterday" ||
day_diff < 7 && day_diff + " days ago" ||
day_diff < 31 && Math.ceil( day_diff / 7 ) + " weeks ago";
}

</script>

{% endif %}


</head>
<body>

<div id="logo">Lockerino</div>

<div id="main-content">

<div id="nav-bar">
<a href='/'><div class="nav-item">HOME</div></a>
<a href='/howto'><div class="nav-item">HOW TO</div></a>
{% if g_user %}
<a href='{{logout_url}}'><div class="nav-item">LOGOUT</div></a><div style="font-size:12px;">Logged in as:<br/>{{g_user.nickname}}</div>
{% else %}
<a href='{{login_url}}'><div class="nav-item">LOGIN</div></a>
{% endif %}

</div>

{% if g_user %}

<div id="lock-buttons">
<button class="lock-button" title="LOCK" onclick="return setStatus('unlocked');">UNLOCK</button><br/>
<button class="lock-button" title="LOCK" onclick="return setStatus('islocked');">LOCK</button>
</div>


<div id="lock-status-div">
Loading...
</div>


{% else %}
<h2>Welcome</h2>If this is your first time here, you need to follow the steps <a href='/howto'>Here.</a><br/><br/>
Otherwise, <a href='{{ login_url }}'>Login</a>
{% endif %}


</div>

<!-- <div id="footer">Disclaimer</div> -->

</body>
</html>




17 changes: 17 additions & 0 deletions app engine/lockerino/index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
indexes:

# AUTOGENERATED

# This index.yaml is automatically updated whenever the dev_appserver
# detects that a new type of query is run. If you want to manage the
# index.yaml file manually, remove the above marker line (the line
# saying "# AUTOGENERATED"). If you want to manage some indexes
# manually, move them above the marker line. The index.yaml file is
# automatically uploaded to the admin console when you next deploy
# your application using appcfg.py.

- kind: TemporaryShortCode
properties:
- name: shortcodenum
- name: date_used
direction: desc
Loading

0 comments on commit 8012b0f

Please sign in to comment.