Skip to content

Instantly share code, notes, and snippets.

@gka
Created December 13, 2012 22:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gka/4280721 to your computer and use it in GitHub Desktop.
Save gka/4280721 to your computer and use it in GitHub Desktop.
Simplified version of flickrperson app. See https://github.com/PyBossa/pybossa.js/issues/8 for more information.
<h2>Do you see a human in this photo?</h2>
<div class="img-container"></div>
<button class="btn btn-large btn-success">Yes</button>
<button class="btn btn-large btn-danger">No</button>
<button class="btn btn-large btn-maybe">I don't know</button>
<script>
pybossa.taskLoaded(function(task, deferred) {
// load image from flickr
var img = $('<img />');
img.load(function() {
// continue as soon the image is loaded
deferred.resolve();
});
img.attr('src', task.info.image_url);
task.info.image = img;
});
pybossa.presentTask(function(task, deferred) {
$('.img-container').html('').append(task.info.image);
$('.btn').off('click').on('click', function(evt) {
var answer = $(evt.target).html();
pybossa.saveTask(task.id, answer).done(function() {
deferred.resolve();
});
});
});
pybossa.run('flickrperson2');
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment