Skip to content

Commit

Permalink
Dev EM-based validation and navigation sub-system:
Browse files Browse the repository at this point in the history
Dev optimization - checkconditions was being called on every onkeyup event for some question types.  Changed all to onchange, but left onkeyup to filter out non-numeric values when needed.

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_dev_tms@11542 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
TMSWhite committed Nov 30, 2011
1 parent 4f95ba5 commit a3aed59
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions qanda1.php
Expand Up @@ -3357,7 +3357,7 @@ function do_multiplechoice($ia)
{
$answer .= ' value="'.htmlspecialchars($_SESSION[$myfname],ENT_QUOTES).'"';
}
$answer .= " onkeyup='$(\"#java{$myfname}\").val(this.value);$checkconditionFunction(this.value, this.name, this.type);if ($.trim($(\"#java{$myfname}\").val())!=\"\" && !document.getElementById(\"answer{$myfname}cbox\").checked) { \$(\"#answer{$myfname}cbox\").attr(\"checked\",\"checked\"); } $numbersonly ".$callmaxanswscriptcheckbox."' />";
$answer .= " onchange='$(\"#java{$myfname}\").val(this.value);$checkconditionFunction(this.value, this.name, this.type);if ($.trim($(\"#java{$myfname}\").val())!=\"\" && !document.getElementById(\"answer{$myfname}cbox\").checked) { \$(\"#answer{$myfname}cbox\").attr(\"checked\",\"checked\"); } $numbersonly ".$callmaxanswscriptcheckbox."' />";
$answer .= '<input type="hidden" name="java'.$myfname.'" id="java'.$myfname.'" value="';

if ($maxansw > 0)
Expand Down Expand Up @@ -3671,7 +3671,7 @@ function do_multiplechoice_withcomments($ia)
."<input class='text ".$kpclass."' type='text' size='40' id='answer$myfname2' name='$myfname2' title='".$clang->gT("Make a comment on your choice here:")."' value='";
if (isset($_SESSION[$myfname2])) {$answer_main .= htmlspecialchars($_SESSION[$myfname2],ENT_QUOTES);}
// --> START NEW FEATURE - SAVE
$answer_main .= "' onclick='cancelBubbleThis(event);' onkeyup='if (jQuery.trim($(\"#answer{$myfname2}\").val())!=\"\") { document.getElementById(\"answer{$myfname}\").checked=true;$checkconditionFunction(document.getElementById(\"answer{$myfname}\").value,\"$myfname\",\"checkbox\");}' onkeyup='".$callmaxanswscriptcheckbox2."(document.getElementById(\"answer{$myfname}\"))' />\n\t</label>\n</span>\n"
$answer_main .= "' onclick='cancelBubbleThis(event);' onchange='if (jQuery.trim($(\"#answer{$myfname2}\").val())!=\"\") { document.getElementById(\"answer{$myfname}\").checked=true;$checkconditionFunction(document.getElementById(\"answer{$myfname}\").value,\"$myfname\",\"checkbox\");}' onkeyup='".$callmaxanswscriptcheckbox2."(document.getElementById(\"answer{$myfname}\"))' />\n\t</label>\n</span>\n"

. "\t</li>\n";
// --> END NEW FEATURE - SAVE
Expand Down Expand Up @@ -4105,7 +4105,7 @@ function do_multipleshorttext($ia)
. "<label for=\"answer$myfname\">{$ansrow['question']}</label>\n"
. "\t<span>\n".$prefix."\n".'
<textarea class="textarea '.$kpclass.'" name="'.$myfname.'" id="answer'.$myfname.'"
rows="'.$drows.'" cols="'.$tiwidth.'" maxlength="'.$maxsize.'" onchange="textLimit(\'answer'.$myfname.'\', '.$maxsize.');" onkeyup="textLimit(\'answer'.$myfname.'\', '.$maxsize.'); '.$checkconditionFunction.'(this.value, this.name, this.type);" '.$numbersonly.'>';
rows="'.$drows.'" cols="'.$tiwidth.'" maxlength="'.$maxsize.'" onchange="textLimit(\'answer'.$myfname.'\', '.$maxsize.'); '.$checkconditionFunction.'(this.value, this.name, this.type);" onkeyup="textLimit(\'answer'.$myfname.'\', '.$maxsize.');" '.$numbersonly.'>';

if($label_width < strlen(trim(strip_tags($ansrow['question']))))
{
Expand Down Expand Up @@ -4146,7 +4146,7 @@ function do_multipleshorttext($ia)
}

// --> START NEW FEATURE - SAVE
$answer_main .= '" onkeyup="'.$checkconditionFunction.'(this.value, this.name, this.type);" '.$numbersonly.' maxlength="'.$maxsize.'" />'."\n".$suffix."\n\t</span>\n"
$answer_main .= '" onchange="'.$checkconditionFunction.'(this.value, this.name, this.type);" '.$numbersonly.' maxlength="'.$maxsize.'" />'."\n".$suffix."\n\t</span>\n"
. "\t</li>\n";
// --> END NEW FEATURE - SAVE

Expand Down Expand Up @@ -4444,7 +4444,7 @@ function do_multiplenumeric($ia)
$answer_main .= $_SESSION[$myfname];
}

