Module: OpenFlashChart::Controller
- Defined in:
- lib/plugins/open_flash_chart/lib/open_flash_chart/open_flash_chart_object.rb
Instance Method Summary (collapse)
- - (Object) get_html(url, div_name, base, swf_file_name, width, height, protocol, obj_id)
- - (Object) get_object_values(url)
- - (Object) open_flash_chart_object(width, height, url, use_swfobject = true, base = "/", swf_file_name = "open-flash-chart.swf")
-
- (Object) open_flash_chart_object_and_div_name(width, height, url, use_swfobject = true, base = "/", swf_file_name = "open-flash-chart.swf")
if you want the div name back for working with js, this is the ticket.
- - (Object) open_flash_chart_object_from_hash(url, options = {})
Instance Method Details
- (Object) get_html(url, div_name, base, swf_file_name, width, height, protocol, obj_id)
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/plugins/open_flash_chart/lib/open_flash_chart/open_flash_chart_object.rb', line 40 def get_html(url, div_name, base, swf_file_name, width, height, protocol, obj_id) # NOTE: users should put this in the <head> section themselves: ## <script type="text/javascript" src="#{base}/javascripts/swfobject.js"></script> <<-HTML <div id="#{div_name}" class="open_flash_chart"></div> <script type="text/javascript"> swfobject.embedSWF("#{base}#{swf_file_name}", "#{div_name}", "#{width}", "#{height}", "9.0.0", "expressInstall.swf",{"data-file":"#{url}"}); </script> HTML end |
- (Object) get_object_values(url)
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/plugins/open_flash_chart/lib/open_flash_chart/open_flash_chart_object.rb', line 29 def get_object_values(url) @ofc_url = CGI::escape(url) # need something that will not be repeated on the same request @special_hash = Base64.encode64(Digest::SHA1.digest("#{rand(1<<64)}/#{Time.now.to_f}/#{Process.pid}/#{@ofc_url}"))[0..7] # only good characters for our div @special_hash = @special_hash.gsub(/[^a-zA-Z0-9]/,rand(10).to_s) @obj_id = "chart_#{@special_hash}" # some sequencing without all the work of tracking it @div_name = "flash_content_#{@special_hash}" @protocol = "http" # !request.nil? ? request.env["HTTPS"] || "http" : "http" end |
- (Object) open_flash_chart_object(width, height, url, use_swfobject = true, base = "/", swf_file_name = "open-flash-chart.swf")
5 6 7 8 |
# File 'lib/plugins/open_flash_chart/lib/open_flash_chart/open_flash_chart_object.rb', line 5 def open_flash_chart_object(width, height, url, use_swfobject=true, base="/", swf_file_name="open-flash-chart.swf") get_object_values(url) get_html(@ofc_url, @div_name, base, swf_file_name, width, height, @protocol, @obj_id) end |
- (Object) open_flash_chart_object_and_div_name(width, height, url, use_swfobject = true, base = "/", swf_file_name = "open-flash-chart.swf")
if you want the div name back for working with js, this is the ticket
11 12 13 14 15 |
# File 'lib/plugins/open_flash_chart/lib/open_flash_chart/open_flash_chart_object.rb', line 11 def open_flash_chart_object_and_div_name(width, height, url, use_swfobject=true, base="/", swf_file_name="open-flash-chart.swf") get_object_values(url) html = get_html(@ofc_url, @div_name, base, swf_file_name, width, height, @protocol, @obj_id) return [html, @div_name] end |
- (Object) open_flash_chart_object_from_hash(url, options = {})
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/plugins/open_flash_chart/lib/open_flash_chart/open_flash_chart_object.rb', line 17 def open_flash_chart_object_from_hash(url, ={}) get_object_values(url) get_html(@ofc_url, [:div_name] || @div_name, [:base] || "/", [:swf_file_name] || "open-flash-chart.swf", [:width] || 550, [:height] || 300, [:protocol] || @protocol, [:obj_id] || @obj_id) end |