Skip to content

Commit 9268e79

Browse files
committed
template and tutorial with both Bootstrap 3 and 2
1 parent 3cb81be commit 9268e79

File tree

4 files changed

+222
-4
lines changed

4 files changed

+222
-4
lines changed

template.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class="row">
22
<!-- Success and Error Messages for the user -->
3-
<div class="span6 offset2" style="height:50px">
3+
<div class="col-md-6 col-md-offset-2" style="height:50px">
44
<div id="success" class="alert alert-success" style="display:none;">
55
<a class="close">×</a>
66
<strong>Well done!</strong> Your answer has been saved
@@ -33,7 +33,7 @@
3333
task.
3434
-->
3535
<div class="row skeleton"> <!-- Start Skeleton Row-->
36-
<div class="span6 "><!-- Start of Question and Submission DIV (column) -->
36+
<div class="col-md-6 "><!-- Start of Question and Submission DIV (column) -->
3737
<h1 id="question">Question</h1> <!-- The question will be loaded here -->
3838
<div id="answer"> <!-- Start DIV for the submission buttons -->
3939
<!-- If the user clicks this button, the saved answer will be value="yes"-->
@@ -65,7 +65,7 @@ <h1 id="question">Question</h1> <!-- The question will be loaded here -->
6565
<!-- Disqus thread for the given task -->
6666
<div id="disqus_thread" style="margin-top:5px;display:none"></div>
6767
</div><!-- End of Question and Submission DIV (column) -->
68-
<div class="span6"><!-- Start of Photo DIV (column) -->
68+
<div class="col-md-6"><!-- Start of Photo DIV (column) -->
6969
<a id="photo-link" href="#">
7070
<img id="photo" src="http://i.imgur.com/GeHxzb7.png" style="max-width=100%">
7171
</a>

