-
Notifications
You must be signed in to change notification settings - Fork 0
/
annotate.html
85 lines (77 loc) · 3.05 KB
/
annotate.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
{% set title = "Annotate" %}
{% extends "template.html" %}
{% macro rating(content, show_content=True, labels=None) -%}
<div class="rating unrated">
{% if show_content %}{{ content.content }}{% endif %}
<input type="hidden" name="content_id" value="{{ content.key.urlsafe() }}" />
{% for star in range(NUMBER_OF_STARS) %}
<span class="star"></span>
{% endfor %}
{% if labels %}
<div class="labels">
<label class="pull-left">{{ labels[0] }}</label>
<label class="pull-right">{{ labels[1] }}</label>
</div>
{% endif %}
</div>
{%- endmacro %}
{% block container %}
<div class="annotation_progress progress progress-striped" style="float: right">
<div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="{{ annotation_streak }}" aria-valuemin="0" aria-valuemax="{{ ANNOTATION_BREAK_AFTER }}" style="width: {{ 100*annotation_streak/ANNOTATION_BREAK_AFTER }}%">
<span class="sr-only"></span>
</div>
<a href="/break">break</a>
</div>
<h1>Annotate</h1>
<p class="lead">Listen carefully to this rhythm. How hard do you think it would be to tap along with the beat in this rhythm?</p>
<div class="row">
<form method="post">
<div class="well col-md-8 col-md-offset-2 text-center">
<div>{{ content.content }}</div>
{% if not subcontents %}
{{ rating(content, show_content=False, labels=('very easy', 'very hard')) }}
{% endif %}
{% for subcontent in subcontents %}
{{ rating(subcontent) }}
{% endfor %}
</div>
</form>
</div>
{% endblock %}
{% block script %}
<script type="text/javascript">
$( document ).ready(function() {
// Handle clicks on stars
$("form .rating span.star").click(function() {
var stars = {{ NUMBER_OF_STARS }}-$(this).index()+1;
var rating = $(this).closest(".rating");
rate(rating, stars);
});
function rate(rating, stars) {
rating.removeClass("unrated");
rating.fadeOut();
var form = rating.closest("form");
form.append('<input type="hidden" name="stars" value="'+stars+'" />');
if(form.find(".unrated").length == 0)
form.submit();
}
// Handle keypresses
$(document).keypress(function(event) {
if(event.charCode == 48 && {{ NUMBER_OF_STARS }} > 9) {
return rate($("form .unrated:first"), 10);
}
if(event.charCode < 49) return;
if(event.charCode > 48+Math.max(9,{{ NUMBER_OF_STARS }})) return;
var stars = event.charCode-48;
rate($("form .unrated:first"), stars);
});
// iPhone & iPad don't do autoplay, so add controls
if ((navigator.platform.indexOf("iPhone") != -1) ||
(navigator.platform.indexOf("iPad") != -1) ||
(navigator.platform.indexOf("iPod") != -1)) {
$("audio").attr("controls", "true");
$(".labels label").css("visibility", "inherit");
}
});
</script>
{% endblock %}