Assignment - Buttons

Definitely fun, but also challenging. I learned a lot! TY.

index.html

<!-- Cattributes   -->
                <div class="form-group">
                    <label for="formControlRange"><b>Eyes Shape</b><span class="badge badge-dark ml-2" id="eyeName"></span></label>
                    <input type="range" min="1" max="7" class="form-control-range" id="eyeshape">
                </div>

                <div class="form-group">
                    <label for="formControlRange"><b>Decoration pattern </b><span class="badge badge-dark ml-2" id="decorationName"></span></label>
                    <input type="range"  min="1" max="7" class="form-control-range" id="decoration">
                </div>

                <div class="form-group">
                    <label for="formControlRange"><b>Decoration color pattern</b></label>
                    <div class="row">
                        <div class="col">
                            <label for="formControlRange"><b>Middle color</b><span class="badge badge-dark ml-2" id="midcode"></span></label>
                            <input type="range" min="10" max="98" class="form-control-range" id="decorationmiddle">
                        </div>
                        <div class="col">
                            <label for="formControlRange"><b>Sides color</b><span class="badge badge-dark ml-2" id="sidecode"></span></label>
                            <input type="range" min="10" max="98" class="form-control-range" id="decorationsides">
                        </div>
                    </div>
                    
                    
                 </div>

                <div class="form-group">
                    <label for="formControlRange"><b>Animation</b><span class="badge badge-dark ml-2" id="animationName"></span></label>
                    <input type="range" min="1" max="6" class="form-control-range" id="animation">
                </div>
            </div>

            </div>

        </div>

        <br>
        <div class="container">
          
            <div class="btn-group">
                <button class="btn btn-primary  tsp-1 m-1 light-b-shadow" onclick="randomCat()"><b>Get random kitty</b></button>
                <button class="btn btn-primary  ml-2 tsp-1 m-1 light-b-shadow" onclick="defaultCat()"><b>Default kitty</b></button>
            </div>
            <div class=" group-btn float-right">
                <button class="btn btn-success mr-5  tsp-1 m-1 light-b-shadow" onclick="getKitties()"><b>Get Kitty</b></button>
                <button class="btn btn-success mr-5  tsp-1 m-1 light-b-shadow" onclick="createKitty()"><b>Create Kitty</b></button>
            </div>



 

  </body>
  <script src="assets/js/colors.js"></script>
  <script src="assets/js/catSettings.js"></script>
  <script src="assets/js/catFactory.js"></script>

</html>

Catsettings.js

var colors = Object.values(allColors())

var defaultDNA = { 
    "headcolor" : 10,
    "mouthColor" : 13,
    "eyesColor" : 96,
    "earsColor" : 10,
    //Cattributes
    "eyesShape" : 1,
    "decorationPattern" : 1,
    "decorationMidcolor" : 13,
    "decorationSidescolor" : 13,
    "animation" :  1,
    "lastNum" :  1
    }

// when page load
$( document ).ready(function() {
    renderCat(defaultDNA)
});

function defaultCat(){
    renderCat(defaultDNA)
}

function randomDNA(){
    var dnaStr = String(Math.floor(Math.random()*1E16))
    //Colors
    var dna = { 
    "headcolor" : dnaStr.substring(0, 2),
    "mouthColor" : dnaStr.substring(2, 4),
    "eyesColor" : dnaStr.substring(4, 6),
    "earsColor" : dnaStr.substring(6, 8),
    //Cattributes
    "eyesShape" : dnaStr.substring(8,9) % 8 + 1    ,
    "decorationPattern" : dnaStr.substring(9, 10)  % 8 + 1,
    "decorationMidcolor" : dnaStr.substring(10, 12),
    "decorationSidescolor" : dnaStr.substring(12, 14),
    "animation" :  dnaStr.substring(14, 15) % 6 + 1,
    "lastNum" :  dnaStr.substring(15, 16)
    }
    return dna
}

//Random cat DNA
function randomCat(){
 var dna = randomDNA()   
    //Rendering Cat
   renderCat(dna)
}
2 Likes

I added a new buttons.js file to keep my JavaScript code more concise.

index.html

<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>CryptoDoggies Factory</title>

        <script type="text/javascript" src="assets/js/jquery-3.4.1.js"></script>
        <link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
        <link rel="stylesheet" href="assets/css/mystyle.css">
        <link rel="stylesheet" href="assets/css/dogs.css">
        <link rel="stylesheet" href="assets/css/animations.css">
        <link rel="stylesheet" href="assets/css/colors.css">
        <link rel="stylesheet" href="assets/css/factory.css">
        <link rel="stylesheet" href="assets/css/frontend.css">
    </head>
    <body>
        <div class="container p-5">
            <div align="center">
                <h1 class="c-white">Crypto Doggies Factory</h1>
                <p class="c-white">Create your custom Doggy</p>
            </div>
        </div>
        <div class="row">
            <div class="col-12 col-lg-6 catBox light-b-shadow">
                <div class="container doggy-container">
                    <div class="bubble">
                        <div class="ear-left">
                            <div class="ear"></div>
                        </div>
                        <div class="ear-right">
                            <div class="ear"></div>
                        </div>
                        <div class="head">
                            <div id="mid" class="head-dots">
                                <div id="leftDot" class="head-dots_first"></div>
                                <div id="rightDot" class="head-dots_second"></div>
                            </div>
                        </div>
                        <div class="dog"></div>
                        <div class="eyes"></div>
                        <div class="nose"></div>
                        <div class="left mouth"></div>
                        <div class="right mouth"></div>
                        <div class="tongue"></div>
                    </div>
                </div>
                <br>
                <div class="dnaDiv" id="dogDNA">
                    <b>
                            DNA:
                            <!-- Colors -->
                            <span id="dnabody"></span>
                            <span id="dnaeyes"></span>
                            <span id="dnaears"></span>
                            <span id="dnamouth"></span>
                            <span id="dnasky"></span>
                            <span id="dnabubble"></span>
                            
                            <!-- Cattributes -->
                            <span id="dnashape"></span>
                            <span id="dnadecoration"></span>
                            <span id="dnadecorationMid"></span>
                            <span id="dnadecorationSides"></span>
                            <span id="dnaanimation"></span>
                            <span id="dnaspecial"></span>
                        </b>
                </div>
            </div>
            <div class="col-12 col-lg-6 cattributes light-b-shadow" >
                <!--Navigation for Colors and Attributes-->
                <ul class="nav nav-pills nav-justified">
                    <li id="colorsMenuBtn" class="nav-item colorsMenuClass">
                      <a class="nav-link active" href="#dogNav">Colors</a>
                    </li>
                    <li id="attributesMenuBtn" class="nav-item attributesMenuClass">
                      <a class="nav-link active" href="#dogNav">Attributes</a>
                    </li>
                  </ul>
                  <br>
                <!-- Cat colors -->
                <div id="dogColors" class="dogColorsClass">
                    <div class="form-group">
                        <label for="formControlRange"><b>Head Color</b><span class="badge badge-dark ml-2" id="headcode"></span></label>
                        <input type="range" min="10" max="98" class="form-control-range" id="bodycolor">
                        <br>
                    </div>   
                    <div class="form-group">
                        <label for="formControlRange"><b>Eye Color</b><span class="badge badge-dark ml-2" id="eyecode"></span></label>
                        <input type="range" min="10" max="98" class="form-control-range" id="eyesColor">
                        <br>
                    </div>     
                    <div class="form-group">
                        <label for="formControlRange"><b>Ear Color</b><span class="badge badge-dark ml-2" id="earscode"></span></label>
                        <input type="range" min="10" max="98" class="form-control-range" id="earsColor">
                        <br>
                    </div>    
                    <div class="form-group">
                        <label for="formControlRange"><b>Mustache Color</b><span class="badge badge-dark ml-2" id="mouthcode"></span></label>
                        <input type="range" min="10" max="98" class="form-control-range" id="mouthColor">
                        <br>
                    </div>    
                    <div class="form-group">
                        <label for="formControlRange"><b>Sky Color</b><span class="badge badge-dark ml-2" id="skycode"></span></label>
                        <input type="range" min="10" max="98" class="form-control-range" id="skyColor">
                        <br>
                    </div>    
                    <div class="form-group">
                        <label for="formControlRange"><b>Bubble Color</b><span class="badge badge-dark ml-2" id="bubblecode"></span></label>
                        <input type="range" min="10" max="98" class="form-control-range" id="bubbleColor">
                        <br>
                    </div>
                    <div class="form-group">
                        <label for="formControlRange"><b>Patch Middle Color</b><span class="badge badge-dark ml-2" id="decorationMidCode"></span></label>
                        <input type="range" min="10" max="98" class="form-control-range" id="decMidColor">
                        <br>
                    </div>
                    <div class="form-group">
                        <label for="formControlRange"><b>Patch Side Color</b><span class="badge badge-dark ml-2" id="decorationSidesCode"></span></label>
                        <input type="range" min="10" max="98" class="form-control-range" id="decSideColor">
                        <br>
                    </div>
                </div>
                <div class="dogAttributesClass">
                    <div class="form-group">
                        <label for="formControlRange"><b>Eye Shape</b><span class="badge badge-dark ml-2" id="eyeName"></span></label>
                        <input type="range" min="1" max="7" class="form-control-range" id="eyeshape">
                        <br>
                    </div>
                    <div class="form-group">
                        <label for="formControlRange"><b>Patch Decoration</b><span class="badge badge-dark ml-2" id="decorationName"></span></label>
                        <input type="range" min="1" max="5" class="form-control-range" id="decorationstyle">
                        <br>
                    </div>
                    <div class="form-group">
                        <label for="formControlRange"><b>Animation</b><span class="badge badge-dark ml-2" id="animationName"></span></label>
                        <input type="range" min="1" max="3" class="form-control-range" id="animation">
                        <br>
                    </div>
                </div>
                <div class="lowerButtonsDiv">
                    <button type="button" id="reset" class="btn btn-secondary btn-lg btn-block">Default Doggy</button>
                    <button type="button" id="random" class="btn btn-primary btn-lg btn-block">Random Doggy</button>
                    <button type="button" class="btn btn-danger btn-lg btn-block">Mint Doggy</button>
                </div>
            </div>
        </div>
        <br> 
        <footer align="left">
            <p>Victor Valdez GoodGains Exchange 2022</p>
        </footer>
    </body>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
    <script src="assets/bootstrap/js/bootstrap.min.js"></script>
    <script src="assets/js/buttons.js"></script>
        <script src="assets/js/colors.js"></script>
        <script src="assets/js/dogSettings.js"></script>
        <script src="assets/js/dogFactory.js"></script>
</html>

buttons.js

//buttons for NFT navigation

const dogColorsBtn = document.getElementById("colorsMenuBtn");
dogColorsBtn.addEventListener("click", showColorsMenu);

const dogAttributesBtn = document.getElementById("attributesMenuBtn");
dogAttributesBtn.addEventListener("click", showAttributesMenu);

async function showColorsMenu() {
    $('.dogColorsClass').css('display', 'block')
    $('.dogAttributesClass').css('display', 'none')
}

async function showAttributesMenu() {
    $('.dogAttributesClass').css('display', 'block')
    $('.dogColorsClass').css('display', 'none')
}

//Randomize Function
$('#random').click(()=>{
    var skycolor = Math.floor(Math.random() * 89) + 10;
    skyColor(colors[skycolor],skycolor)
    $('#skyColor').val(skycolor)
    var bubblecolor = Math.floor(Math.random() * 89) + 10;
    bubbleColor(colors[bubblecolor],bubblecolor)
    $('#bubbleColor').val(bubblecolor)
    var bodycolor = Math.floor(Math.random() * 89) + 10;
    headColor(colors[bodycolor],bodycolor)
    $("#bodycolor").val(bodycolor)
    var mouthcolor = Math.floor(Math.random() * 89) + 10;
    mouthColor(colors[mouthcolor],mouthcolor)
    $("#mouthColor").val(mouthcolor)
    var eyescolor = Math.floor(Math.random() * 89) + 10;
    eyesColor(colors[eyescolor],eyescolor)
    $("#eyesColor").val(eyescolor)
    var earscolor = Math.floor(Math.random() * 89) + 10;
    earsColor(colors[earscolor],earscolor)
    $("#earsColor").val(earscolor)
    var eyevar = Math.floor(Math.random() * (7 - 1 + 1) + 1);
    eyeVariation(eyevar)
    $("#eyeshape").val(eyevar)
    var decovar = Math.floor(Math.random() * (5 - 1 + 1) + 1);
    decorationVariation(decovar)
    $("#decorationstyle").val(decovar)
    var decMidVar = Math.floor(Math.random() * 89) + 10;
    decorationMidColorVar(colors[decMidVar],decMidVar)
    $("#decMidColor").val(decMidVar)
    var decSideVar = Math.floor(Math.random() * 89) + 10;
    decorationSidesColorVar(colors[decSideVar],decSideVar)
    $("#decSideColor").val(decSideVar)
    var anim = Math.floor(Math.random() * (3 - 1 + 1) + 1);
    animationsPlayer(anim)
    $("#animation").val(anim)
  })

//button for default NFT
$('#reset').click(()=>{ 

    headColor(colors[defaultDNA.headColor],defaultDNA.headColor)
    $("#bodycolor").val(defaultDNA.headColor)
   
    mouthColor(colors[defaultDNA.mouthColor],defaultDNA.mouthColor)
    $("#mouthColor").val(defaultDNA.mouthColor)
   
    eyesColor(colors[defaultDNA.eyesColor],defaultDNA.eyesColor)
    $("#eyesColor").val(defaultDNA.eyesColor)
    
    earsColor(colors[defaultDNA.earsColor],defaultDNA.earsColor)
    $("#earsColor").val(defaultDNA.earsColor)
  
    skyColor(colors[defaultDNA.skyColor],defaultDNA.skyColor)
    $('#skyColor').val(defaultDNA.skyColor)
  
    bubbleColor(colors[defaultDNA.bubbleColor],defaultDNA.bubbleColor)
    $('#bubbleColor').val(defaultDNA.bubbleColor)
  
    eyeVariation(defaultDNA.eyesShape)
    $("#eyeshape").val(defaultDNA.eyesShape)
    
    decorationVariation(defaultDNA.decorationPattern)
    $("#decorationstyle").val(defaultDNA.decorationPattern)
  
    decorationMidColorVar(colors[defaultDNA.decorationMidcolor],defaultDNA.decorationMidcolor)
    $("#decMidColor").val(defaultDNA.decorationMidcolor)
    
    decorationSidesColorVar(colors[defaultDNA.decorationSidescolor],defaultDNA.decorationSidescolor)
    $("#decSideColor").val(defaultDNA.decorationSidescolor)
  
    animationsPlayer(defaultDNA.animation)
    $("#animation").val(defaultDNA.animation)
  })

and then to my dogs.css file I just added

.dogColorsClass {
    display: none;
}

.dogAttributesClass {
    display: none;
}
1 Like

I’m gonna add that I designed the page for both mobile, and desktop. It’s fully responsive.

1 Like

niceeee. yeah adding to mobile will be a good challenge and learning about responsive design is key. you should keep the forums updated on how u get on with this

1 Like

Index

<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Jon's kitties </title>
  <script type="text/javascript" src="assets/js/jquery-3.4.1.js"></script>
  <link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
  <script src="assets/bootstrap/js/popper.js"></script>
  <script src="assets/bootstrap/js/bootstrap.min.js"></script>

  <link rel="stylesheet" href="assets/css/animations.css">
  <link rel="stylesheet" href="assets/css/mystyle.css">
  <link rel="stylesheet" href="assets/css/cats.css">
  <link rel="stylesheet" href="assets/css/colors.css">
  <link rel="stylesheet" href="assets/css/factory.css">
  <link rel="stylesheet" href="assets/css/frontend.css">

  
