app/controllers/application_controller/ci_processing.rb
# AJAX driven routine to check for changes in ANY field on the discover form
AJAX driven routine to check for changes in ANY field on the discover form
AJAX driven routine to check for changes in ANY field on the discover form
def discover_field_changed
    render :update do |page|                    
      if params[:from_first]
        if params[:from_first] =~ /[\D]/
          temp = params[:from_first].gsub(/[\.]/, "")
          field_shift = true if params[:from_first] =~ /[\.]/ && params[:from_first].gsub(/[\.]/, "") =~ /[0-9]/ && temp.gsub!(/[\D]/, "").nil?
          page << "$('#from_first').val('#{j_str(params[:from_first]).gsub(/[\D]/, "")}');"
          page << javascript_focus('from_second') if field_shift
        else
          page << "$('#to_first').val('#{j_str(params[:from_first])}');"
          page << javascript_focus('from_second') if params[:from_first].length == 3
        end
      elsif params[:from_second]
        if params[:from_second] =~ /[\D]/
          temp = params[:from_second].gsub(/[\.]/, "")
          field_shift = true if params[:from_second] =~ /[\.]/ && params[:from_second].gsub(/[\.]/, "") =~ /[0-9]/ && temp.gsub!(/[\D]/, "").nil?
          page << "$('#from_second').val('#{j_str(params[:from_second].gsub(/[\D]/, ""))}');"
          page << javascript_focus('from_third') if field_shift
        else
          page << "$('#to_second').val('#{j_str(params[:from_second])}');"
          page << javascript_focus('from_third') if params[:from_second].length == 3
        end
      elsif params[:from_third]
        if params[:from_third] =~ /[\D]/
          temp = params[:from_third].gsub(/[\.]/, "")
          field_shift = true if params[:from_third] =~ /[\.]/ && params[:from_third].gsub(/[\.]/, "") =~ /[0-9]/ && temp.gsub!(/[\D]/, "").nil?
          page << "$('#from_third').val('#{j_str(params[:from_third].gsub(/[\D]/, ""))}');"
          page << javascript_focus('from_fourth') if field_shift
        else
          page << "$('#to_third').val('#{j_str(params[:from_third])}');"
          page << javascript_focus('from_fourth') if params[:from_third].length == 3
        end
      elsif params[:from_fourth] && params[:from_fourth] =~ /[\D]/
        page << "$('#from_fourth').val('#{j_str(params[:from_fourth].gsub(/[\D]/, ""))}');"
      elsif params[:to_fourth] && params[:to_fourth] =~ /[\D]/
        page << "$('#to_fourth').val('#{j_str(params[:to_fourth].gsub(/[\D]/, ""))}');"
      end
      if (request.parameters[:controller] == "ems_cloud" && params[:discover_type_selected]) || (params[:discover_type_ipmi] && params[:discover_type_ipmi].to_s == "1")
        if params[:discover_type_selected] && params[:discover_type_selected] == 'azure'
          page << javascript_hide("discover_credentials")
          page << javascript_show("discover_azure_credentials")
        elsif params[:discover_type_selected] && params[:discover_type_selected] == 'amazon'
          page << javascript_hide("discover_azure_credentials")
          page << javascript_show("discover_credentials")
        else
          @ipmi = true
          page << javascript_show("discover_credentials")
        end
      elsif params[:discover_type_ipmi] && params[:discover_type_ipmi].to_s == "null"
        @ipmi = false
        page << javascript_hide("discover_credentials")
      elsif @ipmi == false
        page << javascript_hide("discover_credentials")
      end
    end
  end
def discover_field_changed render :update do | page | if params [ :from_first ] if params [ :from_first ] =~ / [ \D ] / temp = params [ :from_first ] . gsub ( / [ \. ] / , "" ) field_shift = true if params [ :from_first ] =~ / [ \. ] / && params [ :from_first ] . gsub ( / [ \. ] / , "" ) =~ / [0-9] / && temp . gsub! ( / [ \D ] / , "" ) . nil? page << "$('#from_first').val('#{j_str(params[:from_first]).gsub(/[\D]/, "")}');" page << javascript_focus ( 'from_second' ) if field_shift else page << "$('#to_first').val('#{j_str(params[:from_first])}');" page << javascript_focus ( 'from_second' ) if params [ :from_first ] . length == 3 end elsif params [ :from_second ] if params [ :from_second ] =~ / [ \D ] / temp = params [ :from_second ] . gsub ( / [ \. ] / , "" ) field_shift = true if params [ :from_second ] =~ / [ \. ] / && params [ :from_second ] . gsub ( / [ \. ] / , "" ) =~ / [0-9] / && temp . gsub! ( / [ \D ] / , "" ) . nil? page << "$('#from_second').val('#{j_str(params[:from_second].gsub(/[\D]/, ""))}');" page << javascript_focus ( 'from_third' ) if field_shift else page << "$('#to_second').val('#{j_str(params[:from_second])}');" page << javascript_focus ( 'from_third' ) if params [ :from_second ] . length == 3 end elsif params [ :from_third ] if params [ :from_third ] =~ / [ \D ] / temp = params [ :from_third ] . gsub ( / [ \. ] / , "" ) field_shift = true if params [ :from_third ] =~ / [ \. ] / && params [ :from_third ] . gsub ( / [ \. ] / , "" ) =~ / [0-9] / && temp . gsub! ( / [ \D ] / , "" ) . nil? page << "$('#from_third').val('#{j_str(params[:from_third].gsub(/[\D]/, ""))}');" page << javascript_focus ( 'from_fourth' ) if field_shift else page << "$('#to_third').val('#{j_str(params[:from_third])}');" page << javascript_focus ( 'from_fourth' ) if params [ :from_third ] . length == 3 end elsif params [ :from_fourth ] && params [ :from_fourth ] =~ / [ \D ] / page << "$('#from_fourth').val('#{j_str(params[:from_fourth].gsub(/[\D]/, ""))}');" elsif params [ :to_fourth ] && params [ :to_fourth ] =~ / [ \D ] / page << "$('#to_fourth').val('#{j_str(params[:to_fourth].gsub(/[\D]/, ""))}');" end if ( request . parameters [ :controller ] == "ems_cloud" && params [ :discover_type_selected ] ) || ( params [ :discover_type_ipmi ] && params [ :discover_type_ipmi ] . to_s == "1" ) if params [ :discover_type_selected ] && params [ :discover_type_selected ] == 'azure' page << javascript_hide ( "discover_credentials" ) page << javascript_show ( "discover_azure_credentials" ) elsif params [ :discover_type_selected ] && params [ :discover_type_selected ] == 'amazon' page << javascript_hide ( "discover_azure_credentials" ) page << javascript_show ( "discover_credentials" ) else @ipmi = true page << javascript_show ( "discover_credentials" ) end elsif params [ :discover_type_ipmi ] && params [ :discover_type_ipmi ] . to_s == "null" @ipmi = false page << javascript_hide ( "discover_credentials" ) elsif @ipmi == false page << javascript_hide ( "discover_credentials" ) end end end
AJAX driven routine to check for changes in ANY field on the discover form
AJAX driven routine to check for changes in ANY field on the discover form
# Use JS to update the display # params[:from][:first] =~ /[a-zA-Z]/