function Run(Parameters)
{
   Mode = Parameters['mode'];
   RunMode = SystemGameMode+'_'+Mode;

   //alert(Parameters['mode']);

   Log('Run '+RunMode);             //this allow keep same flow but different function for single or multi player mode
   //set message box to blank
   AddHtmlToContainer('box-message','');
   switch(RunMode)
   {
      case 'open_step1':         //start of a new game, no SystemGameMode yet
      case 'single_step1':       //when coming back
      case 'multi_step1':
            SystemGameMode='open';  //reset mode once user press back button
            DisableKeys();
            Step1();
      break;
      case 'open_step2':         //configure game option
            Step2();
      break;
     case 'single_step3':       //configure game before launch      
      case 'multi_step3':
            DisableKeys();
            Step3();
      break;
      case 'multi_reset_timer_bar':
            counter=0;
            ResizeBar(counter);
      break;
      case 'multi_configure_step3': //use the user parameter to configure game
            ConfigureMultiStep3();
      break;
      case 'single_configure_step3': //use the user parameter to configure game
	    //to be moved to a function and code reorgaized
        $('#box-timer').show();   	
        $('#box-timer').css('width',(SecondPerRound*StepTimerBar)+'px');
        $('#box-timer').css('left',Math.floor((SystemTimerContainerWidth-(SecondPerRound*StepTimerBar))/2)+'px');
      break;
      case 'single_init':           //group configure and init??
            InitializeTimerSinglePlayerGame();
            //remove button, cannot start the game again
            $('#footer').empty();
            //NextQuestion();
      break;
      case 'multi_init':
            InitializeTimerMultiPlayerGame();
            //change button to put next question and not start game
            $('#footer').html('<div style="float:right">'+ButtonNextStep('next_question', MessageDictionnary('Continuer'))+'</div><div style="clear:both"></div>');
            //NextQuestion();   
      break; 

      case 'single_next_question':           //playing single first round
            StartTimerSinglePlayerGame();
            NextQuestion();
      break;
      case 'multi_next_question':            //loop on question as long game not win
            NextQuestion();
      break;

      case 'multi_end_next_question':        //reset timer for multi player game , leave it countdown otherwize
            counter=0;
            timer.reset();
            timer.play();
      break;
      case 'single_end_next_question':        //hide button for next question in single mode
            FooterMenu({'mode':'empty'});
            $('#footer').html(ButtonNextStep('replay', MessageDictionnary('Rejouer')));
      break;
 
      case 'multi_pre_answer':              //reset timer and show it ready to start on next question button push
         counter=0;
         ResizeBar(counter);
      break;

      case 'multi_form_change_player_data':  
         AddHtmlToPopupBox('player_data');
         FormChangePlayerData();
      break;

      case 'multi_do_change_player_data':
         DoChangePlayerData();   
         
      break;

      case 'multi_popup_answer_form':
         IdPlayer= Parameters['id_player'];
         MultiPlayerInitPopupAnswer(IdPlayer);
         
      break;

     case 'single_configure_popup_form':     //single mode: pre select player 0
         $(document).one(PopupAnswerForm(0));
      break;

     case 'multi_configure_popup_form':      //multi mode, no player selected
         $(document).one(PopupAnswerForm(-1));
         break;         

      case 'multi_close_popup_answer_form':  //restart timer for multi player game
         if(counter < SecondPerRound)
         {
            timer.toggle();
         }
      break;

      case 'multi_answer':                   //multi mode: check for winner and wait user click next question 
         DisableKeys();    
         Answer($('#player_id').val());
         IsGameWin($('#player_id').val());
         IsPlayerDisqualified($('#player_id').val());
      break;

      case 'single_answer':                  //loop to next question after answer
         //single player, run next question as soon as correct answer given
         //Answer($('#player_id').val());
         DisableKeys();
         if(Answer(0)===true)
         {
            NextQuestion();
            //$('#inline_input_player_answer').focus();
            $('#inline_input_player_answer');
         }else
         {
            //wait for correct answer
         }
      break;

     case 'multi_replay':
      case 'single_replay':
         Replay();
      break;

      default:
         Log('Run '+Mode+MessageDictionnary(' : Ce mode est inconnu du programmme'));//AddHtmlToContainer('box-message',Mode+MessageDictionnary(' : Ce mode est inconnu du programmme'));
      break;    
     
   }
}
/*
  * Single entry point: it is main and squeleton of this pogram. Main phase/function grouped here
  *
  * @param associative array
  */