</head>
  <body>
    <div class="container p-5" style="margin-top: 12vh;margin-bottom: 10vh;">
        <div align="center">
        <h1 class="c-white">Kitties-Factory</h1>
        <p class="c-white">Create your custom Kitty</p>
    </div>
        <div class="row">
            <div class="col-lg-4 catBox m-2 light-b-shadow">
                <div class="cat">
                    <div class="cat__ear">
                        <div id="leftEar" class="cat__ear--left">
                            <div class="cat__ear--left-inside"></div>
                        </div>
                        <div id="rightEar" class="cat__ear--right">
                            <div class="cat__ear--right-inside"></div>
                        </div>
                    </div>

                    <div id="head" class="cat__head">
                        <div id="midDot" class="cat__head-dots">
                            <div id="leftDot" class="cat__head-dots_first"></div>
                            <div id="rightDot" class="cat__head-dots_second"></div>
                        </div>
                        <div class="cat__eye">
                            <div class="cat__eye--left">
                                <span class="pupil-left"></span>
                            </div>
                            <div class="cat__eye--right">
                                <span class="pupil-right"></span>
                            </div>
                        </div>
                        <div class="cat__nose"></div>

                        <div class="cat__mouth-contour"></div>
                        <div class="cat__mouth-left"></div>
                        <div class="cat__mouth-right"></div>

                        <div class="cat__whiskers-left"></div>
                        <div class="cat__whiskers-right"></div>
                    </div>

                    <div class="cat__body">

                        <div class="cat__chest"></div>

                        <div class="cat__chest_inner"></div>


                        <div class="cat__paw-left"></div>
                        <div class="cat__paw-left_inner"></div>


                        <div class="cat__paw-right"></div>
                        <div class="cat__paw-right_inner"></div>


                        <div id="tail" class="cat__tail"></div>
                    </div>
                </div>
                <br>
                <div class="dnaDiv" id="catDNA">
                    <b>
                        DNA:
                        <!-- Colors -->
                         <span id="dnabody"></span>
                         <span id="dnamouth"></span>
                         <span id="dnaeyes"></span>
                         <span id="dnaears"></span>
                        
                         <!-- Cattributes -->
                         <span id="dnashape"></span>
                         <span id="dnadecoration"></span>
                         <span id="dnadecorationMid"></span>
                         <span id="dnadecorationSides"></span>
                         <span id="dnaanimation"></span>
                         <span id="dnaspecial"></span>
                    </b>
                </div>
            </div>
            <div class="col-lg-7 cattributes m-2 light-b-shadow">

<!-- Cat colors -->
<div id="catColors">
    <nav>
        <ul class="nav nav-pills">
            <li class="nav-item"><a href="#ColorsTab" class="nav-link" id="colors-tab" role="tab" data-toggle="tab">Colors</a></li>
            <li class="nav-item"><a href="#AttributesTab" class="nav-link" id="attributes-tab" role="tab" data-toggle="tab">Attributes</a></li>
        </ul>
    </nav>
    <div class="tab-content">
        <div id="ColorsTab" class="tab-pane fade show active" role="tabpanel" aria-controls="colors-tab">
                <div class="form-group">
                    <label for="formControlRange"><b>Head and body</b><span class="badge badge-dark ml-2" id="headcode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="bodycolor">
                </div>
                    <!--Slider-->
                <div class="form-group">
                    <label for="formControlRange"><b>Mouth</b><span class="badge badge-dark ml-2" id="mouthcode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="mouthcolor">
                </div>
                    <!--Slider-->
                <div class="form-group">
                    <label for="formControlRange"><b>Eye Color</b><span class="badge badge-dark ml-2" id="eyecode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="eyecolor">
                </div>
                    <!--Slider-->
                <div class="form-group">
                    <label for="formControlRange"><b>Ears, Feet, and Tail</b><span class="badge badge-dark ml-2" id="earcode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="earcolor">
                </div>
            </div>
            <div class="tab-pane fade" id="AttributesTab" aria-controls="attributes-tab" role="tabpanel"</div>
                    <!--Slider Eye Shape-->
                <div class="form-group">
                    <label for="formControlRange"><b>Eye Shape</b><span class="badge badge-dark ml-2" id="eyeName"></span></label>
                    <input type="range" min="1" max="7" class="form-control-range" id="eyeshape">
                </div>
                <!--Slider Decoration Shape-->
                <div class="form-group">
                    <label for="formControlRange"><b>Decoration Shape</b><span class="badge badge-dark ml-2" id="decorationName"></span></label>
                    <input type="range" min="1" max="6" class="form-control-range" id="decorationshape">
                </div>
                <!--Slider Middle Decoration Color-->
                <div class="form-group">
                    <label for="formControlRange"><b>Middle Decoration Color</b><span class="badge badge-dark ml-2" id="decorationMid"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="decorationmid">
                </div>
                <!--Slider Side Decoration Color-->
                <div class="form-group">
                    <label for="formControlRange"><b>Side Decoration Color</b><span class="badge badge-dark ml-2" id="decorationSides"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="decorationsides">
                </div>
                <!--Slider Animation-->
                <div class="form-group">
                    <label for="formControlRange"><b>Animation</b><span class="badge badge-dark ml-2" id="animationName"></span></label>
                    <input type="range" min="1" max="6" class="form-control-range" id="animation">
                </div>
            </div>
        </div>
            </div>
            </div>
            <div class="form-group ">
            <button type="button" id="random"class="btn white-btn">Random</button>
            <button type="button" id= "default" class="btn white-btn">Default</button>
            <button type="button" id="create" class="btn  white-btn">Create</button>
            </div>
        </div>
    </div>
    
            
    <footer align="left">
        <p>My Kitty Clone 2022</p>
    </footer>

  </body>
  <script src="assets/js/colors.js"></script>
  <script src="assets/js/catSettings.js"></script>
  <script src="assets/js/catFactory.js"></script>

</html>

catFactory.js

//Random color
function getColor() {
    var randomColor = Math.floor(Math.random() * 16777215).toString(16);
    return randomColor
}

function getRandomInt(min, max) {
    return Math.floor(Math.random() * (max - min + 1) ) + min;
  }

function genColors(){
    var colors = []
    for(var i = 10; i < 99; i ++){
      var color = getColor()
      colors[i] = color
    }
    return colors
}

//This function code needs to modified so that it works with Your cat code.
function headColor(color,code) {
    $('.cat__head, .cat__chest').css('background', '#' + color)  //This changes the color of the cat
    $('#headcode').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnabody').html(code) //This updates the body color part of the DNA that is displayed below the cat
}

function mouthColor(color,code) {
    $('.cat__mouth-contour, .cat__chest_inner').css('background', '#' + color)  //This changes the color of the cat
    $('#mouthcode').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnamouth').html(code) //This updates the body color part of the DNA that is displayed below the cat
}

function eyeColor(color,code) {
    $('.pupil-left, .pupil-right').css('background', '#' + color)  //This changes the color of the cat
    $('#eyecode').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnaeyes').html(code) //This updates the body color part of the DNA that is displayed below the cat
}

function earColor(color,code) {
    $('.cat__ear--left, .cat__ear--right, .cat__paw-left, .cat__paw-left_inner, .cat__paw-right, .cat__paw-right_inner, .cat__tail').css('background', '#' + color)  //This changes the color of the cat
    $('#earcode').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnaears').html(code) //This updates the body color part of the DNA that is displayed below the cat
}

function mdecorationColor(color,code) {
    $('.cat__head-dots').css('background', '#' + color)  //This changes the color of the cat
    $('#decorationMid').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnadecorationMid').html(code) //This updates the body color part of the DNA that is displayed below the cat
}

function sdecorationColor(color,code) {
    $('.cat__head-dots_first, .cat__head-dots_second').css('background', '#' + color)  //This changes the color of the cat
    $('#decorationSides').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnadecorationSides').html(code) //This updates the body color part of the DNA that is displayed below the cat
}


//###################################################
//Functions below will be used later on in the project
//###################################################
function eyeVariation(num) {

    $('#dnashape').html(num)
    switch (num) {
        case 1:
            normalEyes()
            $('#eyeName').html('Basic')
            break
        case 2:
            normalEyes()
            $('#eyeName').html('Chill')
            eyesType1()
            break
        case 3:
            normalEyes()
            $('#eyeName').html('Look Up')
            eyesType2()
            break
        case 4:
            normalEyes()
            $('#eyeName').html('Zombie Eyes')
            eyesType3()
            break
        case 5:
            normalEyes()
            $('#eyeName').html('Sad Eyes')
            eyesType4()
            break
        case 6:
            normalEyes()
            $('#eyeName').html('???')
            eyesType5()
            break
        case 7:
            normalEyes()
            $('#eyeName').html('Look Left')
            eyesType6()
            break
    }
}

function decorationVariation(num) {
    $('#dnadecoration').html(num)
    switch (num) {
        case 1:
            $('#decorationName').html('Basic')
            normaldecoration()
            break
        case 2:
            normaldecoration()
            $('#decorationName').html('Tilted')
            decoration1()
            break
        case 3:
            normaldecoration()
            $('#decorationName').html('Only Middle')
            decoration2()
            break
        case 4:
            normaldecoration()
            $('#decorationName').html('Short')
            decoration3()
            break
        case 5:
            normaldecoration()
            $('#decorationName').html('Missing Left')
            decoration4()
            break
        case 6:
            normaldecoration()
            $('#decorationName').html('Missing Right')
            decoration5()
            break    
    }
}

function animationVariation(num){
    $('#dnaanimation').html(num)
    switch (num) {
        case 1:
            $('#animationName').html('Head')
            animation1()
            break
        case 2:
            $('#animationName').html('Tail')
            animation2()
            break
        case 3:
            $('#animationName').html('Left Ear')
            animation3()
            break
        case 4:
             $('#animationName').html('Right Ear')
            animation4()
            break
        case 5:
             $('#animationName').html('Ears')
            animation5()
            break
        case 6:
             $('#animationName').html('Tilt Head')
            animation6()
            break
    }
}

//cat animations
async function resetAnimation(){
    $("#head").removeClass("movingHead")
    $('#leftEar').removeClass('movingEarsLeft')
    $('#rightEar').removeClass('movingEarsRight') 
    $('#tail').removeClass('movingTail')  
    $('#head').removeClass('tiltHead')
}

function animation1() {
    resetAnimation()
        $('#head').addClass('movingHead')   
}

function animation2() {
    resetAnimation()
    $('#tail').addClass('movingTail')   
}

async function animation3(){
    resetAnimation()
    $("#leftEar").addClass("movingEarsLeft")
}

async function animation4(){
    resetAnimation()
    $("#rightEar").addClass("movingEarsRight")
}

async function animation5(){
    resetAnimation()
    $("#leftEar").addClass("movingEarsLeft")
    $("#rightEar").addClass("movingEarsRight")
}

async function animation6(){
    resetAnimation()
    $("#head").addClass("tiltHead")
}

//cat eye type
async function normalEyes() {
    await $('.cat__eye').find('span').css('border', 'none')
}

async function eyesType1() {
    await $('.cat__eye').find('span').css('border-top', '15px solid')
}

async function eyesType2() {
    await $('.cat__eye').find('span').css('border-bottom', '15px solid')
}

async function eyesType3() {
    await $('.cat__eye').find('span').css('border-top', '39px solid')
}

async function eyesType4() {
    await $('.cat__eye').find('span').css('border-left', '10px solid')
}

async function eyesType5() {
    await $('.cat__eye').find('span.pupil-left').css('border-top', '15px solid')
    await $('.cat__eye').find('span.pupil-right').css('border-bottom', '15px solid')
}

async function eyesType6() {
    await $('.cat__eye').find('span').css({"transform": "rotate(-25deg)"})
}

//cat decoration patterns
async function normaldecoration() {
    //Remove all style from other decorations
    //In this way we can also use normalDecoration() to reset the decoration style
    $('.cat__head-dots').css({ "transform": "rotate(0deg)", "height": "48px", "width": "14px", "top": "1px", "border-radius": "0 0 50% 50%" })
    $('.cat__head-dots_first').css({ "transform": "rotate(0deg)", "height": "35px", "width": "14px", "top": "1px", "border-radius": "50% 0 50% 50%" })
    $('.cat__head-dots_second').css({ "transform": "rotate(0deg)", "height": "35px", "width": "14px", "top": "1px", "border-radius": "0 50% 50% 50%" })
}

async function decoration1() {
    //Remove all style from other decorations
    //In this way we can also use normalDecoration() to reset the decoration style
    $('.cat__head-dots').css({ "transform": "rotate(0deg)", "height": "48px", "width": "14px", "top": "1px", "border-radius": "0 0 50% 50%" })
    $('.cat__head-dots_first').css({ "transform": "rotate(15deg)", "height": "35px", "width": "14px", "top": "1px", "border-radius": "50% 0 50% 50%" })
    $('.cat__head-dots_second').css({ "transform": "rotate(-15deg)", "height": "35px", "width": "14px", "top": "1px", "border-radius": "0 50% 50% 50%" })
}

async function decoration2() {
    //Remove all style from other decorations
    //In this way we can also use normalDecoration() to reset the decoration style
    $('.cat__head-dots').css({ "transform": "rotate(0deg)", "height": "48px", "width": "14px", "top": "1px", "border-radius": "0 0 50% 50%" })
    $('.cat__head-dots_first').css({ "transform": "rotate(0deg)", "height": "0px", "width": "0px", "top": "1px", "border-radius": "50% 0 50% 50%" })
    $('.cat__head-dots_second').css({ "transform": "rotate(0deg)", "height": "0px", "width": "0px", "top": "1px", "border-radius": "0 50% 50% 50%" })
}

async function decoration3() {
    $('.cat__head-dots').css({ "transform": "rotate(0deg)", "height": "24px", "width": "14px", "top": "1px", "border-radius": "0 0 50% 50%" })
    $('.cat__head-dots_first').css({ "transform": "rotate(0deg)", "height": "17px", "width": "14px", "top": "1px", "border-radius": "50% 0 50% 50%" })
    $('.cat__head-dots_second').css({ "transform": "rotate(0deg)", "height": "17px", "width": "14px", "top": "1px", "border-radius": "0 50% 50% 50%" })
}

async function decoration4() {
    $('.cat__head-dots').css({ "transform": "rotate(0deg)", "height": "48px", "width": "14px", "top": "1px", "border-radius": "0 0 50% 50%" })
    $('.cat__head-dots_first').css({ "transform": "rotate(0deg)", "height": "0px", "width": "14px", "top": "1px", "border-radius": "50% 0 50% 50%" })
    $('.cat__head-dots_second').css({ "transform": "rotate(0deg)", "height": "35px", "width": "14px", "top": "1px", "border-radius": "0 50% 50% 50%" })
}

async function decoration5() {
    $('.cat__head-dots').css({ "transform": "rotate(0deg)", "height": "48px", "width": "14px", "top": "1px", "border-radius": "0 0 50% 50%" })
    $('.cat__head-dots_first').css({ "transform": "rotate(0deg)", "height": "35px", "width": "14px", "top": "1px", "border-radius": "50% 0 50% 50%" })
    $('.cat__head-dots_second').css({ "transform": "rotate(0deg)", "height": "0px", "width": "14px", "top": "1px", "border-radius": "0 50% 50% 50%" })
}


catSettings.js


var colors = Object.values(allColors())

