Project

General

Profile

Feature #675 » recaptchaplugin_add_ajax_api_support.patch

evan wheeler, 2008-07-07 17:24

View differences:

lib/recaptcha.rb
19 19
        if options[:display] 
20 20
          xhtml.script(:type => "text/javascript"){ xhtml.text! "var RecaptchaOptions = #{options[:display].to_json};\n"}
21 21
        end
22
        xhtml.script(:type => "text/javascript", :src => "#{uri}/challenge?k=#{key}&error=#{error}") {}
23
        unless options[:noscript] == false
24
          xhtml.noscript do
25
            xhtml.iframe(:src => "#{uri}/noscript?k=#{key}",
26
                         :height => options[:iframe_height] ||= 300,
27
                         :width  => options[:iframe_width]  ||= 500,
28
                         :frameborder => 0) {}; xhtml.br
29
            xhtml.textarea(:name => "recaptcha_challenge_field", :rows => 3, :cols => 40) {}
30
            xhtml.input :name => "recaptcha_response_field",
31
                        :type => "hidden", :value => "manual_challenge"
22
        if options[:ajax]
23
         xhtml.div(:id => 'dynamic_recaptcha') {}
24
         xhtml.script(:type => "text/javascript", :src => "#{uri}/js/recaptcha_ajax.js") {}
25
         xhtml.script(:type => "text/javascript") do
26
           xhtml.text! "Recaptcha.create('#{key}', document.getElementById('dynamic_recaptcha') );"
27
         end
28
        else
29
          xhtml.script(:type => "text/javascript", :src => "#{uri}/challenge?k=#{key}&error=#{error}") {}
30
          unless options[:noscript] == false
31
            xhtml.noscript do
32
              xhtml.iframe(:src => "#{uri}/noscript?k=#{key}",
33
                           :height => options[:iframe_height] ||= 300,
34
                           :width  => options[:iframe_width]  ||= 500,
35
                           :frameborder => 0) {}; xhtml.br
36
              xhtml.textarea(:name => "recaptcha_challenge_field", :rows => 3, :cols => 40) {}
37
              xhtml.input :name => "recaptcha_response_field",
38
                          :type => "hidden", :value => "manual_challenge"
39
            end
32 40
          end
33 41
        end
34 42
        raise ReCaptchaError, "No public key specified." unless key
(1-1/4)