$answer_main .= '" onkeyup="'.$checkconditionFunction.'(this.value, this.name, this.type);" '.$numbersonly.' maxlength="'.$maxsize."\" />\n\t".$suffix."\n</span>\n\t</li>\n";
$answer_main .= '" onchange="'.$checkconditionFunction.'(this.value, this.name, this.type);" '.$numbersonly.' maxlength="'.$maxsize."\" />\n\t".$suffix."\n</span>\n\t</li>\n";

}
else
Expand Down Expand Up @@ -4845,7 +4845,7 @@ function do_shortfreetext($ia)

// --> START NEW FEATURE - SAVE
$answer = '<textarea class="textarea '.$kpclass.'" name="'.$ia[1].'" id="answer'.$ia[1].'" '
.'rows="'.$drows.'" cols="'.$tiwidth.'" maxlength="'.$maxsize.'" onchange="textLimit(\'answer'.$ia[1].'\', '.$maxsize.');" onkeyup="textLimit(\'answer'.$ia[1].'\', '.$maxsize.'); '.$checkconditionFunction.'(this.value, this.name, this.type);" '.$numbersonly.'>';
.'rows="'.$drows.'" cols="'.$tiwidth.'" maxlength="'.$maxsize.'" onchange="textLimit(\'answer'.$ia[1].'\', '.$maxsize.');'.$checkconditionFunction.'(this.value, this.name, this.type);" onkeyup="textLimit(\'answer'.$ia[1].'\', '.$maxsize.'); " '.$numbersonly.'>';
// --> END NEW FEATURE - SAVE

if ($_SESSION[$ia[1]]) {$answer .= str_replace("\\", "", $_SESSION[$ia[1]]);}
Expand Down Expand Up @@ -4903,7 +4903,7 @@ function do_shortfreetext($ia)
<input class=\"text location ".$kpclass."\" type=\"text\" size=\"20\" name=\"$ia[1]_c\"
id=\"answer$ia[1]_c\" value=\"$currentLocation\"
onkeyup=\"$checkconditionFunction(this.value, this.name, this.type)\" />
onchange=\"$checkconditionFunction(this.value, this.name, this.type)\" />
</p>
<input type=\"hidden\" name=\"boycott_$ia[1]\" id=\"boycott_$ia[1]\"
Expand Down Expand Up @@ -4933,7 +4933,7 @@ class=\"mapservice\" value = \"{$qidattributes['location_mapservice']}\" >
//no question attribute set, use common input text field
$answer = "<p class=\"question\">\n\t$prefix\n\t<input class=\"text $kpclass\" type=\"text\" size=\"$tiwidth\" name=\"$ia[1]\" id=\"answer$ia[1]\" value=\""
.htmlspecialchars($_SESSION[$ia[1]],ENT_QUOTES,'UTF-8')
."\" maxlength=\"$maxsize\" onkeyup=\"$checkconditionFunction(this.value, this.name, this.type)\" $numbersonly />\n\t$suffix\n</p>\n";
."\" maxlength=\"$maxsize\" onchange=\"$checkconditionFunction(this.value, this.name, this.type)\" $numbersonly />\n\t$suffix\n</p>\n";
}


Expand Down Expand Up @@ -5022,7 +5022,7 @@ function do_longfreetext($ia)

// --> START NEW FEATURE - SAVE
$answer = '<textarea class="textarea '.$kpclass.'" name="'.$ia[1].'" id="answer'.$ia[1].'" alt="'.$clang->gT('Answer').'" '
.'rows="'.$drows.'" cols="'.$tiwidth.'" maxlength="'.$maxsize.'" onchange="textLimit(\'answer'.$ia[1].'\', '.$maxsize.');" onkeyup="textLimit(\'answer'.$ia[1].'\', '.$maxsize.'); '.$checkconditionFunction.'(this.value, this.name, this.type)">';
.'rows="'.$drows.'" cols="'.$tiwidth.'" maxlength="'.$maxsize.'" onchange="textLimit(\'answer'.$ia[1].'\', '.$maxsize.'); '.$checkconditionFunction.'(this.value, this.name, this.type)" onkeyup="textLimit(\'answer'.$ia[1].'\', '.$maxsize.');">';
// --> END NEW FEATURE - SAVE

if ($_SESSION[$ia[1]]) {$answer .= str_replace("\\", "", $_SESSION[$ia[1]]);}
Expand Down Expand Up @@ -5101,7 +5101,7 @@ function do_hugefreetext($ia)

// --> START NEW FEATURE - SAVE
$answer = '<textarea class="textarea '.$kpclass.'" name="'.$ia[1].'" id="answer'.$ia[1].'" alt="'.$clang->gT('Answer').'" '
.'rows="'.$drows.'" cols="'.$tiwidth.'" maxlength="'.$maxsize.'" onchange="textLimit(\'answer'.$ia[1].'\', '.$maxsize.');" onkeyup="textLimit(\'answer'.$ia[1].'\', '.$maxsize.'); '.$checkconditionFunction.'(this.value, this.name, this.type)">';
.'rows="'.$drows.'" cols="'.$tiwidth.'" maxlength="'.$maxsize.'" onchange="textLimit(\'answer'.$ia[1].'\', '.$maxsize.');'.$checkconditionFunction.'(this.value, this.name, this.type)" onkeyup="textLimit(\'answer'.$ia[1].'\', '.$maxsize.');">';
// --> END NEW FEATURE - SAVE

if ($_SESSION[$ia[1]]) {$answer .= str_replace("\\", "", $_SESSION[$ia[1]]);}
Expand Down

0 comments on commit a3aed59

Please sign in to comment.