var defaultDNA = {
    "headcolor" : 10,
    "mouthColor" : 13,
    "eyesColor" : 96,
    "earsColor" : 10,
    //Cattributes
    "eyesShape" : 1,
    "decorationPattern" : 1,
    "decorationMidcolor" : 13,
    "decorationSidescolor" : 13,
    "animation" :  1,
    "lastNum" :  1
    }

// when page load
$( document ).ready(function() {
  $('#dnabody').html(defaultDNA.headColor);
  $('#dnamouth').html(defaultDNA.mouthColor);
  $('#dnaeyes').html(defaultDNA.eyesColor);
  $('#dnaears').html(defaultDNA.earsColor);
    
   $('#dnashape').html(defaultDNA.eyesShape);
   $('#dnadecoration').html(defaultDNA.decorationPattern);
   $('#dnadecorationMid').html(defaultDNA.decorationMidcolor);
   $('#dnadecorationSides').html(defaultDNA.decorationSidescolor);
   $('#dnaanimation').html(defaultDNA.animation);
   $('#dnaspecial').html(defaultDNA.lastNum);

  renderCat(defaultDNA)
});

function getDna(){
    var dna = ''
    dna += $('#dnabody').html()
    dna += $('#dnamouth').html()
    dna += $('#dnaeyes').html()
    dna += $('#dnaears').html()
    dna += $('#dnashape').html()
    dna += $('#dnadecoration').html()
    dna += $('#dnadecorationMid').html()
    dna += $('#dnadecorationSides').html()
    dna += $('#dnaanimation').html()
    dna += $('#dnaspecial').html()

    return parseInt(dna)
}

function renderCat(dna){
    headColor(colors[dna.headcolor],dna.headcolor)
    $('#bodycolor').val(dna.headcolor)
    mouthColor(colors[dna.mouthColor],dna.mouthColor)
    $('#mouthcolor').val(dna.mouthColor)
    eyeColor(colors[dna.eyesColor],dna.eyesColor)
    $('#eyecolor').val(dna.eyesColor)
    earColor(colors[dna.earsColor],dna.earsColor)
    $('#earcolor').val(dna.earsColor)
    eyeVariation(dna.eyesShape)
    $('#eyeshape').val(dna.eyesShape)
    decorationVariation(dna.decorationPattern)
    $('#decorationshape').val(dna.decorationPattern)
    mdecorationColor(colors[dna.decorationMidcolor],dna.decorationMidcolor)
    $('#decorationmid').val(dna.decorationMidcolor)
    sdecorationColor(colors[dna.decorationSidescolor],dna.decorationSidescolor)
    $('#decorationsides').val(dna.decorationSidescolor)
    animationVariation(dna.animation)
    $('#animation').val(dna.animation)
}

// Changing cat colors
$('#bodycolor').change(()=>{
    var colorVal = $('#bodycolor').val()
    headColor(colors[colorVal],colorVal)
})

// Changing mouth colors
$('#mouthcolor').change(()=>{
  var colorVal = $('#mouthcolor').val()
  mouthColor(colors[colorVal],colorVal)
})

// Changing eye colors
$('#eyecolor').change(()=>{
  var colorVal = $('#eyecolor').val()
  eyeColor(colors[colorVal],colorVal)
})

// Changing ear colors
$('#earcolor').change(()=>{
  var colorVal = $('#earcolor').val()
  earColor(colors[colorVal],colorVal)
})

// Changing eye shape
$('#eyeshape').change(()=>{
  var shape = parseInt($('#eyeshape').val())
  eyeVariation(shape)
})

// Changing decoration shape
$('#decorationshape').change(()=>{
  var shape = parseInt($('#decorationshape').val())
  decorationVariation(shape)
})

// Changing mid decoration colors
$('#decorationmid').change(()=>{
  var colorVal = $('#decorationmid').val()
  mdecorationColor(colors[colorVal],colorVal)
})

// Changing side decoration colors
$('#decorationsides').change(()=>{
  var colorVal = $('#decorationsides').val()
  sdecorationColor(colors[colorVal],colorVal)
})

// Changing animation
$('#animation').change(()=>{
  var animationVal = parseInt($('#animation').val())
  animationVariation(animationVal)
})

//default Cat
$('#default').click(() =>{
  renderCat(defaultDNA);
})

//random cat
$('#random').click(() =>{
  colorVal=getRandomInt(10,98);
  $('#bodycolor').val(colorVal);
  headColor(colors[colorVal],colorVal);

  colorVal=getRandomInt(10,98);
  $('#mouthcolor').val(colorVal);
  mouthColor(colors[colorVal],colorVal);

  colorVal=getRandomInt(10,98);
  $('#eyecolor').val(colorVal);
  eyeColor(colors[colorVal],colorVal);

  colorVal=getRandomInt(10,98);
  $('#earcolor').val(colorVal);
  earColor(colors[colorVal],colorVal);

  // attributes

  shape=getRandomInt(1,7);
  $('#eyeshape').val(shape);
  eyeVariation(shape);

  pattern=getRandomInt(1,7);
  $('#decorationpattern').val(pattern);
  decorationVariation(pattern);

  colorVal=getRandomInt(10,98);
  $('#decorationmid').val(colorVal);
  mdecorationColor(colors[colorVal],colorVal);

  colorVal=getRandomInt(10,98);
  $('#decorationsides').val(colorVal);
  sdecorationColor(colors[colorVal],colorVal);

  animation=getRandomInt(1,6);
  $('#animation').val(animation);
  animationVariation(animation);

})
2 Likes


index.html

<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Academy kitties </title>
  <script type="text/javascript" src="assets/js/jquery-3.4.1.js"></script>
  <link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
  <script src="assets/bootstrap/js/popper.js"></script>
  <script src="assets/bootstrap/js/bootstrap.min.js"></script>

  <link rel="stylesheet" href="assets/css/mystyle.css">
  <link rel="stylesheet" href="assets/css/cats.css">
  <link rel="stylesheet" href="assets/css/colors.css">
  <link rel="stylesheet" href="assets/css/factory.css">
  <link rel="stylesheet" href="assets/css/frontend.css">
  <link rel="stylesheet" href="assets/css/animations.css">
</head>
  <body>
    <div class="container p-5" style="margin-top: 12vh;margin-bottom: 10vh;">
        <div align="center">
        <h1 class="c-white">Kitties-Factory</h1>
        <p class="c-white">Create your custom Kitty</p>
    </div>
        <div class="row">
            <div class="col-lg-4 catBox m-2 light-b-shadow">
                <div class="cat">
                    <div class="ears">
                        <div class="ear left_ear">
                            <div class="inner-ear"></div>
                        </div>
                        <div class="ear right_ear">
                            <div class="inner-ear"></div>
                        </div>
                    </div>
                    <div id="head" class="">
                        <div class="whisker_left whiskers one"></div>
                        <div class="whisker_left whiskers"></div>
                        <div class="whisker_left whiskers three"></div>
                        <div class="whisker_right whiskers R-one"></div>
                        <div class="whisker_right whiskers R-two"></div>
                        <div class="whisker_right whiskers R-three"></div>
                        <div class="eyes">
                            <div class="eye">
                                <div class="pupils">
                                    <div class="pupil_reflect"></div>
                                </div>
                            </div>
                            <div class="eye">
                                <div class="pupils">
                                    <div class="pupil_reflect"></div>
                                </div>
                            </div>
                        </div>
                        <div class="nose"></div>
                        <div class="cat__mouth-left"></div>
                        <div class="cat__mouth-right"></div>
                        <div class="head_mark"></div>
                        <div class="head_mark_2"></div>
                        <div class="head_mark_3"></div>
                    </div>
                    <div class="body">
                        <div class="leg leg-one"></div>
                        <div class="leg leg-two"></div>
                        <div class="leg leg-three"></div>
                        <div class="leg leg-four"></div>
                        <div class="belly"></div>
                    </div>
                    <div class="tail"></div>
                </div>
                <br>
                <div class="dnaDiv" id="catDNA">
                    <b>
                        DNA:
                        <!-- Colors -->
                         <span id="dnahead"></span>
                         <span id="dnaearsandbody"></span>
                         <span id="dnapaws"></span>
                         <span id="dnaeyes"></span>
                        
                         <!-- Cattributes -->
                         <span id="dnashape"></span>
                         <span id="dnadecoration"></span>
                         <span id="dnadecorationMid"></span>
                         <span id="dnadecorationSides"></span>
                         <span id="dnaanimation"></span>
                         <span id="dnaspecial"></span>
                    </b>
                </div>
            </div>
            <div class="col-lg-7 cattributes m-2 light-b-shadow">

<!-- Cat colors -->
<div id="catColors">
    <div class="btn btn-group-toggle" data-toggle="buttons">
        <label class="btn btn-primary active colors">
          <input type="radio" name="options" id="option1" autocomplete="off" checked> Colors
        </label>
        <label class="btn btn-primary colors2">
          <input type="radio" name="options" id="option2" autocomplete="off"> Cattributes
        </label>
      </div>
            <div class="section1">
                <div class="form-group">
                    <label for="formControlRange"><b>Head and Tail</b><span class="badge badge-dark ml-2" id="headcode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="headcolor">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Outer Ears and Body</b><span class="badge badge-dark ml-2" id="ear_bodycode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="ear_body">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Paws</b><span class="badge badge-dark ml-2" id="pawscode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="pawscolor">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Eyes</b><span class="badge badge-dark ml-2" id="eyecode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="eyecolor">
                </div>
            </div>
            <section class="section2">
                <div class="form-group">
                    <label for="formControlRange"><b>Eyes shape</b><span class="badge badge-dark ml-2" id="eyeName"></span></label>
                    <input type="range" min="1" max="7" class="form-control-range" id="eyeshape">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Marking Style</b><span class="badge badge-dark ml-2" id="markingName"></span></label>
                    <input type="range" min="1" max="4" class="form-control-range" id="marking">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Big Marking</b><span class="badge badge-dark ml-2" id="bigMarkingCode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="bigmarking">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Little Markings</b><span class="badge badge-dark ml-2" id="littleMarkingCode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="littlemarking">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Animations</b><span class="badge badge-dark ml-2" id="animationsName"></span></label>
                    <input type="range" min="1" max="6" class="form-control-range" id="animations">
                </div>
            </section>
                
            </div>

            </div>
            <div style="padding-left: 30px; padding-top: 7px;">
                <button type="button" class="btn btn-primary random">Get random cat</button>
                <button id="Defaultcat" type="button" class="btn btn-primary">Default cat</button>
                <button style="margin-left: 400px;" type="button" class="btn btn-success">Mint Cat</button>
            </div>
            
             
            </div>
            <br>

        </div>



    </div>
    <footer align="left">
        <p>Ivan on Tech Academy Bootcamp July 2020</p>
    </footer>

  </body>
  <script src="assets/js/colors.js"></script>
  <script src="assets/js/catSettings.js"></script>
  <script src="assets/js/catFactory.js"></script>

</html>

catSettings.js

var colors = Object.values(allColors())

var defaultDNA = {
    "headcolor" : 10,
    "earsBodyColor" : 13,
    "pawsColor" : 96,
    "eyesColor" : 15,
    //Cattributes
    "eyesShape" : 1,
    "markingStyle" : 1,
    "bigMarkingColor" : 13,
    "littleMarkingColor" : 13,
    "animation" :  1,
    "lastNum" :  1
    }

// when page load
$( document ).ready(function() {
  $('#dnahead').html(defaultDNA.headColor);
  $('#dnaearsbody').html(defaultDNA.earsBodyColor);
  $('#dnapaws').html(defaultDNA.pawsColor);
  $('#dnaeyes').html(defaultDNA.eyesColor);
    
  $('#dnashape').html(defaultDNA.eyesShape)
  $('#dnadecoration').html(defaultDNA.markingStyle)
  $('#dnadecorationMid').html(defaultDNA.bigMarkingColor)
  $('#dnadecorationSides').html(defaultDNA.littleMarkingColor)
  $('#dnaanimation').html(defaultDNA.animation)
  $('#dnaspecial').html(defaultDNA.lastNum)

  renderCat(defaultDNA)
});

function getDna(){
    var dna = ''
    dna += $('#dnahead').html()
    dna += $('#dnaearsandbody').html()
    dna += $('#dnapaws').html()
    dna += $('#dnaeyes').html()
    dna += $('#dnashape').html()
    dna += $('#dnadecoration').html()
    dna += $('#dnadecorationMid').html()
    dna += $('#dnadecorationSides').html()
    dna += $('#dnaanimation').html()
    dna += $('#dnaspecial').html()

    return parseInt(dna)
}

function renderCat(dna){
    headColor(colors[dna.headcolor],dna.headcolor)
    $('#headcolor').val(dna.headcolor)
    earBodyColor(colors[dna.earsBodyColor],dna.earsBodyColor) 
    $('#ear_body').val(dna.earsBodyColor)
    pawsColor(colors[dna.pawsColor],dna.pawsColor)
    $('#pawscolor').val(dna.pawsColor)
    eyesColor(colors[dna.eyesColor],dna.eyesColor)
    $('#eyecolor').val(dna.eyesColor)
    bigMarkingColor(colors[dna.bigMarkingColor],dna.bigMarkingColor)
    $('#bigmarking').val(dna.bigMarkingColor)
    littleMarkingColor(colors[dna.littleMarkingColor],dna.littleMarkingColor)
    $('#littlemarking').val(dna.littleMarkingColor)
    eyeVariation(dna.eyesShape)
    $('#eyeshape').val(dna.eyesShape)
    markingVariation(dna.markingStyle)
    $('#marking').val(dna.markingStyle)
    animationVariation(dna.animation)
    $('#animations').val(dna.animation)
}

// Changing cat colors
$('#headcolor').change(()=>{
    var colorVal = $('#headcolor').val()
    headColor(colors[colorVal],colorVal)
})

$('#ear_body').change(()=>{
  var colorVal = $('#ear_body').val()
  earBodyColor(colors[colorVal],colorVal)
})

$('#pawscolor').change(()=>{
  var colorVal = $('#pawscolor').val()
  pawsColor(colors[colorVal],colorVal)
})

$('#eyecolor').change(()=>{
  var colorVal = $('#eyecolor').val()
  eyesColor(colors[colorVal],colorVal)
})

$('#bigmarking').change(()=>{
  var colorVal = $('#bigmarking').val()
  bigMarkingColor(colors[colorVal],colorVal)
})

$('#littlemarking').change(()=>{
  var colorVal = $('#littlemarking').val()
  littleMarkingColor(colors[colorVal],colorVal)
})

//changing cattributes
$('#eyeshape').change(()=>{
  var shape = parseInt($('#eyeshape').val())
  eyeVariation(shape)
})

$('#marking').change(()=>{
  var shape = parseInt($('#marking').val())
  markingVariation(shape)
})

$('#animations').change(()=>{
  var animation = parseInt($('#animations').val())
  animationVariation(animation)
})

//tab functions
$(".btn.colors").ready(()=>{
  $(".section1").css('display', 'block');
  $(".section2").css('display', 'none');
})
$(".btn.colors").click(()=>{
  $(".section1").css('display', 'block');
  $(".section2").css('display', 'none');
})
$(".btn.colors2").click(()=>{
  $(".section1").css('display', 'none');
  $(".section2").css('display', 'block');
})