template_bootstrap2.html

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
<div class="row">
2+
<!-- Success and Error Messages for the user -->
3+
<div class="span6 offset2" style="height:50px">
4+
<div id="success" class="alert alert-success" style="display:none;">
5+
<a class="close">×</a>
6+
<strong>Well done!</strong> Your answer has been saved
7+
</div>
8+
<div id="loading" class="alert alert-info" style="display:none;">
9+
<a class="close">×</a>
10+
Loading next task...
11+
</div>
12+
<div id="taskcompleted" class="alert alert-info" style="display:none;">
13+
<strong>The task has been completed!</strong> Thanks a lot!
14+
</div>
15+
<div id="finish" class="alert alert-success" style="display:none;">
16+
<strong>Congratulations!</strong> You have participated in all available tasks!
17+
<br/>
18+
<div class="alert-actions">
19+
<a class="btn small" href="/">Go back</a>
20+
<a class="btn small" href="/app">or, Check other applications</a>
21+
</div>
22+
</div>
23+
<div id="error" class="alert alert-error" style="display:none;">
24+
<a class="close">×</a>
25+
<strong>Error!</strong> Something went wrong, please contact the site administrators
26+
</div>
27+
</div> <!-- End Success and Error Messages for the user -->
28+
</div> <!-- End of Row -->
29+
30+
<!--
31+
Task DOM for loading the Flickr Images
32+
It uses the class="skeleton" to identify the elements that belong to the
33+
task.
34+
-->
35+
<div class="row skeleton"> <!-- Start Skeleton Row-->
36+
<div class="span6 "><!-- Start of Question and Submission DIV (column) -->
37+
<h1 id="question">Question</h1> <!-- The question will be loaded here -->
38+
<div id="answer"> <!-- Start DIV for the submission buttons -->
39+
<!-- If the user clicks this button, the saved answer will be value="yes"-->
40+
<button class="btn btn-success btn-answer" value='Yes'><i class="icon icon-white icon-thumbs-up"></i> Yes</button>
41+
<!-- If the user clicks this button, the saved answer will be value="no"-->
42+
<button class="btn btn-danger btn-answer" value='No'><i class="icon icon-white icon-thumbs-down"></i> No</button>
43+
<!-- If the user clicks this button, the saved answer will be value="NoPhoto"-->
44+
<button class="btn btn-answer" value='NoPhoto'><i class="icon icon-white icon-exclamation"></i> No photo</button>
45+
<!-- If the user clicks this button, the saved answer will be value="NotKnown"-->
46+
<button class="btn btn-answer" value='NotKnown'><i class="icon icon-white icon-question-sign"></i> I don't know</button>
47+
</div><!-- End of DIV for the submission buttons -->
48+
<!-- Feedback items for the user -->
49+
<p>You are working now on task: <span id="task-id" class="label label-warning">#</span></p>
50+
<p>You have completed: <span id="done" class="label label-info"></span> tasks from
51+
<!-- Progress bar for the user -->
52+
<span id="total" class="label label-inverse"></span></p>
53+
<div class="progress progress-striped">
54+
<div id="progress" rel="tooltip" title="#" class="bar" style="width: 0%;"></div>
55+
</div>
56+
<!--
57+
This application uses Disqus to allow users to provide some feedback.
58+
The next section includes a button that when a user clicks on it will
59+
load the comments, if any, for the given task
60+
-->
61+
<div id="disqus_show_btn" style="margin-top:5px;">
62+
<button class="btn btn-primary btn-large btn-disqus" onclick="loadDisqus()"><i class="icon-comments"></i> Show comments</button>
63+
<button class="btn btn-large btn-disqus" onclick="loadDisqus()" style="display:none"><i class="icon-comments"></i> Hide comments</button>
64+
</div><!-- End of Disqus Button section -->
65+
<!-- Disqus thread for the given task -->
66+
<div id="disqus_thread" style="margin-top:5px;display:none"></div>
67+
</div><!-- End of Question and Submission DIV (column) -->
68+
<div class="span6"><!-- Start of Photo DIV (column) -->
69+
<a id="photo-link" href="#">
70+
<img id="photo" src="http://i.imgur.com/GeHxzb7.png" style="max-width=100%">
71+
</a>
72+
</div><!-- End of Photo DIV (columnt) -->
73+
</div><!-- End of Skeleton Row -->
74+
75+
<script type="text/javascript">
76+
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
77+
78+
/* * * DON'T EDIT BELOW THIS LINE * * */
79+
function loadDisqus() {
80+
$("#disqus_thread").toggle();
81+
$(".btn-disqus").toggle();
82+
var disqus_shortname = 'pybossa'; // required: replace example with your forum shortname
83+
//var disqus_identifier = taskId;
84+
var disqus_developer = 1;
85+
86+
(function() {
87+
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
88+
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
89+
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
90+
})();
91+
}
92+
93+
</script>
94+
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
95+
96+
<script>
97+
function loadUserProgress() {
98+
pybossa.userProgress('flickrperson').done(function(data){
99+
var pct = Math.round((data.done*100)/data.total);
100+
$("#progress").css("width", pct.toString() +"%");
101+
$("#progress").attr("title", pct.toString() + "% completed!");
102+
$("#progress").tooltip({'placement': 'left'});
103+
$("#total").text(data.total);
104+
$("#done").text(data.done);
105+
});
106+
}
107+
108+
pybossa.taskLoaded(function(task, deferred) {
109+
if ( !$.isEmptyObject(task) ) {
110+
// load image from flickr
111+
var img = $('<img />');
112+
img.load(function() {
113+
// continue as soon as the image is loaded
114+
deferred.resolve(task);
115+
});
116+
img.attr('src', task.info.url_b).css('height', 460);
117+
img.addClass('img-polaroid');
118+
task.info.image = img;
119+
}
120+
else {
121+
deferred.resolve(task);
122+
}
123+
});
124+
125+
pybossa.presentTask(function(task, deferred) {
126+
if ( !$.isEmptyObject(task) ) {
127+
loadUserProgress();
128+
$('#photo-link').html('').append(task.info.image);
129+
$("#photo-link").attr("href", task.info.link);
130+
$("#question").html(task.info.question);
131+
$('#task-id').html(task.id);
132+
$('.btn-answer').off('click').on('click', function(evt) {
133+
var answer = $(evt.target).attr("value");
134+
if (typeof answer != 'undefined') {
135+
//console.log(answer);
136+
pybossa.saveTask(task.id, answer).done(function() {
137+
deferred.resolve();
138+
});
139+
$("#loading").fadeIn(500);
140+
if ($("#disqus_thread").is(":visible")) {
141+
$('#disqus_thread').toggle();
142+
$('.btn-disqus').toggle();
143+
}
144+
}
145+
else {
146+
$("#error").show();
147+
}
148+
});
149+
$("#loading").hide();
150+
}
151+
else {
152+
$(".skeleton").hide();
153+
$("#loading").hide();
154+
$("#finish").fadeIn(500);
155+
}
156+
});
157+
158+
pybossa.run('flickrperson');
159+
</script>

