-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.html
234 lines (216 loc) · 9.8 KB
/
template.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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
<style>
#notification {
position: fixed;
top:0;
z-index: 10000;
background: rgba(0,0,0,0.9);
width: 100%;
text-align: center;
padding: 25px;
color: white;
text-transform: uppercase;
transform: translateY(-150px);
}
.show-notification {
animation: slideDown 0.5s 0.0s 1 ease forwards;
}
.hide-notification {
animation: slideUp 1s 0.0s 1 ease forwards;
}
@keyframes slideDown {
0% {transform: translateY(-150px);}
100% { transform: translateY(0px); }
}
@keyframes slideUp {
0% {transform: translateY(0px);}
100% { transform: translateY(-150px); }
}
.tutorial {
position: fixed;
top: 25%;
right: -25px;
-webkit-transform: rotate(-90deg);
-ms-transform: rotate(-90deg);
transform: rotate(-90deg);
z-index: 99999;
}
@media (max-width:320px) {
.tutorial {
top: 35%;
}
}
</style>
<div class="col-md-2 pull-right ">
<a class="btn btn-primary btn-large tutorial" href="/project/raspberrypi/tutorial"><i class="icon-question-sign"></i> Tutorial</a>
</div>
<div class="row skeleton"> <!-- Start Skeleton Row-->
<div class="col-xs-12 col-sm-6 col-sm-offset-3 col-md-6 col-md-offset-3" style="text-align: center;"><!-- Start of Question and Submission DIV (column) -->
<h2 id="question"><span id="i18n_question">Do you see an insect in this photo?</span></h2> <!-- The question will be loaded here -->
<div id="answer" style="text-align: center;"> <!-- Start DIV for the submission buttons -->
<!-- If the user clicks this button, the saved answer will be value="No"-->
<button class="btn btn-answer" value='no'>No</button>
<!-- If the user clicks this button, the saved answer will be value="wasp"-->
<button class="btn btn-success btn-answer" value='wasp'><span id="i18n_wasp">Yes! A Wasp</span></button>
<!-- If the user clicks this button, the saved answer will be value="no"-->
<button class="btn btn-danger btn-answer" value='bee'><span id="i18n_bee">Yes! A Bee</span></button>
<!-- If the user clicks this button, the saved answer will be value="NoPhoto"-->
<button class="btn btn-answer" value='noPhoto'><span id="i18n_no_photo">No photo</span></button>
<!-- If the user clicks this button, the saved answer will be value="NotKnown"-->
<button class="btn btn-answer" value='notKnown'><span id="i18n_i_dont_know">I don't know</span></button>
</div><!-- End of DIV for the submission buttons -->
</div><!-- End of Question and Submission DIV (column) -->
<div id="photo-frame" class="col-xs-12 col-sm-6 col-sm-offset-3 col-md-6 col-md-offset-3"><!-- Start of Photo DIV (column) -->
<img id="photo" src="http://i.imgur.com/GeHxzb7.png" class="img-responsive">
</div><!-- End of Photo DIV (columnt) -->
<div class="col-xs-12 col-md-6 col-md-offset-3" style="text-align:center;">
<!--
This application uses Disqus to allow users to provide some feedback.
The next section includes a button that when a user clicks on it will
load the comments, if any, for the given task
-->
<div id="disqus_show_btn" style="margin-top:5px;">
<button class="btn btn-primary btn-large btn-disqus" onclick="loadDisqus()"><i class="fa fa-comments"></i> <span id="i18n_show_comments">Show comments</span></button>
<button class="btn btn-large btn-disqus" onclick="loadDisqus()" style="display:none"><i class="fa fa-comments"></i> <span id="i18n_hide_comments">Hide comments</span></button>
</div><!-- End of Disqus Button section -->
<!-- Disqus thread for the given task -->
<div id="disqus_thread" style="margin-top:5px;display:none"></div>
</div>
</div><!-- End of Skeleton Row -->
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
/* * * DON'T EDIT BELOW THIS LINE * * */
function loadDisqus() {
$("#disqus_thread").toggle();
$(".btn-disqus").toggle();
var disqus_shortname = 'pybossa'; // required: replace example with your forum shortname
//var disqus_identifier = taskId;
var disqus_developer = 1;
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
}
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<script>
// Default language
var userLocale = "en";
// Translations
var messages = {"en": {
"i18n_welldone": "Well done!",
"i18n_welldone_text": "Your answer has been saved",
"i18n_loading_next_task": "Loading next task...",
"i18n_task_completed": "The task has been completed!",
"i18n_thanks": "Thanks a lot!",
"i18n_congratulations": "Congratulations",
"i18n_congratulations_text": "You have participated in all available tasks!",
"i18n_wasp": "Yes! A Wasp",
"i18n_bee": "Yes! A Bee",
"i18n_no_photo": "No photo",
"i18n_i_dont_know": "I don't know",
"i18n_working_task": "You are working now on task:",
"i18n_tasks_completed": "You have completed:",
"i18n_tasks_from": "tasks from",
"i18n_show_comments": "Show comments",
"i18n_hide_comments": "Hide comments",
"i18n_question": "Do you see an insect in this photo?",
},
"es": {
"i18n_welldone": "Bien hecho!",
"i18n_welldone_text": "Tu respuesta ha sido guardada",
"i18n_loading_next_task": "Cargando la siguiente tarea...",
"i18n_task_completed": "La tarea ha sido completadas!",
"i18n_thanks": "Muchísimas gracias!",
"i18n_congratulations": "Enhorabuena",
"i18n_congratulations_text": "Has participado en todas las tareas disponibles!",
"i18n_wasp": "¡Sí! Una avispa",
"i18n_bee": "¡Sí! Una abeja",
"i18n_no_photo": "No hay foto",
"i18n_i_dont_know": "No lo sé",
"i18n_working_task": "Estás trabajando en la tarea:",
"i18n_tasks_completed": "Has completado:",
"i18n_tasks_from": "tareas de",
"i18n_show_comments": "Mostrar comentarios",
"i18n_hide_comments": "Ocultar comentarios",
"i18n_question": "¿Ves un insecto en esta foto?",
},
};
// Update userLocale with server side information
$(document).ready(function(){
userLocale = document.getElementById('PYBOSSA_USER_LOCALE').textContent.trim();
});
function i18n_translate() {
var ids = Object.keys(messages[userLocale])
for (i=0; i<ids.length; i++) {
if (document.getElementById(ids[i]) != null) {
document.getElementById(ids[i]).innerHTML = messages[userLocale][ids[i]];
}
}
}
function notify(text, showNotification){
$("#notification").remove();
var div = $("<div/>");
div.attr("id", "notification");
div.html(text);
if (showNotification === true) {
div.addClass("show-notification");
$("body").prepend(div);
}
else {
$("#notification").addClass("hide-notification");
}
}
pybossa.taskLoaded(function(task, deferred) {
if ( !$.isEmptyObject(task) ) {
// load image from flickr
var img = $('<img />');
img.load(function() {
// continue as soon as the image is loaded
notify("Loading next photo...", false);
deferred.resolve(task);
});
img.attr('src', task.info.url_b);
img.attr('id', 'photo-' + task.id);
img.addClass('img-responsive');
task.info.image = img;
}
else {
deferred.resolve(task);
}
});
pybossa.presentTask(function(task, deferred) {
if ( !$.isEmptyObject(task) ) {
i18n_translate();
window.scrollTo(0, $("#question").offset().top - 85);
$('#photo-frame').html('').append(task.info.image);
$('#photo-' + task.id).addClass('animated bounceInRight');
$('#task-id').html(task.id);
$('.btn-answer').off('click').on('click', function(evt) {
var answer = $(this).attr("value");
if (typeof answer != 'undefined') {
//console.log(answer);
pybossa.saveTask(task.id, answer).done(function() {
notify("Loading next photo...", true);
$('#photo-' + task.id).addClass('animated bounceOutLeft');
$('#photo-' + task.id).one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function(){
deferred.resolve();
});
});
if ($("#disqus_thread").is(":visible")) {
$('#disqus_thread').toggle();
$('.btn-disqus').toggle();
}
}
else {
notify("Something went wrong. Contact info@crowdcrafting.org", true);
}
});
}
else {
$(".skeleton").hide();
notify("You have contributed to all available tasks. Thanks a lot", true);
}
});
pybossa.run('raspberrypi');
</script>