//get random cat
$(".btn.random").click(()=>{
 var randomDNA = {
  "headcolor" : Math.floor(Math.random()*89) + 10,
  "earsBodyColor" : Math.floor(Math.random()*89) + 10,
  "pawsColor" : Math.floor(Math.random()*89) + 10,
  "eyesColor" : Math.floor(Math.random()*89) + 10,
  //Cattributes
  "eyesShape" : Math.floor(Math.random()*7) + 1,
  "markingStyle" : Math.floor(Math.random()*4) + 1,
  "bigMarkingColor" : Math.floor(Math.random()*89) + 10,
  "littleMarkingColor" : Math.floor(Math.random()*89) + 10,
  "animation" :  Math.floor(Math.random()*6) + 1,
  "lastNum" :  1
 }
  $('#dnahead').html(randomDNA.headColor);
  $('#dnaearsbody').html(randomDNA.earsBodyColor);
  $('#dnapaws').html(randomDNA.pawsColor);
  $('#dnaeyes').html(randomDNA.eyesColor);
    
  $('#dnashape').html(randomDNA.eyesShape)
  $('#dnadecoration').html(randomDNA.markingStyle)
  $('#dnadecorationMid').html(randomDNA.bigMarkingColor)
  $('#dnadecorationSides').html(randomDNA.littleMarkingColor)
  $('#dnaanimation').html(randomDNA.animation)
  $('#dnaspecial').html(randomDNA.lastNum)

  renderCat(randomDNA)
})


//get default cat
document.getElementById("Defaultcat").addEventListener("click", defaultCat);

function defaultCat(){ 
  $('#dnahead').html(defaultDNA.headColor);
  $('#dnaearsbody').html(defaultDNA.earsBodyColor);
  $('#dnapaws').html(defaultDNA.pawsColor);
  $('#dnaeyes').html(defaultDNA.eyesColor);
    
  $('#dnashape').html(defaultDNA.eyesShape)
  $('#dnadecoration').html(defaultDNA.markingStyle)
  $('#dnadecorationMid').html(defaultDNA.bigMarkingColor)
  $('#dnadecorationSides').html(defaultDNA.littleMarkingColor)
  $('#dnaanimation').html(defaultDNA.animation)
  $('#dnaspecial').html(defaultDNA.lastNum)

  renderCat(defaultDNA)

}
2 Likes

index.html

<button type="button" class="btn btn-info">Colors</button>
    <button type="button" class="btn btn-warning">Cattributes</button>

    <div class="section1">
        <div class="form-group">
            <label for="formControlRange"><b>Head and body</b><span class="badge badge-dark ml-2" id="headcode"></span></label>
            <input type="range" min="10" max="98" class="form-control-range" id="bodycolor">
        </div>


        <div class="form-group">
            <label for="formControlRange"><b>Mouth/Body/Tail Color</b><span class="badge badge-dark ml-2" id="mouthcode"></span></label>
            <input type="range" min="10" max="98" class="form-control-range" id="mouthcolor">
        </div>

        <div class="form-group">
            <label for="formControlRange"><b>Eye Color</b><span class="badge badge-dark ml-2" id="eyecode"></span></label>
            <input type="range" min="10" max="98" class="form-control-range" id="eyecolor">
        </div>

        <div class="form-group">
            <label for="formControlRange"><b>Ear Color</b><span class="badge badge-dark ml-2" id="earcode"></span></label>
            <input type="range" min="10" max="98" class="form-control-range" id="earcolor">
        </div>
    </div>
</id>
    
    <div class="section2">
        <div class="form-group">
            <label for="formControlRange"><b>Eyes shape</b><span class="badge badge-dark ml-2" id="eyeName"></span></label>
            <input type="range" min="1" max="7" class="form-control-range" id="eyeshape">
        </div>

        <div class="form-group">
            <label for="formControlRange"><b>Dots</b><span class="badge badge-dark ml-2" id="dotName"></span></label>
            <input type="range" min="1" max="5" class="form-control-range" id="dotshape">
        </div>

        <div class="form-group">
            <label for="formControlRange"><b>Outer Dot Color</b><span class="badge badge-dark ml-2" id="dotName2"></span></label>
            <input type="range" min="10" max="98" class="form-control-range" id="dotcolor">
        </div>

        <div class="form-group">
            <label for="formControlRange"><b>Inner Dot Color</b><span class="badge badge-dark ml-2" id="dotName3"></span></label>
            <input type="range" min="10" max="98" class="form-control-range" id="dotcolor2">
        </div>

        <div class="form-group">
            <label for="formControlRange"><b>Animation</b><span class="badge badge-dark ml-2" id="animationName"></span></label>
            <input type="range" min="1" max="5" class="form-control-range" id="animation">
        </div>

    </div>  

            </div>

            <div class="buttons">
                <button type="button" id="primary1" class="btn btn-primary">Get Random Kitten</button>
                <button type="button" id="primary2" class="btn btn-primary">Default Kitten</button>
                <button type="button" class="btn btn-success">Mint Kitten</button>
            </div>  

            </div>
            <br>

        </div>



    </div>
    <footer align="left">
        <p>Ivan on Tech Academy Bootcamp July 2020</p>
    </footer>

  </body>
  <script src="assets/js/colors.js"></script>
  <script src="assets/js/catSettings.js"></script>
  <script src="assets/js/catFactory.js"></script>

</html>

catSettings.js

var colors = Object.values(allColors())

var defaultDNA = {
    "headcolor" : 10,
    "mouthColor" : 13,
    "eyesColor" : 96,
    "earsColor" : 10,
    //Cattributes
    "eyesShape" : 1,
    "decorationPattern" : 1,
    "decorationMidcolor" : 13,
    "decorationSidescolor" : 13,
    "animation" :  1,
    "lastNum" :  1
    }

// when page load
$( document ).ready(function() {
  $('#dnabody').html(defaultDNA.headColor);
  $('#dnamouth').html(defaultDNA.mouthColor);
  $('#dnaeyes').html(defaultDNA.eyesColor);
  $('#dnaears').html(defaultDNA.earsColor);
    
  $('#dnashape').html(defaultDNA.eyesShape)
  $('#dnadecoration').html(defaultDNA.decorationPattern)
  $('#dnadecorationMid').html(defaultDNA.decorationMidcolor)
  $('#dnadecorationSides').html(defaultDNA.decorationSidescolor)
  $('#dnaanimation').html(defaultDNA.animation)
  $('#dnaspecial').html(defaultDNA.lastNum)

  renderCat(defaultDNA)
}); 

function getDna(){
    var dna = ''
    dna += $('#dnabody').html()
    dna += $('#dnamouth').html()
    dna += $('#dnaeyes').html()
    dna += $('#dnaears').html()
    dna += $('#dnashape').html()
    dna += $('#dnadecoration').html()
    dna += $('#dnadecorationMid').html()
    dna += $('#dnadecorationSides').html()
    dna += $('#dnaanimation').html()
    dna += $('#dnaspecial').html()

    return parseInt(dna)
} 

