-
Notifications
You must be signed in to change notification settings - Fork 5
/
scoreboard.html
170 lines (118 loc) · 3.18 KB
/
scoreboard.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<html>
<head>
<title>CrowdTagger - Smile Version</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
<style>
@import url(../style.css?20120427);
svg {
font: 10px sans-serif;
}
.bar rect {
fill: steelblue;
}
.bar:hover rect {
fill: brown;
}
.value {
fill: white;
}
.axis {
shape-rendering: crispEdges;
}
.axis path {
stroke: none;
}
.x.axis line {
stroke: #fff;
stroke-opacity: .8;
}
.y.axis path {
stroke: green;
}
</style>
<link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
<script src="js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="js/raphael-min.js"></script>
<script language='javascript'>
$( document ).ready(function() {
var canvas_width = 800;
var canvas_height = 1200;
var bar_colors = ["pink", "lightblue"];
// Creates canvas 320 × 200 at 10, 50
var paper = Raphael("canvas", canvas_width, canvas_height);
function showSummary(){
$.ajax({
url : "/?action=getSummary",
contentType : 'application/json',
success : function(data, status){
displaySummary(data);
setTimeout(showSummary, 5000);
},
error : function(jqXHR, status, message){
console.log("error ");
console.log(status);
console.log(message);
}
});
}
function displaySummary(data){
$("#total_objects").text(data.total_objects.rows[0].value);
$("#total_tagged_objects").text(data.total_tagged_objects.rows[0].value);
if(!data.email_data){
return;
}
var email_data = data.email_data.sort(function(a, b){return b.faces - a.faces});
var num_emails = email_data.length;
if(num_emails == 0){
return;
}
var item_height = canvas_height / num_emails;
var max_num = email_data[0].faces;
if(max_num == 0){
return;
}
var tick_size = canvas_width / max_num;
var cur_y = 0;
paper.clear();
$.each(email_data, function(index, value){
// console.log(value);
var num_faces = value.faces;
var email = value.email;
var rect_length = num_faces * tick_size;
var rect_height = item_height - 3;
var color = bar_colors[index % 2];
var rect = paper.rect(0, cur_y, rect_length, rect_height, item_height / 3);
rect.attr("fill", bar_colors[index % bar_colors.length]);
var email_text = paper.text(canvas_width / 2, cur_y + (item_height / 3), email);
var bbox = email_text.getBBox();
var text_w = bbox.width;
email_text.attr("x", (text_w /2 ) + 20);
email_text.attr("font-size", 12);
var num_text= paper.text(canvas_width / 2, cur_y + (item_height / 3), num_faces);
num_text.attr("font-size",24);
cur_y += item_height;
});
}
showSummary();
});
</script>
<head>
<body>
<div class="container">
<div class="row-fluid-banner">
<div class="span7" ><h1>SmileTagger Scoreboard</h1></div>
<div class="span4" valign="bottom" >
Objects in Database: <span id="total_objects">4</span><BR>
Objects Tagged: <span id="total_tagged_objects">10</span>
</div>
</div>
<div class="row-fluid-banner">
<div class="span12">
<div id="canvas" />
</div>
</div>
</div>
<script src="js/bootstrap.min.js"></script>
</body>