Single entry point: it is main and squeleton of this pogram. Main phase/function grouped here
@param associative array
Single entry point : it is main and squeleton of this pogram . Main phase / function grouped here @param associative array
function Run(Parameters)
{
   Mode = Parameters['mode'];
   RunMode = SystemGameMode+'_'+Mode;
   Log('Run '+RunMode);             
   AddHtmlToContainer('box-message','');
   switch(RunMode)
   {
      case 'open_step1':         
      case 'single_step1':       
      case 'multi_step1':
            SystemGameMode='open';  
            DisableKeys();
            Step1();
      break;
      case 'open_step2':         
            Step2();
      break;
     case 'single_step3':       
      case 'multi_step3':
            DisableKeys();
            Step3();
      break;
      case 'multi_reset_timer_bar':
            counter=0;
            ResizeBar(counter);
      break;
      case 'multi_configure_step3': 
            ConfigureMultiStep3();
      break;
      case 'single_configure_step3': 
        $('#box-timer').show();   	
        $('#box-timer').css('width',(SecondPerRound*StepTimerBar)+'px');
        $('#box-timer').css('left',Math.floor((SystemTimerContainerWidth-(SecondPerRound*StepTimerBar))/2)+'px');
      break;
      case 'single_init':           
            InitializeTimerSinglePlayerGame();
            $('#footer').empty();
      break;
      case 'multi_init':
            InitializeTimerMultiPlayerGame();
            $('#footer').html('<div style="float:right">'+ButtonNextStep('next_question', MessageDictionnary('Continuer'))+'</div><div style="clear:both"></div>');
      break; 
      case 'single_next_question':           
            StartTimerSinglePlayerGame();
            NextQuestion();
      break;
      case 'multi_next_question':            
            NextQuestion();
      break;
      case 'multi_end_next_question':        
            counter=0;
            timer.reset();
            timer.play();
      break;
      case 'single_end_next_question':        
            FooterMenu({'mode':'empty'});
            $('#footer').html(ButtonNextStep('replay', MessageDictionnary('Rejouer')));
      break;
      case 'multi_pre_answer':              
         counter=0;
         ResizeBar(counter);
      break;
      case 'multi_form_change_player_data':  
         AddHtmlToPopupBox('player_data');
         FormChangePlayerData();
      break;
      case 'multi_do_change_player_data':
         DoChangePlayerData();   
      break;
      case 'multi_popup_answer_form':
         IdPlayer= Parameters['id_player'];
         MultiPlayerInitPopupAnswer(IdPlayer);
      break;
     case 'single_configure_popup_form':     
         $(document).one(PopupAnswerForm(0));
      break;
     case 'multi_configure_popup_form':      
         $(document).one(PopupAnswerForm(-1));
         break;         
      case 'multi_close_popup_answer_form':  
         if(counter < SecondPerRound)
         {
            timer.toggle();
         }
      break;
      case 'multi_answer':                   
         DisableKeys();    
         Answer($('#player_id').val());
         IsGameWin($('#player_id').val());
         IsPlayerDisqualified($('#player_id').val());
      break;
      case 'single_answer':                  
         DisableKeys();
         if(Answer(0)===true)
         {
            NextQuestion();
            $('#inline_input_player_answer');
         }else
         {
         }
      break;
     case 'multi_replay':
      case 'single_replay':
         Replay();
      break;
      default:
         Log('Run '+Mode+MessageDictionnary(' : Ce mode est inconnu du programmme'));
      break;    
   }
}
function Run ( Parameters ) { Mode = Parameters [ 'mode' ] ; RunMode = SystemGameMode + '_' + Mode ; Log ( 'Run ' + RunMode ) ; AddHtmlToContainer ( 'box-message' , '' ) ; switch ( RunMode ) { case 'open_step1' : case 'single_step1' : case 'multi_step1' : SystemGameMode = 'open' ; DisableKeys ( ) ; Step1 ( ) ; break ; case 'open_step2' : Step2 ( ) ; break ; case 'single_step3' : case 'multi_step3' : DisableKeys ( ) ; Step3 ( ) ; break ; case 'multi_reset_timer_bar' : counter = 0 ; ResizeBar ( counter ) ; break ; case 'multi_configure_step3' : ConfigureMultiStep3 ( ) ; break ; case 'single_configure_step3' : $ ( '#box-timer' ) . show ( ) ; $ ( '#box-timer' ) . css ( 'width' , ( SecondPerRound * StepTimerBar ) + 'px' ) ; $ ( '#box-timer' ) . css ( 'left' , Math . floor ( ( SystemTimerContainerWidth - ( SecondPerRound * StepTimerBar ) ) / 2 ) + 'px' ) ; break ; case 'single_init' : InitializeTimerSinglePlayerGame ( ) ; $ ( '#footer' ) . empty ( ) ; break ; case 'multi_init' : InitializeTimerMultiPlayerGame ( ) ; $ ( '#footer' ) . html ( '<div style="float:right">' + ButtonNextStep ( 'next_question' , MessageDictionnary ( 'Continuer' ) ) + '</div><div style="clear:both"></div>' ) ; break ; case 'single_next_question' : StartTimerSinglePlayerGame ( ) ; NextQuestion ( ) ; break ; case 'multi_next_question' : NextQuestion ( ) ; break ; case 'multi_end_next_question' : counter = 0 ; timer . reset ( ) ; timer . play ( ) ; break ; case 'single_end_next_question' : FooterMenu ( { 'mode' : 'empty' } ) ; $ ( '#footer' ) . html ( ButtonNextStep ( 'replay' , MessageDictionnary ( 'Rejouer' ) ) ) ; break ; case 'multi_pre_answer' : counter = 0 ; ResizeBar ( counter ) ; break ; case 'multi_form_change_player_data' : AddHtmlToPopupBox ( 'player_data' ) ; FormChangePlayerData ( ) ; break ; case 'multi_do_change_player_data' : DoChangePlayerData ( ) ; break ; case 'multi_popup_answer_form' : IdPlayer = Parameters [ 'id_player' ] ; MultiPlayerInitPopupAnswer ( IdPlayer ) ; break ; case 'single_configure_popup_form' : $ ( document ) . one ( PopupAnswerForm ( 0 ) ) ; break ; case 'multi_configure_popup_form' : $ ( document ) . one ( PopupAnswerForm ( - 1 ) ) ; break ; case 'multi_close_popup_answer_form' : if ( counter < SecondPerRound ) { timer . toggle ( ) ; } break ; case 'multi_answer' : DisableKeys ( ) ; Answer ( $ ( '#player_id' ) . val ( ) ) ; IsGameWin ( $ ( '#player_id' ) . val ( ) ) ; IsPlayerDisqualified ( $ ( '#player_id' ) . val ( ) ) ; break ; case 'single_answer' : DisableKeys ( ) ; if ( Answer ( 0 ) === true ) { NextQuestion ( ) ; $ ( '#inline_input_player_answer' ) ; } else { } break ; case 'multi_replay' : case 'single_replay' : Replay ( ) ; break ; default : Log ( 'Run ' + Mode + MessageDictionnary ( ' : Ce mode est inconnu du programmme' ) ) ; break ; } }
Single entry point: it is main and squeleton of this pogram.
Single entry point : it is main and squeleton of this pogram .
//alert(Parameters['mode']); //this allow keep same flow but different function for single or multi player mode //set message box to blank //start of a new game, no SystemGameMode yet //when coming back //reset mode once user press back button //configure game option //configure game before launch       //use the user parameter to configure game //use the user parameter to configure game //to be moved to a function and code reorgaized //group configure and init?? //remove button, cannot start the game again //NextQuestion(); //change button to put next question and not start game //NextQuestion();    //playing single first round //loop on question as long game not win //reset timer for multi player game , leave it countdown otherwize //hide button for next question in single mode //reset timer and show it ready to start on next question button push //single mode: pre select player 0 //multi mode, no player selected //restart timer for multi player game //multi mode: check for winner and wait user click next question  //loop to next question after answer //single player, run next question as soon as correct answer given //Answer($('#player_id').val()); //$('#inline_input_player_answer').focus(); //wait for correct answer //AddHtmlToContainer('box-message',Mode+MessageDictionnary(' : Ce mode est inconnu du programmme'));