function renderCat(dna){
    headColor(colors[dna.headcolor],dna.headcolor)
    $('#bodycolor').val(dna.headcolor)
    mouthColor(colors[dna.mouthColor],dna.mouthColor)
    $('#mouthcolor').val(dna.mouthColor)
    eyesColor(colors[dna.eyesColor],dna.eyesColor)
    $('#eyecolor').val(dna.eyesColor)
    earsColor(colors[dna.earsColor],dna.earsColor)
    $('#earcolor').val(dna.earsColor)
    eyeVariation(dna.eyesShape)
    $('#eyeshape').val(dna.eyesShape)
    decorationVariation(dna.decorationPattern)
    $('#dotshape').val(dna.decorationPattern)
    innerDotColor(colors[dna.decorationMidcolor],dna.decorationMidcolor)
    $('#dotcolor').val(dna.decorationMidcolor)
    outerDotColor(colors[dna.decorationSidescolor],dna.decorationSidescolor)
    $('#dotcolor2').val(dna.decorationSidescolor)
    animationVariation(dna.animation)
    $('#animation').val(dna.animation)
$('#animation').change(()=>{
  var animationVal = parseInt($('#animation').val())
  animationVariation(animationVal)
})

$(".btn-info").ready(()=>{
  $(".section1").css('display', 'block');
  $(".section2").css('display', 'none');
})
$(".btn-info").click(()=>{
  $(".section1").css('display', 'block');
  $(".section2").css('display', 'none');
})
$(".btn-warning").click(()=>{
  $(".section1").css('display', 'none');
  $(".section2").css('display', 'block');
})

$("#primary1").click(()=>{
  var randomDNA = {
    // color
   "headcolor" : Math.floor(Math.random()*97) + 10,
   "mouthColor" : Math.floor(Math.random()*97) + 10,
   "eyesColor" : Math.floor(Math.random()*97) + 10,
   "earsColor" : Math.floor(Math.random()*97) + 10,
   //Cattributes
   "eyesShape" : Math.floor(Math.random()*6) + 1,
   "decorationPattern" : Math.floor(Math.random()*4) + 1,
   "decorationMidcolor" : Math.floor(Math.random()*97) + 10,
   "decorationSidescolor" : Math.floor(Math.random()*97) + 10,
   "animation" : Math.floor(Math.random()*4) + 1,
   "lastNum" : 1
  }
   $('#dnabody').html(randomDNA.headcolor);
   $('#dnamouth').html(randomDNA.mouthColor);
   $('#dnaeyes').html(randomDNA.eyesColor);
   $('#dnaears').html(randomDNA.earsColor);
     
   $('#dnashape').html(randomDNA.eyesShape)
   $('#dnadecoration').html(randomDNA.decorationPattern)
   $('#dnadecorationMid').html(randomDNA.decorationMidcolor)
   $('#dnadecorationSides').html(randomDNA.decorationSidescolor)
   $('#dnaanimation').html(randomDNA.animation)
   $('#dnaspecial').html(randomDNA.lastNum)
 
   renderCat(randomDNA)
 })
 
 
 //get default cat
 document.getElementById("primary2").addEventListener("click", defaultKitten);
 
 function defaultKitten(){ 
   $('#dnabody').html(defaultDNA.bodycolor);
   $('#dnamouth').html(defaultDNA.mouthcolor);
   $('#dnaeyes').html(defaultDNA.eyecolor);
   $('#dnaears').html(defaultDNA.earcolor);
     
   $('#dnashape').html(defaultDNA.eyeshape)
   $('#dnadecoration').html(defaultDNA.dotshape)
   $('#dnadecorationMid').html(defaultDNA.dotcolor)
   $('#dnadecorationSides').html(defaultDNA.dotcolor2)
   $('#dnaanimation').html(defaultDNA.animation)
   $('#dnaspecial').html(defaultDNA.lastNum)
 
   renderCat(defaultDNA)
 
 }

Hii All,

Here’s my code.

Catsettings.js


var colors = Object.values(allColors())

var defaultDNA = {
    "headcolor" : 23,
    "mouthColor" : 44,
    "eyesColor" : 62,
    "earsColor" : 15,
    //Cattributes
    "eyesShape" : 4,
    "decorationPattern" : 2,
    "decorationColor" : 15,
    "animation" :  4,
    "lastNum" :  1
    }

// when page load
$( document ).ready(function() {
    $('#dnabody').html(defaultDNA.headColor);
    $('#dnamouth').html(defaultDNA.mouthColor);
    $('#dnaeyes').html(defaultDNA.eyesColor);
    $('#dnaears').html(defaultDNA.earsColor);
      
    $('#dnashape').html(defaultDNA.eyesShape)
    $('#dnadecoration').html(defaultDNA.decorationPattern)
    $('#dnadecorationcolor').html(defaultDNA.decorationColor)
    $('#dnaanimation').html(defaultDNA.animation)
    $('#dnaspecial').html(defaultDNA.lastNum)

  renderCat(defaultDNA)
});

function getDna(){
    var dna = ''
    dna += $('#dnabody').html()
    dna += $('#dnamouth').html()
    dna += $('#dnaeyes').html()
    dna += $('#dnaears').html()
    dna += $('#dnashape').html()
    dna += $('#dnadecoration').html()
    dna += $('#dnadecorationcolor').html()
    dna += $('#dnaanimation').html()
    dna += $('#dnaspecial').html()

    return parseInt(dna)
}

function renderCat(dna){
    headColor(colors[dna.headcolor],dna.headcolor)
    $('#bodycolor').val(dna.headcolor)
    mouthAndBellyColor(colors[dna.mouthcolor],dna.mouthcolor)
    $('#mouthcolor').val(dna.mouthcolor)
    eyeColor(colors[dna.eyecolor],dna.eyecolor)
    $('#eyecolor').val(dna.eyecolor)
    earsAndPaw(colors[dna.earsColor],dna.earsColor)
    $('#earcolor').val(dna.earsColor)
    eyeVariation(dna.eyesShape)
    $('#eyeshape').val(dna.eyesShape)
    decorationVariation(dna.decorationPattern)
    $('#decorationvariation').val(dna.decorationPattern)
    decorationColor(colors[dna.decorationColor], dna.decorationColor)
    $('#decorationcolor').val(dna.decorationColor)
    animationVariation(dna.animation)
    $('#animation').val(dna.animation)
}

// Changing cat colors
$('#bodycolor').change(()=>{
    var colorVal = $('#bodycolor').val()
    headColor(colors[colorVal],colorVal)
})
$('#mouthcolor').change(()=>{
  var colorVal = $('#mouthcolor').val()
  mouthAndBellyColor(colors[colorVal],colorVal)
})
$('#eyecolor').change(()=>{
  var colorVal = $('#eyecolor').val()
  eyeColor(colors[colorVal],colorVal)
})
$('#earcolor').change(()=>{
  var colorVal = $('#earcolor').val()
  earsAndPaw(colors[colorVal],colorVal)
})
$('#eyeshape').change(()=>{
  var shape = parseInt($('#eyeshape').val()) // value between 1 and 7 
  eyeVariation(shape)
})
$('#decorationvariation').change(()=>{
  var shape = parseInt($('#decorationvariation').val()) // value between 1 and 7
  var animation = parseInt($('#animation').val())
  decorationVariation(shape, animation)
})
$('#decorationcolor').change(()=>{
  var colorVal = $('#decorationcolor').val()
  decorationColor(colors[colorVal],colorVal)
})

$('#animation').change(()=>{
  var animation = parseInt($('#animation').val()) // value between 1 and 7
  var shape = parseInt($('#decorationvariation').val())
  animationVariation(animation, shape)
})

function showCattributes(){
  $('#cattributes').removeClass('hidden')
  $('#catColors').addClass('hidden')
}

function showColors(){
  $('#cattributes').addClass('hidden')
  $('#catColors').removeClass('hidden')
}

//Default Kitty
$('#default').click(()=>{
  renderCat(defaultDNA)
})

// Random Kitty

$('#random').click(()=>{

  var body = Math.floor(Math.random()* 89) +10
  headColor(colors[body],body)
  $('#bodycolor').val(body)

  var mouthcolor = Math.floor(Math.random()* 89) +10
  mouthAndBellyColor(colors[mouthcolor],mouthcolor)
  $('#mouthcolor').val(mouthcolor)

  var eyecolor = Math.floor(Math.random()* 89) +10
  eyeColor(colors[eyecolor],eyecolor)
  $('#eyecolor').val(eyecolor)

  var earcolor = Math.floor(Math.random()* 89) +10
  earsAndPaw(colors[earcolor],earcolor)
  $('#earcolor').val(earcolor)

  var eyeshape = Math.floor(Math.random()*7) +1 // value between 1 and 7 
  eyeVariation(eyeshape)
  $('#eyeshape').val(eyeshape)
  
  var decoshape = Math.floor(Math.random()*7) +1 // value between 1 and 7
  var decoanimation = Math.floor(Math.random()*7) +1
  decorationVariation(decoshape, decoanimation)
  parseInt( $('#decorationvariation').val(decoshape))

  var decocolor = Math.floor(Math.random()*89) +10
  decorationColor(colors[decocolor],decocolor)
  $('#decorationcolor').val()

  var animation = Math.floor(Math.random()*7) +1 // value between 1 and 7
  var shape = Math.floor(Math.random()*7) +1
  if(animation == 4){
    parseInt( $('#animation').val(decoanimation))
    parseInt( $('#decorationvariation').val(decoshape))
    animationVariation(decoanimation, decoshape)
  }
  else{
    parseInt( $('#animation').val(animation))
    animationVariation(animation, shape)
  }

})

catFactory.js

const translate = require("solc/translate");

//Storage Variables
specialNum;

//Random color
function getColor() {
    var randomColor = Math.floor(Math.random() * 16777215).toString(16);
    return randomColor
}

function genColors(){
    var colors = []
    for(var i = 10; i < 99; i ++){
      var color = getColor()
      colors[i] = color
    }
    return colors
}

//This function code needs to modified so that it works with Your cat code.
function headColor(color,code) {
    $('.cat__head, .cat__chest').css('background', '#' + color)  //This changes the color of the cat
    $('#headcode').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnabody').html(code) //This updates the body color part of the DNA that is displayed below the cat
}
function mouthAndBellyColor(color,code) {
    $('.cat__mouth-contour, cat__tail, .cat__chest_inner').css('background', '#' + color)  //This changes the mouth color of the cat
    $('#mouthcode').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnamouth').html(code) //This updates the body color part of the DNA that is displayed below the cat
}
function eyeColor(color,code) {
    $('.pupil-left, .pupil-right').css('background', '#' + color)  //This changes the eye color of the cat
    $('#eyecode').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnaeyes').html(code) //This updates the body color part of the DNA that is displayed below the cat
}
function earsAndPaw(color,code) {
    $('.cat__ear--left, .cat__ear--right, .cat__paw--left, .cat__paw--right, .cat__paw-right_inner, .cat__paw-left_inner').css('background', '#' + color)  //This changes the ear color of the cat
    $('#earscode').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnaears').html(code) //This updates the body color part of the DNA that is displayed below the cat
}
function decorationColor(color,code) {
    $('#midDot, .cat__head-dots_first, .cat__head-dots_second').css('background','#' + color)
    $('#decorationvariationcolor').html('code: '+code)
    $('#dnadecorationcolor').html(code)
}

function eyeVariation(num) {

        $('#dnashape').html(num)
        switch (num) {
            case 1:

                normalEyes()
                $('#eyeName').html('Basic')//set the badge to "Basic"
                break
            case 2:
                normalEyes()//Reset the settings so no errors could occur
                $('#eyeName').html('Chill')//set the badge to "Chill"
                eyesType1() //Set border to change the shape of the eyes
                break
            case 3:
                normalEyes()//Reset the settings so no errors could occur
                $('#eyeName').html('Thinking')//set the badge to "Chill"
                eyesType2() //Set border to change the shape of the eyes
                break
                case 4:
                    normalEyes()//Reset the settings so no errors could occur
                    $('#eyeName').html('Professor')//set the badge to "Chill"
                    eyesType3() //Set border to change the shape of the eyes
                    break
                case 5:
                    $('#eyeName').html('Cross-eyed')//set the badge to "Chill"
                    eyesType4() //Set border to change the shape of the eyes
                break  
                case 6:
                    normalEyes()
                    $('#eyeName').html('Sfynx')//set the badge to "Chill"
                    eyesType5() //Set border to change the shape of the eyes
                break   
                case 7:
                    normalEyes()
                    $('#eyeName').html('Small Eyer')//set the badge to "Chill"
                    eyesType6() //Set border to change the shape of the eyes
                break       
            default:
                console.log("Not 1 or 2")
                break
        }
}
function decorationVariation(num, animation) {
    $('#dnadecoration').html(num)
    switch (num) {
        case 1:
            if(num == 1){
                $('#variationName').html('Special Animation1')//3D Decorative Pattern
                specialAnimationType1()
            }
            else{
                $('#decorationName').html('Basic')
                normaldecoration()
                break
            }
        case 2:
            if(num == 2){
                $('#variationName').html('Special Animation2')//3D Decorative Pattern
                specialAnimationType2()
            }
            else{
                $('#decorationName').html('Croscy')//set the badge to Biggie
                decorationType1()
                break
            }   
        case 3:
            if(num == 3){
                $('#variationName').html('Special Animation3')//3D Decorative Pattern
                specialAnimationType3()
            }
            else{
                $('#decorationName').html('Meowthy')
                decorationType2()
                break
            }      
        case 4:
            if(num == 4){
                $('#variationName').html('Special Animation4')//3D Decorative Pattern
                specialAnimationType4()
            }
            else{
                $('#decorationName').html('Nothing')
                decorationType3()
                break    
            }
        case 5:
            if(num == 5){
                $('#variationName').html('Special Animation5')//3D Decorative Pattern
                specialAnimationType5()
            }
            else{
                $('#decorationName').html('Lefty')
                decorationType4()
                break   
            }
        case 6:
            if(num == 6){
                $('#variationName').html('Special Animation6')//3D Decorative Pattern
                specialAnimationType6()
            }
            else{
                $('#decorationName').html('Mirrory')
                decorationType5()
                break    
            }
        case 7:
            if(num == 7){
                $('#variationName').html('Special Animation7')//3D Decorative Pattern
                specialAnimationType7()
            }
            else{
                $('#decorationName').html('Browser')
                decorationType6()
                break                
            }
        case 8:
                $('#decorationName').html('Strange')
                decorationType7()
                break
        }
}

function animationVariation(num, shape){
    $('#dnadanimation').html(num)
        switch (num) {
            case 1:
                $('#variationName').html('Nodding')//Nodding Head
                AnimationType1()    
                break
            case 2:
                $('#variationName').html('Eye Roller')//Rolling Eyes
                AnimationType2()
                break
            case 3:
                $('#variationName').html('Tails')//Wagging Tail
                AnimationType3()
                break    
            case 4:
                 if(shape == 1){
                     $('#variationName').html('Special Animation1')//3D Decorative Pattern
                     specialAnimationType1()
                 }
                 if(shape == 2){
                    $('#variationName').html('Special Animation2')//3D Decorative Pattern
                    specialAnimationType2()
                }
                if(shape == 3){
                    $('#variationName').html('Special Animation3')//3D Decorative Pattern
                    specialAnimationType3()
                }
                if(shape == 4){
                    $('#variationName').html('Special Animation4')//3D Decorative Pattern
                    specialAnimationType4()
                }
                if(shape == 5){
                    $('#variationName').html('Special Animation5')//3D Decorative Pattern
                    specialAnimationType5()
                }
                if(shape == 6){
                    $('#variationName').html('Special Animation6')//3D Decorative Pattern
                    specialAnimationType6()
                }
                if (shape == 7){
                    $('#variationName').html('Browser')
                    specialAnimationType7()
                }
                break    
            case 5:
                $('#variationName').html('Cloaky Invisibility')//Disappearing Cat
                InvisibilityAnimation()
                break    
            case 6:
                $('#variationName').html('The Walking Cat')// The Walking Cat
                AnimationType4()
                break       
        }


}
function normalEyes() {
    $('.cat__eye').find('span').css('border', 'none', 'transform', 'scale(1)')
    $('.cat__eye--left').find('span').css('transform', 'scale(1.0)')
    $('.cat__eye--right').find('span').css('transform','scale(1.0)')
}

//Cattributes Eyes Types 1-6
function eyesType1(){
    $('.cat__eye').find('span').css('border-top','15px solid')
}

function eyesType2(){
    $('.cat__eye').find('span').css('border-bottom','15px solid')
}
function eyesType3(){
    $('.cat__eye').find('span').css('border-bottom','5px solid')
    $('.cat__eye--left').find('span').css('transform','scale(1.5)', 'border-top','7px solid')
    $('.cat__eye--right').find('span').css('transform','scale(1.2)')
}
function eyesType4(){
    normalEyes()//Reset the settings so no errors could occur
    $('.cat__eye--left').find('span').css({
        "border-top": '0px solid',
        "border-right": '5px solid',
        "border-bottom": '0px solid',
        "border-left": '0px solid',
        "border-image": 'initial',
        "transform": 'scale(-1, 1)'

    })
    $('.cat__eye--right').find('span').css({
        "border-top": '0px solid',
        "border-right": '5px solid',
        "border-bottom": '0px solid',
        "border-left": '0px solid',
        "border-image": 'initial',
        "transform": 'scale(1)'

    })
}
function eyesType5() {
    $('.cat__eye').find('span').css({ 'border-right': '15px solid', 'border-left': '15px solid' })
}
function eyesType6(){
    $('.cat__eye--left').find('span').css({
        "border-top": '5px solid',
        "border-right": '13px solid',
        "border-bottom": '5px solid',
        "border-left": '13px solid',
        "border-image": 'initial',
        "transform": 'scale(0.8)'

    })
    $('.cat__eye--right').find('span').css({
        "border-top": '5px solid',
        "border-right": '13px solid',
        "border-bottom": '5px solid',
        "border-left": '13px solid',
        "border-image": 'initial',
        "transform": 'scale(-0.8, 0.8)'
    })
}

//Decoration Types 1-6
function normaldecoration() {
    //Remove all style from other decorations
    //In this way we can also use normalDecoration() to reset the decoration style
    $('.cat__head-dots').css({ 
        "transform": "rotate(0deg)", 
        "height": "48px", 
        "width": "14px", 
        "top": "1px", 
        "border-radius": "0 0 50% 50%", 
        "visibility": "inherit",
        "left": "103px",
        "filter": "invert(0)"
    })

    $('.cat__head-dots_first').css({ 
        "transform": "rotate(0deg)", 
        "height": "35px", 
        "width": "14px", 
        "top": "1px", 
        "border-radius": 
        "50% 0 50% 50%", 
        "visibility": "inherit", 
        "left": "-20px",
        "filter": "invert(1)"
    })
    $('.cat__head-dots_second').css({ 
        "transform": "rotate(0deg)", 
        "height": "35px", 
        "width": "14px", 
        "top": "1px", 
        "border-radius": "0 50% 50% 50%", 
        "visibility": "inherit",   
        "left": "18px",
        "filter":"invert(1)"
    })
}

function decorationType1() { //Croscy
    normaldecoration()//Reset the settings so no errors could occur
    $('.cat__head-dots').css({
        "height": "68px",
        "width": "20px",
        "top": "1px",
        "left": "98px",
        "transform": "rotate(0)",
        "border-radius": "100%",

    })
        $('.cat__head-dots_first').css({
        "transform": "rotate(120deg)",
        "height": "68px",
        "width": "20px",
        "top": "0px",
        "border-radius": "100%",
        "left": "0px",
        "margin": "initial"
        })
    $('.cat__head-dots_second').css({
        "transform": "rotate(60deg)",
        "height": "68px",
        "width": "20px",
        "top": "0px",
        "border-radius": "100%", 
        "left": "0px",
    })
}

function decorationType2() { //Meowth
    normaldecoration()//Reset the settings so no errors could occur
    $('.cat__head-dots').css({
        "transform": 'rotate(0deg)',
        "height": '68px',
        "width": '35px',
        "top": '-37px',
        "border-radius": '50% 50% 30% 30%',
        "visibility": 'inherit',
        "left": '91px',
    })
    $('.cat__head-dots_first').css({
        "transform": 'rotate(0deg)',
        "height": '55px',
        "width": '13px',
        "top": '9px',
        "borderRadius": '100% 0% 0% 100%',
        "visibility": 'inherit',
        "left": '5px',
        "margin": 'initial'
    })
    $('.cat__head-dots_second').css({
        "transform": 'rotate(0deg)',
        "height": '55px',
        "width": '13px',
        "top": '9px',
        "border-radius": '0% 100% 100% 0%',
        "visibility": 'inherit',
        "left": '17px'
    })
}

function decorationType3() { //Nothing
    normaldecoration()//Reset the settings so no errors could occur
    $('.cat__head-dots').css(
        "visibility","hidden"
    )
    $('.cat__head-dots_first').css(
        "visibility","hidden"
    )
    $('.cat__head-dots_second').css(
        "visibility","hidden"
    )
}

function decorationType4() { //Lefty
    normaldecoration()//Reset the settings so no errors could occur
    $('.cat__head-dots').css(
        "transform", "rotate(30deg)",
        "left", "90px",
        "top", "13px",
    )
    $('.cat__head-dots_first').css(
        "top","10px"
    )
    $('.cat__head-dots_second').css(
        "top","-10px"
    )
}

function decorationType5() { //Mirrory
    normaldecoration()//Reset the settings so no errors could occur
    $('.cat__head-dots').css({
        "transform": "scaleY(-1.0)"
    })
    $('.cat__head-dots_first').css()
    $('.cat__head-dots_second').css()
}

function decorationType6() { //Browser
    normaldecoration()//Reset the settings so no errors could occur
    $('.cat__head-dots').css({
        'height': '48px',
        'width': '25px',
        'top': '1px',
        "border-radius": '5% 5% 50% 50%',
        'left': '95px',
    })
    $('.cat__head-dots_first').css({
        "transform": "rotate(100deg)",
        "height": "51px",
        "width": "14px",
        "top": "33px",
        "border-radius": "50% 50%",
        "left": "-55px"
})
    $('.cat__head-dots_second').css({
        'transform': 'rotate(80deg)',
        "height": '51px',
        "width": '14px',
        "top": '33px',
        "border-radius": '50% 50%',
        "left": '69px',
    })
}

function resetAnimation() {
    $('#head').removeClass("movingHead")
    $('#midDot').removeClass("SpecialPattern1")
    $('#midDot').removeClass("SpecialPattern2")
    $('#midDot').removeClass("SpecialPattern3")
    $('#midDot').removeClass("SpecialPattern4")
    $('#midDot').removeClass("SpecialPattern5")
    $('#midDot').removeClass("SpecialPattern6")
    $('#catEyes').removeClass("rollingEyes")
    $('#midDot').removeClass("rollingEyes")
    $('#tail').removeClass("waggingTails")
    $('#fullCat').removeClass("disappearingCat")
    $('#fullCat').removeClass("walkingCat")
}

function AnimationType1() {
    resetAnimation();
    $("#head").addClass("movingHead")
}

function AnimationType2() {
    resetAnimation();
    $('#catEyes').addClass("rollingEyes")
}

function AnimationType3() {
    resetAnimation();
    $('#tail').addClass("waggingTails")
}

function AnimationType4() {
    resetAnimation();
    $('#fullCat').addClass("walkingCat")
}

function specialAnimationType1() {
    resetAnimation();
    $('#midDot').addClass("SpecialPattern1")
}
function specialAnimationType2() {
    resetAnimation();
    $('#midDot').addClass("SpecialPattern2")
}
function specialAnimationType3() {
    resetAnimation();
    $('#midDot').addClass("SpecialPattern3")
}
function specialAnimationType4() {
    resetAnimation();
    $('#midDot').addClass("SpecialPattern4")
}
function specialAnimationType5() {
    resetAnimation();
    $('#midDot').addClass("SpecialPattern5")
}
function specialAnimationType6() {
    resetAnimation();
    $('#midDot').addClass("SpecialPattern6")
}
function InvisibilityAnimation(){
    resetAnimation();
    $('#fullCat').addClass("disappearingCat")
}```
1 Like

animations.css

/*
//Rolling Eyes
//Wagging Tail
//Special with each Decorative Pattern
//Disappearing Cat
// The Walking Cat
*/

/* Link animation with a .css class => .MoveHead in this case

To use the keyframe, a link has to be made. 
That is why we make the .class.
To link the class with the keyframe, so we can call the class to activate the animation.
*/
/* Why use @keyframes?
keyframes are used to set the steps of the animation i.e.
To change the settings that transforms the design */


.movingHead {
    animation: moveHead 5s infinite;
  /*animation: name duration timing-function delay iteration-count direction fill-mode;*/
}

.rollingEyes {
    animation: roleEyes 3s infinite;
}
.waggingTails {
    animation: waggTail 6s infinite;
}
.waggingWhiskers {
    animation: movingWhiskers 3s infinite;
}
.SpecialPattern1 {
    animation: specialty1 5s infinite;
}
.specialPattern2 {
    animation: specialty2 2s infinite;
}
.SpecialPattern3 {
    animation: specialty3 2s infinite;
}
.SpecialPattern4 {
    animation: specialty4 4s infinite;
}
.SpecialPattern5 {
    animation: specialty5 6s infinite;
}
.SpecialPattern6 {
    animation: specialty6 1s infinite;
}
.SpecialPattern7 {
    animation: specialty7 1s infinite;
}
.disappearingCat {
    animation: disappearing 10s infinite;
}
.walkingCat {
    animation: walking 1.25s 256;
}
@keyframes moveHead { 
    0% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(5deg);
    }
    50% {
        transform: rotate(0deg);
    }
    75% {
        transform: rotate(-5deg);
    }
    100% {
        transform: rotate(0deg);
    }
}
@keyframes roleEyes{
    0% {
        margin-top: 0px;
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(2deg);
        margin-top: -10px;
    }
    50% {
        transform: rotate(0deg);
    }
    75% {
        transform: rotate(-2deg);
        margin-top: -10px;   
    }
    100% {
        transform: rotate(0deg);
        margin-top: 0px;
    }
}
@keyframes waggTail{
    0% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(-25deg);
    }
    50% {
        transform: rotate(0deg);
    }
    75% {
        transform: rotate(-25deg);
    }
    100% {
        transform: rotate(0deg);
    }
}
@keyframes specialty1{
    0% {
        transform: rotateX(0deg);
    }
    25% {
        transform: rotateX(180deg);
    }
    50% {
        transform: rotateX(360deg);
    }
    75% {
        transform: rotateX(180deg);
    }
    100% {
        transform: rotateX(0deg);
    }
}

/*All keyframes for the second Specialty*/
@keyframes specialty2{
    0% {
        transform:scale(1);
    }
    25% {
        transform:scale(1.125);
    }
    50% {
        transform:scale(1);
    }
    75% {
        transform:scale(1.25);
    }
    100% {
        transform:scale(1);
    }
}
@keyframes specialty3{
    0% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(90deg);
    }
    50% {
        transform: rotate(180deg);
    }
    75% {
        transform: rotate(270deg);
    }
    100% {
        transform: rotate(360deg);
    }
}
@keyframes specialty4{
    0% {
        left:103px;
        top: 1px;
        transform: rotate(30deg) scale(1) skew(0deg, 0deg);
    }
    50% {
        left: 66px;
        top: 21px;
        transform: rotate(60deg) scale(1.125) skew(4deg, -22deg);
    }
    100% {
        top: 1px;
        transform: rotate(30deg) scale(1) skew(0deg, 0deg);;
    }
}
@keyframes specialty5{
    0% {
        transform: scaleY(1) scaleX(1);
    }
    25% {
        transform: scaleY(1.125) scaleX(1.25);
    }
    50% {
        transform: scaleY(1.3) scaleX(1.6);
    }
    75% {
        transform: scaleY(1.125) scaleX(1.25);
    }
    100% {
        transform: scaleY(1) scaleX(1);
    }
}
@keyframes specialty6{
    0% {
        transform:scale(1) skew(0deg, 0deg);
    }
    10% {
        transform: skew(10deg, 0deg);
    }
    20% {
        transform: scale(1.25) skew(15deg, 0deg);
    }
    30% {
        transform: skew(10deg, 0deg);
    }
    40% {
        transform: scale(1) skew(0deg, 0deg);
    } 
    50% {
        transform:scale(1) skew(0deg, 0deg);
    }
    60% {
        transform: rskew(-10deg, 0deg);
    }
    70% {
        transform: scale(1.25)skew(-15deg, 0deg);
    }
    80% {
        transform: skew(-10deg, 0deg);
    }
    90% {
        transform: skew( 0deg, -10deg);
    } 
    100% {
        transform: scale(1) skew(0deg, 0deg);
    }
}
@keyframes disappearing{
    0% {
        opacity:1;
        transform: rotate(0deg);
    }
    25% {
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    60% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }  
}
@keyframes walking{
    0% {
        margin-top: 0px; 
        margin-left: 0px;   
    }
    10% {
        margin-top: -10px;
        margin-left: 10px    
    }
    20% {
        margin-top: 0px;
        margin-left: 20px   
    }
    30% {
        margin-top: -10px;
        margin-left: 30px;  
    }
    40% {
        margin-top: 0px;
        margin-left: 40px
    }
    50% {
        margin-top: -10px;
        margin-left: 50px;
    }
    60% {
        margin-top: 0px;
        margin-left: 40px  
    }
    70% {
        margin-top: -10px;
        margin-left: 30px
    }
    80% {
        margin-top: 0px;
        margin-left: 20px;   
    }
    90% {
        margin-top: -10px;
        margin-left: 10px
    }
    100% {
        margin-top: 0px;
        margin-left: 0px;
    }
}

index.html

<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Academy kitties </title>
  <script type="text/javascript" src="assets/js/jquery-3.4.1.js"></script>
  <link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
  <script src="assets/bootstrap/js/popper.js"></script>
  <script src="assets/bootstrap/js/bootstrap.min.js"></script>

  <link rel="stylesheet" href="assets/css/mystyle.css">
  <link rel="stylesheet" href="assets/css/cats.css">
  <link rel="stylesheet" href="assets/css/colors.css">
  <link rel="stylesheet" href="assets/css/factory.css">
  <link rel="stylesheet" href="assets/css/frontend.css">
  <link rel="stylesheet" href="assets/css/animations.css">
</head>
  <body>
    <div class="container p-5" style="margin-top: 12vh;margin-bottom: 10vh;">
        <div align ="center">
        <h1 class="c-white">Kitties-Factory</h1>
        <p class="c-white">Create your custom Kitty</p>
    </div>
        <div class="row">
            <div class="col-lg-4 catBox m-2 light-b-shadow">
                <div class="cat" id="fullCat">
                    <div class="cat__ear">
                        <div id="leftEar" class="cat__ear--left">
                            <div class="cat__ear--left-inside"></div>
                        </div>
                        <div id="rightEar" class="cat__ear--right">
                            <div class="cat__ear--right-inside"></div>
                        </div>
                    </div>

                    <div id="head" class="cat__head">
                        <div id="midDot" class="cat__head-dots">
                            <div id="leftDot" class="cat__head-dots_first"></div>
                            <div id="rightDot" class="cat__head-dots_second"></div>
                        </div>
                        <div class="cat__eye" id="catEyes">
                            <div class="cat__eye--left">
                                <span class="pupil-left"></span>
                            </div>
                            <div class="cat__eye--right">
                                <span class="pupil-right"></span>
                            </div>
                        </div>
                        <div class="cat__nose"></div>

                        <div class="cat__mouth-contour"></div>
                        <div class="cat__mouth-left"></div>
                        <div class="cat__mouth-right"></div>

                        <div class="cat__whiskers-left"></div>
                        <div class="cat__whiskers-right"></div>
                    </div>

                    <div class="cat__body">

                        <div class="cat__chest"></div>

                        <div class="cat__chest_inner"></div>


                        <div class="cat__paw-left"></div>
                        <div class="cat__paw-left_inner"></div>


                        <div class="cat__paw-right"></div>
                        <div class="cat__paw-right_inner"></div>


                        <div id="tail" class="cat__tail"></div>
                    </div>
                </div>
                <br>
                <div class="dnaDiv" id="catDNA">
                    <b>
                        DNA:
                        <!-- Colors -->
                         <span id="dnabody"></span>
                         <span id="dnamouth"></span>
                         <span id="dnaeyes"></span>
                         <span id="dnaears"></span>
                        
                         <!-- Cattributes -->
                         <span id="dnashape"></span>
                         <span id="dnadecoration"></span>
                         <span id="dnadecorationcolor"></span>
                         <span id="dnadanimation"></span>
                         <span id="dnaspecial"></span>
                    </b>
                </div>
            </div>
            <div class="col-lg-7 cattributes m-2 light-b-shadow">

<!-- Cat colors -->
<div class="btn-group mb-3">
    <button class="Button" onclick="showColors()">Colors</button>
    <button class="Button" onclick="showCattributes()"><b>Cattributes</b></button>
</div>

<div id="catColors">
                <div class="form-group">
                    <label for="formControlRange"><b>Head and body</b><span class="badge badge-dark ml-2" id="headcode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="bodycolor">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Mouth, Body & Tail</b><span class="badge badge-dark ml-2" id="mouthcode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="mouthcolor">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Eye Color</b><span class="badge badge-dark ml-2" id="eyecode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="eyecolor">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Ears & Paws</b><span class="badge badge-dark ml-2" id="earscode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="earcolor">
                </div>
            </div>

            <div id="cattributes" class="hidden">
                <div class="form-group">
                    <label for="formControlRange"><b>Eyes Shape</b><span class="badge badge-dark ml-2" id="eyeName"></span></label>
                    <input type="range" min="1" max="7" class="form-control-range" id="eyeshape">
                </div>   
                <div class="form-group" >
                    <label for="formControlRange"><b>Decorative Pattern</b><span class="badge badge-dark ml-2" id="decorationName"></span></label>
                    <input type="range" min="1" max="7" class="form-control-range" id="decorationvariation">
                </div>
                <div class="form-group" >
                    <label for="formControlRange, Cattributes"><b>Decorative Color</b><span class="badge badge-dark ml-2" id="decorationvariationcolor"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="decorationcolor">
                </div>   
                <div class="form-group">
                    <label for="formControlRange, Cattributes"><b>Animation</b><span class="badge badge-dark ml-2" id="variationName"></span></label>
                    <input type="range" min="1" max="6" class="form-control-range" id="animation">
                </div> 
</div>
    <div class="container">
        <button id="random" class="Button">Randomize Me</button>
        <button id="default" class="Button">Default Me</button>
        <button id="create" class="Button">Create Me</button>
    </div>
    <footer align="left">
        <p>Moralis Academy Bootcamp July 2020</p>
    </footer>

  </body>
  <script src="assets/js/colors.js"></script>
  <script src="assets/js/catSettings.js"></script>
  <script src="assets/js/catFactory.js"></script>

</html>

1 Like

Hi all,

I’m facing two problems with the animations and I can’t move on.

  1. the numbers that appears next to “DNA” below the cat, don’t change as I move the animation.
  2. don’t know why ears continue moving as I change the animation.

Here is my code, hope someone can help me.

CatFactory.js


//Random color
function getColor() {
    var randomColor = Math.floor(Math.random() * 16777215).toString(16);
    return randomColor
}

function genColors(){
    var colors = []
    for(var i = 10; i < 99; i ++){
      var color = getColor()
      colors[i] = color
    }
    return colors
}

//This function code needs to modified so that it works with Your cat code.
function headColor(color,code) {
    $('.cat__head, .cat__chest').css('background', '#' + color)  //This changes the color of the cat
    $('#headcode').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnabody').html(code) //This updates the body color part of the DNA that is displayed below the cat
}

function mouthBellyAndTailColor(color, code){
    $('.cat__mouth-contour, .cat__chest_inner, .cat__tail').css('background', '#' + color)
    $('#mouthcode').html('code: '+code);
    $('#dnamouth').html(code)
}

function eyesColor(color, code){
    $('.cat__eye').find('span').css('background', '#' + color)
    $('#eyecode').html('code: '+code);
    $('#dnaeyes').html(code)

}

function earsAndPawColor(color, code){
    $('.cat__ear--left, .cat__ear--right, .cat__paw-left, .cat__paw-right, .cat__paw-left_inner, .cat__paw-right_inner').css('background', '#' + color)
    $('#earscode').html('code: '+code);
    $('#dnaears').html(code)
}


//###################################################
//Functions below will be used later on in the project
//###################################################
function eyeVariation(num) {

    $('#dnashape').html(num)
    switch (num) {
        case 1:
            normalEyes()
            $('#eyeName').html('Basic')
            break
        case 2:
            normalEyes()
            $('#eyeName').html('Chiller')
            eyesType1();
            break
        case 3:
            normalEyes()
            $('#eyeName').html('Welling Up')
            eyesType2();
            break  
        case 4:
            normalEyes()
            $('#eyeName').html('watcher')
            eyesType3();
            break
        case 5:
            normalEyes()
            $('#eyeName').html('Looking Down left')
            eyesType4();
            break
        case 6:
            normalEyes()
            $('#eyeName').html('Looking Down right')
            eyesType5();
            break
        case 7:
            normalEyes()
            $('#eyeName').html('cross-eyed')
            eyesType6();
            break

    }
}

async function normalEyes() {
    await $('.cat__eye').find('span').css('border', 'none')
}
async function eyesType1() {
    await $('.cat__eye').find('span').css('border-top', '15px solid')
}

async function eyesType2() {
    await $('.cat__eye').find('span').css('border-bottom', '15px solid')
}

async function eyesType3() {
    await $('.cat__eye').find('span').css('border-bottom', '15px solid')
    await $('.cat__eye').find('span').css('border-top', '15px solid')
}

async function eyesType4() { //looking down left
    await $('.cat__eye').find('span').css('border-top', '12px solid')
    await $('.cat__eye').find('span').css('border-right', '12px solid')

}

async function eyesType5() { //looking down right
    await $('.cat__eye').find('span').css('border-top', '12px solid')
    await $('.cat__eye').find('span').css( 'border-left', '12px solid')
}

async function eyesType6() { //cross-eyed
    await $('.cat__eye').find('span').css('border-left', '11px solid')
    await $('.cat__eye').find('span').css('border-right', '12px solid')
    await $('.cat__eye').find('span::after').css('top', '17px')
    await $('.cat__eye').find('span::after').css('left', '5px')
    await $('.cat__eye').find('.cat__eye span::after').css('width', '4px')
    await $('.cat__eye').find('.cat__eye span::after').css('height', '11px')
}

function decorationVariation(num) {
    $('#dnadecoration').html(num)
    switch (num) {
        case 1:
            $('#decorationName').html('Basic')
            normaldecoration()
            break
        case 2:
            normaldecoration()
            $('#decorationName').html('Long')
            decorationType1()
            break
        case 3:
            normaldecoration()
            $('#decorationName').html('Short')
            decorationType2()
            break
        case 4:
            normaldecoration()
            $('#decorationName').html('Thin')
            decorationType3()
            break
        case 5:
            normaldecoration()
            $('#decorationName').html('Narrow angle')
            decorationType4()
            break
        case 6:
            normaldecoration()
            $('#decorationName').html('Thick')
            decorationType5()
            break
        case 7:
            normaldecoration()
            $('#decorationName').html('Inverted')
            decorationType6()
            break
    }
}

async function normaldecoration() {
    //Remove all style from other decorations
    //In this way we can also use normalDecoration() to reset the decoration style
    $('.cat__head-dots').css({ "transform": "rotate(0deg)", "height": "48px", "width": "14px", "top": "1px", "border-radius": "0 0 50% 50%" })
    $('.cat__head-dots_first').css({ "transform": "rotate(0deg)", "height": "35px", "width": "14px", "top": "1px", "border-radius": "50% 0 50% 50%" })
    $('.cat__head-dots_second').css({ "transform": "rotate(0deg)", "height": "35px", "width": "14px", "top": "1px", "border-radius": "0 50% 50% 50%" })
}

async function decorationType1(){
    $('.cat__head-dots_first').css({ "transform": "rotate(0deg)", "height": "45px", "width": "14px", "top": "1px", "border-radius": "50% 0 50% 50%" })
    $('.cat__head-dots').css({ "transform": "rotate(0deg)", "height": "58px", "width": "14px", "top": "1px", "border-radius": "0 0 50% 50%" })
    $('.cat__head-dots_second').css({ "transform": "rotate(0deg)", "height": "45px", "width": "14px", "top": "1px", "border-radius": "0 50% 50% 50%" })
}

async function decorationType2() {
    $('.cat__head-dots').css({ "transform": "rotate(0deg)", "height": "33px", "width": "14px", "top": "1px", "border-radius": "0 0 50% 50%" })
    $('.cat__head-dots_first').css({ "transform": "rotate(0deg)", "height": "20px", "width": "14px", "top": "1px", "border-radius": "50% 0 50% 50%" })
    $('.cat__head-dots_second').css({ "transform": "rotate(0deg)", "height": "20px", "width": "14px", "top": "1px", "border-radius": "0 50% 50% 50%" })
}

async function decorationType3() {
    $('.cat__head-dots').css({ "transform": "rotate(0deg)", "height": "48px", "width": "7px", "top": "1px", "border-radius": "0 0 50% 50%" })
    $('.cat__head-dots_first').css({ "transform": "rotate(0deg)", "height": "35px", "width": "7px", "top": "1px", "border-radius": "50% 0 50% 50%" })
    $('.cat__head-dots_second').css({ "transform": "rotate(0deg)", "height": "35px", "width": "7px", "top": "1px", "border-radius": "0 50% 50% 50%" })
}

async function decorationType4() {
    $('.cat__head-dots').css({ "transform": "rotate(0deg)", "height": "48px", "width": "14px", "top": "1px", "border-radius": "0 0 50% 50%" })
    $('.cat__head-dots_first').css({ "transform": "rotate(-25deg)", "height": "35px", "width": "14px", "top": "1px", "border-radius": "50% 0 50% 50%" })
    $('.cat__head-dots_second').css({ "transform": "rotate(25deg)", "height": "35px", "width": "14px", "top": "1px", "border-radius": "0 50% 50% 50%" })
}

async function decorationType5() {
    $('.cat__head-dots').css({ "transform": "rotate(0deg)", "height": "48px", "width": "18px", "top": "1px", "border-radius": "0 0 50% 50%" })
    $('.cat__head-dots_first').css({ "transform": "rotate(0deg)", "height": "35px", "width": "18px", "top": "1px", "border-radius": "50% 0 50% 50%" })
    $('.cat__head-dots_second').css({ "transform": "rotate(0deg)", "height": "35px", "width": "18px", "top": "1px", "border-radius": "0 50% 50% 50%" })
}

async function decorationType6() {
    $('.cat__head-dots').css({ "transform": "rotate(182deg)", "height": "48px", "width": "14px", "top": "1px", "border-radius": "0 0 50% 50%" })
    $('.cat__head-dots_first').css({ "transform": "rotate(-11deg)", "height": "35px", "width": "14px", "top": "1px", "border-radius": "50% 0 50% 50%" })
    $('.cat__head-dots_second').css({ "transform": "rotate(11deg)", "height": "35px", "width": "14px", "top": "1px", "border-radius": "0 50% 50% 50%" })
}

function decorationMidColor(color,code) {
    $('#midDot').css('background', '#' + color)
    $('#middlecolorname').html('code: '+code)
    $('#dnadecorationMid').html(code)
}

function decorationSideColor(color,code) {
    $('#leftDot, #rightDot').css('background', '#' + color)
    $('#sidescolorname').html('code: '+code)
    $('#dnadecorationSides').html(code)
}


function animationVariation(num) {
    $('#dnaanimation').html(num)
    switch (num) {
        case 1:
            animationType1()
            $('#animationName').html('Head')
            break
        case 2:
            animationType2()
            $('#animationName').html('Waving Ears')
            break 
        case 3:
            animationType3()
            $('#animationName').html('Waving Tail')
            break  
        case 4:
            animationType4()
            $('#animationName').html('Ear Right')
            break 
        case 5:
            animationType5()
            $('#animationName').html('Ear Left')
            break   
        case 6:
            animationType6()
            $('#animationName').html('Ear Right Up')
            break     
        case 7:
            animationType7()
            $('#animationName').html('Ear Left Up')
            break  
    }
}

function animationType1() {
    resetAnimation();
    $("#head").addClass("movingHead");
    $(".cat__ear--right").addClass("movingEarsRight");
    $(".cat__ear--left").addClass("movingEarsLeft");
}

function animationType2() {
    resetAnimation();
    $(".cat__ear--right").addClass("movingEarsRight");
    $(".cat__ear--left").addClass("movingEarsLeft");
}

function animationType3() {
    resetAnimation();
    $("#tail").addClass("movingTail");
}

function animationType4() {
    resetAnimation();
    $("#rightEar").addClass("moving-Single-EarRight");
}

function animationType5() {
    resetAnimation();
    $(".cat__ear--left").addClass("moving-Single-EarLeft");
}

function animationType6() {
    resetAnimation();
    $(".cat__ear--right").addClass("attentionRight");
}

function animationType7() {
    resetAnimation();
    $(".cat__ear--left").addClass("attentionLeft");

}

function resetAnimation() {
    $("#head").removeClass("movingHead");
    $(".cat__ear").removeClass("movingEarsRight");
    $(".cat__ear").removeClass("movingEarsLeft");
    $("#tail").removeClass("movingTail");
    $("#rightEar").removeClass("moving-Single-EarRight");
    $(".cat__ear--left").removeClass("moving-Single-EarLeft");
    $(".cat__ear--right").removeClass("attentionRight");
    $(".cat__ear--left").removeClass("attentionLeft");
}

Animations.css

.movingHead {
    animation: moveHead 4s infinite;
}

.movingEarsRight {
    animation: moveEarsRight 4s infinite;

}

.movingEarsLeft {
    animation: moveEarsLeft 4s infinite;

}

.moving-Single-EarRight {
    animation: earRight 3s infinite;
}

.moving-Single-EarLeft {
    animation: earLeft 3s infinite;
}

.attentionRight {
    animation: earUpRight 6s infinite;
}

.attentionLeft {
    animation: earUpLeft 6s infinite;
}

.movingTail {
    animation: moveTail 4s infinite;

}

@keyframes moveHead {
    0%, 50%, 100%, 56%, 89%{
        transform: rotate(0deg);
    }
    51%, 55% {
        transform: rotate(5deg);
    }
    90%, 98%{
        transform: rotate(-5deg);
    }
}

@keyframes moveEarsRight {
    0%, 50% {
        transform: rotate(170deg);
    }
    51%, 55% {
        transform: rotate(175deg);
    }
    56%, 89% {
        transform: rotate(170deg);
    }
    90%, 98% {
        transform: rotate(165deg);
    }
    100% {
        transform: rotate(170deg);
    }
}

@keyframes moveEarsLeft {
    0%, 50% {
        transform: scale(-1, 1) rotate(170deg);
    }
    51%, 55% {
        transform: scale(-1, 1) rotate(175deg);
    }
    56%, 89% {
        transform: scale(-1, 1) rotate(170deg);
    }
    90%, 98% {
        transform: scale(-1, 1) rotate(165deg);
    }
    100% {
        transform: scale(-1, 1) rotate(-170deg);
    }
}


@keyframes earRight {
    0%, 50% {
        transform: rotate(170deg);
    }
    51%, 55% {
        transform: rotate(175deg);
    }
    56%, 100%{
        transform: rotate(170deg);
    }
}

@keyframes earLeft {
    0%, 50% {
        transform: scale(-1, 1) rotate(170deg);
    }
    51%, 55% {
        transform: scale(-1, 1) rotate(175deg);
    }
    56%, 100%{
        transform: scale(-1, 1) rotate(170deg);
    }
}

@keyframes earUpRight {
    0%, 30% {
        transform: rotate(170deg);
    }
    31%, 89% {
        transform: rotate(160deg);
    }
    90%, 100%{
        transform: rotate(170deg);
    }
}

@keyframes earUpLeft {
    0%, 30% {
        transform: scale(-1, 1) rotate(170deg);
    }
    31%, 89% {
        transform: scale(-1, 1) rotate(160deg);
    }
    90%, 100%{
        transform: scale(-1, 1) rotate(170deg);
    }
}


@keyframes moveTail {
    0% {
        transform: rotate(0deg);
    }
    30% {
        transform: rotate(15deg);
    }
    60% {
        transform: rotate(-20deg);
    }
    100% {
        transform: rotate(0deg);
    }
}

Would you be able to create a github repository for your project? It will be easier for me to replicate your issue by downloading your project. :nerd_face:

Carlos Z

1 Like

Yes, sure. Here it is.
https://github.com/avisas/Cryptokitties

Thanks.

1 Like

You misstyped dnaanimation, thats why it does not update the number :nerd_face:

First I create the Basic Animamtion, which will be none (it trigger reset animation, so the cat will start with no animations).

The second error about the ears, its because the resetAnimation function is not removing the animation on .cat__ear--right and .cat__ear--left, so i add it to it.

Also the 1st animation head was also applying the animation for the ears, so i also remove them from animationType1 function. (check the image).

Carlos Z

2 Likes

Well, thank you very much !! I fixed those errors and now it’s working fine.
Also, for the 1st animation head, my idea was to apply the animation for the ears too. But now the thing is that there’s a little extra movement when I select the first and the second animation . The rest of the options are good.
I already checked the animations.css file but apparently everything is fine and can’t find where’s the error or maybe that’s not where the error comes from.
Thanks

2 Likes

Here is my solution. I decided to put the buttons into a separate file.

factoryButtons

/*
Visibility of Color and Attribute selections
*/
let colorSection = document.querySelector("#bearColors");
let colorBtn = document.querySelector(".colorBtn");

let attributeSection = document.querySelector("#bearAttributes");
let attributeBtn = document.querySelector(".attributeBtn");

//Setting initial state
$( document ).ready(function() {
    toggleColorVis();
});

function toggleColorVis(){
    //visibility changed on click
    attributeSection.style.display = "none";
    colorSection.style.display = "block";
    //setting button colors
    colorBtn.style.backgroundColor = "#006600";
    attributeBtn.style.backgroundColor = "#166edacb";
}

function toggleAttributeVis(){
    //visibility changed on click
    colorSection.style.display = "none";
    attributeSection.style.display = "block";
    //setting button colors
    colorBtn.style.backgroundColor = "#166edacb";
    attributeBtn.style.backgroundColor = "#006600";
}

/*
Button Get random Bear
*/
function randomBear(){
    //Head
    let rndHead = Math.floor(Math.random() * 89) + 10;//random number
    headColor(colors[rndHead],rndHead);//setting bear
    $('#bodycolor').val(rndHead);

    //Mouth, Belly & Nose Color
    let rndMouth = Math.floor(Math.random() * 89) + 10;
    mouthColor(colors[rndMouth],rndMouth);
    $('#mouthcolor').val(rndMouth);

    //Eye Color
    let rndEyes = Math.floor(Math.random() * 89) + 10;
    eyesColor(colors[rndEyes],rndEyes);
    $('#eyescolor').val(rndEyes);

    //Ear & Paw Color
    let rndEars = Math.floor(Math.random() * 89) + 10;
    earsColor(colors[rndEars],rndEars);
    $('#earscolor').val(rndEars);

    //Eye Shape
    let rndEyeShape = Math.floor(Math.random() * 7) + 1;
    eyeVariation(rndEyeShape);
    $('#eyesshape').val(rndEyeShape);

    //Hat Shape
    let rndHatShape = Math.floor(Math.random() * 7) + 1;
    decorationVariation(rndHatShape);
    $('#hatshape').val(rndHatShape);

    //Hat Top Color
    let rndHatTop = Math.floor(Math.random() * 89) + 10;
    decorationColor1(colors[rndHatTop], rndHatTop);
    $('#hattopcolor').val(rndHatTop);

    //Hat Brim Color
    let rndHatBrim = Math.floor(Math.random() * 89) + 10;
    decorationColor2(colors[rndHatBrim], rndHatBrim);
    $('#hatbrimcolor').val(rndHatBrim);

    //Animation
    let rndAnimation = Math.floor(Math.random() * 7) + 1;
    animationVariation(rndAnimation);
    $("#animation").val(rndAnimation);
}

/*
Button Default Bear calls on renderBear(defaultDna) in bearSettings.js
*/

/*
Button Create New Bear
*/

factory.css

.toggleBtn {
    background-color: #166edacb;
    border-radius: 10px;
    width: 100px;
    height: 40px;
    margin: 10px;
}

.bearCreateButtons {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 10px;
}

.bearCreateBtn {
    background-color: #166edacb;
    border-radius: 10px;
    width: 100px;
    height: 80px;
    margin: 10px;
}

index.html; Buttons for Bear Creation

                <div class="bearCreateButtons">
                    <!-- Buttons -->
                    <button onclick="randomBear()" class="bearCreateBtn randomBearBtn">Create Random Bear</button>
                    <button onclick="renderBear(defaultDNA)" class="bearCreateBtn defaultBearBtn">Create Default Bear</button>
                    <button onclick="" class="bearCreateBtn newBearBtn">Create New Bear</button>
                </div>
2 Likes

We now have tabs and buttons:

Index.html
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Academy kitties </title>
    <script type="text/javascript" src="assets/js/jquery-3.4.1.js"></script>
    <link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
    <script src="assets/bootstrap/js/popper.js"></script>
    <script src="assets/bootstrap/js/bootstrap.min.js"></script>

    <link rel="stylesheet" href="assets/css/animations.css">
    <link rel="stylesheet" href="assets/css/mystyle.css">
    <link rel="stylesheet" href="assets/css/cats.css">
    <link rel="stylesheet" href="assets/css/scared_cat.css">
    <link rel="stylesheet" href="assets/css/colors.css">
    <link rel="stylesheet" href="assets/css/factory.css">
    <link rel="stylesheet" href="assets/css/frontend.css">
</head>

<body>
    <div class="container p-5" style="margin-top: 12vh;margin-bottom: 10vh;">
        <div align="center">
            <h1 class="c-white">Kitty Freakout</h1>
            <p class="c-white">This kitty accidently broke an OFAC sanction</p>
        </div>
        <div class="row">
            <div class="col-lg-6 catBox m-2 light-b-shadow">
                <div class="cat">
                    <div class="ears">
                        <div class="ear left-ear"></div>
                        <div class="ear right-ear"></div>
                    </div>
                    <div id="head">
                        <div class="eyes">
                            <div class="eye">
                                <div class="pupils"></div>
                            </div>
                            <div class="eye">
                                <div class="pupils"></div>
                            </div>
                        </div>

                        <div class="mouth">

                        </div>

                    </div>
                    <div class="catbody">
                        <div class="legs">
                            <div class="legs" id="leg1"></div>
                            <div class="legs" id="leg2"></div>
                        </div>
                    </div>
                </div>

                <br>
                <div class="dnaDiv" id="catDNA">
                    <b>
                        DNA:
                        <!-- Colors -->
                        <span id="dnabody"></span>
                        <span id="dnahead"></span>
                        <span id="dnaears"></span>
                        <span id="dnalegs"></span>

                        <!-- Cattributes -->
                        <span id="dnashape"></span>
                        <span id="dnaactivity"></span>
                        <span id="dnaprivacy"></span>
                        <span id="dnamouth"></span>
                        <span id="dnaanimation"></span>
                        <span id="dnaspecial"></span>
                    </b>
                </div>
            </div>
            <div class="col-lg-5 cattributes m-2 light-b-shadow">

                <p>
                <div class="tab-menu">
                    <div class="tab-buttons">
                        <label><input type="radio" name="tab-menu" value=1>Colors</label>
                        <label><input type="radio" name="tab-menu" value=2>Cattributes</label>
                    </div>
                </div>
                </p>

                <div class="tabs">
                    <div id="tab-colors">
                        <div class="form-group">
                            <label for="formControlRange"><b>Body</b><span class="badge badge-dark ml-2"
                                    id="bodycode"></span></label>
                            <input type="range" min="10" max="98" class="form-control-range" id="bodycolor">
                            <label for="formControlRange"><b>Head</b><span class="badge badge-dark ml-2"
                                    id="headcode"></span></label>
                            <input type="range" min="10" max="98" class="form-control-range" id="headcolor">
                            <label for="formControlRange"><b>Ears</b><span class="badge badge-dark ml-2"
                                    id="earscode"></span></label>
                            <input type="range" min="10" max="98" class="form-control-range" id="earscolor">
                            <label for="formControlRange"><b>Legs</b><span class="badge badge-dark ml-2"
                                    id="legscode"></span></label>
                            <input type="range" min="10" max="98" class="form-control-range" id="legscolor">
                        </div>
                    </div>
                    <div id="tab-cattributes">

                        <div class="form-group">
                            <label for="formControlRange"><b>Eye Shape</b>
                                <span class="badge badge-dark ml-2" id="eyeshapecode"></span>
                            </label>
                            <input type="range" min="1" max="3" class="form-control-range" id="eyeshape">

                        </div>

                        <div class="form-group">
                            <label><b>Activity</b></label>

                            <label><input type="radio" name="decoration" value=1>Run</label>

                            <label><input type="radio" name="decoration" value=2>Rest</label>
                        </div>

                        <div class="form-group">
                            <label for="formControlRange"><b>Privacy</b>
                                <span class="badge badge-dark ml-2" id="incognitocode"></span>
                            </label>
                            <input type="range" min="0" max="10" class="form-control-range" id="incognito">

                            <label for="formControlRange"><b>Mouth color</b>
                                <span class="badge badge-dark ml-2" id="mouthcolorcode"></span>
                            </label>
                            <input type="range" min="1" max="90" class="form-control-range" id="mouthcolor">

                            <label for="formControlRange"><b>Animation</b>
                                <span class="badge badge-dark ml-2" id="animationcode"></span>
                            </label>
                            <input type="range" min="0" max="2" class="form-control-range" id="animation">

                        </div>
                    </div>
                </div>
            </div>
        </div>
        <p align="center">
            <button id="randomkitty" class="white-btn">Get random kitty</button>
            <button id="defaultkitty" class="white-btn">Reset to factory settings</button>
            <button id="createkitty" class="red-btn">Mint new kitty</button>
        </p>
    </div>

    <footer align="left">
        <p>Ivan on Tech Academy Bootcamp July 2020</p>
    </footer>

</body>
<script src="assets/js/colors.js"></script>
<script src="assets/js/catSettings.js"></script>
<script src="assets/js/catFactory.js"></script>

</html>
catSettings.js

var colors = Object.values(allColors())

var defaultDNA = {
    "bodyColor" : 95,
    "headColor" : 10,
    "earsColor" : 92,
    "legsColor" : 92,
    //Cattributes
    "eyesShape" : 1,
    "activity" : 1,
    "privacy" : 0,
    "mouthColor" : 73,
    "animation" :  0,
    "lastNum" :  1
    }

// when page load
$( document ).ready(function() {
  $('#dnabody').html(defaultDNA.bodyColor);
  $('#dnahead').html(defaultDNA.headColor);
  $('#dnaears').html(defaultDNA.earsColor);
  $('#dnalegs').html(defaultDNA.legsColor);
    
  $('#dnashape').html(defaultDNA.eyesShape)
  $('#dnaactivity').html(defaultDNA.activity)
  $('#dnaprivacy').html(defaultDNA.privacy)
  $('#dnamouth').html(defaultDNA.mouthColor)
  $('#dnaanimation').html(defaultDNA.animation)
//   $('#dnaspecial').html(defaultDNA.lastNum)

  renderCat(defaultDNA)

  // $('.tabx .tab1').show().siblings().hide();
  // $("input[name='decoration'][value="+dna.activity+"]").prop("checked", true)
  $(".tab-menu input[value=1]").prop("checked", true)
  showTabs(1)

});

function getDna(){
    var dna = ''
    dna += $('#dnabody').html()
    dna += $('#dnahead').html()
    dna += $('#dnaears').html()
    dna += $('#dnalegs').html()
    dna += $('#dnashape').html()
    dna += $('#dnaactivity').html()
    dna += $('#dnaprivacy').html()
    dna += $('#dnamouth').html()
    dna += $('#dnaanimation').html()
    dna += $('#dnaspecial').html()

    return parseInt(dna)
}

function renderCat(dna){
  bodyColor(colors[dna.bodyColor], dna.bodyColor)
  $('#bodycolor').val(dna.bodyColor)

  headColor(colors[dna.headColor], dna.headColor)
  $('#headcolor').val(dna.headColor)

  earsColor(colors[dna.earsColor], dna.earsColor)
  $('#earscolor').val(dna.earsColor)

  legsColor(colors[dna.legsColor], dna.legsColor)
  $('#legscolor').val(dna.legsColor)

  eyeVariation(dna.eyesShape)
  $('#eyeshape').val(dna.eyesShape)

  legVariation(dna.activity)
  $("input[name='decoration'][value="+dna.activity+"]").prop("checked", true)

  opacityVariation(dna.privacy)
  $('#incognito').val(dna.privacy)

  mouthColor(colors[dna.mouthColor], dna.mouthColor)
  $('#mouthcolor').val(dna.mouthColor)

  animationVariation(dna.animation)
  $('#animation').val(dna.animation)

}





// Changing cat colors
$('#bodycolor').change(() => {
  var colorVal = $('#bodycolor').val()
  bodyColor(colors[colorVal], colorVal)
})

$('#headcolor').change(() => {
  var colorVal = $('#headcolor').val()
  headColor(colors[colorVal], colorVal)
})

$('#earscolor').change(() => {
  var colorVal = $('#earscolor').val()
  earsColor(colors[colorVal], colorVal)
})

$('#legscolor').change(() => {
  var colorVal = $('#legscolor').val()
  legsColor(colors[colorVal], colorVal)
})

$('#eyeshape').change(() => {
  var shapeVal = $('#eyeshape').val()
  eyeVariation(shapeVal)
})

$('#legshape').change(() => {
  var shapeVal = $('#legshape').val()
  legVariation(shapeVal)
})

$("input[name='decoration']").change(() => {
  var legVal = $("input[name='decoration']:checked").val()

  console.log('leg value: '+ legVal)
  legVariation(legVal)
})

$('#incognito').change(() => {
  var opacityVal = $('#incognito').val()
  opacityVariation(opacityVal)
})

$('#mouthcolor').change(() => {
  var colorVal = $('#mouthcolor').val()
  mouthColor(colors[colorVal], colorVal)
})

$('#animation').change(() =>{
  var animationVal = $('#animation').val()
  animationVariation(animationVal)
})


// Changing tabs
$(".tab-menu input").change(() => {
  var tabVal = $(".tab-menu input:checked").val()

  console.log('selected tab: '+ tabVal)

  showTabs(tabVal)

})

// random kitty button
$("#randomkitty").click(()=>{
  randomDNA = computeRandomKitty()

  renderCat(randomDNA)
})

// default kitty button
$("#defaultkitty").click(()=>{
  renderCat(defaultDNA)  
})

1 Like

and the computation of the random kitty is here:

catFactory.js

//Random color
function getColor() {
    var randomColor = Math.floor(Math.random() * 16777215).toString(16);
    return randomColor
}

function genColors(){
    var colors = []
    for(var i = 10; i < 99; i ++){
      var color = getColor()
      colors[i] = color
    }
    return colors
}


function bodyColor(color,code) {
    $('.catbody').css('background-color', '#' + color)  //This changes the color of the cat
    $('#bodycode').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnabody').html(code) //This updates the body color part of the DNA that is displayed below the cat
}


//This function code needs to modified so that it works with Your cat code.
function headColor(color,code) {
    $('#head').css('background-color', '#' + color)  //This changes the color of the cat head
    $('#headcode').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnahead').html(code) //This updates the body color part of the DNA that is displayed below the cat
}


function earsColor(color,code) {
    $('.ear').css('background-color', '#' + color)  //This changes the color of the cat ears
    $('#earscode').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnaears').html(code) //This updates the body color part of the DNA that is displayed below the cat
}


function legsColor(color,code) {
    $('.legs').css('background-color', '#' + color)  //This changes the color of the cat legs
    $('#legscode').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnalegs').html(code) //This updates the body color part of the DNA that is displayed below the cat
}



//###################################################
//Functions below will be used later on in the project
//###################################################
function eyeVariation(n) {
    num = parseInt(n)
    $('#dnashape').html(num)

    switch (num) {
        case 1:
            normalEyes()
            $('#eyeshapecode').html('Basic')
            break;
        case 2:
            startledEyes()
            $('#eyeshapecode').html('Startled')
            break;
        case 3:
            blindEyes()
            $('#eyeshapecode').html('Blind')
            break;
    }
}

function legVariation(n) {
    num = parseInt(n)
    $('#dnaactivity').html(n)

    switch (num){
        case 1:
            runLegs()
            $('#legshapecode').html("Run")
            break;
        case 2:
            restLegs()
            $('#legshapecode').html("Rest")
            break;
        default:
    }
}




function runLegs(){
    $('#leg1').css({
        "width": "23px",
        "height": "52px",
        "top": "87px",
        "left": "148px",
        "transform": "rotate(-40deg)"        
    })

    $('#leg2').css({
        "width": "23px",
        "height": "52px",
        "top": "78px",
        "left": "179px",
        "transform": "rotate(-50deg)"       
    })

}

function restLegs(){
    $('#leg1').css({
        "width": "23px",
        "height": "52px",
        "top": "87px",
        "left": "21px",
        "transform": "rotate(15deg)"
    })

    $('#leg2').css({
        "width": "23px",
        "height": "52px",
        "top": "90px",
        "left": "62px",
        "transform": "rotate(-10deg)"
    })

}

function opacityVariation(num){
    $('#dnaprivacy').html(num)

    opacity = (10-num)/10
 
    $('.cat').css("opacity", opacity)
    $('#incognitocode').html(num*10 + '%')

}

function mouthColor(color,code) {
    $('.mouth').css('background-color', '#' + color)  //This changes the color of the cat head
    $('#mouthcolorcode').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnamouth').html(code) //This updates the body color part of the DNA that is displayed below the cat
}


function animationVariation(n){
    num = parseInt(n)
    $('#dnaanimation').html(num)

    switch(num){
        case 0:
            $('#animationcode').html("still")
            resetAnimations()
            break;
        case 1:
            $('#animationcode').html("flee")
            animateLegs()
            break;
        case 2:
            $('#animationcode').html("hide")
            animateHide()
            break;
        default:
            resetAnimations()

    }
}


function animateLegs(){
    $('#leg1').addClass("runningleg1")
    $('#leg2').addClass("runningleg2")
}


function animateHide(){
    $('.cat').addClass("hiding")
}

function resetAnimations(){
    $('#leg1').removeClass("runningleg1")
    $('#leg2').removeClass("runningleg2")
    $('.cat').removeClass("hiding")
}

function decorationVariation(num) {
    $('#dnadecoration').html(num)
    switch (num) {
        case 1:
            $('#decorationName').html('Basic')
            normaldecoration()
            break
    }
}

async function normalEyes() {

    $('.pupils').css({
        "background-color": "black",
        "width": "20px",
        "height": "30px",
        "top": "10px",
        "left": "24px"
    })

}


function startledEyes() {
    
    $('.pupils').css({
        "background-color": "black",
        "width": "45px",
        "height": "45px",
        "top": "3px",
        "left": "3px"
    })
}

function blindEyes() {
    
    $('.pupils').css({
        "background-color": "white"
    })
}


async function normaldecoration() {
    //Remove all style from other decorations
    //In this way we can also use normalDecoration() to reset the decoration style
    $('.cat__head-dots').css({ "transform": "rotate(0deg)", "height": "48px", "width": "14px", "top": "1px", "border-radius": "0 0 50% 50%" })
    $('.cat__head-dots_first').css({ "transform": "rotate(0deg)", "height": "35px", "width": "14px", "top": "1px", "border-radius": "50% 0 50% 50%" })
    $('.cat__head-dots_second').css({ "transform": "rotate(0deg)", "height": "35px", "width": "14px", "top": "1px", "border-radius": "0 50% 50% 50%" })
}



function showTabs(tabVal){
    
    num = parseInt(tabVal)
    switch (num) {
        case 1:
            $("#tab-colors").show()
            $("#tab-cattributes").hide()
            break;
        case 2:
            $("#tab-colors").hide()
            $("#tab-cattributes").show()
            break;
        default:
            console.log('Wrong tab selection')
    }
}


function computeRandomKitty(){


    var randomDNA = {
        //Colors
        "bodyColor" : 95,
        "headColor" : 10,
        "earsColor" : 92,
        "legsColor" : 92,
        //Cattributes
        "eyesShape" : 1,
        "activity" : 1,
        "privacy" : 0,
        "mouthColor" : 73,
        "animation" :  0,
        "lastNum" :  1
        }
    
    //Colors    
    randomDNA.bodyColor = Math.floor(Math.random()*88+10)
    randomDNA.headColor = Math.floor(Math.random()*88+10)
    randomDNA.earsColor = Math.floor(Math.random()*88+10)
    randomDNA.legsColor = Math.floor(Math.random()*88+10)

    //Cattributes
    randomDNA.eyesShape = Math.floor(Math.random()*3+1)
    randomDNA.activity =  Math.floor(Math.random()*2+1)
    randomDNA.privacy = Math.floor(Math.random()*11)
    randomDNA.mouthColor = Math.floor(Math.random()*90+1)
    randomDNA.animation = Math.floor(Math.random()*3)

    return randomDNA
}


1 Like

Hi codinginlondon, how are you doing with this project “Cat Factory-Ethereum Dapp”? Some video instructions are missing to complete the project, could you get them? Let me know if you are interested in trying to solve it together.
Thank you!

VdSR

Hi valleria, I am about to start assignment at this point of the course:
https://academy.moralis.io/lessons/erc721-intro-assignment

and so far I have:

  • installed the truffle environment under Ubuntu,
  • prepared a git repository under github and
  • cloned it under Ubuntu.

Where are you at?

Happy to help (or get your help when I get stuck)

Matt

1 Like

I made some additional changes. For animations I used toggle switches and for background animations I kept the slider. I added to the DNA string, hope that won’t be an issue moving forward with the next parts of the class. Also fixed up some of the design for better mobile response.

You can check out the latest update on my github page:
https://ciphergrind.github.io/TrippySquirrelsNFTMaker/

Github repo:
https://github.com/CipherGrind/TrippySquirrelsNFTMaker/tree/gh-pages

2 Likes