You are here

function BotchaRecipeHoneypot::getJsValue in BOTCHA Spam Prevention 7.2

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

Overrides BotchaRecipeUsingJsAbstract::getJsValue

1 method overrides BotchaRecipeHoneypot::getJsValue()
BotchaRecipeHoneypot2::getJsValue in controller/botcha_recipe.controller.inc

File

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

Class

BotchaRecipeHoneypot

Code

function getJsValue() {

  // Just ensure that parameters are set.
  $fields = $this
    ->getProperty($this->settings['fields'], 'getFields');
  $js = $this
    ->getProperty($this->settings['js'], 'getJs');
  $js_tok1 = reset($js['chops']);
  $js_tok2 = next($js['chops']);
  return <<<END
(function (\$) {
  Drupal.behaviors.{<span class="php-variable">$js</span>[<span class="php-string">'name'</span>]} = {
    attach: function (context, settings) {
      \$("input.{<span class="php-variable">$fields</span>[<span class="php-constant">0</span>][<span class="php-string">'class'</span>]}").each(function() {
        f=\$(this)[0];
        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>]})+"{<span class="php-variable">$js_tok2</span>}";}
      });
    }
  };
})(jQuery);
END;
}