-
+
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');