Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Overview/turk/getAnswers.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
set_time_limit ( 10000);

include("../../amtKeys.php");
include("../../baseURL.php");
include("../../config.php");
include("../../isSandbox.php");
include("../../getDB.php");
include 'turk_functions.php';
Expand Down
2 changes: 1 addition & 1 deletion Overview/turk/moneyLeft.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
error_reporting(E_ALL);

include("../../amtKeys.php");
include("../../baseURL.php");
include("../../config.php");
include("../../isSandbox.php");
include 'turk_functions.php';

Expand Down
2 changes: 2 additions & 0 deletions Retainer/instructions.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<h2 class="instructions" style="margin-left:15px"><u>Instructions</u></h2>
<?php
// This should be surrounded by something like
// if (isDebugMode()) {
error_reporting(E_ALL);
ini_set("display_errors", 1);

Expand Down
7 changes: 7 additions & 0 deletions Retainer/scripts/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,12 @@ $(document).ready( function() {
});
}

// This file appears to do nothing?
// If these are meant to be global functions it is best to namespace them, for example
window.legion = {
call : call,
query_available : query_available
};


});
45 changes: 27 additions & 18 deletions Retainer/scripts/setOnline.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
$(document).ready(function() {
setInterval( function() {
var worker = gup("workerId");
var assignment = gup("assignmentId");
var task = gup('task') ? gup('task') : "default";
//if( assignment != "ASSIGNMENT_ID_NOT_AVAILABLE" ) {
$.ajax({
url: "php/ajax_whosonline.php",
data: {task: task, worker: worker, role: "crowd"},
dataType: "text",
success: function(d) {
//
},
fail: function() {
alert("setOnline failed!")
},
});
//}
}, 3000);
setInterval( function() {
var worker = gup("workerId"),
assignment = gup("assignmentId"),
task = gup('task') ? gup('task') : "default";

//if( assignment === "ASSIGNMENT_ID_NOT_AVAILABLE" ) {
// return;
// }
$.ajax({
url: "php/ajax_whosonline.php",
dataType: "text",
data: {
task : task,
worker : worker,
assignment : assignment,
role : "crowd"
},
success: function() { },
fail: function() {
throw {
name: 'counterfailed',
message:'something important here'
}
}
});
}, 3000);
});
// Wow i think i wrote this one???
4 changes: 2 additions & 2 deletions Retainer/style/legion.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@

.legion-score-display-r {
z-index: 100;
background: none !important;
background: none !important; // !important should be avoided as much as possible
border: none !important;
color: #F00 !important;
font-weight: bold;
overflow: hidden;
font-size: 1.2em;
font-size: 1.2em; // industry seems to prefer px lately
}

.legion-score-display-a {
Expand Down
5 changes: 2 additions & 3 deletions Retainer/style/trigger.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
text-align: center;
}

// block stuff like this is often put into a "reset.css" file which comes before the rest of css
body{
padding-left:20px;
}
Expand All @@ -17,6 +18,4 @@ body{
height: 21em;
}

.recruitingDiv button{
/*margin-bottom: 10px;*/
}
// delete unused code :)
2 changes: 1 addition & 1 deletion Retainer/trigger.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<script type="text/javascript" src="scripts/bootstrap.touchspin.js"></script>
<script type="text/javascript" src="scripts/hitsOverview.js"></script>

<script> var baseURL = "<?php include('../baseURL.php'); echo $baseURL; ?>"; </script>
<script> var baseURL = "<?php include('../config.php'); echo $baseURL; ?>"; </script>

<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<link rel="stylesheet" href="style/trigger.css">
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<script type="text/javascript" src="Retainer/scripts/jquery.blockUI.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>

<script> var baseURL = "<?php include('baseURL.php'); echo $baseURL; ?>"; </script>
<script> var baseURL = "<?php include('config.php'); echo $baseURL; ?>"; </script>

<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<link rel="stylesheet" href="Retainer/style/trigger.css">
Expand Down
17 changes: 5 additions & 12 deletions isSandbox.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
<?php


//uncomment and comment as neccesary to determine sandbox usage
//$SANDBOX=false;
$SANDBOX=true;

//if a URL parameter is preset, override the previous variable

if(isset($_REQUEST['useSandbox']))
{
if($_REQUEST['useSandbox'] == "true") $SANDBOX = true;
else if ($_REQUEST['useSandbox'] == "false") $SANDBOX = false;
}
// I would recommend an API like this.
// If &sandbox is in URL then it is sandboxed, else it is not.
function useSandbox() {
return (isset($_GET['sandbox']));
}

?>
26 changes: 17 additions & 9 deletions mturk.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,19 @@ var form_selector = "#mturk_form";

// function for getting URL parameters
function gup(name) {
// Every regex in the world needs a comment describing it!
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp(regexS);

var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.href);
if(results == null)
return "";
else return unescape(results[1]);
// Always check for what you are looking for, instead of what it shouldn't be
// this is called "whitelisting" as opposed to "blacklisting"
if(typeof results !== "String") {
return "";
}

return unescape(results[1]);
}

// Turkify the captioning page.
Expand All @@ -29,15 +35,17 @@ $(document).ready(function () {
if((aid = gup("assignmentId"))!="" && $(form_selector).length>0) {

// If the HIT hasn't been accepted yet, disabled the form fields.
if(aid == "ASSIGNMENT_ID_NOT_AVAILABLE") {
// Always use triple equality in js
if(aid === "ASSIGNMENT_ID_NOT_AVAILABLE") {
$('input,textarea,select').attr("DISABLED", "disabled");
}

// Add a new hidden input element with name="assignmentId" that
// with assignmentId as its value.
var aid_input = $("<input type='hidden' name='assignmentId' value='" + aid + "'>").appendTo($(form_selector));
var workerId_input = $("<input type='hidden' name='workerId' value='" + gup("workerId") + "'>").appendTo($(form_selector));
var hitId_input = $("<input type='hidden' name='hitId' value='" + gup("hitId") + "'>").appendTo($(form_selector));
// name jquery objects with a $ in front of name - good code convention
var $aid_input = $("<input type='hidden' name='assignmentId' value='" + aid + "'>").appendTo($(form_selector));
var $workerId_input = $("<input type='hidden' name='workerId' value='" + gup("workerId") + "'>").appendTo($(form_selector));
var $hitId_input = $("<input type='hidden' name='hitId' value='" + gup("hitId") + "'>").appendTo($(form_selector));

// Make sure the submit form's method is POST
$(form_selector).attr('method', 'POST');
Expand Down