2014-02-17 18:05:39 +01:00
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<%= stylesheet_link_tag 'application' %>
|
|
|
|
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script>
|
|
|
|
<%= javascript_include_tag 'application' %>
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
<div class="recent_status">
|
|
|
|
<% @statuses.each do |r| %>
|
2014-03-14 00:16:35 +01:00
|
|
|
<div ><span class="status_messages" id="<%= r.entry_id %>"><%= r.status %><br><abbr class="timeago" title="<%= r.created_at %>"><%= r.created_at %></abbr></div>
|
|
|
|
<br>
|
2014-02-17 18:05:39 +01:00
|
|
|
<% end %>
|
|
|
|
<div>
|
|
|
|
<script>
|
2014-08-01 21:57:02 +02:00
|
|
|
$(document).on('page:load ready', function() {
|
2014-02-17 18:05:39 +01:00
|
|
|
$(".timeago").timeago();
|
|
|
|
var refreshInterval = setInterval(refreshStatus, 1 * 60 * 1000);
|
2014-08-01 21:57:02 +02:00
|
|
|
});
|
2014-02-17 18:05:39 +01:00
|
|
|
function refreshStatus() {
|
2014-08-01 21:57:02 +02:00
|
|
|
|
2014-02-17 18:05:39 +01:00
|
|
|
$.getJSON("/channels/<%= @channel_id %>/status/recent", function(data){
|
|
|
|
//look for most recent status and only append if the new status has a greater entry_id
|
|
|
|
|
|
|
|
var firstId = $(".status_messages").first().attr('id');
|
|
|
|
|
|
|
|
|
|
|
|
for(var i in data) {
|
|
|
|
|
|
|
|
if (data[i].entry_id > firstId) {
|
2014-08-01 21:57:02 +02:00
|
|
|
$(".recent_status").prepend("<div><span class=\"status_messages\" id=\"" +
|
|
|
|
data[i].entry_id + "\">"+
|
2014-02-17 18:05:39 +01:00
|
|
|
data[i].status +
|
2014-08-01 21:57:02 +02:00
|
|
|
"</span><br><abbr class=\"timeago\" title=\"" +
|
|
|
|
data[i].created_at + "\">" +
|
2014-02-17 18:05:39 +01:00
|
|
|
data[i].created_at + "</abbr></div></br>");
|
|
|
|
}
|
2014-08-01 21:57:02 +02:00
|
|
|
|
2014-02-17 18:05:39 +01:00
|
|
|
}
|
|
|
|
$(".timeago").timeago();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|
2014-08-01 21:57:02 +02:00
|
|
|
|