9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/planbcd/rails/view_helpers.rb', line 9
def pbcd_init
unless js_url = PlanBCD::Rails.configuration.js_url.presence
raise PlanBCD::Rails::RuntimeError, "PlanBCD Javascript has not been set."
end
if js_url.respond_to?(:call)
js_url = js_url.call(controller)
else
js_url.gsub!(%r|^https?://|, '//')
end
s = '<script type="text/javascript">'
s += %Q~(function(){!function(a,b,c,d,e){return d="http"+("https:"===c?"s":"")+":"+d,a.planBCDObject=e,a[e]||(a[e]=function(){var b;return((b=a[e]).q||(b.q=[])).push(arguments),a[e].l=1*new Date}),b.write(unescape('%3Cscript type="text/javascript" src="'+d+'"%3E%3C/script%3E'))}(window,document,document.location.protocol,"#{html_escape(js_url)}","pbcd")}).call(this);~
s += '</script>'
s.html_safe
end
|