Class: Gricer::CaptureController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/gricer/capture_controller.rb

Overview

This is the controller to capture additional values from the Javascript track tag.

Instance Method Summary collapse

Instance Method Details

#indexObject

This action stores the data submitted by the Javascript.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/controllers/gricer/capture_controller.rb', line 7

def index
  gricer_request = ::Gricer.config.request_model.first_by_id(params[:id])
  gricer_session = ::Gricer.config.session_model.first_by_id(session[:gricer_session])
  
  if gricer_session
    gricer_session.javascript          = true
    gricer_session.java                = params[:j]
    gricer_session.flash_version       = params[:f] unless params[:f] == 'false'
    gricer_session.silverlight_version = params[:sl] unless params[:sl] == 'false'
    gricer_session.screen_width        = params[:sx]
    gricer_session.screen_height       = params[:sy]
    gricer_session.screen_size         = "#{params[:sx]}x#{params[:sy]}" unless params[:sx].blank? or params[:sy].blank?
    gricer_session.screen_depth        = params[:sd] 
    gricer_session.save
   
    if gricer_request and gricer_request.session == gricer_session
          
      gricer_request.javascript          = true
      gricer_request.window_width        = params[:wx]
      gricer_request.window_height       = params[:wy]
  
      if gricer_request.save
        render text: 'ok'
      else
        render text: 'session only', status: 500
      end
      return
    else
      render text: 'session only'
      return
    end
  end
  render text: 'failed', status: 500
end