tutorial.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div class="row">
2-
<div class="span12">
2+
<div class="col-md-12">
33
<div id="modal" class="modal hide fade">
44
<div class="modal-header">
55
<h3>Flickr Person Finder tutorial</h3>

tutorial_bootstrap2.html

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<div class="row">
2+
<div class="span12">
3+
<div id="modal" class="modal hide fade">
4+
<div class="modal-header">
5+
<h3>Flickr Person Finder tutorial</h3>
6+
</div>
7+
<div id="0" class="modal-body" style="display:none">
8+
<p><strong>Hi!</strong> This is a <strong>demo application</strong> that shows how you can do pattern recognition on pictures or images using the PyBossa framework in Crowdcrafting.org.
9+
</p>
10+
</div>
11+
<div id="1" class="modal-body" style="display:none">
12+
<p>The application is really simple. It loads a photo from <a href="http://flickr.com">Flickr</a> and asks you this question: <strong>Do you see a human in this photo?</strong></p>
13+
<img src="http://farm7.staticflickr.com/6109/6286728068_2f3c6912b8_q.jpg" class="img-polaroid"/>
14+
<p>You will have 3 possible answers:
15+
<ul>
16+
<li>Yes,</li>
17+
<li>No, and</li>
18+
<li>I don't know</li>
19+
</ul>
20+
</p>
21+
<p>
22+
</p>
23+
<p>All you have to do is to click in one of the three possible answers and you will be done. This demo application could be adapted for more complex pattern recognition problems.</p>
24+
</div>
25+
<div class="modal-footer">
26+
<a id="prevBtn" href="#" onclick="showStep('prev')" class="btn">Previous</a>
27+
<a id="nextBtn" href="#" onclick="showStep('next')" class="btn btn-success">Next</a>
28+
<a id="startContrib" href="../flickrperson/newtask" class="btn btn-primary" style="display:none"><i class="icon-thumbs-up"></i> Try the demo!</a>
29+
</div>
30+
</div>
31+
</div>
32+
</div>
33+
<script>
34+
var step = -1;
35+
function showStep(action) {
36+
$("#" + step).hide();
37+
if (action == 'next') {
38+
step = step + 1;
39+
}
40+
if (action == 'prev') {
41+
step = step - 1;
42+
}
43+
if (step == 0) {
44+
$("#prevBtn").hide();
45+
}
46+
else {
47+
$("#prevBtn").show();
48+
}
49+
50+
if (step == 1 ) {
51+
$("#nextBtn").hide();
52+
$("#startContrib").show();
53+
}
54+
$("#" + step).show();
55+
}
56+
57+
showStep('next');
58+
$("#modal").modal('show');
59+
</script>

0 commit comments

Comments
 (0)