From 31453a7e9be4fcab649cd37e43ff963eefb96290 Mon Sep 17 00:00:00 2001 From: DonatoB Date: Fri, 6 Jun 2014 17:25:27 -0400 Subject: [PATCH] Some ideas to hopefully help out d exit --- Overview/turk/getAnswers.php | 2 +- Overview/turk/moneyLeft.php | 2 +- Retainer/instructions.php | 2 ++ Retainer/scripts/api.js | 7 ++++++ Retainer/scripts/setOnline.js | 45 +++++++++++++++++++++-------------- Retainer/style/legion.css | 4 ++-- Retainer/style/trigger.css | 5 ++-- Retainer/trigger.php | 2 +- baseURL.php => config.php | 0 index.php | 2 +- isSandbox.php | 17 ++++--------- mturk.js | 26 +++++++++++++------- 12 files changed, 66 insertions(+), 48 deletions(-) rename baseURL.php => config.php (100%) diff --git a/Overview/turk/getAnswers.php b/Overview/turk/getAnswers.php index 186976a..d5267cf 100755 --- a/Overview/turk/getAnswers.php +++ b/Overview/turk/getAnswers.php @@ -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'; diff --git a/Overview/turk/moneyLeft.php b/Overview/turk/moneyLeft.php index 8c36275..8cda931 100755 --- a/Overview/turk/moneyLeft.php +++ b/Overview/turk/moneyLeft.php @@ -2,7 +2,7 @@ error_reporting(E_ALL); include("../../amtKeys.php"); -include("../../baseURL.php"); +include("../../config.php"); include("../../isSandbox.php"); include 'turk_functions.php'; diff --git a/Retainer/instructions.php b/Retainer/instructions.php index f1212f3..3190572 100755 --- a/Retainer/instructions.php +++ b/Retainer/instructions.php @@ -1,5 +1,7 @@

Instructions

- + diff --git a/baseURL.php b/config.php similarity index 100% rename from baseURL.php rename to config.php diff --git a/index.php b/index.php index 969cfd1..f36bedf 100755 --- a/index.php +++ b/index.php @@ -11,7 +11,7 @@ - + diff --git a/isSandbox.php b/isSandbox.php index 1847866..c18b73a 100755 --- a/isSandbox.php +++ b/isSandbox.php @@ -1,16 +1,9 @@ diff --git a/mturk.js b/mturk.js index f854214..239193e 100755 --- a/mturk.js +++ b/mturk.js @@ -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. @@ -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 = $("").appendTo($(form_selector)); - var workerId_input = $("").appendTo($(form_selector)); - var hitId_input = $("").appendTo($(form_selector)); + // name jquery objects with a $ in front of name - good code convention + var $aid_input = $("").appendTo($(form_selector)); + var $workerId_input = $("").appendTo($(form_selector)); + var $hitId_input = $("").appendTo($(form_selector)); // Make sure the submit form's method is POST $(form_selector).attr('method', 'POST');