Skip to content
Snippets Groups Projects
Commit f33ca4cd authored by Brian Moe's avatar Brian Moe
Browse files

Hooks for timeline.

parent 6fc85f7a
No related branches found
No related tags found
No related merge requests found
......@@ -416,6 +416,30 @@ def search(request):
{ 'form' : form },
context_instance=RequestContext(request))
def timeline(request):
import simplejson
from templatetags.timeutil import gpsToUtc
from django.utils import dateformat
response = HttpResponse(mimetype='application/javascript')
events = []
for event in Event.objects.exclude(group__name="Test").all():
if event.gpstime:
t = dateformat.format(gpsToUtc(event.gpstime), "F j, Y h:i:s")+" UTC"
events.append({
'start': t,
'title': event.get_analysisType_display(),
'description':
"%s<br/>%s" %(event.get_analysisType_display(),"GPS time:%s"%event.gpstime),
'durationEvent':False,
})
d = {'events': events}
msg = simplejson.dumps(d)
response['Content-length'] = len(msg)
response.write(msg)
return response
#-----------------------------------------------------------------
# Things that aren't views and should really be elsewhere.
#-----------------------------------------------------------------
......
var tl;
var eventSource = new Timeline.DefaultEventSource();
function onLoad() {
var bandInfos = [
Timeline.createBandInfo({
eventSource: eventSource,
//date: "Sat May 20 1961 00:00:00 GMT-0600",
width: "70%",
intervalUnit: Timeline.DateTime.HOUR,
intervalPixels: 100
}),
Timeline.createBandInfo({
eventSource: eventSource,
//date: "Sat May 20 1961 00:00:00 GMT-0600",
width: "15%",
intervalUnit: Timeline.DateTime.DAY,
intervalPixels: 100,
overview: true
}),
Timeline.createBandInfo({
eventSource: eventSource,
//date: "Sat May 20 1961 00:00:00 GMT-0600",
width: "15%",
intervalUnit: Timeline.DateTime.MONTH,
intervalPixels: 200,
overview: true
})
];
bandInfos[1].syncWith = 0;
bandInfos[1].highlight = true;
bandInfos[2].syncWith = 1;
bandInfos[2].highlight = true;
tl = Timeline.create(document.getElementById("tl"), bandInfos);
Timeline.loadJSON("/gracedb/events/timeline",
function(json, url) { eventSource.loadJSON(json, url); });
}
var resizeTimerID = null;
function onResize() {
if (resizeTimerID == null) {
resizeTimerID = window.setTimeout(function() {
resizeTimerID = null;
tl.layout();
}, 500);
}
}
......@@ -17,9 +17,10 @@ function changeTime(obj, label) {
}
</script>
<!-- END TESTING -->
{% block jscript %}{% endblock %}
</head>
<body id="{% block pageid %}{% endblock %}">
<body id="{% block pageid %}{% endblock %}"{% block bodyattrs %}{% endblock %}>
<div id="header">
<!-- Header -->
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment