You are here

function BotchaRecipeHoneypot2::getJsValue in BOTCHA Spam Prevention 6.2

Same name and namespace in other branches
  1. 6.3 controller/recipe/botcha.recipe.controller.inc \BotchaRecipeHoneypot2::getJsValue()
  2. 7.2 controller/botcha_recipe.controller.inc \BotchaRecipeHoneypot2::getJsValue()
  3. 7.3 controller/recipe/botcha.recipe.controller.inc \BotchaRecipeHoneypot2::getJsValue()

Overrides BotchaRecipeHoneypot::getJsValue

File

controller/botcha_recipe.controller.inc, line 684
Controller layer of the BotchaRecipe objects.

Class

BotchaRecipeHoneypot2

Code

function getJsValue() {
  $fields = $this
    ->getProperty($this->settings['fields'], 'getFields');
  $js = $this
    ->getProperty($this->settings['js'], 'getJs');
  $js_tok1 = reset($js['chops']);
  $selector = "input.{$fields[0]['class']}";

  // @todo Abstract it.
  return <<<END
Drupal.behaviors.{<span class="php-variable">$js</span>[<span class="php-string">'name'</span>]} = function() {
  \$("{<span class="php-variable">$selector</span>}").each(function() {
    f=\$(this)[0];
    tok2=\$.trim(\$(f).css('fontFamily').split(',')[1]);
    if(tok2.charAt(0) == "'" || tok2.charAt(0) == '"') tok2=tok2.substring(1, tok2.length-1);
    tok2=tok2.substring(1, tok2.length);
    if (f.value.indexOf("{<span class="php-variable">$js</span>[<span class="php-string">'match'</span>]}")==0){f.value="{<span class="php-variable">$js_tok1</span>}"+f.value.substring({<span class="php-variable">$js</span>[<span class="php-string">'pos'</span>]})+tok2;}
  });
};
END;
}