Created
April 19, 2012 23:03
-
-
Save gilbo/2424766 to your computer and use it in GitHub Desktop.
mTurk Work Item (not working)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> | |
<script type='text/javascript' src="mmturkey.js"></script> | |
</head> | |
<body> | |
<p id="display"> Some Text </p> | |
<button id="submit">Submit</button> | |
<script type='text/javascript'> | |
var dummy_data = "dummy data entry" | |
var fullURL = window.location.href | |
turk.onTurk = (turk.assignmentId != "") | |
$('p#display').html( | |
"assignmentId = " + turk.assignmentId + "<br />" + | |
"hitId = " + turk.hitId + "<br />" + | |
"workerId = " + turk.workerId + "<br />" + | |
"turkSubmitTo = " + turk.turkSubmitTo + "<br />" + | |
"turk.onTurk = " + turk.onTurk + "<br />" + | |
"turk.previewMode = " + turk.previewMode + "<br />" + | |
"url = " + fullURL | |
) | |
if(!(turk.onTurk)) { | |
// we're not embedded on mechanical turk right now | |
$('button#submit').click(function(){ | |
$('p#display').html("Sorry, we're not on mTurk right now.") | |
}) | |
} else { | |
if(turk.previewMode) { | |
// We're currently just being previewed | |
$('button#submit').click(function(){ | |
$('p#display').html("Sorry, this is just a preview.") | |
}) | |
} else { | |
// store the basic info with some dummy data | |
// in our database, and then tell turk we're done | |
$('button#submit').click(function(){ | |
$.post("handle_post.php", { | |
assignmentId: turk.assignmentId, | |
hitId: turk.hitId, | |
workerId: turk.workerId, | |
data: dummy_data | |
}) | |
turk.submit() | |
}) | |
} | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment