@ -4,6 +4,8 @@ 
			
		
	
		
		
			
				
					class  PageBuilder  { class  PageBuilder  {  
			
		
	
		
		
			
				
					    # cssClasses ;     # cssClasses ;  
			
		
	
		
		
			
				
					    # functions ;     # functions ;  
			
		
	
		
		
			
				
					    # delayedFunctions ;  
			
		
	
		
		
			
				
					    # repeatingFunctions ;  
			
		
	
		
		
			
				
					    # functionNames ;     # functionNames ;  
			
		
	
		
		
			
				
					    # cssElementIdentifiers ;     # cssElementIdentifiers ;  
			
		
	
		
		
			
				
					
 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
						
					 
					@ -12,6 +14,8 @@ class PageBuilder { 
			
		
	
		
		
			
				
					        this . # functions  =  document . createElement ( "script" ) ;         this . # functions  =  document . createElement ( "script" ) ;  
			
		
	
		
		
			
				
					        this . # functionNames  =  [ ] ;         this . # functionNames  =  [ ] ;  
			
		
	
		
		
			
				
					        this . # cssElementIdentifiers  =  [ ] ;         this . # cssElementIdentifiers  =  [ ] ;  
			
		
	
		
		
			
				
					        this . # delayedFunctions  =  [ ] ;  
			
		
	
		
		
			
				
					        this . # repeatingFunctions  =  { } ;  
			
		
	
		
		
			
				
					    }     }  
			
		
	
		
		
			
				
					
 
			
		
	
		
		
			
				
					    / * *     / * *  
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
						
					 
					@ -26,6 +30,22 @@ class PageBuilder { 
			
		
	
		
		
			
				
					        }         }  
			
		
	
		
		
			
				
					    }     }  
			
		
	
		
		
			
				
					
 
			
		
	
		
		
			
				
					    / * *  
			
		
	
		
		
			
				
					     *  @ experimental  Attention  is  adviced ,  registration  mechanism  doesn ' t  work  yet  
			
		
	
		
		
			
				
					     *  @ param  { string }  name  The  name  the  interval  will  be  tied  to  
			
		
	
		
		
			
				
					     *  @ param  { Function }  fun  the  function  that  is  supposed  to  be  executed  repeatedly  
			
		
	
		
		
			
				
					     *  @ param  { number }  interval  the  time  in  ms  between  executions  
			
		
	
		
		
			
				
					     * /  
			
		
	
		
		
			
				
					    registerRepeatingFunction ( name ,  fun ,  interval )  {  
			
		
	
		
		
			
				
					        if  ( ! Object . keys ( this . # repeatingFunctions ) . includes ( name ) )  {  
			
		
	
		
		
			
				
					            this . # repeatingFunctions [ name ]  =  {  
			
		
	
		
		
			
				
					                name :  name ,  
			
		
	
		
		
			
				
					                fun :  fun ,  
			
		
	
		
		
			
				
					                interval :  interval  
			
		
	
		
		
			
				
					            } ;  
			
		
	
		
		
			
				
					        }  
			
		
	
		
		
			
				
					    }  
			
		
	
		
		
			
				
					
 
			
		
	
		
		
			
				
					    / * *     / * *  
			
		
	
		
		
			
				
					     *  Adds  the  styling  rules  to  the  element  identifiers  into  the  style  tag .      *  Adds  the  styling  rules  to  the  element  identifiers  into  the  style  tag .  
			
		
	
		
		
			
				
					     *  An  elementDefinition  can  only  be  used  once ,  repeated  use  will  be  ignored .      *  An  elementDefinition  can  only  be  used  once ,  repeated  use  will  be  ignored .  
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
						
					 
					@ -44,13 +64,49 @@ class PageBuilder { 
			
		
	
		
		
			
				
					    }     }  
			
		
	
		
		
			
				
					
 
			
		
	
		
		
			
				
					    / * *     / * *  
			
		
	
		
		
			
				
					
					     *  Adds  a  script  tag  into  the  head  of  the  document .       *  Adds  into  the  ( head )  document .   
			
				
				
			
		
	
		
		
	
		
		
			
				
					     *  -  script  tag  
			
		
	
		
		
			
				
					     *  -  function  tag  
			
		
	
		
		
			
				
					     *  -  sets  and  registers  repeatedly  executed  functions  
			
		
	
		
		
			
				
					     *  -  sets  ( timeout  and )  functions  that  are  supposed  to  be  executed  after  load  
			
		
	
		
		
			
				
					     * /      * /  
			
		
	
		
		
			
				
					    generate ( )  {     generate ( )  {  
			
		
	
		
		
			
				
					        let  head  =  document . querySelector ( "head" ) ;         let  head  =  document . querySelector ( "head" ) ;  
			
		
	
		
		
			
				
					        head . appendChild ( this . # functions )         head . appendChild ( this . # functions )  
			
		
	
		
		
			
				
					        head . appendChild ( this . # cssClasses )         head . appendChild ( this . # cssClasses )  
			
		
	
		
		
			
				
					
 
			
		
	
		
		
			
				
					        /* set repeating functions  */  
			
		
	
		
		
			
				
					        let  repeatedFun  =  Object . values ( this . # repeatingFunctions )  
			
		
	
		
		
			
				
					            . reduce ( ( a ,  c ,  i ,  arr )  =>  Object . assign ( a ,  {  
			
		
	
		
		
			
				
					                [ c . name ] :  setInterval ( c . fun ,  c . interval )  
			
		
	
		
		
			
				
					            } ) ,  { } ) ;  
			
		
	
		
		
			
				
					
 
			
		
	
		
		
			
				
					        /* set timeouts for funcitons executed after load */  
			
		
	
		
		
			
				
					        for  ( let  i  =  0 ;  i  <  this . # delayedFunctions . length ;  i ++ )  {  
			
		
	
		
		
			
				
					            let  func  =  this . # delayedFunctions [ i ] ;  
			
		
	
		
		
			
				
					            if  ( func . repeat )  {  
			
		
	
		
		
			
				
					                setTimeout ( setInterval ( func . func ,  func . interval ) ,  func . dl ,  func . args ) ;  
			
		
	
		
		
			
				
					            }  else  {  
			
		
	
		
		
			
				
					                setTimeout ( func . func ,  func . dl ,  func . args ) ;  
			
		
	
		
		
			
				
					            }  
			
		
	
		
		
			
				
					        }  
			
		
	
		
		
			
				
					        console . log ( this . # functionNames ) ;  
			
		
	
		
		
			
				
					    }  
			
		
	
		
		
			
				
					
 
			
		
	
		
		
			
				
					    / * *  
			
		
	
		
		
			
				
					     *  Registeres  a  function  to  be  executed  after  page - load  
			
		
	
		
		
			
				
					     *  @ param  { Function }  func  the  function  that  will  be  executed  
			
		
	
		
		
			
				
					     *  @ param  { number }  delay  the  time  in  ms  the  execution  is  delayed  after  load  
			
		
	
		
		
			
				
					     *  @ param  { string }  name  if  provided  the  function  will  be  registered  as  well  
			
		
	
		
		
			
				
					     *  @ param  { Array < any > }  args  arguments  for  the  function  
			
		
	
		
		
			
				
					     *  @ param  { boolean }  repeat  defines  if  the  function  is  supposed  to  be  repeated  as  well  
			
		
	
		
		
			
				
					     *  @ param  { number }  interval  if  the  function  is  supposed  to  repeat ,  this  defines  the  interval  of  repetition  
			
		
	
		
		
			
				
					     * /  
			
		
	
		
		
			
				
					    executeAfterLoad ( func ,  delay  =  1000 ,  name  =  '' ,  args  =  [ ] ,  repeat  =  false ,  interval  =  5000 )  {  
			
		
	
		
		
			
				
					        if  ( name  !==  '' )  {  
			
		
	
		
		
			
				
					            this . registerFunction ( name ,  func ) ;  
			
		
	
		
		
			
				
					        }  
			
		
	
		
		
			
				
					        this . # delayedFunctions . push ( {  dl :  delay ,  func :  func ,  args :  args ,  repeat :  repeat ,  interval :  interval  } ) ;  
			
		
	
		
		
			
				
					    }     }  
			
		
	
		
		
			
				
					
 
			
		
	
		
		
			
				
					    / * *     / * *