Class FontController
In: app/controllers/font_controller1.rb
app/controllers/font_controller.rb
Parent: ApplicationController

Methods

Public Instance methods

[Source]

     # File app/controllers/font_controller.rb, line 113
113:         def backspace
114:                 if session[:state]==0
115:                         redirect_to("/modules/first_time")
116:                 else
117:                         session[:state]=0
118:                         redirect_to :action=>"index"
119:                 end
120:         end

[Source]

    # File app/controllers/font_controller.rb, line 24
24:         def designers
25: 'co-designers: Deepak Garg , Manpreet Singh, Parth Mehta'
26:         end

[Source]

     # File app/controllers/font_controller.rb, line 82
 82:         def extras
 83:                 @title='Font selector' #needs changing
 84:                 @font_data=get_font_data
 85: 
 86:                 get_selected_size
 87:                 get_selected_color
 88:                 get_selected_font
 89:                 get_unselected_size
 90:                 get_unselected_color
 91:                 get_unselected_font
 92:                 get_bgcolor
 93: 
 94:                 session[:preselected] = %Q{<P ALIGN=LEFT><FONT COLOR="#{session[:selected_color]}"><FONT SIZE="7" STYLE="font-size:
 95: #{session[:selected_size]}"><SPAN STYLE="background: #{session[:bgcolor]}; font-family: #{session[:selected_font]}">}
 96:                 session[:postselected] = %Q{</SPAN></FONT></FONT></P>}
 97:                 session[:preunselected] = %Q{<P ALIGN=LEFT><FONT COLOR="#{session[:unselected_color]}"><FONT SIZE="7"
 98: STYLE="font-size: #{session[:unselected_size]}; font-family: #{session[:unselected_font]}"><B>}
 99:                 session[:postunselected] = %Q{</B></FONT></FONT></P>}
100: 
101: 
102:                 @preselected = get_preselected
103:                 @postselected = get_postselected
104:                 @preunselected = get_preunselected
105:                 @postunselected = get_postunselected
106: 
107:                 if session[:state]==1
108:                         @selected_item = session[:freeze] % get_choices.size
109:                         @title="You can now change the #{get_choices[@selected_item]}"
110:                 end
111:         end

[Source]

     # File app/controllers/font_controller1.rb, line 82
 82:         def extras
 83:                 @fd=get_fd
 84: 
 85:                 session[:preselected] = %Q{<P ALIGN=LEFT><FONT
 86: COLOR="#{session[:selected_color]}"><FONT SIZE="7"
 87: STYLE="font-size:  #{session[:selected_size]}"><SPAN
 88: STYLE="background: black; font-family:
 89: #{session[:selected_font]}">}
 90:                 session[:postselected] = %Q{</SPAN></FONT></FONT></P>}
 91:                 session[:preunselected] = %Q{<P ALIGN=LEFT><FONT
 92: COLOR="#{session[:unselected_color]}"><FONT SIZE="7"
 93: STYLE="font-size: #{session[:unselected_size]}; font-family:
 94: #{session[:unselected_font]}"><B>}
 95:                 session[:postunselected] = '</B></FONT></FONT></P>'
 96: 
 97: 
 98:                 @preselected = get_preselected
 99:                 @postselected = get_postselected
100:                 @preunselected = get_preunselected
101:                 @postunselected = get_postunselected
102: 
103:                 if session[:state]==1
104:                         @selected_item = session[:freeze]%get_choices.size
105:                 end
106:                 logger.info("state1:#{session[:state]}")
107: 
108: logger.info("selitem:#{@selected_item},sess_sel_item:#{
109: session[:selected_item]},freeze:#{session[:freeze]}" )
110: 
111:         end

[Source]

    # File app/controllers/font_controller.rb, line 21
21:         def filechoices?
22:                 false
23:         end

[Source]

    # File app/controllers/font_controller.rb, line 10
10:         def first_time
11:                 session[:freeze]=nil
12:                 session[:state]=0
13:                 session[:selected_item]=0
14:                 redirect_to :action => "index"
15:         end

[Source]

    # File app/controllers/font_controller1.rb, line 3
 3:         def first_time
 4:                 session[:choices]=['selected size',
 5:                                          'selected color',
 6:                                          'selected font',
 7:                                          'unselected size',
 8:                                          'unselected color',
 9:                                          'unselected font'
10:                                       ]
11: 
12:                 session[:freeze]=nil
13: 
14:                 session[:separator]=','
15:                 #state 0 => we are choosing what to change

16:                 #state 1 => we have chosen what to change

17:                 session[:state]=0
18:                 session[:title]='select what to change'
19:                 session[:selected_item]=0
20:                 redirect_to :action => "index"
21:         end

[Source]

    # File app/controllers/font_controller1.rb, line 27
27:         def get_fd
28:                 {
29: :color=>["maroon","purple","orange","aqua",
30: "yellow","red","blue"],
31:                                    :size=>["25pt","30pt","35pt","40pt",
32: "45pt","50pt"],
33:                                 :font=>["Times New Roman","Tempus Sans ITC",
34:                 "Australian Sunrise","Arial"] }
35:         end

[Source]

    # File app/controllers/font_controller.rb, line 27
27:         def get_font_data
28:                 { :color=>["pink","red","orange","aqua","maroon",
29: "black","skyblue","teal","darkblue","yellow",
30:                         "silver","green","purple","violet","blue",
31:                         "olive","lightgreen","fuchsia"],
32:                   :size=>["12pt","15pt","20pt","25pt",
33:                         "30pt","33pt","40pt","45pt",
34: 
35:                         "48pt","53pt","58pt","63pt",
36:                         "70pt","75pt","80pt","86pt"],
37:                   :font=>["Times New Roman","Monotype Corsiva",
38:                         "Comic Sans MS","Impact","MS Serif","Terminal",
39:                         "Arial Black","Modern","Garamond"],
40:                   :bgcolor=>["green","pink","gray","purple","gray",
41:                         "skyblue","maroon","silver","lightgreen","darkgray",
42:                         "olive","pink","skyblue","aqua","violet","black",
43:                         "darkblue","silver"]
44:                 }
45:         end

[Source]

    # File app/controllers/font_controller1.rb, line 23
23:         def get_freeze
24:                 session[:freeze] ||= session[:selected_item]
25:         end

[Source]

    # File app/controllers/font_controller.rb, line 18
18:         def get_freeze
19:                 session[:freeze] ||= session[:selected_item]
20:         end

[Source]

    # File app/controllers/font_controller1.rb, line 37
37:         def process_choice selected_choice
38: 
39:                 if session[:state]==1
40:                         session[:state]=0
41:                         session[:freeze]=nil
42:                         session[:title]='select what to change'
43:                 else
44:                         session[:state]=1
45:                         session[:title]='up-down changes '+
46:                                 get_choices[get_freeze%session[:choices].size]
47:                         logger.info("freeze:#{session[:freeze]}")
48:                 end
49:                 logger.info("sel_state:#{session[:state]}")
50: 
51:         end

[Source]

    # File app/controllers/font_controller.rb, line 47
47:         def process_choice selected_choice
48:                 if session[:state]==1
49:                         session[:state]=0
50:                         session[:freeze]=nil
51:                 else
52:                         session[:state]=1
53:                         get_freeze
54:                 end
55:         end

[Source]

    # File app/controllers/font_controller.rb, line 16
16:         def reformat_choices
17:         end

[Source]

   # File app/controllers/font_controller.rb, line 2
2:         def start_choices
3:                 ['selected size',
4:                 'selected color',
5:                 'selected font',
6:                 'unselected size',
7:                 'unselected color',
8:                 'unselected font']
9:         end

[Source]

    # File app/controllers/font_controller1.rb, line 53
53:         def updownevent
54:                 if session[:state]==1
55:                         tempchoice = get_choices
56:                         choice=tempchoice[get_freeze % tempchoice.size]
57:                         logger.info("choice:#{choice}")
58:                         temp_var = choice.strip.gsub(' ','_')
59:                         logger.info("tempvar:#{temp_var}")
60: 
61:                         var = temp_var.to_sym
62:                         logger.info("var:#{var}")
63: 
64:                         array=choice.split(" ")
65:                         temp_symbol=array[1].strip
66:                         symbol=temp_symbol.to_sym
67:                         logger.info("symb:#{symbol}")
68: 
69: 
70:                         @fd=get_fd
71:                         font_attr=@fd[symbol]
72:                         @rhs=get_selected_item % font_attr.size
73:                         session[var] = font_attr[@rhs]
74:                         logger.info("font attr:#{session[var]}")
75:                         logger.info("font attr_size:#{font_attr.size}")
76: 
77:                 end
78:                 logger.info("state:#{session[:state]}")
79:                 logger.info("sel_item:#{session[:selected_item]}")
80:         end

[Source]

    # File app/controllers/font_controller.rb, line 57
57:         def updownevent
58:                 if session[:state]==1
59:                         tempchoice = get_choices
60:                         choice=strip_href(tempchoice[session[:freeze] %
61: tempchoice.size])
62:                         temp_var = choice.strip.gsub(' ','_')
63:                         var = temp_var.to_sym
64: 
65:                         array=choice.split(" ")
66:                         temp_symbol=array[1].strip
67:                         symbol=temp_symbol.to_sym
68: 
69:                         @font_data=get_font_data
70:                         @font_data[:size].reverse!
71:                         font_attr=@font_data[symbol]
72:                         @rhs=get_selected_item % font_attr.size
73:                         session[var] = font_attr[@rhs]
74: 
75:                         if temp_var=='selected_color'
76:                                 bckground=@font_data[:bgcolor]
77:                                 session[:bgcolor]=bckground[@rhs]
78:                         end
79:                 end
80:         end

[Validate]