Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: 9be968d5ee
Fetching contributors…

Cannot retrieve contributors at this time

68 lines (59 sloc) 2.569 kB
{% extends 'base.html' %}
{% block content %}
<form method="post">
<textarea name="body"></textarea><br />
<input type="submit" value="Update" />
</form>
{% for update in updates %}
<p>{{update.body}} | {{update.created|timesince}} ago | {{update.user_fullname}} |
<a href="javascript:void()" onclick="toggleComment({{update.key.id}})" id="comment-link-{{update.key.id}}">Comment</a>
<form action="/comment/{{update.key.id}}" method="post" id="comment-form-{{update.key.id}}" style="display: none;">
<input type="text" name="body" /> <input type="submit" value="Comment" />
<a href="javascript:void()" onclick="toggleComment({{update.key.id}})">Cancel</a>
</form>
</p>
{% for comment in update.comment_set %}
<p style="margin-left: 20px;">
{{comment.body}} | {{comment.created|timesince}} ago | {{comment.user_fullname}}
</p>
{% endfor %}
{% endfor %}
<div id="load-more">
<a href="javascript:loadMoreUpdates('{{updates_query.cursor}}')">Load more...</a>
</div>
<script type="text/javascript">
function toggleComment(id) {
if ($('#comment-form-'+id).css('display') == 'inline') {
$('#comment-form-'+id).css('display', 'none');
$('#comment-link-'+id).css('display', 'inline');
} else {
$('#comment-form-'+id).css('display', 'inline');
$('#comment-link-'+id).css('display', 'none');
}
}
function loadMoreUpdates(cursor){
$.get('/updates/' + cursor, function(data) {
var foo = eval("(" + data + ")" );
console.log(foo);
for(var i=0; i<foo[0].messages.length;i++){
$("#content")[0].innerHTML += renderUpdate(foo[0].messages[i])
}
$("#load-more").remove();
$("#content")[0].innerHTML += renderLoadMore(foo[1].cursor);
});
}
function renderLoadMore(cursor){
return "<div id='load-more'><a href='javascript:loadMoreUpdates(\"" + cursor + "\")'>Load more...</a></div>";
}
function renderUpdate(update){
u = "<p>" + update.body + " | " + update.ago + " | " + update.user_fullname + " |";
u += "<a href='javascript:void() onclick='toggleComment(" + update.id + ")' id='comment-link-" + update.id + "'>Comment</a>";
u += "<form action='/comment/"+update.id+"' method='post' id='comment-form-"+update.id+"' style='display:none;'>";
u += "<input type='text' name='body'/><input type='submit' value='Comment' />";
u += "<a href='javascript:void()' onclick='toggleComment("+u.id+")'>Cancel</a>";
u += "</form>";
u += "</p>";
return u;
}
</script>
{% endblock %}
Jump to Line
Something went wrong with that request. Please try again.