Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
127 lines (119 sloc) 5.71 KB
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>
{% block title %}
GeoCam Talk
{% endblock %}
</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.css" />
<link rel="stylesheet" href="/resources/css/jquery.mobile.css" />
<link rel="stylesheet" href="/resources/css/site.css" />
<script src="http://code.jquery.com/jquery-1.5.2.min.js"></script>
<script src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
$(document).bind("mobileinit", function () {
//$.mobile.ajaxEnabled = true;
$.extend($.mobile, {
ajaxFormsEnabled: false/*,
ajaxEnabled: false*/
});
});
var running_timestamp = {{ timestamp }};
var new_message_count = {{ user.profile.getUnreadMessageCount }};
var updateFunction = function() {
var url = '{% url geocamTalk.views.feed_messages %}';
url += '?since=' + running_timestamp;
$.getJSON(url, function(data) {
var html_str = "";
for (var i in data['ms']) {
var msg = data['ms'][i];
var pk = msg['messageId'];
var content = msg['content'];
var has_geolocation = msg['hasGeolocation'];
var authorUsername = msg['authorUsername'];
var authorFullname = msg['authorFullname'];
{% if recipient %}
authorFullname = '<a href="{% url geocamTalk.views.message_list recipient.username %}/' +authorUsername+ '">' +authorFullname+ '</a>' ;
{% endif %}
var msgDate = new Date (msg['contentTimestamp']);
var content_timestamp =
msgDate.getDate() + "/" + msgDate.getMonth() + "/" + msgDate.getFullYear()
+ " " + msgDate.getHours() + ":" + msgDate.getMinutes();
html_str += '<li id="message_'+pk+'"><p id="message_'+pk+'_header">';
html_str += 'On '+content_timestamp+' '+authorFullname;
if (has_geolocation == true) {
html_str += '<a href="#" data-rel="dialog" data-transition="pop" data-inline="true" data-role="button" data-icon="geoCam-map" data-iconpos="notext" title="Map Info" data-theme="c" class="ui-btn ui-btn-inline ui-btn-icon-notext ui-btn-corner-all ui-shadow ui-btn-up-c"><span class="ui-btn-inner ui-btn-corner-all"><span class="ui-btn-text">Map Info</span><span class="ui-icon ui-icon-geoCam-map ui-icon-shadow"></span></span></a>';
}
html_str += '</p>';
html_str += '<p id="message_'+pk+'_content">'+content+'</p>';
html_str += '</li>';
}
running_timestamp = data['ts'];
new_message_count += data['msgCnt'];
$('div[data-role="page"]').each(function() {
$(this).find('#message_list').prepend(html_str);
$(this).find('#new_message_count').html(new_message_count);
});
if (new_message_count > 0
&& $('div[data-role="page"]').find('#clear_link').length == 0) {
var link = $('<a href="#" id="clear_link" data-role="button" data-inline="true" data-theme="c" class="ui-btn ui-btn-inline ui-btn-corner-all ui-shadow ui-btn-up-c"><span class="ui-btn-inner ui-btn-corner-all"><span class="ui-btn-text">Clear Received Messages</span></span></a>');
link.click(function() {
$.get('{% url geocamTalk.views.clear_messages %}', function(data) {
$('div[data-role="page"]').each(function() {
$(this).find('#clear_link').remove();
$(this).find('#new_message_count').html(0);
});
running_timestamp = data['ts'];
});
});
$('div[data-role="page"]').find('#new_message_link').after(link);
}
});
}
$('div').live('pagebeforeshow', function(event, ui){
$('a.media').media( { width: 300, height: 20 } );
updateFunction();
});
setInterval(updateFunction, 60 * 10 * 1000); // 10 minutes
</script>
<script src="http://code.jquery.com/mobile/1.0a4/jquery.mobile-1.0a4.min.js"></script>
<script src="http://jquery.malsup.com/media/jquery.media.js?v.92"></script>
{% block css %}{% endblock %}
</head>
<body>
<div id="bodydiv" data-role="page" data-theme="c">
<header>
<div data-role="header">
<h1>{% block pagetitle %}GeoCam Talk{% endblock %}</h1>
<a href="/talk/messages" data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-right jqm-home">Home</a>
<div data-role="navbar">
<ul id="bigsigh">
<li><a id="my_messages_link" href="{% url geocamTalk.views.message_list user.username%}">My Messages (<span id="new_message_count">{{user.profile.getUnreadMessageCount}}</span>)</a></li>
<li><a href="{% url geocamTalk.views.message_list%}">All Messages</a></li>
<li><a href="{% url geocamTalk.views.message_map %}">Talk Map</a></li>
</ul>
</div>
</div>
</header>
<content>
<div data-role="content">
<a id="new_message_link" href="{% url geocamTalk.views.create_message %}" data-role="button" data-inline="true">New Message</a>
{% block content %}
{% endblock %}
</div>
</content>
<footer>
<div data-role="footer" class="ui-bar">
{% if user.is_authenticated %}
<a href="/accounts/logout/" class="ui-btn-right">Logout {% firstof user.first_name user.username %}</a>
{% else %}
<a href="/accounts/login/">Login</a>
{% endif %}
</div>
</footer>
{% block js %} {% endblock %}
</div>
</body>
</html>
Something went wrong with that request. Please try again.