Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script>
  2. var main = false;
  3. var boots = true;
  4. var keys = true;
  5. var contact = true;
  6.  
  7. $(document).ready(function(){
  8.     if (main !== true) {
  9.         main = createMain(10,3);
  10.     }
  11. });
  12. $(document).ready(function(){
  13.     $( "#mainbut" ).click(function() {
  14.         if (main == true) {
  15.             $( "content" ).hide( "drop", { direction: "down" }, "slow" );
  16.             deleteMain();
  17.             main = createMain(4,2);
  18.             $( "content" ).show( "drop", { direction: "up" }, "slow" );
  19.             boots = true;
  20.             keys = true;
  21.             contact = true;
  22.         }
  23.     });
  24.  
  25.  
  26.     $( "#szewcbut" ).click(function() {
  27.         if (boots == true) {
  28.             $( "content" ).hide( "drop", { direction: "down" }, "slow" );
  29.             deleteMain();
  30.             boots = createMain(4,2);
  31.             $( "content" ).show( "drop", { direction: "up" }, "slow" );
  32.             main = true;
  33.             keys = true;
  34.             contact = true;
  35.         }
  36.     });
  37.  
  38.    
  39.     $( "#keysbut" ).click(function() {
  40.         if (keys == true) {
  41.             $( "content" ).hide( "drop", { direction: "down" }, "slow" );
  42.             deleteMain();
  43.             keys = createMain(4,2);
  44.             $( "content" ).show( "drop", { direction: "up" }, "slow" );
  45.             main = true;
  46.             boots = true;
  47.             contact = true;
  48.         }
  49.     });
  50.  
  51.  
  52.     $( "#contactbut" ).click(function() {
  53.         if (contact == true) {
  54.             $( "content" ).hide( "drop", { direction: "down" }, "slow" );
  55.             deleteMain();
  56.             contact = createMain(4,2);
  57.             $( "content" ).show( "drop", { direction: "up" }, "slow" );
  58.             main = true;
  59.             boots = true;
  60.             keys = true;
  61.         }
  62.     });
  63. });
  64.  
  65.  
  66.  
  67.  
  68. function createMain(howmanyrows,quan){
  69.    
  70.  
  71.     var j;
  72.     var where = document.getElementById('main');
  73.     for (var i = 1 ; i <= howmanyrows; i++){
  74.         var row = document.createElement('div');
  75.         row.classList.add('row');
  76.         row.id = 'row'+i;
  77.         where.appendChild(row);
  78.         if(quan == 2){ 
  79.             for (j = 2 ; j <= 3; j++){
  80.                 var column = document.getElementById('row'+i);
  81.                 var newcolumn = document.createElement('div');
  82.                 newcolumn.classList.add('container50');
  83.                 if (j % 2) {
  84.                     newcolumn.id = 'column_right'+i;
  85.                     column.appendChild(newcolumn);
  86.                 }
  87.                 else{
  88.                     newcolumn.id ='column_left'+i;
  89.                     column.appendChild(newcolumn);
  90.                 }  
  91.             }      
  92.         }
  93.         else if(quan ==3){
  94.             for (j = 1 ; j <= 3; j++){
  95.                 var column = document.getElementById('row'+i);
  96.                 var newcolumn = document.createElement('div');
  97.                 newcolumn.classList.add('container30');
  98.                 column.appendChild(newcolumn);
  99.                
  100.                
  101.                 }  
  102.             }      
  103.         }
  104.  
  105.    
  106.  
  107.     return false;
  108. }
  109. function deleteMain(){
  110.     var i = 1;
  111.     var rows;
  112.     var howmanyrows = document.getElementsByClassName('row').length;
  113.     if (howmanyrows > 0) {
  114.         while(howmanyrows >= 1){
  115.             rows = document.getElementById('row'+i);
  116.             var rowsParent =  document.getElementById('main');
  117.             rowsParent.removeChild(rows);
  118.             var howmanyrows = document.getElementsByClassName('row').length;
  119.             i++;
  120.         }
  121.  
  122.     }
  123. }  
  124.  
  125.    
  126.  
  127.  
  128.  
  129.  
  130. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement