|
| 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> |
0 commit comments