Assignment - Cattributes

Updated Fishies Factory code and screencap! I will clean up the extra “cat” code later in the project.

index.html
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Academy fishies </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">
</head>
  <body>
    <div class="container p-5" style="margin-top: 12vh;margin-bottom: 10vh;">
        <div align="center">
        <h1 class="c-white">Fishies-Factory</h1>
        <p class="c-white">Create your custom Fishy</p>
        </div>
        <div class="row">
            <div class="col-lg-4 catBox m-2 light-b-shadow">
                <div class="fish">
                    <div class="fins">
                        <div id="leftFin" class="fish__fin--left">
                            <div id="leftShade" class="fish__fin-leftShade"></div>
                        </div>
                        <div id="rightFin" class="fish__fin--right">
                            <div id="rightShade" class="fish__fin-rightShade"></div>
                        </div>
                        <div id="topFin" class="fish__tailFin--top">
                            <div id="topTailShade" class="fish__tailFin-topShade"></div>
                        </div>
                        <div id="bottomFin" class="fish__tailFin--bottom">
                            <div id="bottomTailShade" class="fish__tailFin-bottomShade"></div>
                        </div>
                        <div id="dorsalFin" class="fish__stableFin--dorsal"></div>
                        <div id="st_leftFin" class="fish__stableFin--left"></div>
                        <div id="st_rightFin" class="fish__stableFin--right"></div>
                    </div>

                    <div id="body" class="fish__body">
                        <div class="fish__eye">
                            <span class="fish__eye--left">
                                <div class="pupil-left"></div>
                            </span>
                            <span class="fish__eye--right">
                                <div class="pupil-right"></div>
                            </span>
                        </div>
                        <div class="fish__mouth">
                            <div id="teeth" class="fish__mouth-teeth"></div>
                        </div>
                    </div>
                </div>
                <br>
                <div class="dnaDiv" id="catDNA">
                    <b>
                        DNA:
                        <!-- Colors -->
                         <span id="dnabody"></span>
                         <span id="dnaside"></span>
                         <span id="dnatail"></span>
                         <span id="dnastablizer"></span>
                         <span id="dnaeye"></span>
                        
                         <!-- Cattributes -->
                         <span id="dnashape"></span>
                         <span id="dnadecoration"></span>
                         <span id="dnadecorationMid"></span>
                         <span id="dnadecorationSides"></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 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>Side Fins</b><span class="badge badge-dark ml-2" id="sideFinCode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="sideFinColor">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Tail Fins</b><span class="badge badge-dark ml-2" id="tailcode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="tailFinColor">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Stabilizer Fins</b><span class="badge badge-dark ml-2" id="stablizercode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="stableFinColor">
                </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 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="4" class="form-control-range" id="eyesShape">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Fin Decoration</b><span class="badge badge-dark ml-2" id="finDecorationName"></span></label>
                    <input type="range" min="1" max="4" class="form-control-range" id="finDecoration">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Fin Decoration</b><span class="badge badge-dark ml-2" id="sideShadeCode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="sideShadeColor">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Fin Decoration</b><span class="badge badge-dark ml-2" id="tailShadeCode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="tailShadeColor">
                </div>
            </div>

            </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>

cats.css
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: inherit;
}
html {
    box-sizing: border-box;
    overflow-y: scroll;
}
body {
    background: #607d8b;

}

.fish__body {
    background-color: rgb(79, 153, 153);
    width: 180px;
    height: 200px;
    border-radius: 50%;
    position: relative;
    left: 25px;
    top:30px;
    z-index: 20;
    border: 0.5px solid;
}

.fish__eye {
    position: absolute;
    top: 35px;
    left: 5px;
    display: flex;
}

.fish__eye--left, .fish__eye--right {
    background-color: white;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    margin: 18px;
    z-index: 100;
    border: 0.5px solid;
}

.fish__eye span.fish__eye--left {
    left: 25px;
}

.fish__eye span.fish__eye--right {
    left: 105px;
}

.pupil-left, .pupil-right {
    background-color: black;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    top: 5px;
    left: 10px;
    position: relative;
}

.fish__mouth {
    background-color: black;
    width: 40px;
    height: 55px;
    border-radius: 50%;
    position: absolute;
    left: 70px;
    top: 120px;
}

.fins{
    position: relative;
}

.fish__fin--left, .fish__fin--right{
    border-radius: 50px 10px 50px 10px;
    background-color: rgb(104, 168, 147);
    transform: rotate(25deg);
    height: 65px;
    width: 100px;
    position: absolute;
    top: 130px;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 3px solid;
}

.fish__fin--left {
    transform: scale(1,-1) rotate(25deg);
    right: 236px;
}

.fish__fin--right {
    left: 185px;
}

.fish__fin-leftShade, .fish__fin-rightShade {
    background-color: rgb(104, 168, 147);
    border-radius: 50px 10px 50px 10px;
    height: 55px;
    width: 50px;
    position: absolute;
    border: 2px solid;
}

.fish__fin-leftShade {
    transform: scale(1,-1) rotate(60deg);
    left: 30px;
    top: -3px;
}

.fish__fin-rightShade {
    left: 15px;
    transform: rotate(25deg);
}

.fish__tailFin--top, .fish__tailFin--bottom {
    border-radius: 5px 150px 5px 90px;
    background-color: rgb(80, 116, 136);
    height: 125px;
    width: 100px;
    position: absolute;
    left: -10px;
    border: 3px solid;
}

.fish__tailFin--top {
    top: -40px;
}

.fish__tailFin--bottom {
    transform: scale(1,-1) rotate(-1deg);
    top: 190px;
}

.fish__tailFin-topShade, .fish__tailFin-bottomShade {
    background-color: rgb(249, 251, 252);
    border-radius: 75px 150px 35px 90px;
    height: 105px;
    width: 30px;
    position: absolute;
    left: 40px;
    border: 2px solid;
    top: 25px;
}

.fish__tailFin-topShade {
    transform:  rotate(-25deg);

}

.fish__tailFin-bottomShade {
    transform:  rotate(-30deg);

}

.fish__stableFin--dorsal, .fish__stableFin--left, .fish__stableFin--right {
    border-radius: 90px 1px 75px 1px;
    background-color: rgb(51, 79, 94);
    height: 125px;
    width: 60px;
    position: absolute;
    border: 3px solid;
}

.fish__stableFin--dorsal {
    left: 80px;
    top: -20px;
    transform: rotate(-25deg);
}

.fish__stableFin--left {
    transform: rotate(-1deg);
    top: 125px; left: 45px;
}

.fish__stableFin--right {
    transform: scale(1,-1) rotate(-1deg);
    top: 125px; left: 115px;
}


.cat__head {
    position: relative;
    width: 230px;
    height: 200px;
    border: 6px solid transparent;
    -webkit-border-radius: 50% 50% 45% 45%;
    border-radius: 50% 50% 45% 45%;
    background: #ffcc80;
    z-index: 20;
}
.cat__head-dots {
    position: absolute;
    left: 101px;
    height: 48px;
    top: 1px;
    width: 14px;
    background: #ffb74d;
    -webkit-border-radius: 0 0 50% 50%;
    border-radius: 0 0 50% 50%;
}

 .cat__head-dots_first {
    position: absolute;
    content: '';
    top: 1px;
    width: 14px;    
    height: 35px;
    background: #ffb74d;
    left: -20px;
    border-radius: 50% 0 50% 50%;
}
.cat__head-dots_second {
    position: absolute;
    content: '';
    top: 1px;
    width: 14px;    
    height: 35px;
    background: #ffb74d;
    left: 20px;
    border-radius: 0 50% 50% 50%;
}

.cat__ear {
    position: relative;
}
.cat__ear--left, .cat__ear--right {
    position: absolute;
    top: -8px;
    width: 150px;
    height: 150px;
    border: 5px solid  transparent;
    border-radius: 90% 0 90% 0;
    background: #ffcc80;
    display: flex;
    justify-content: center;
    align-items: center;
}
.cat__ear--left {
    transform: scale(-1, 1) rotate(170deg);
    left: -14px;
}
.cat__ear--right {
    transform: rotate(170deg);
    left: 94px;
}
.cat__ear--left-inside, .cat__ear--right-inside {
    width: 108px;
    height: 108px;
    border-radius: 90% 0 90% 0;
    background: #e57373;
}
.cat__eye {
    position: absolute;
    top: 35px;
    left: -16px;
    display: flex;
}
.cat__eye--left, .cat__eye--right {
    width: 49px;
    height: 49px;
    background: #fff;
    border-radius: 50%;
    margin: 38px;
    z-index: 100;
}
.cat__eye span {
    position: absolute;
    top: 41px;
    width: 42px;
    height: 42px;
    background: #373737;
    border-radius: 50%;
    z-index: 200;
}
.cat__eye span::after {
    content: '';
    top: 8px;
    left: 8px;
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #fff;
}
.cat__eye span::before {
    content: '';
    top: 20px;
    left: 8px;
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #fff;
}
.cat__eye span.pupil-left {
    left: 42px;
}
.cat__eye span.pupil-right {
    left: 166px;
}
.cat__nose {
    position: absolute;
    top: 115px;
    left: 95px;
    width: 0;
    height: 0;
    border-right: 14px solid rgba(255, 255, 255, 0);
    border-left: 14px solid rgba(255, 255, 255, 0);
    border-top: 14px solid #e57373;
    border-radius: 40%;
    z-index: 100;
}
.cat__mouth-contour {
    position: absolute;
    top: 97px;
    left: 19px;
    background: #fff3e0;
    width: 180px;
    height: 90px;
    -webkit-border-radius: 55% 55% 60% 60%;
    border-radius: 55% 55% 60% 60%;
}
.cat__mouth-left, .cat__mouth-right {
    position: absolute;
    top: 120px;
    width: 23px;
    height: 23px;
    -webkit-border-radius: 50%;
    border-radius: 50%;
    border: 4px solid  #373737;
    border-right: 3px solid rgba(255, 255, 255, 0);
    border-top: 3px solid rgba(255, 255, 255, 0);
    transform: rotate(-45deg);
}
.cat__mouth-left {
    left: 88px;
}
.cat__mouth-right {
    left: 108px;
}
.cat__whiskers-left, .cat__whiskers-right {
    position: relative;
}
.cat__whiskers-left, .cat__whiskers-right, .cat__whiskers-left::after, .cat__whiskers-right::after, .cat__whiskers-left::before, .cat__whiskers-right::before {
    width: 32px;
    height: 5px;
    background: #373737;
}
.cat__whiskers-left::before, .cat__whiskers-right::before, .cat__whiskers-left::after, .cat__whiskers-right::after {
    content: '';
    position: absolute;
    left: 0;
}
.cat__whiskers-left {
    top: 112px;
    left: -18px;
}
.cat__whiskers-left::before {
    top: -16px;
    transform: rotate(15deg);
}
.cat__whiskers-left::after {
    top: 16px;
    transform: rotate(-15deg);
}
.cat__whiskers-right {
    top: 108px;
    left: 205px;
}
.cat__whiskers-right::before {
    top: -16px;
    transform: rotate(-15deg);
}
.cat__whiskers-right::after {
    top: 16px;
    transform: rotate(15deg);
}
.cat__body {
    position: relative;
}
.cat__chest {
    position: absolute;
    left: 54px;
    top: -48px;
    width: 120px;
    height: 120px;
    background: #ffcc80;
    border: 5px solid  transparent;
    border-radius: 50% 50% 40% 40%;
    z-index: 3;
}
.cat__chest_inner {
    content: '';
    position: absolute;
    top: 30px;
    left: 70px;
    width: 88px;
    height: 35px;
    border-radius: 50%;
    background: #fff3e0;
    z-index: 4;
}
.cat__paw-left, .cat__paw-right {
    position: absolute;
    top: 24px;
    width: 28px;
    height: 48px;
    background: #ffcc80;
    border: none;
    border-bottom: 5px solid transparent;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    z-index: 5;
}

.cat__paw-right_inner {
    content: '';
    position: absolute;
    top: 40px;
    left: 148px;
    width: 35px;
    height: 32px;
    background: #ffcc80;
    border-radius: 45%;
    border: 5px solid transparent;
    z-index: 2;
}

.cat__paw-left_inner {
    content: '';
    position: absolute;
    top: 40px;
    left: 48px;
    width: 35px;
    height: 32px;
    background: #ffcc80;
    border-radius: 45%;
    border: 5px solid transparent;
    z-index: 2;
}
.cat__paw-left {
    left: 78px;
    border-radius: 0 0 45% 35%;
}
.cat__paw-left::after {
    left: -32px;
}
.cat__paw-right {
    left: 122px;
    border-radius: 0 0 35% 45%;
}
.cat__paw-right::after {
    left: 16px;
}
.cat__tail {
    position: absolute;
    top: 20px;
    left: 130px;
    width: 90px;
    height: 23px;
    background: #ffcc80;
    border: 5px solid transparent;
    border-radius: 45%;
    z-index: 1;
    transform: rotate(-45deg);
}
/* .cursor {
    position: absolute;
    height: 23px;
    width: 23px;
    border: none;
    border-radius: 50%;
    background: #b40660;
    transform: translateX(-50%) translateY(-50%);
    z-index: 4000;
} */

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/fish code.
function headColor(color,code) {
    $('.fish__body').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
}

//Side Fin color function
function sideFinColor(color,code) {
    $('.fish__fin--left, .fish__fin--right').css('background', '#' + color)  //This changes the color of the side fins
    $('#sideFinCode').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnaside').html(code) //This updates the side fin color part of the DNA that is displayed below the fish
}

//Tail Fin color function
function tailFinColor(color,code) {
    $('.fish__tailFin--top, .fish__tailFin--bottom').css('background', '#' + color)  //This changes the color of the tailfin
    $('#tailcode').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnatail').html(code) //This updates the tail fin color part of the DNA that is displayed below the fish
}

//Stabilizer Fin color function
function stableFinColor(color,code) {
        //This changes the color of the stabilizer fins
    $('.fish__stableFin--dorsal, .fish__stableFin--left, .fish__stableFin--right').css('background', '#' + color)  
    $('#stablizercode').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnastablizer').html(code) //This updates the stabilizer fin color part of the DNA that is displayed below the fish
}

//Eye color function
function eyeColor(color,code) {
    $('.fish__eye--left, .fish__eye--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
    $('#dnaeye').html(code) //This updates the eye color part of the DNA that is displayed below the cat
}



//Side Shade Fin color function
function sideShadeColor(color,code) {
    $('.fish__fin-leftShade, .fish__fin-rightShade').css('background', '#' + color)  //This changes the color of the side fins
    $('#sideShadeCode').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnadecorationSides').html(code) //This updates the side fin color part of the DNA that is displayed below the fish
}

//Tail Shade Fin color function
function tailShadeColor(color,code) {
    $('.fish__tailFin-topShade, .fish__tailFin-bottomShade').css('background', '#' + color)  //This changes the color of the tailfin
    $('#tailShadeCode').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnadecorationMid').html(code) //This updates the tail fin color part of the DNA that is displayed below the fish
}


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

    $('#dnashape').html(num)
    switch (num) {
        case 1:
            normalEyes()
            $('#eyeName').html('Basic') //Set the badge to "Basic"
            break
        case 2:
            normalEyes() //reset
            $('#eyeName').html('Chill') //Set the badge to "Chill"
            eyesType1() //Set border to change the shape of the eyes
            break
        case 3:
            normalEyes() //reset
            $('#eyeName').html('Excite') //Set the badge to "Excite"
            eyesType2() //Set border to change the shape of the eyes
            break
        case 4:
            normalEyes() //reset
            $('#eyeName').html('Shark!!!') //Set the badge to "Shark!!!"
            eyesType3() //Set border to change the shape of the eyes
            break
        default:
            console.log("Not 1 - 4")
            break
    }
}

function decorationVariation(num) {
    $('#dnadecoration').html(num)
    switch (num) {
        case 1:
            $('#finDecorationName').html('Standard')
            normaldecoration()
            break
        case 2:
            normaldecoration() //reset
            $('#finDecorationName').html('Floating')
            decorationType1()
            break
        case 3:
            normaldecoration() //reset
            $('#finDecorationName').html('Half Cut')
            decorationType2()
            break
        case 4:
            normaldecoration() //reset
            $('#finDecorationName').html('No Decoration')
            decorationType3()
            break
        default:
            console.log("Not 1 - 4")
            break
    }
}

async function normalEyes() {
    await $('.fish__eye').find('span').css('border', 'none')
}

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

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

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

async function normaldecoration() { //STANDARD
    //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%" })
    $('.fish__fin-leftShade').css({ "border-radius": "50px 10px 50px 10px", "height": "55px", "width": "50px", "border": "2px solid",
                                    "transform": "scale(1,-1) rotate(60deg)", "left": "30px", "top": "-3px" })
    $('.fish__fin-rightShade').css({ "border-radius": "50px 10px 50px 10px", "height": "55px", "width": "50px", "border": "2px solid",
                                      "transform": "rotate(25deg)", "left": "15px", "top": "0.5px" })
    $('.fish__tailFin-topShade').css({ "border-radius": "75px 150px 35px 90px", "height": "105px", "width": "30px", "border": "2px solid",
                                       "left": "40px", "top": "25px", "transform": "rotate(-25deg)" })
    $('.fish__tailFin-bottomShade').css({ "border-radius": "75px 150px 35px 90px", "height": "105px", "width": "30px", "border": "2px solid",
                                      "left": "40px", "top": "25px", "transform": "rotate(-30deg)" })
}

function decorationType1() { //FLOATING
    $('.fish__fin-leftShade').css({ "border-radius": "50px 10px 50px 10px", "height": "55px", "width": "30px", "border": "2px solid",
                                    "transform": "scale(1,-1) rotate(90deg)", "left": "30px" })
    $('.fish__fin-rightShade').css({ "border-radius": "50px 10px 50px 10px", "height": "55px", "width": "30px", "border": "2px solid",
                                      "transform": "rotate(270deg) scale(-1,1)", "left": "35px", "top": "0.5px" })
    $('.fish__tailFin-topShade').css({ "border-radius": "75px 150px 95px 90px", "height": "55px", "width": "30px", "border": "2px solid",
                                       "left": "25px", "top": "25px", "transform": "rotate(-25deg)" })
    $('.fish__tailFin-bottomShade').css({ "border-radius": "75px 150px 95px 90px", "height": "55px", "width": "30px", "border": "2px solid",
                                      "left": "25px", "top": "25px", "transform": "rotate(-35deg)" })
}

async function decorationType2() { //HALF-CUT
    $('.fish__fin-leftShade').css({ "border-radius": "50px 10px 50px 10px", "height": "55px", "width": "30px", "border": "2px solid",
                                    "transform": "scale(1,-1) rotate(90deg)", "left": "70px", "top": "-10px" })
    $('.fish__fin-rightShade').css({ "border-radius": "50px 10px 50px 10px", "height": "55px", "width": "30px", "border": "2px solid",
                                      "transform": "rotate(55deg)", "left": "-5px", "top": "12px" })
    $('.fish__tailFin-topShade').css({ "border-radius": "75px 150px 35px 90px", "height": "105px", "width": "30px", "border": "2px solid",
                                       "left": "50px", "top": "55px", "transform": "rotate(-25deg)" })
    $('.fish__tailFin-bottomShade').css({ "border-radius": "75px 150px 35px 90px", "height": "105px", "width": "30px", "border": "2px solid",
                                      "left": "50px", "top": "55px", "transform": "rotate(-30deg)" })
}


async function decorationType3() { //NO DECORATION
    $('.fish__fin-leftShade').css({ "border-radius": "50px 10px 50px 10px", "height": "5px", "width": "5px", "border": "2px solid",
                                    "transform": "scale(1,-1) rotate(60deg)", "left": "180px", "top": "-3px" })

    $('.fish__fin-rightShade').css({ "border-radius": "50px 10px 50px 10px", "height": "5px", "width": "5px", "border": "2px solid",
                                      "transform": "rotate(5deg)", "left": "-15px", "top": "0.5px" })
                                    //
    $('.fish__tailFin-topShade').css({ "border-radius": "75px 150px 35px 90px", "height": "5px", "width": "5px", "border": "2px solid",
                                       "left": "60px", "top": "215px", "transform": "rotate(-25deg)" })
                                    //
    $('.fish__tailFin-bottomShade').css({ "border-radius": "75px 150px 35px 90px", "height": "5px", "width": "5px", "border": "2px solid",
                                      "left": "60px", "top": "125px", "transform": "rotate(-30deg)" })
}


catSettings.js

var colors = Object.values(allColors())

var defaultDNA = {
    "headcolor" : 45,
    "sideColor" : 73,
    "tailColor" : 96,
    "stablizerColor" : 17,
    "eyeColor" : 32,
    //Cattributes
    "eyesShape" : 1,
    "decorationPattern" : 1,
    "decorationMidcolor" : 13,
    "decorationSidescolor" : 13,
    "animation" :  1,
    "lastNum" :  1
    }

// when page load
$( document ).ready(function() {
  $('#dnabody').html(defaultDNA.headColor);
  $('#dnaside').html(defaultDNA.sideColor);
  $('#dnatail').html(defaultDNA.tailColor);
  $('#dnastablizer').html(defaultDNA.stablizerColor);
  $('#dnaeye').html(defaultDNA.eyeColor);
    
  $('#dnashape').html(defaultDNA.eyesShape);
  $('#dnadecoration').html(defaultDNA.decorationPattern);
  $('#dnadecorationMid').html(defaultDNA.decorationMidcolor);
  $('#dnadecorationSides').html(defaultDNA.decorationSidescolor);
  $('#dnaanimation').html(defaultDNA.animation);
  $('#dnaspecial').html(defaultDNA.lastNum);

  renderFish(defaultDNA);
});

function getDna(){
    var dna = ''
    dna += $('#dnabody').html()
    dna += $('#dnaside').html()
    dna += $('#dnatail').html()
    dna += $('#dnastablizer').html()
    dna += $('#dnaeye').html()
    dna += $('#dnashape').html()
    dna += $('#dnadecoration').html()
    dna += $('#dnadecorationMid').html()
    dna += $('#dnadecorationSides').html()
    dna += $('#dnaanimation').html()
    dna += $('#dnaspecial').html()

    return parseInt(dna)
}

function renderFish(dna){
  //catFactory.js_function (colors[dna.defaultDNA_value],dna.defaultDNA_value)
  //$('#index.html_input_id').val(dna.defaultDNA_value)
    headColor(colors[dna.headcolor],dna.headcolor)
    $('#bodycolor').val(dna.headcolor)
    sideFinColor(colors[dna.sideColor],dna.sideColor)
    $('#sideFinColor').val(dna.sideColor)
    tailFinColor(colors[dna.tailColor],dna.tailColor)
    $('#tailFinColor').val(dna.tailColor)
    stableFinColor(colors[dna.stablizerColor],dna.stablizerColor)
    $('#stableFinColor').val(dna.stablizerColor)
    eyeColor(colors[dna.eyeColor],dna.eyeColor)
    $('#eyeColor').val(dna.eyeColor)

    eyeVariation(dna.eyesShape)
    $('#eyesShape').val(dna.eyesShape)
    decorationVariation(dna.decorationPattern)
    $('#finDecoration').val(dna.decorationPattern)

    sideShadeColor(colors[dna.decorationSidescolor],dna.decorationSidescolor)
    $('#sideShadeColor').val(dna.decorationSidescolor)

    tailShadeColor(colors[dna.decorationMidcolor],dna.decorationMidcolor)
    $('#tailShadeColor').val(dna.decorationMidcolor)
}

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

// Changing fish colors, side fins
$('#sideFinColor').change(()=>{
  var colorVal = $('#sideFinColor').val()
  sideFinColor(colors[colorVal],colorVal)
})

// Changing fish colors, tail fins
$('#tailFinColor').change(()=>{
  var colorVal = $('#tailFinColor').val()
  tailFinColor(colors[colorVal],colorVal)
})

// Changing fish colors, stabilizer fins
$('#stableFinColor').change(()=>{
  var colorVal = $('#stableFinColor').val()
  stableFinColor(colors[colorVal],colorVal)
})

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

// Changing fish shape, eyes
$('#eyesShape').change(()=>{
  var shape = parseInt($('#eyesShape').val())
  eyeVariation(shape)
})

// Changing fish decoration, tail + fins
$('#finDecoration').change(()=>{
  var shape = parseInt($('#finDecoration').val())
  decorationVariation(shape)
})

// Changing fish colors, side shade fins
$('#sideShadeColor').change(()=>{
  var colorVal = $('#sideShadeColor').val()
  sideShadeColor(colors[colorVal],colorVal)
})

// Changing fish colors, tail shade fins
$('#tailShadeColor').change(()=>{
  var colorVal = $('#tailShadeColor').val()
  tailShadeColor(colors[colorVal],colorVal)
})



2 Likes

My Updated Code:

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">
</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="dnadanimation"></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="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="1" max="98" class="form-control-range" id="bodycolor">
                            </div>
                        </div>
                            <div class="form-group">
                                <label for="formControlRange"><b>Mouth, Body and Tail</b><span class="badge badge-dark ml-2" id="mouthcode"></span></label>
                                <input type="range" min="1" max="98" class="form-control-range" id="mouthcolor">
                            </div>
                            <div class="form-group">
                                <label for="formControlRange"><b>Eyes</b><span class="badge badge-dark ml-2" id="eyescode"></span></label>
                                <input type="range" min="1" max="98" class="form-control-range" id="eyescolor">
                            </div>
                            <div class="form-group">
                                <label for="formControlRange"><b>Ears</b><span class="badge badge-dark ml-2" id="earscode"></span></label>
                                <input type="range" min="1" max="98" class="form-control-range" id="earscolor">
                            </div>
                            <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</b><span class="badge badge-dark ml-2" id="decorationName"></span></label>
                                <input type="range" min="1" max="9" class="form-control-range" id="decorationshape">
                            </div>
                            <div class="form-group">
                                <label for="formControlRange"><b>Middle Color</b><span class="badge badge-dark ml-2" id="decorationMidColor"></span></label>
                                <input type="range" min="1" max="98" class="form-control-range" id="decorationmid">
                            </div>
                            <div class="form-group">
                                <label for="formControlRange"><b>Outside Color</b><span class="badge badge-dark ml-2" id="decorationSideColor"></span></label>
                                <input type="range" min="1" max="98" class="form-control-range" id="decorationside">
                            </div>
            </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.headcolor)
    eyesColor(colors[dna.eyescolor],dna.eyescolor)
    $('#eyescolor').val(dna.eyescolor)
    earsColor(colors[dna.earscolor],dna.earscolor)
    $('#earscolor').val(dna.earscolor)
}

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

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

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

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

//Changing Eye Shape
$('#eyeshape').change(()=>{
  var shape = parseInt ($('#eyeshape').val()) //between 1 and 7
  eyeVariation(shape)
})

//Changing Decoration
$('#decorationshape').change(()=>{
  var shape = parseInt ($('#decorationshape').val()) //between 1 and 9
  decorationVariation(shape)
})

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

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

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 head color part of the DNA that is displayed below the cat
}

function mouthColor(color,code) {
    $('.cat__mouth-contour, .cat__chest_inner, .cat__tail').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 mouth color part of the DNA that is displayed below the cat
}

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

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

function decorationMidColor(color,code) {
    $('.cat__head-dots').css('background', '#' + color)  //This changes the mid decoration color of the cat
    $('#decorationmid').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnadecorationMid').html(code) 
}

function decorationSideColor(color,code) {
    $('.cat__head-dots_first, .cat__head-dots_second').css('background', '#' + color)  //This changes the side decoration color of the cat
    $('#decorationside').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnadecorationSides').html(code)
}

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

    $('#dnashape').html(num)
    switch (num) {
        case 1:
            normalEyes() //set the badge to "Basic"
            $('#eyeName').html('Basic')
            break
        case 2:
            normalEyes()
            $('#eyeName').html('Chill')
            eyesType1() //set border to change the shape of the eye
            break
        case 3:
            normalEyes()
            $('#eyeName').html('Cute')
            eyesType2() //set border to change the shape of the eye
            break
        case 4:
            normalEyes()
            $('#eyeName').html('Right')
            eyesType3() //set border to change the shape of the eye
            break
        case 5:
            normalEyes()
            $('#eyeName').html('Left')
            eyesType4() //set border to change the shape of the eye
            break
        case 6:
            normalEyes()
            $('#eyeName').html('Pinch')
            eyesType5() //set border to change the shape of the eye
            break   
        case 7:
            normalEyes()
            $('#eyeName').html('High')
            eyesType6() //set border to change the shape of the eye
            break  
        default:
            console.log("Not 1 or 2");
            break;
    }
}

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('Wide Angle')
            decorationType3()
            break
        case 5:
            normaldecoration()
            $('#decorationName').html('Narrow Angle')
            decorationType4()
            break
        case 6:
            normaldecoration()
            $('#decorationName').html('Thin')
            decorationType5()
            break
        case 7:
            normaldecoration()
            $('#decorationName').html('Thick')
            decorationType6()
            break 
        case 8:
            normaldecoration()
            $('#decorationName').html('Round')
            decorationType7()
            break     
        case 9:
            normaldecoration()
            $('#decorationName').html('Inverted')
            decorationType8()
            break      
    }
}

function normalEyes() {
    $('.cat__eye').find('span').css('border', 'none')
}
function eyesType1() {
    $('.cat__eye').find('span').css('border-top', '15px solid')
}
function eyesType2() {
    $('.cat__eye').find('span').css('border-bottom', '10px solid')
}
function eyesType3() {
    $('.cat__eye').find('span').css('border-left', '10px solid')
}
function eyesType4() {
    $('.cat__eye').find('span').css('border-right', '10px solid')
}
function eyesType5() {
    $('.cat__eye').find('span').css('border-top' , '10px solid').css('border-bottom' , '10px solid')
}
function eyesType6() {
    $('.cat__eye').find('span').css('border-left' , '10px solid').css('border-right' , '10px solid')
}

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 decorationType1() {
    $('.cat__head-dots').css({ "transform": "rotate(0deg)", "height": "58px", "width": "14px", "top": "1px", "border-radius": "0 0 50% 50%" })
    $('.cat__head-dots_first').css({ "transform": "rotate(0deg)", "height": "45px", "width": "14px", "top": "1px", "border-radius": "50% 0 50% 50%" })
    $('.cat__head-dots_second').css({ "transform": "rotate(0deg)", "height": "45px", "width": "14px", "top": "1px", "border-radius": "0 50% 50% 50%" })
}
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%" })
}
function decorationType3() {
    $('.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(45deg)", "height": "35px", "width": "14px", "top": "-4px", "border-radius": "50% 0 50% 50%" })
    $('.cat__head-dots_second').css({ "transform": "rotate(-45deg)", "height": "35px", "width": "14px", "top": "-4px", "border-radius": "0 50% 50% 50%" })
}
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%" })
}
function decorationType5() {
    $('.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%" })
}
function decorationType6() {
    $('.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%" })
}
function decorationType7() {
    $('.cat__head-dots').css({ "transform": "rotate(0deg)", "height": "16px", "width": "16px", "top": "1px", "border-radius": "50%" })
    $('.cat__head-dots_first').css({ "transform": "rotate(0deg)", "height": "13px", "width": "13px", "top": "1px", "border-radius": "50%" })
    $('.cat__head-dots_second').css({ "transform": "rotate(0deg)", "height": "13px", "width": "13px", "top": "1px", "border-radius": "50%" })
}
function decorationType8() {
    $('.cat__head-dots').css({ "transform": "rotate(0deg)", "height": "49px", "width": "16px", "top": "1px", "border-radius": "50% 50% 0 0" })
    $('.cat__head-dots_first').css({ "transform": "rotate(0deg)", "height": "35px", "width": "13px", "top": "13px", "border-radius": "50%  50% 0 50%" })
    $('.cat__head-dots_second').css({ "transform": "rotate(0deg)", "height": "35px", "width": "13px", "top": "13px", "border-radius": "50% 50% 50% 0"  })
}

1 Like

Have been using Filip’s cat as I’m more interested in learning the programming side of things, as opposed the visuals.

So Here is the Code:

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">
</head>
  <body>
    <div class="container p-5" style="margin-top: 12vh;margin-bottom: 10vh;">
        <div align="center">
        <h1 class="c-white">Kreative Kitties</h1>
        <p class="c-white">Kreate Your Kustom 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="dnadanimation"></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="form-group">
                    <label for="formControlRange"><b>Head and Body Color</b><span class="badge badge-dark ml-2" id="headcode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range mb-3" id="bodycolor">

                    <label for="formControlRange"><b>Mouth and Tail Color</b><span class="badge badge-dark ml-2" id="mouthtailcode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range mb-3" id="mouthtailcolor">

                    <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 mb-3" id="eyecolor">

                    <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 mb-3" id="earcolor">

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

                    <label for="formControlRange"><b>Hair Type</b><span class="badge badge-dark ml-2" id="decorationName"></span></label>
                    <input type="range" min="1" max="5" class="form-control-range mb-3" id="decorationpattern">

                    <label for="formControlRange"><b>Primary Hair Color</b><span class="badge badge-dark ml-2" id="haircolorprimaryname"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range mb-3" id="haircolorprimary">

                    <label for="formControlRange"><b>Secondary Hair Color</b><span class="badge badge-dark ml-2" id="haircolorsecondaryname"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range mb-3" id="haircolorsecondary">

                </div>
            </div>

            </div>

            </div>
            <br>

        </div>



    </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() {
  $('#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);


    
//   $('#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)

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

    eyeColor(colors[dna.eyesColor], dna.eyesColor)
    $('#eyecolor').val(dna.eyesColor)

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

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

    decorationVariation(dna.decorationPattern)
    $('#decorationpattern').val(dna.decorationPattern)

    hairColorPrimary(colors[dna.decorationMidcolor], dna.decorationMidcolor)
    $('#haircolorprimary').val(dna.decorationMidcolor)

    hairColorSecondary(colors[dna.decorationSidescolor], dna.decorationSidescolor)
    $('#haircolorsecondary').val(dna.decorationSidescolor)
}

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

$('#mouthtailcolor').change(() => {
  var mouthTailColorVal = $('#mouthtailcolor').val()
  mouthTailColor(colors[mouthTailColorVal], mouthTailColorVal)
})

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

$('#earcolor').change(() => {
  var earColorVal = $('#earcolor').val()
  earColor(colors[earColorVal], earColorVal)
})


// Changing Cattributes

$('#eyeshape').change(() => {
  var eyeShapeVal = parseInt($('#eyeshape').val()) // Between 1 and 7
  eyeVariation(eyeShapeVal)
})

$('#decorationpattern').change(() => {
  var decorationVal = parseInt($('#decorationpattern').val())
  decorationVariation(decorationVal)
})

$('#haircolorprimary').change(() => {
  var hairColorPrimaryVal = $('#haircolorprimary').val()
  hairColorPrimary(colors[hairColorPrimaryVal], hairColorPrimaryVal)
})

$('#haircolorsecondary').change(() => {
  var hairColorSecondaryVal = $('#haircolorsecondary').val()
  hairColorSecondary(colors[hairColorSecondaryVal], hairColorSecondaryVal)
})

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 mouthTailColor(color, code) {
    $('.cat__mouth-contour, .cat__mouth-left, cat__mouth-right').css('background', '#' + color)
    $('#mouthtailcode').html('code: '+code) // Updates Badge
    $('#dnamouth').html(code) // Updates DNA String
}

function eyeColor(color, code) {
    $('.pupil-left, .pupil-right').css('background', '#' + color)
    $('#eyecode').html('code: ' +code) // Updates Bade
    $('#dnaeyes').html(code) // Updates DNA String
}

function earColor(color, code) {
    $('#leftEar, #rightEar').css('background', '#' + color)
    $('#earcode').html('code: ' + code) // Updates Badge
    $('#dnaears').html(code) // Updates DNA String
}

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

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


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

    $('#dnashape').html(num) // Set DNA String
    switch (num) {
        case 1:
            normalEyes()
            $('#eyename').html('Basic') // Set Badge To 'Basic'
            break
        case 2:
            normalEyes()
            $('#eyename').html('Looking Down') // Set Badge To 'Looking Down'
            eyesType1()
            break
        case 3:
            normalEyes()
            $('#eyename').html('Looking Up') // Set Badge To 'Looking Up'
            eyesType2()
            break
        case 4:
            normalEyes()
            $('#eyename').html('Looking Left') // Set Badge To 'Looking Left'
            eyesType3()
            break
        case 5:
            normalEyes()
            $('#eyename').html('Looking Right') // Set Badge To 'Looking Right'
            eyesType4()
            break
        case 6:
            normalEyes()
            $('#eyename').html('Tiny Eyes') // Set Badge To 'Tiny Eyes'
            eyesType5()
            break
        default:
            normalEyes()
            $('#eyename').html('Error')
            break
    }
}

function decorationVariation(num) {
    $('#dnadecoration').html(num) // Set DNA String
    switch (num) {
        case 1:
            $('#decorationName').html('Basic')
            normaldecoration()
            break
        case 2:
            normaldecoration()
            $('#decorationName').html('Long Hair')
            decorationType1()
            break
        case 3:
            normaldecoration()
            $('#decorationName').html('Messy')
            decorationType2()
            break
        case 4:
            normaldecoration()
            $('#decorationName').html('Spiky')
            decorationType3()
            break
        case 5:
            normaldecoration()
            $('#decorationName').html('Flat')
            decorationType4()
            break
        default:
            normaldecoration()
            $('#decorationName').html('Error')
    }
}

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-right', '15px solid')
}

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

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

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() {
    await $('#midDot, #leftDot, #rightDot').css('height', '70px')
}

async function decorationType2() {
    await $('#leftDot').css('transform', 'rotate(-45deg)')
    await $('#rightDot').css('transform', 'rotate(45deg)')
}

async function decorationType3() {
    await $('#midDot, #leftDot, #rightDot').css('transform', 'rotate(180deg)')
}

async function decorationType4() {
    await $('#midDot, #leftDot, #rightDot').css('width', '20px')
}
1 Like

Great learning experience. You get the most of it by doing it on your own after watching the video lecture and doing some fun experimentation.

Relevant HTML Code added:

                <div class="form-group">
                    <label for="formControlRange"><b>Eyes Shape</b><span class="badge badge-dark ml-2" id="eyesshapecode"></span></label>
                    <input type="range" min="1" max="4" class="form-control-range" id="eyesshape">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Decoration Pattern</b><span class="badge badge-dark ml-2" id="decorationcode"></span></label>
                    <input type="range" min="1" max="4" class="form-control-range" id="decorationpattern">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Decoration Mid 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="decorationmidcolor">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Decoration Side</b><span class="badge badge-dark ml-2" id="decorationsidecode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="decorationsidecolor">
                </div>

CSS Code:

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: inherit;
}
html {
    box-sizing: border-box;
    overflow-y: scroll;
}
body {
    background: #607d8b;
 
}

#face {
    background-color: #f5f590;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    position: relative;
}

.forehead {
    background-color: black;
    position: relative;
    left: 98px;
    top: 10px;
    flex-direction: row;
}

.forehead_marker {
    background-color: #dbcb44;
    position: absolute;
    width: 10px;
    height: 20px;
}

.forehead_marker_left {
    left: -15px;
    border-radius: 50% 50% 50% 50%;
}

.forehead_marker_right {
    left: 15px;
    border-radius: 50% 50% 50% 50%;
}

.forehead_marker_mid {
    height: 30px;
    border-radius: 50% 50% 50% 50%;
}

.eyes {
    position: relative;
    top: 10px;
    display: flex;
}

.eye {
    background-color: white;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    margin: 25px;
    position: relative;
}

.pupils {
    background-color: black;
    width: 28px;
    height: 35px;
    border-radius: 50%;
    position: relative;
    top: 10px;
    left: 12px;
}

.ears {
    position: relative;
}

.ear {
    background-color: #f5f590;
    border-radius: 90% 10% 90% 10%;
    height: 100px;
    width: 100px;
    position: absolute;
}

.ear_left {
    transform: scale(1, -1);
    left: 0px;
}

.ear_right {
    left: 100px;
}

.inner_ears {
    background-color: rgb(241, 189, 189);
    border-radius: 90% 10% 90% 10%;
    height: 75px;
    width: 75px;
    position: absolute; 
}

.ear_left_inner {
    left: 10px;
    bottom: 10px;
}

.ear_right_inner {
    top: 10px;
    left: 15px;
}

.whiskers {
    position: relative;
}

.whisker {
    background-color: rgb(51, 113, 138);
    height: 2px;
    width: 50px;
    position: absolute;
}

.whisker_left_group {
    position: relative;
    right: 10px;
}

.whisker_right_group {
    position: relative;
    left: 165px;
}

.whisker_first_pair {
    top: 20px;
}

.whisker_second_pair {
    top: 35px;
}

.whisker_third_pair {
    top: 50px;
}

.whisker_left_top {
    transform: rotate(10deg);
}

.whisker_left_bottom {
    transform: rotate(-10deg);
}

.whisker_right_top {
    transform: rotate(-10deg);
}

.whisker_right_bottom {
    transform: rotate(10deg);
}

.nose {
    background-color: coral;
    height: 20px;
    width: 20px;
    position: relative;
    margin: auto;
    border-radius: 30% 30% 90% 90%;
}

.mouth {
    background-color: rgb(201, 141, 198);
    height: 10px;
    width: 25px;  
    position: relative;
    top: 30px;
    margin: auto;
    border-radius: 5% 5% 95% 95%;
}

.body {
    background-color: #f5f590;
    width: 185px;
    height: 210px;
    border-radius: 90% 90% 35% 35%;
    position: relative;
    top: -15px;
}

.tail {
    background-color: #dbcb44;
    width: 40px;
    height: 160px;
    position: absolute; 
    top: 305px;
    left: 250px;
    border-radius: 100% 30% 100% 30%;
    transform: rotate(45deg);
}

.paws {
    position: absolute;
    display: flex;
    top: 155px;
    left: -5px;
}

.paw {
    background-color: #dbcb44;
    width: 45px;
    height: 32px;
    margin: 27px;
    border-radius: 90% 90% 10% 10%;
}

catSettings.js code:


var colors = Object.values(allColors())

var defaultDNA = {
    "headcolor" : 10,
    "tailColor" : 27,
    "pawColor" : 84,
    "eyecolor" : 21,
    "whiskerColor" : 60,
    "noseColor" : 87,
    "mouthColor" : 19,
    //Cattributes
    "eyesShape" : 1,
    "decorationPattern" : 1,
    "decorationMidcolor" : 13,
    "decorationSidescolor" : 13,
    "animation" :  1,
    "lastNum" :  1
    }

// when page load
$( document ).ready(function() {
  $('#dnabody').html(defaultDNA.headColor);
  $('#dnatail').html(defaultDNA.tailColor);
  $('#dnapaw').html(defaultDNA.pawColor);
  $('#dnaeyes').html(defaultDNA.eyecolor);
  $('#dnawhisker').html(defaultDNA.whiskerColor);
  $('#dnanose').html(defaultDNA.noseColor);
  $('#dnamouth').html(defaultDNA.mouthColor);
    
  $('#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 += $('#dnatail').html()
    dna += $('#dnapaw').html()
    dna += $('#dnaeyes').html()
    dna += $('#dnawhisker').html()
    dna += $('#dnanose').html()
    dna += $('#dnamouth').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)
    tailColor(colors[dna.tailColor],dna.tailColor)
    $('#tailcolor').val(dna.tailColor)
    pawColor(colors[dna.pawColor],dna.pawColor)
    $('#pawcolor').val(dna.pawColor)
    eyeColor(colors[dna.eyecolor],dna.eyecolor)
    $('#eyecolor').val(dna.eyecolor)
    whiskerColor(colors[dna.whiskerColor],dna.whiskerColor)
    $('#whiskercolor').val(dna.whiskerColor)
    noseColor(colors[dna.noseColor],dna.noseColor)
    $('#nosecolor').val(dna.noseColor)
    mouthColor(colors[dna.mouthColor],dna.mouthColor)
    $('#mouthcolor').val(dna.mouthColor)

    eyeVariation(dna.eyesShape)
    $('#eyesshape').val(dna.eyesShape)
    decorationVariation(dna.decorationPattern)
    $('#decorationpattern').val(dna.decorationPattern)
    decorationMidColor(colors[dna.decorationMidcolor],dna.decorationMidcolor)
    $('#decorationmidcolor').val(dna.decorationMidcolor)
    decorationSideColor(colors[dna.decorationSidescolor],dna.decorationSidescolor)
    $('#decorationsidecolor').val(dna.decorationSidescolor)
}

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

$('#tailcolor').change(()=>{
  var colorVal = $('#tailcolor').val()
  tailColor(colors[colorVal],colorVal)
});

$('#pawcolor').change(()=>{
  var colorVal = $('#pawcolor').val()
  pawColor(colors[colorVal],colorVal)
});

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

$('#whiskercolor').change(()=>{
  var colorVal = $('#whiskercolor').val()
  whiskerColor(colors[colorVal],colorVal)
});

$('#nosecolor').change(()=>{
  var colorVal = $('#nosecolor').val()
  noseColor(colors[colorVal],colorVal)
});

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

// Changing cattributes
$('#eyesshape').change(()=>{
  var eyesShape = parseInt($('#eyesshape').val())
  eyeVariation(eyesShape)
});

$('#decorationpattern').change(()=>{
  var decorationPatten = parseInt($('#decorationpattern').val())
  decorationVariation(decorationPatten)
});

$('#decorationmidcolor').change(()=>{
  var colorVal = $('#decorationmidcolor').val()
  decorationMidColor(colors[colorVal],colorVal)
});

$('#decorationsidecolor').change(()=>{
  var colorVal = $('#decorationsidecolor').val()
  decorationSideColor(colors[colorVal],colorVal)
});

Lastly, the relevant code changes in catFactory.js:

// Cattributes Funtions
function eyeVariation(num) {

    $('#dnashape').html(num)
    switch (num) {
        case 1:
            $('#eyesshapecode').html('Basic')
            normalEyes()
            break
        case 2:
            normalEyes()
            $('#eyesshapecode').html('Wide')
            wideEyes()
            break
        case 3:
            normalEyes()
            $('#eyesshapecode').html('Snake')
            snakeEyes()
            break
        case 4:
            normalEyes()
            $('#eyesshapecode').html('Half Moon')
            halfMoonEyes()
            break          
        default:
            $('#eyesshapecode').html('Basic')
            normalEyes()
            break
    }
}

function decorationVariation(num) {

    $('#dnadecoration').html(num)
    switch (num) {
        case 1:
            $('#decorationcode').html('Basic')
            normaldecoration()
            break
        case 2:
            normaldecoration()
            $('#decorationcode').html('Spread')
            spreadDecoration()
            break
        case 3:
            normaldecoration()
            $('#decorationcode').html('V Shape')
            vShapeDecoration()
            break
        case 4:
            normaldecoration()
            $('#decorationcode').html('Dots')
            dotsDecoration()
            break          
        default:
            $('#decorationcode').html('Basic')
            normaldecoration()
            break
    }
}

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

function decorationSideColor(color,code) {
    $('.forehead_marker_left, .forehead_marker_right').css('background', '#' + color)
    $('#decorationsidecode').html('code: '+code)
    $('#dnadecorationSides').html(code)
}

async function normalEyes() {
    await $('.pupils').css({"width": "28px", "height": "35px", "border-radius": "50% 50% 50% 50%", "transform": "rotate(0deg)", "top": "10px", "left": "12px"});
}

async function wideEyes() {
    await $('.pupils').css({"width": "30px", "height": "35px", "border-radius": "0% 100% 0% 100%", "transform": "rotate(-50deg)", "top": "10px", "left": "10px"});
}

async function snakeEyes() {
    await $('.pupils').css({"width": "10px", "height": "44px", "border-radius": "0% 100% 0% 100%", "transform": "rotate(7deg)", "top": "3px", "left": "20px"});
}

async function halfMoonEyes() {
    await $('.pupils').css({"width": "28px", "height": "25px", "border-radius": "100% 100% 20% 20%", "top": "13px", "left": "12px"});
}

async function normaldecoration() {
    //Remove all style from other decorations
    //In this way we can also use normalDecoration() to reset the decoration style
    $('.forehead_marker_mid').css({"width": "10px", "height": "30px", "border-radius": "50% 50% 50% 50%", "left": "0px", "transform": "none"})
    $('.forehead_marker_left').css({"width": "10px", "height": "20px", "border-radius": "50% 50% 50% 50%", "left": "-15px", "transform": "none"})
    $('.forehead_marker_right').css({"width": "10px", "height": "20px", "border-radius": "50% 50% 50% 50%", "left": "15px", "transform": "none"})
}

async function spreadDecoration() {
    //Remove all style from other decorations
    //In this way we can also use normalDecoration() to reset the decoration style
    $('.forehead_marker_mid').css({"width": "10px", "height": "30px", "border-radius": "50% 50% 50% 50%", "left": "0px"})
    $('.forehead_marker_left').css({"width": "10px", "height": "20px", "border-radius": "50% 50% 50% 50%", "left": "-15px", "transform": "rotate(45deg)"})
    $('.forehead_marker_right').css({"width": "10px", "height": "20px", "border-radius": "50% 50% 50% 50%", "left": "15px", "transform": "rotate(-45deg)"})
}

async function vShapeDecoration() {
    //Remove all style from other decorations
    //In this way we can also use normalDecoration() to reset the decoration style
    $('.forehead_marker_mid').css({"width": "10px", "height": "20px", "border-radius": "50% 50% 50% 50%", "left": "0px"})
    $('.forehead_marker_left').css({"width": "10px", "height": "40px", "border-radius": "50% 50% 50% 50%", "left": "-15px", "transform": "rotate(-20deg)"})
    $('.forehead_marker_right').css({"width": "10px", "height": "40px", "border-radius": "50% 50% 50% 50%", "left": "15px", "transform": "rotate(20deg)"})
}

async function dotsDecoration() {
    //Remove all style from other decorations
    //In this way we can also use normalDecoration() to reset the decoration style
    $('.forehead_marker_mid').css({"width": "10px", "height": "10px", "border-radius": "50% 50% 50% 50%", "left": "0px"})
    $('.forehead_marker_left').css({"width": "10px", "height": "10px", "border-radius": "50% 50% 50% 50%", "left": "-15px"})
    $('.forehead_marker_right').css({"width": "10px", "height": "10px", "border-radius": "50% 50% 50% 50%", "left": "15px"})
}
1 Like

I cant seem to get the eye shape to change, here is all of the code, I am not sure what I’m getting wrong here:

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">
</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="dnadanimation"></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="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 and 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>Eyes</b><span class="badge badge-dark ml-2" id="eyescode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="eyescolor">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Ears and 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="earscolor">
                </div>
                <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>

            </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)
    $('#eyescolor').val(dna.eyesColor)
    earsAndPaws(colors[dna.earsColor],dna.earsColor)
    $('#earscolor').val(dna.earsColor)
}

// Changing cat colors
$('#bodycolor').change(()=>{
    var colorVal = $('#bodycolor').val()
    headColor(colors[colorVal],colorVal)
})
$('#mouthcolor').change(()=>{
  var colorVal = $('#mouthcolor').val()
  mouthColor(colors[colorVal],colorVal)
})
$('#eyescolor').change(()=>{
  var colorVal = $('#eyescolor').val()
  eyesColor(colors[colorVal],colorVal)
})
$('#earscolor').change(()=>{
  var colorVal = $('#earscolor').val()
  earsAndPaws(colors[colorVal],colorVal)
})
// Changing cat attributes
$('#eyeshape').change(()=>{
  var shape = parseInt($('#eyeshape').val()) //between 1 and 7
  eyeVariation(shape)
})

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, .cat__chest_inner').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__tail').css('background', '#' + color)
    $('#mouthcode').html('code: ' + code)
    $('#dnamouth').html(code)
}
function eyesColor(color,code) {
    $('.cat__eye--left, .cat__eye--right').css('background', '#' + color)
    $('#eyescode').html('code: ' + code)
    $('#dnaeyes').html(code)
}
function earsColor(color,code) {
    $('.cat__ear, .cat__paw-left, .cat__paw-right, .cat__paw-right_inner, .cat__paw-left_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') //Set the badge to basic
            break
        case 2:
            normalEyes()
            $('#eyeName').html('Chill')
            eyesType1() //Set border to change the shape of the eye
            break
        case 3:
            normalEyes()
            $('#eyeName').html('Looking Up')
            eyesType2() //Set border to change the shape of the eye
            break
    }
}

function decorationVariation(num) {
    $('#dnadecoration').html(num)
    switch (num) {
        case 1:
            $('#decorationName').html('Basic')
            normaldecoration()
            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 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%" })
}

I have followed Filip’s code for these as I was struggling to get my own cat to work. Any help would be greatly appreciated!

hey @GahuckImGoofy!
First of all you dont need async and await in this functions since they are not a promess.

The code looks generally good. I will like to test it my self. Can you please upload the repo to github and pass me the link? So I can fully test it and review it.

@kenn.eth I have deleted the async and await parts of this section of the code. It also seems that the code is loading correctly now, I’m not sure why but the page on the python3 server seems to be very slow at loading - which is why I thought it wasn’t working.

1 Like

index.html:

<!DOCTYPE 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">
</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="dnadanimation"></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="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 and 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>Eyes</b><span class="badge badge-dark ml-2" id="eyescode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="eyescolor">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Ears and 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="earscolor">
                </div>
                <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>Head 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="decorationpattern">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Middle Color</b><span class="badge badge-dark ml-2" id="decorationMid"></span></label>
                    <input type="range" min="1" max="98" class="form-control-range" id="decorationmid">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Sides Color</b><span class="badge badge-dark ml-2" id="decorationSides"></span></label>
                    <input type="range" min="1" max="98" class="form-control-range" id="decorationsides">
                </div>
            </div>

            </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)
    $('#eyescolor').val(dna.eyesColor)
    earsColor(colors[dna.earsColor],dna.earsColor)
    $('#earscolor').val(dna.earsColor)
    //Cattributes section
    eyeVariation(shape[dna.eyesShape],dna.eyesShape)
    $('#eyesShape').val(dna.eyesShape)
    decorationVariation(decorationPattern[dna.decorationPattern],dna.decorationPattern)
    $('#decorationPattern').val(dna.decorationPattern)
    decorationMidColor(colors[dna.decorationMidColor],dna.decorationMidColor)
    $('#decorationmid').val(dna.decorationMidColor)
    decorationSidesColor(colors[dna.decorationSidesColor],dna.decorationSidesColor)
    $('#decorationsides').val(dna.decorationSidesColor)
}

// Changing cat colors
$('#bodycolor').change(()=>{
    var colorVal = $('#bodycolor').val()
    headColor(colors[colorVal],colorVal)
})
$('#mouthcolor').change(()=>{
  var colorVal = $('#mouthcolor').val()
  mouthColor(colors[colorVal],colorVal)
})
$('#eyescolor').change(()=>{
  var colorVal = $('#eyescolor').val()
  eyesColor(colors[colorVal],colorVal)
})
$('#earscolor').change(()=>{
  var colorVal = $('#earscolor').val()
  earsColor(colors[colorVal],colorVal)
})
$('#decorationmid').change(()=>{
  var colorVal = $('#decorationmid').val()
  decorationMidColor(colors[colorVal],colorVal)
})
$('#decorationsides').change(()=>{
  var colorVal = $('#decorationsides').val()
  decorationSidesColor(colors[colorVal],colorVal)
})
// Changing cat attributes
$('#eyeshape').change(()=>{
  var shape = parseInt($('#eyeshape').val()) //between 1 and 7
  eyeVariation(shape)
})
$('#decorationpattern').change(()=>{
  var decorationPattern = parseInt($('#decorationpattern').val())
  decorationVariation(decorationPattern)
})

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, .cat__chest_inner').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__tail').css('background', '#' + color)
    $('#mouthcode').html('code: ' + code)
    $('#dnamouth').html(code)
}
function eyesColor(color,code) {
    $('.pupil-left, .pupil-right').css('background', '#' + color)
    $('#eyescode').html('code: ' + code)
    $('#dnaeyes').html(code)
}
function earsColor(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)
    $('#earscode').html('code: ' + code)
    $('#dnaears').html(code)
}
// Cattributes (decoration) Colors
function decorationMidColor(color,code) {
    $('.cat__head-dots').css('background', '#' + color)
    $('#decorationmid').html('code: ' + code)
    $('#dnadecorationMid').html(code)
}
function decorationSidesColor(color,code) {
    $('.cat__head-dots_first, .cat__head-dots_second').css('background', '#' + color)
    $('#decorationsides').html('code: ' + code)
    $('#dnadecorationSides').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') //Set the badge to basic
            break
        case 2:
            normalEyes()
            $('#eyeName').html('Chill')
            eyesType1() //Set border to change the shape of the eye
            break
        case 3:
            normalEyes()
            $('#eyeName').html('Looking Up')
            eyesType2() //Set border to change the shape of the eye
            break
        case 4:
            normalEyes()
            $('#eyeName').html('Looking Left')
            eyesType3()
            break
        case 5:
            normalEyes()
            $('#eyeName').html('Looking Right')
            eyesType4()
            break
        case 6:
            normalEyes()
            $('#eyeName').html('Up and Down Cross-Eyed')
            eyesType5()
            break
        case 7:
            normalEyes()
            $('#eyeName').html('Cross-Eyed')
            eyesType6()
            break
    }
}

function decorationVariation(num) {
    $('#dnadecoration').html(num)
    switch (num) {
        case 1:
            normaldecoration()
            $('#decorationName').html('Basic')
            break
        case 2:
            normaldecoration()
            $('#decorationName').html('Upside Down')
            upsideDown()
            break
        case 3:
            normaldecoration()
            $('#decorationName').html('Spiked')
            spiked()
            break
        case 4:
            normaldecoration()
            $('#decorationName').html('Right Spike')
            rightSpike()
            break
        case 5:
            normaldecoration()
            $('#decorationName').html('Left Spike')
            leftSpike()
            break
    }
}

function normalEyes() {
    $('.cat__eye').find('span').css('border', 'none')
}
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-right', '15px solid')
}
function eyesType4() {
    $('.cat__eye').find('span').css('border-left', '15px solid')
}
function eyesType5() {
    $('.cat__eye--left').find('span').css('border-top', '15px solid')
    $('.cat__eye--right').find('span').css('border-bottom', '15px solid')
}
function eyesType6() {
    $('.cat__eye--left').find('span').css('border-left', '15px solid')
    $('.cat__eye--right').find('span').css('border-right', '15px solid')
}
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 upsideDown() {
    $('.cat__head-dots').css({ "transform": "rotate(180deg)", "height": "48px", "width": "14px", "top": "1px", "border-radius": "0 0 50% 50%" })
}
async function spiked() {
    $('.cat__head-dots').css({"transform": "rotate(180deg)", "height": "48px", "width":"14px", "top": "-45px", "border-radius": "0px 0px 50% 50%"})
}
async function rightSpike() {
    $('.cat__head-dots_first').css({"transform": "rotate(180deg)", "height": "35px", "width": "14px", "top": "-35px", "border-radius": "50% 0px 50% 50%"})
}
async function leftSpike() {
    $('.cat__head-dots_second').css({"transform": "rotate(180deg)", "height": "35px", "width": "14px", "top": "-35px", "border-radius": "50% 0px 50% 50%"})
}
1 Like

cat settings :

$('#patternshape').change(()=>{
  var shape = parseInt($('#patternshape').val()) // between 1 and 7
   decorationVariation(shape)
})
$('#patternColor1').change(()=>{

  var colorVal = $('#patternColor1').val()
   patternColor1(colors[colorVal],colorVal)
})

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

cat Factorysettings

function patternColor1(color,code) {
    $('.cat__head-dots').css('background', '#' + color)  //This changes the color of the cat
    $('#patternMid').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 patternColor2(color,code) {
    $('.cat__head-dots_first, .cat__head-dots_second').css('background', '#' + color)  //This changes the color of the cat
    $('#patternSides').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
}
1 Like

Updated along with some dynamic changes to stripes.

index.html
<meta charset="UTF-8">

<meta http-equiv="X-UA-Compatible" content="IE=edge">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Document</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">
<div class="container p-5" style="margin-top: 12vh;margin-bottom: 10vh;">

    <div align="center">

        <h1 class="c-black">Kitties-Factory</h1>

        <p class="c-black">Create your custom Kitty</p>

    </div>

    <div class="row">

        <div class="col-lg-4 catBox m-2 light-b-shadow">

            <div id="cs-container">

                <div id="tail"></div>

                <div id="tail-mask"></div>

                <div id="tail-end"></div>

               

                <div id="body">

                    <div class="ear" id="ear-left">

                        <div class="ear-inner" id="ear-inner-left"></div>

                    </div>

                    <div class="ear" id="ear-right">

                        <div class="ear-inner" id="ear-inner-right"></div>

                    </div>

                   

                    <div id="mask"></div>

                   

                    <div id="patch">

                        <div class="fur"></div>

                        <div class="fur"></div>

                        <div class="fur"></div>

                    </div>

                   

                    <div id="eyes">

                        <div class="eye" id="eye-left">

                        <div class="shine" id="shine-left"></div>

                        </div>

                        <div class="eye" id="eye-right">

                        <div class="shine" id="shine-right"></div>

                        </div>

                    </div>

                   

                    <div id="whisk-left">

                        <div class="whisker" id="whisk-one"></div>

                        <div class="whisker"></div>

                        <div class="whisker" id="whisk-three"></div>

                    </div>

                   

                    <div id="nose"></div>

                   

                    <div id="whisk-right">

                        <div class="whisker" id="whisk-four"></div>

                        <div class="whisker"></div>

                        <div class="whisker" id="whisk-six"></div>

                    </div>

                   

                    <div id="smile">

                        <div id="smile-left-align">

                            <div id="smile-left"></div>

                            <div id="mask-left"></div>

                        </div>

                       

                        <div id="smile-right-align">

                            <div id="smile-right"></div>

                            <div id="mask-right"></div>

                        </div>

                    </div>

                   

                    <div id="tongue"></div>

                    <div id="tummy"></div>

                </div>

            </div>

            <br>

            <div class="dnaDiv" id="catDNA">

                <b>

                    DNA:

                    <!-- Colors -->

                    <span id="dnabody"></span>

                    <span id="dnaeyes"></span>

                    <span id="dnaears"></span>

                    <span id="dnabelly"></span>

                    <span id="dnastripes"></span>

                   

                    <!-- Cattributes -->

                    <span id="dnashape"></span>

                    <span id="dnadecoration"></span>

                    <span id="dnadecorationMid"></span>

                    <span id="dnadecorationSides"></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 id="catColors">

                <div class="form-group">

                    <label for="formControlRange"><b>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>

           

            <!-- Eyes colors -->

            <div id="catColors">

                <div class="form-group">

                    <label for="formControlRange"><b>Eyes 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>

            <!-- Ear & Tail colors -->

            <div id="catColors">

                <div class="form-group">

                    <label for="formControlRange"><b>Ear | Tail</b><span class="badge badge-dark ml-2" id="ETcode"></span></label>

                    <input type="range" min="10" max="98" class="form-control-range" id="ETcolor">

                </div>

            </div>

            <!-- Inner Ear & Belly colors -->

            <div id="catColors">

                <div class="form-group">

                    <label for="formControlRange"><b>Inner Ear | Belly</b><span class="badge badge-dark ml-2" id="IEBcode"></span></label>

                    <input type="range" min="10" max="98" class="form-control-range" id="IEBcolor">

                </div>

            </div>

            <!-- Eye Shape -->

            <div id="catColors">

                <div class="form-group">

                    <label for="formControlRange"><b>Eye Shape</b><span class="badge badge-dark ml-2" id="eyesShapecode"></span></label>

                    <input type="range" min="1" max="3" class="form-control-range" id="eyesShape">

                </div>

            </div>

            <!-- Decoration Style -->

            <div id="catColors">

                <div class="form-group">

                    <label for="formControlRange"><b>Decoration Style</b><span class="badge badge-dark ml-2" id="DStylecode"></span></label>

                    <input type="range" min="1" max="6" class="form-control-range" id="DStyle">

                </div>

            </div>

            <!-- Decoration Center Color -->

            <div id="catColors">

                <div class="form-group">

                    <label for="formControlRange"><b>Decoration Mid Color</b><span class="badge badge-dark ml-2" id="DMcode"></span></label>

                    <input type="range" min="10" max="98" class="form-control-range" id="DMcolor">

                </div>

            </div>

            <!-- Decoration Side Color -->

            <div id="catColors">

                <div class="form-group">

                    <label for="formControlRange"><b>Decoration Side Color</b><span class="badge badge-dark ml-2" id="DSidecode"></span></label>

                    <input type="range" min="10" max="98" class="form-control-range" id="DSidecolor">

                </div>

            </div>

        </div>

    </div>

    <br/>

   

</div>

<footer align="left">

    <p>Angnima Sherpa - 2022</p>

</footer>
catSettings.js

var colors = Object.values(allColors())

var defaultDNA = {

"headcolor" : 10,

"tummyColor" : 55,

"eyesColor" : 96,

"earsColor" : 10,

"stripesColor" : 90,

//Cattributes

"eyesShape" : 1,

"decorationPattern" : 1,

"decorationMidcolor" : 90,

"decorationSidescolor" : 90,

"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){

$('#bodycolor').val(dna.headcolor)

headColor(colors[dna.headcolor],dna.headcolor)

$('#eyecolor').val(dna.eyesColor)

eyeColor(colors[dna.eyesColor],dna.eyesColor)

$('#ETcolor').val(dna.earsColor)

ETColor(colors[dna.earsColor],dna.earsColor)

$('#IEBcolor').val(dna.tummyColor)

IEBColor(colors[dna.tummyColor],dna.tummyColor)

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

EyeShape(dna.eyesShape)

$('#SWcolor').val(dna.stripesColor)

SWColor(colors[dna.stripesColor],dna.stripesColor)

$('#DStyle').val(dna.decorationPattern)

changeDStyle(dna.decorationPattern)

$('#DMcolor').val(dna.decorationMidcolor)

DMColor(colors[dna.decorationMidcolor], dna.decorationMidcolor);

$("#DSidecolor").val(dna.decorationSidescolor);

DSideColor(colors[dna.decorationSidescolor], dna.decorationSidescolor);

}

// Changing cat colors

$(’#bodycolor’).change(()=>{

var colorVal = $('#bodycolor').val()

headColor(colors[colorVal],colorVal)

})

$(’#eyecolor’).change(()=>{

var colorVal = $(’#eyecolor’).val()

eyeColor(colors[colorVal],colorVal)

})

$(’#ETcolor’).change(()=>{

var colorVal = $(’#ETcolor’).val()

ETColor(colors[colorVal], colorVal)

})

$(’#IEBcolor’).change(()=>{

var colorVal = $(’#IEBcolor’).val()

IEBColor(colors[colorVal], colorVal)

})

$(’#eyesShape’).change(()=>{

var shapeVal = $(’#eyesShape’).val()

EyeShape(shapeVal)

})

$(’#DStyle’).change(()=>{

var StyleVal = $(’#DStyle’).val()

changeDStyle(StyleVal)

})

$(’#SWcolor’).change(()=>{

var colorVal = $(’#SWcolor’).val()

SWColor(colors[colorVal], colorVal)

})

$(’#DMcolor’).change(()=>{

var colorVal = $(’#DMcolor’).val()

DMColor(colors[colorVal], colorVal)

})

$(’#DSidecolor’).change(()=>{

var colorVal = $(’#DSidecolor’).val()

DSideColor(colors[colorVal], colorVal)

})

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) {

$('#body, #mask, #mask-right, #smile-right, #mask-left, #smile-left').css('background-color', '#' + color)  //This changes the color of the cat

// $("#tail").css("border", "15px solid #" + color);

// $("#tail-end").css("background-color", "#" + color);

$('#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 eyeColor(color,code) {

$('.eye').css('background-color', '#' + 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 ETColor(color,code) {

$("#tail").css("border", "15px solid #" + color);

$("#tail-end").css("background-color", "#" + color);

$(".ear").css("background-color", "#" + color);



$('#ETcode').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 IEBColor(color,code) {

$(".ear-inner").css("background-color", "#" + color);

$("#tummy").css("background-color", "#" + color);



$('#IEBcode').html('code: '+code) //This updates text of the badge next to the slider

$('#dnabelly').html(code) //This updates the body color part of the DNA that is displayed below the cat

}

function SWColor(color,code) {

$(".fur").css("background-color", "#" + color);



$('#SWcode').html('code: ' + code); //This updates text of the badge next to the slider

$('#dnastripes').html(code) //This updates the body color part of the DNA that is displayed below the cat

}

function DMColor(color, code) {

$(".fur:even").css("background-color", "#" + color);

$('#DMcode').html('code: ' + code);

$('#dnadecorationMid').html(code);

}

function DSideColor(color, code) {

$(".fur:odd").css("background-color", "#" + color);

$('#DSidecode').html('code: ' + code);

$('#dnadecorationSides').html(code);

}

function EyeShape(code) {

normalEyes()

$("#dnashape").html(code)

if(code == 3) {

    $(".eye").css("border-top", "6px solid");

    $("#eyesShapecode").html("Sleepy");

}else if(code == 2) {

    $(".eye").css("border-bottom", "6px solid");

    $("#eyesShapecode").html("Sus");

}else {

    $(".eye").css("border-top", "none");

    $("#eyesShapecode").html("Basic");

}

}

function changeDStyle(style) {

$("#dnadecoration").html(style)

switch (style) {

    case "1":

        normalDStyle()

        $('#DStylecode').html('Basic');

        break;

    case "2":

        normalDStyle()

        $(".fur:first").css("transform", "translate(10px, 10px)")

        $('#DStylecode').html('Ping');

        break;

    case "3":

        normalDStyle()

        $(".fur:first").css("transform", "translate(10px, 10px)")

        $(".fur:last").css("transform", "rotate(90deg) translate(3px, 9px)");

        $('#DStylecode').html('Cross');

        break;

    case "4":

        normalDStyle()

        $(".fur:first").css("transform", "rotate(90deg) translate(6px, -9px)");

        $(".fur:last").css("transform", "rotate(90deg) translate(3px, 9px)");

        $('#DStylecode').html('Pyramid');

        break;

    case "5":

        normalDStyle()

        $(".fur:first").css("transform", "translate(10px, 20px)");

        $(".fur:last").css("transform", "rotate(90deg) translate(3px, 9px)");

        $('#DStylecode').html('Guru');

        break;

    case "6":

        normalDStyle()

        $(".fur:first").css("transform", "translate(10px, 10px) rotate(90deg)");

        $(".fur:last").css("transform", "translate(-9px, 6px)");

        $('#DStylecode').html('Gunner');

        break;

    default:

        normalDStyle()

        $('#DStylecode').html('Basic');

        break;

}

}

//###################################################

//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

}

}

function decorationVariation(num) {

$('#dnadecoration').html(num)

switch (num) {

    case 1:

        $('#decorationName').html('Basic')

        normaldecoration()

        break

}

}

async function normalEyes() {

await $('.eye').css('border', 'none')

}

async function normalDStyle() {

await $(".fur").css("transform", "none");

}

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%" })

}

1 Like

Hello
I don’t know why my code is not working I can print “eyesType1” to the console but the color of the eye does not change. I wanting to get the color working as a test then change it to shape but at the moment it doesn’t change anything.
Index:

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

  <link rel="stylesheet" href="/Penguin NFT Marketplace/css/mystyle.css">
  <link rel="stylesheet" href="/Penguin NFT Marketplace/css/penguin.css">
  <link rel="stylesheet" href="/Penguin NFT Marketplace/css/colors.css">
  <link rel="stylesheet" href="/Penguin NFT Marketplace/css/factory.css">
  <link rel="stylesheet" href="/Penguin NFT Marketplace/css/frontend.css">
</head>
  <body>
    <div class="container p-5" style="margin-top: 12vh;margin-bottom: 10vh;">
        <div align="center">
        <h1 class="c-white">Penguin-Factory</h1>
        <p class="c-white">Create your custom Penguin</p>
    </div>
        <div class="row">
            <div class="col-lg-4 penguinBox m-2 light-b-shadow">
                <div class="penguin">
                    <div class="penguin-bottom">
                    <div class="right-hand"></div> 
                    <div class="left-hand"></div>
                    <div class="right-feet"></div>
                    <div class="left-feet"></div>
                    </div>

                    <div id="head" class="penguin-top">
                      <div class="belly"></div>
                        
                        <div class="left-cheek"></div>
                        <div class="right-cheek"></div>
                        <div class="beak-bottom"></div>
                        <div class="beak-top"></div>
                        <div class="blush-left"></div>
                        <div class="blush-right"></div>
                        <div class="left-eye">
                          <div class="sparkle"></div>
                        </div>
                        <div class="right-eye">
                          <div class="sparkle"></div>
                        </div>
                        

                    </div>



                    
                </div>
                <br>
                <div class="dnaDiv" id="penguinDNA">
                    <b>
                        DNA:
                        <!-- Colors -->
                         <span id="dnabody"></span>
                         <span id="dnabelly"></span>
                         <span id="dnaface"></span>
                         <span id="dnahand"></span>
                        
                         <!-- attributes -->
                         <span id="dnashape"></span>
                         <span id="dnadecoration"></span>
                         <span id="dnadecorationMid"></span>
                         <span id="dnadecorationSides"></span>
                         <span id="dnadanimation"></span>
                         <span id="dnaspecial"></span>
                    </b>
                </div>
            </div>
            <div class="col-lg-7 attributes m-2 light-b-shadow">

penguinFactory:

//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) {

    $('.penguin-bottom, .penguin-top').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 bellyColor(color, code) {

    $('.belly').css('background', '#' + color)

    $('#bellycode').html('code: '+code)

    $('#dnabelly').html(code)

}

function faceColor(color, code) {

    $('.left-cheek, .right-cheek').css('background', '#' + color)

    $('#facecode').html('code: '+code)

    $('#dnaface').html(code)

}

function handColor(color, code) {

    $('.left-hand, .right-hand').css('background', '#' + color)

    $('#handcode').html('code: '+code)

    $('#dnahand').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')

            console.log("Basic")

            break

        case 2:

            normalEyes()

            $('#eyeName').html('Chill')

            eyesType1()

            console.log("Chill")

            break

       

    }

}

function decorationVariation(num) {

    $('#dnadecoration').html(num)

    switch (num) {

        case 1:

            $('#decorationName').html('Basic')

            normaldecoration()

            break

    }

}

async function normalEyes() {

    await $('.left-eye, .right-eye').find('span').css('border', 'none')

}

async function eyesType1() {

    await $('.left-eye, .right-eye').find('span').css('background', 'red')

    console.log("eyesType1")

}

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%" })

}

penguinSetting:


var colors = Object.values(allColors())

var defaultDNA = {
    "headColor" : 10,
    "bellyColor" : 13,
    "faceColor" : 13,
    "handColor" : 10,
    
    //attributes
    "eyesShape" : 1,
    "decorationPattern" : 1,
    "decorationMidcolor" : 13,
    "decorationSidescolor" : 13,
    "animation" :  1,
    "lastNum" :  1
    }

// when page load
$( document ).ready(function() {
  $('#dnabody').html(defaultDNA.headColor);
  $('#dnabelly').html(defaultDNA.bellyColor);
  $('#dnaface').html(defaultDNA.faceColor);
  $('#dnahand').html(defaultDNA.handColor);
  $('#dnashape').html(defaultDNA.eyesShape)
  $('#dnadecoration').html(defaultDNA.decorationPattern)
  $('#dnadecorationMid').html(defaultDNA.decorationMidcolor)
  $('#dnadecorationSides').html(defaultDNA.decorationSidescolor)
  $('#dnaanimation').html(defaultDNA.animation)
  $('#dnaspecial').html(defaultDNA.lastNum)

  renderPenguin(defaultDNA)
});

function getDna(){
    var dna = ''
    dna += $('#dnabody').html()
    dna += $('#dnabelly').html()
    dna += $('#dnaface').html()
    dna += $('#dnahand').html()
    dna += $('#dnashape').html()
    dna += $('#dnadecoration').html()
    dna += $('#dnadecorationMid').html()
    dna += $('#dnadecorationSides').html()
    dna += $('#dnaanimation').html()
    dna += $('#dnaspecial').html()

    
    return parseInt(dna)
}

function renderPenguin(dna){
    headColor(colors[dna.headColor],dna.headColor)
    $('#bodycolor').val(dna.headColor)
    bellyColor(colors[dna.bellyColor],dna.bellyColor)
    $('#bellycolor').val(dna.bellyColor)
    faceColor(colors[dna.faceColor],dna.faceColor)
    $('#facecolor').val(dna.faceColor)
    handColor(colors[dna.handColor],dna.handColor)
    $('#handcolor').val(dna.handColor)
    eyeVariation(dna.eyesShape)
    $('eyeshape').val(dna.eyesShape)
    

}

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

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

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

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

//Eye Shape

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


Hello
My code is now working this is it:

index.html

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

  <link rel="stylesheet" href="/Penguin NFT Marketplace/css/mystyle.css">
  <link rel="stylesheet" href="/Penguin NFT Marketplace/css/penguin.css">
  <link rel="stylesheet" href="/Penguin NFT Marketplace/css/colors.css">
  <link rel="stylesheet" href="/Penguin NFT Marketplace/css/factory.css">
  <link rel="stylesheet" href="/Penguin NFT Marketplace/css/frontend.css">
</head>
  <body>
    <div class="container p-5" style="margin-top: 12vh;margin-bottom: 10vh;">
        <div align="center">
        <h1 class="c-white">Penguin-Factory</h1>
        <p class="c-white">Create your custom Penguin</p>
    </div>
        <div class="row">
            <div class="col-lg-4 penguinBox m-2 light-b-shadow">
                <div class="penguin">
                    <div class="penguin-bottom">
                    <div class="right-hand"></div> 
                    <div class="left-hand"></div>
                    <div class="right-feet"></div>
                    <div class="left-feet"></div>
                    </div>

                    <div id="head" class="penguin-top">
                      <div class="belly"></div>
                        
                        <div class="pattern"></div>
                        <div class="pattern-left"></div>
                        <div class="pattern-right"></div>
                        <div class="left-cheek"></div>
                        <div class="right-cheek"></div>
                        <div class="beak-bottom"></div>
                        <div class="beak-top"></div>
                        <div class="blush-left"></div>
                        <div class="blush-right"></div>
                        <div class="left-eye">
                          <div class="sparkle"></div>
                        </div>
                        <div class="right-eye">
                          <div class="sparkle"></div>
                        </div>
                        

                    </div>



                    
                </div>
                <br>
                <div class="dnaDiv" id="penguinDNA">
                    <b>
                        DNA:
                        <!-- Colors -->
                         <span id="dnabody"></span>
                         <span id="dnabelly"></span>
                         <span id="dnaface"></span>
                         <span id="dnahand"></span>
                        
                         <!-- attributes -->
                         <span id="dnashape"></span>
                         <span id="dnadecoration"></span>
                         <span id="dnadecorationMid"></span>
                         <span id="dnadecorationSides"></span>
                         <span id="dnadanimation"></span>
                         <span id="dnaspecial"></span>
                    </b>
                </div>
            </div>
            <div class="col-lg-7 attributes m-2 light-b-shadow">

<!-- Penguin colors -->
<div id="penguinColors">
                <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>Belly</b><span class="badge badge-dark ml-2" id="bellycode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="bellycolor">
                </div>  
                <div class="form-group">
                  <label for="formControlRange"><b>Face</b><span class="badge badge-dark ml-2" id="facecode"></span></label>
                  <input type="range" min="10" max="98" class="form-control-range" id="facecolor">
                </div>
                <div class="form-group">
                  <label for="formControlRange"><b>Hands</b><span class="badge badge-dark ml-2" id="handcode"></span></label>
                  <input type="range" min="10" max="98" class="form-control-range" id="handcolor">
                </div>
                <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>
                <div class="form-group">
                  <label for="formControlRange"><b>Pattern</b><span class="badge badge-dark ml-2" id="decorationPattern"></span></label>
                  <input type="range" min="1" max="7" class="form-control-range" id="patternshape">
                </div>
                <div class="form-group">
                  <label for="formControlRange"><b>Pattern Color Mid</b><span class="badge badge-dark ml-2" id="decorationMidcolor"></span></label>
                  <input type="range" min="10" max="98" class="form-control-range" id="patterncolormid">
                </div>
                <div class="form-group">
                  <label for="formControlRange"><b>Pattern Color Sides</b><span class="badge badge-dark ml-2" id="decorationSidescolor"></span></label>
                  <input type="range" min="10" max="98" class="form-control-range" id="patterncolorsides">
                </div>
            </div>

            </div>

            </div>
            <br>

        </div>



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

  </body>
  <script src="/Penguin NFT Marketplace/js/colors.js"></script>
  <script src="/Penguin NFT Marketplace/js/penguinFactory.js"></script>
  <script src="/Penguin NFT Marketplace/js/penguinSettings.js"></script>

</html>


penguinSetting.js

var colors = Object.values(allColors())

var defaultDNA = {
    "headColor" : 10,
    "bellyColor" : 13,
    "faceColor" : 13,
    "handColor" : 10,
    
    //attributes
    "eyesShape" : 1,
    "decorationPattern" : 1,
    "decorationMidcolor" : 13,
    "decorationSidescolor" : 13,
    "animation" :  1,
    "lastNum" :  1
    }

// when page load
$( document ).ready(function() {
  $('#dnabody').html(defaultDNA.headColor);
  $('#dnabelly').html(defaultDNA.bellyColor);
  $('#dnaface').html(defaultDNA.faceColor);
  $('#dnahand').html(defaultDNA.handColor);
  $('#dnashape').html(defaultDNA.eyesShape)
  $('#dnadecoration').html(defaultDNA.decorationPattern)
  $('#dnadecorationMid').html(defaultDNA.decorationMidcolor)
  $('#dnadecorationSides').html(defaultDNA.decorationSidescolor)
  $('#dnaanimation').html(defaultDNA.animation)
  $('#dnaspecial').html(defaultDNA.lastNum)

  renderPenguin(defaultDNA)
});

function getDna(){
    var dna = ''
    dna += $('#dnabody').html()
    dna += $('#dnabelly').html()
    dna += $('#dnaface').html()
    dna += $('#dnahand').html()
    dna += $('#dnashape').html()
    dna += $('#dnadecoration').html()
    dna += $('#dnadecorationMid').html()
    dna += $('#dnadecorationSides').html()
    dna += $('#dnaanimation').html()
    dna += $('#dnaspecial').html()

    
    return parseInt(dna)
}

function renderPenguin(dna){
    headColor(colors[dna.headColor],dna.headColor)
    $('#bodycolor').val(dna.headColor)

    bellyColor(colors[dna.bellyColor],dna.bellyColor)
    $('#bellycolor').val(dna.bellyColor)

    faceColor(colors[dna.faceColor],dna.faceColor)
    $('#facecolor').val(dna.faceColor)

    handColor(colors[dna.handColor],dna.handColor)
    $('#handcolor').val(dna.handColor)

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

    decorationVariation(dna.decorationPattern)
    $('#patternshape').val(dna.decorationPattern)
    
    patternColorMid(colors[dna.decorationMidcolor],dna.decorationMidcolor)
    $('#patterncolormid').val(dna.decorationMidcolor)

    patternColorSides(colors[dna.decorationSidescolor],dna.decorationSidescolor)
    $('#patterncolorsides').val(dna.decorationSidescolor)


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

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

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

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

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

$('#patterncolorsides').change(()=>{
    var colorVal = $('#patterncolorsides').val()
    patternColorSides(colors[colorVal],colorVal)
    console.log("1")
})

//Eye Shape

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

$('#patternshape').change(()=>{
    var pattern = parseInt($('#patternshape').val())
    decorationVariation(pattern)
})
}

penguinFactory.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) {
    $('.penguin-bottom, .penguin-top').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 bellyColor(color, code) {
    $('.belly').css('background', '#' + color)
    $('#bellycode').html('code: '+code)
    $('#dnabelly').html(code)
}
function faceColor(color, code) {
    $('.left-cheek, .right-cheek').css('background', '#' + color)
    $('#facecode').html('code: '+code)
    $('#dnaface').html(code)
}
function handColor(color, code) {
    $('.left-hand, .right-hand').css('background', '#' + color)
    $('#handcode').html('code: '+code)
    $('#dnahand').html(code)
    console.log(color)
    console.log(code)
}

function patternColorMid(color, code) {
    $('.pattern').css('background', '#' + color)
    $('#decorationMidcolor').html('code: '+code)
    $('#dnadecorationMid').html(code)
    
}

function patternColorSides(color, code) {
    $('.pattern-right, .pattern-left').css('background', '#' + color)
    $('#decorationSidescolor').html('code: '+code)
    $('#dnadecorationSides').html(code)
    console.log(color)
    console.log(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')
            console.log("Basic")
            break
        case 2:
            normalEyes()
            $('#eyeName').html('Down')
            eyesType1()
            console.log("Down")
            break
        case 3:
            normalEyes()
            $('#eyeName').html('Up')
            eyesType2()
            break
        case 4:
            normalEyes()
            $('#eyeName').html('Tired')
            eyesType3()
            break
        case 5:
            normalEyes()
            $('#eyeName').html('Up-Down')
            eyesType4()
            break
        case 6:
            normalEyes()
            $('#eyeName').html('Cross-Eyed')
            eyesType5()
            break
        case 7:
            normalEyes()
            $('#eyeName').html('Far-eyes')
            eyesType6()
            break
    }
}



function normalEyes() {
    $('.left-eye, .right-eye').find('div').css('top', '25%').css('left', '15%').css('width', '35%').css('height', '35%')
    
}   

function eyesType1() {
    $('.left-eye, .right-eye').find('div').css('top', '50%',).css('left', '30%')
    console.log("eyesType1")
}

function eyesType2() {
    $('.left-eye, .right-eye').find('div').css('top', '10%').css('left', '30%')
}

function eyesType3() {
    $('.left-eye, .right-eye').find('div').css('width', '69%').css('height', '24%')
}

function eyesType4() {
    $('.left-eye').find('div').css('top', '10%').css('left', '30%')
    $('.right-eye').find('div').css('top', '50%').css('left', '30%')
}

function eyesType5() {
    $('.right-eye').find('div').css('top', '25%').css('left', '-8%')
    $('.left-eye').find('div').css('top', '25%').css('left', '74%')
}

function eyesType6() {
    $('.right-eye').find('div').css('top', '25%').css('left', '74%')
    $('.left-eye').find('div').css('top', '25%').css('left', '-8%')
}

function decorationVariation(num) {
    $('#dnadecoration').html(num)
    switch (num) {
        case 1:
            $('#decorationPattern').html('Clear')
            normalDecoration()
            break
        case 2:
            normalDecoration()
            $('#decorationPattern').html('Three-line')
            pattern1()
            break
        case 3:
            normalDecoration()
            $('#decorationPattern').html('One-line')
            pattern2()
            break
        case 4:
            normalDecoration()
            $('#decorationPattern').html('Two-line')
            pattern3()
            break
        case 5:
            normalDecoration()
            $('#decorationPattern').html('T')
            pattern4()
            break
        case 6:
            normalDecoration()
            $('#decorationPattern').html('Cross')
            pattern5()
            break
        case 7:
            normalDecoration()
            $('#decorationPattern').html('X')
            pattern6()
            break

    }
}

function normalDecoration() {
    //Remove all style from other decorations
    //In this way we can also use normalDecoration() to reset the decoration style
    $('.pattern, .pattern-left, .pattern-right').css('visibility', 'hidden').css('height', '50px').css('width', '16px').css('top', '116px')
    $('.pattern').css('left', '67px')
    $('.pattern-left').css('left', '40px')
    $('.pattern-right').css('left', '95px')
    $('.pattern, .pattern-right').css('transform', 'rotate(0deg)')
    //console.log("Clear")
}

function pattern1() {
    $('.pattern, .pattern-left, .pattern-right').css('visibility', 'visible')
    $('.pattern, .pattern-left, .pattern-right').css('background', 'red') 
    //console.log("Basic")
}

function pattern2 () {
    $('.pattern').css('visibility', 'visible')
    console.log("One-line")
}

function pattern3 () {
    $('.pattern').css('visibility', 'visible').css('left', '50px')
    $('.pattern-right').css('visibility', 'visible').css('left', '85px')
}

function pattern4() {
    $('.pattern').css('visibility', 'visible').css('left', '67px')
    $('.pattern-right').css('visibility', 'visible').css('height', '16px').css('width', '50px').css('left', '51px')
}

function pattern5() {
    $('.pattern').css('visibility', 'visible').css('left', '67px')
    $('.pattern-right').css('visibility', 'visible').css('height', '16px').css('width', '50px').css('left', '51px').css('top', '127px')
}

function pattern6() {
    $('.pattern').css('visibility', 'visible').css('left', '67px')
    $('.pattern-right').css('visibility', 'visible').css('height', '16px').css('width', '50px').css('left', '51px').css('top', '133px')
    $('.pattern, .pattern-right').css('transform', 'rotate(45deg)')
}



1 Like

Hello,

I am having problems having eye shape show up with this code. It works when I tested manually by injecting code with “inspect” element, but doesnt work when I try it in the slider. Any ideas whats wrong?

Uploaded to github:
https://github.com/Jani-commits/cats

Here is my Bear Code:

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/bears.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">Bears-Factory</h1>
        <p class="c-white">Create your custom Bear</p>
    </div>
        <div class="row">
            <div class="col-lg-4 bearBox m-2 light-b-shadow">
            <div class="bear">
                <div class="head">
                    <div class="ears">
                        <div class="left ear">
                            <div class="inner-ear inner-ear-left"></div>
                        </div>
                        <div class="right ear">
                            <div class="inner-ear inner-ear-right"></div>
                        </div>
                    </div>
                    <div class="eyes">
                        <div class="eye">
                            <div class="pupils left-pupil">
                                <div class="inner"></div>
                            </div>
                        </div>
                        <div class="eye">
                            <div class="pupils right-pupil">
                                <div class="inner right"></div>
                            </div>
                        </div>
                    </div>
                    <div class="snout">
                        <div class="nose"></div>
                        <div class="mouth mouth-left"></div>
                        <div class="mouth mouth-right"></div>
                    </div>
                </div>
        </div>
                <br>
                <div class="dnaDiv" id="catDNA">
                    <b>
                        DNA:
                        <!-- Colors -->
                         <span id="dnafur"></span>
                         <span id="dnamouth"></span>
                         <span id="dnaeyes"></span>
                         <span id="dnaears"></span>
                        
                         <!-- Cattributes -->
                         <span id="dnashape"></span>
                         <span id="dnanosecolor"></span>
                         <span id="dnanosewidth"></span>
                         <span id="dnanoseheight"></span>
                         <span id="dnaspecial"></span>
                    </b>
                </div>
            </div>
            <div class="col-lg-7 bear-attributes m-2 light-b-shadow">

            <!-- Bears colors -->
            <div id="bearColors">
                <div class="form-group">
                    <label for="formControlRange"><b>Fur</b><span class="badge badge-dark ml-2" id="furcode"></span></label>
                    <input type="range" min="10" max="99" class="form-control-range" id="furcolor">
                </div>
                <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="00" max="99" class="form-control-range" id="mouthcolor">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Eyes</b><span class="badge badge-dark ml-2" id="eyescode"></span></label>
                    <input type="range" min="00" max="99" class="form-control-range" id="eyescolor">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Ears</b><span class="badge badge-dark ml-2" id="earscode"></span></label>
                    <input type="range" min="00" max="99" class="form-control-range" id="earscolor">
                </div>
                <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="shapeCode">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Nose Color</b><span class="badge badge-dark ml-2" id="noseCode"></span></label>
                    <input type="range" min="0" max="99" class="form-control-range" id="nosecolor">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Nose Width</b><span class="badge badge-dark ml-2" id="noseWidth"></span></label>
                    <input type="range" min="0" max="99" class="form-control-range" id="nosewidth">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Nose Height</b><span class="badge badge-dark ml-2" id="noseHeight"></span></label>
                    <input type="range" min="0" max="99" class="form-control-range" id="noseheight">
                </div>
            </div>

            </div>

            </div>
            <br>

        </div>



    </div>
    <footer align="left">
        <p>Christoph Weissteiner NFT Marketplace March 2022</p>
    </footer>

  </body>
  <script src="assets/js/colors.js"></script>
  <script src="assets/js/bearSettings.js"></script>
  <script src="assets/js/bearFactory.js"></script>

</html>

bearSettings.js


var colors = Object.values(allColors())

var defaultDNA = {
  "furColor": 13,
  "mouthColor": 26,
  "eyesColor": 66,
  "earsColor": 10,
  //Cattributes
  "eyesShape": 1,
  "noseColor": 44,
  "noseWidth": 13,
  "noseHeight": 13,
  "lastNum": 1
}

// when page load
$(document).ready(function () {
  $('#dnafur').html(defaultDNA.furColor);
  $('#dnamouth').html(defaultDNA.mouthColor);
  $('#dnaeyes').html(defaultDNA.eyesColor);
  $('#dnaears').html(defaultDNA.earsColor);

  $('#dnashape').html(defaultDNA.eyesShape)
  $('#dnanosecolor').html(defaultDNA.noseColor)
  $('#dnanosewidth').html(defaultDNA.noseWidth)
  $('#dnanoseheight').html(defaultDNA.noseHeight)
  $('#dnaspecial').html(defaultDNA.lastNum)

  renderBear(defaultDNA)
});

function getDna() {
  var dna = ''
  dna += $('#dnafur').html()
  dna += $('#dnamouth').html()
  dna += $('#dnaeyes').html()
  dna += $('#dnaears').html()
  dna += $('#dnashape').html()
  dna += $('#dnanosecolor').html()
  dna += $('#dnanosewidth').html()
  dna += $('#dnanoseheight').html()
  dna += $('#dnaspecial').html()

  return parseInt(dna)
}

function renderBear(dna) {
  furColor(colors[dna.furColor], dna.furColor)
  $('#furcolor').val(dna.furColor)
  mouthColor(colors[dna.mouthColor], dna.mouthColor)
  $('#mouthcolor').val(dna.mouthColor)
  eyesColor(colors[dna.eyesColor], dna.eyesColor)
  $('#eyescolor').val(dna.eyesColor)
  earsColor(colors[dna.earsColor], dna.earsColor)
  $('#earscolor').val(dna.earsColor)
  eyeVariation(dna.eyesShape)
  $('#shapeCode').val(dna.eyesShape)
  noseColor(colors[dna.noseColor], dna.noseColor)
  $('#nosecolor').val(dna.noseColor)
  noseWidth(dna.noseWidth)
  $('#nosewidth').val(dna.noseWidth)
  noseHeight(dna.noseHeight)
  $('#noseheight').val(dna.noseHeight)
}

// Changing bear colors
$('#furcolor').change(() => {
  var colorVal = $('#furcolor').val()
  furColor(colors[colorVal], colorVal)
})

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

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

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

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

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

$('#nosewidth').change(() => {
  var val = $('#nosewidth').val()
  noseWidth(parseInt(val))
})

$('#noseheight').change(() => {
  var val = $('#noseheight').val()
  noseHeight(parseInt(val))
})

bearFactory.js


var colors = Object.values(allColors())

var defaultDNA = {
  "furColor": 13,
  "mouthColor": 26,
  "eyesColor": 66,
  "earsColor": 10,
  //Cattributes
  "eyesShape": 1,
  "noseColor": 44,
  "noseWidth": 13,
  "noseHeight": 13,
  "lastNum": 1
}

// when page load
$(document).ready(function () {
  $('#dnafur').html(defaultDNA.furColor);
  $('#dnamouth').html(defaultDNA.mouthColor);
  $('#dnaeyes').html(defaultDNA.eyesColor);
  $('#dnaears').html(defaultDNA.earsColor);

  $('#dnashape').html(defaultDNA.eyesShape)
  $('#dnanosecolor').html(defaultDNA.noseColor)
  $('#dnanosewidth').html(defaultDNA.noseWidth)
  $('#dnanoseheight').html(defaultDNA.noseHeight)
  $('#dnaspecial').html(defaultDNA.lastNum)

  renderBear(defaultDNA)
});

function getDna() {
  var dna = ''
  dna += $('#dnafur').html()
  dna += $('#dnamouth').html()
  dna += $('#dnaeyes').html()
  dna += $('#dnaears').html()
  dna += $('#dnashape').html()
  dna += $('#dnanosecolor').html()
  dna += $('#dnanosewidth').html()
  dna += $('#dnanoseheight').html()
  dna += $('#dnaspecial').html()

  return parseInt(dna)
}

function renderBear(dna) {
  furColor(colors[dna.furColor], dna.furColor)
  $('#furcolor').val(dna.furColor)
  mouthColor(colors[dna.mouthColor], dna.mouthColor)
  $('#mouthcolor').val(dna.mouthColor)
  eyesColor(colors[dna.eyesColor], dna.eyesColor)
  $('#eyescolor').val(dna.eyesColor)
  earsColor(colors[dna.earsColor], dna.earsColor)
  $('#earscolor').val(dna.earsColor)
  eyeVariation(dna.eyesShape)
  $('#shapeCode').val(dna.eyesShape)
  noseColor(colors[dna.noseColor], dna.noseColor)
  $('#nosecolor').val(dna.noseColor)
  noseWidth(dna.noseWidth)
  $('#nosewidth').val(dna.noseWidth)
  noseHeight(dna.noseHeight)
  $('#noseheight').val(dna.noseHeight)
}

// Changing bear colors
$('#furcolor').change(() => {
  var colorVal = $('#furcolor').val()
  furColor(colors[colorVal], colorVal)
})

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

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

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

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

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

$('#nosewidth').change(() => {
  var val = $('#nosewidth').val()
  noseWidth(parseInt(val))
})

$('#noseheight').change(() => {
  var val = $('#noseheight').val()
  noseHeight(parseInt(val))
})
1 Like

hey @Gry ! Do you have errors in console or is just that the code is not applying. Please send a screen shot with the issue.

When I press “random cat” just these two DNA numbers update, nothing else

Also soz for the extremely ugly cat, only doing for learning purpose

index.html sliders:

                <div id="catColors">
                    <div class="form-group">
                        <label for="formControlRangeBodyColor"><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="formControlRangeMouthColor"><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>

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

                    <div class="form-group">
                        <label for="formControlRangeEarsColor"><b>Ear</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">
                    </div>

                    <div class="form-group">
                        <label for="formControlRangeEyeShape"><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="formControlRangeDecorPat"><b>Decorative Patern</b><span class="badge badge-dark ml-2" id="decorationName"></span></label>
                        <input type="range" min="1" max="7" class="form-control-range" id="decorationpattern">
                    </div>
                    <div class="form-group">
                        <label for="formControlRangeDecorMid"><b>Decoration Mid Color</b><span class="badge badge-dark ml-2" id="midcolorcode"></span></label>
                        <input type="range" min="10" max="98" class="form-control-range" id="decorationmid">
                    </div>
                    <div class="form-group">
                        <label for="formControlRangeDecorSides"><b>Decoration Sides Color</b><span class="badge badge-dark ml-2" id="sidecolorcode"></span></label>
                        <input type="range" min="10" max="98" class="form-control-range" id="decorationsides">
                    </div>
                </div>

catSettings.js


var colors = Object.values(allColors())

var defaultDNA = {
    "headColor" : 10,
    "mouthColor" : 13,
    "eyesColor" : 35,
    "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)
    $('#eyescolor').val(dna.eyesColor)

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

    eyeVariation(dna.eyesShape)
    $('#eyeshape').val(dna.eyesShape)
    
    decorationVariation(dna.decorationPattern)
    $('#decorationpattern').val(dna.decorationPattern)
    
    decorationMidColor(colors[dna.decorationMidcolor],dna.decorationMidcolor)
    $('#decorationmid').val(dna.decorationMidcolor)
    
    decorationSidesColor(colors[dna.decorationSidescolor],dna.decorationSidescolor)
    $('#decorationsides').val(dna.decorationSidescolor)
}

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

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

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

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

//--

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

$('#decorationpattern').change(()=>{
  var pattern = parseInt($('#decorationpattern').val())
  decorationVariation(pattern)
})

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

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

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 mouthColor(color,code) {
    $('.cat__mouth-contour').css('background', '#' + color)
    $('#mouthcode').html('code: '+code)
    $('#dnamouth').html(code)
}

function eyesColor(color,code) {
    $('.pupil-left, .pupil-right').css('background', '#' + color)
    $('#eyescode').html('code: '+code)
    $('#dnaeyes').html(code)
}

function earsColor(color,code) {
    $('.cat__ear--left, .cat__ear--right').css('background', '#' + color)
    $('#earscode').html('code: '+code)
    $('#dnaears').html(code)
}

function decorationMidColor(color,code) {
    $('.cat__head-dots').css('background', '#' + color)
    $('#midcolorcode').html('code: '+code)
    $('#dnadecorationMid').html(code)
}

function decorationSidesColor(color,code) {
    $('.cat__head-dots_first, .cat__head-dots_second').css('background', '#' + color)
    $('#sidecolorcode').html('code: '+code)
    $('#dnadecorationSides').html(code)
}

// Variation functions for range-bars

// 8 eye types
function eyeVariation(num) {
    $('#dnashape').html(num)
    $('.cat__eye').find('span').css('border', 'none')
    switch (num) {
        default:
            $('#eyeName').html('1: Basic')
            break
        case 2:
            $('#eyeName').html('2: Chill')
            $('.cat__eye').find('span').css('border-top', '15px solid')
            break
        case 3:
            $('#eyeName').html('3: Looking up')
            $('.cat__eye').find('span').css('border-bottom', '15px solid')
            break
        case 4:
            $('#eyeName').html('4: Looking left')
            $('.cat__eye').find('span').css('border-left', 'solid 10px')
            break
        case 5:
            $('#eyeName').html('5: Looking right')
            $('.cat__eye').find('span').css('border-right', 'solid 10px')
            break
        case 6:
            $('#eyeName').html('6: Focused')
            $('.cat__eye').find('span').css('border-top', 'solid 7px')
            $('.cat__eye').find('span').css('border-bottom', 'solid 7px')
            $('.cat__eye').find('span').css('border-left', 'solid 7px')
            $('.cat__eye').find('span').css('border-right', 'solid 7px')
            break
        case 7:
            $('#eyeName').html('7: Dreamy')
            $('.cat__eye').find('span').css('border-bottom', 'solid 10px')
            $('.cat__eye').find('span').css('border-left', 'solid 10px')
            $('.cat__eye').find('span').css('border-right', 'solid 10px')
            break
    }
}

function decorationVariation(num) {
    $('#dnadecoration').html(num)
    $('.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%" })
    switch (num) {
        default:
            $('#decorationName').html('1: Basic')
            break
        case 2:
            $('#decorationName').html('2: Long')
            $('.cat__head-dots').css({ "transform": "rotate(0deg)", "height": "55px", "width": "14px", "top": "1px", "border-radius": "0 0 50% 50%" })
            $('.cat__head-dots_first').css({ "transform": "rotate(0deg)", "height": "42px", "width": "14px", "top": "1px", "border-radius": "50% 0 50% 50%" })
            $('.cat__head-dots_second').css({ "transform": "rotate(0deg)", "height": "42px", "width": "14px", "top": "1px", "border-radius": "0 50% 50% 50%" })
            break
        case 3:
            $('#decorationName').html('3: Longer')
            $('.cat__head-dots').css({ "transform": "rotate(0deg)", "height": "63px", "width": "14px", "top": "1px", "border-radius": "0 0 50% 50%" })
            $('.cat__head-dots_first').css({ "transform": "rotate(0deg)", "height": "50px", "width": "14px", "top": "1px", "border-radius": "50% 0 50% 50%" })
            $('.cat__head-dots_second').css({ "transform": "rotate(0deg)", "height": "50px", "width": "14px", "top": "1px", "border-radius": "0 50% 50% 50%" })
            break
        case 4:
            $('#decorationName').html('4: Long to left')
            $('.cat__head-dots').css({ "transform": "rotate(20deg)", "height": "55px", "width": "14px", "top": "1px", "border-radius": "0 0 50% 50%" })
            $('.cat__head-dots_first').css({ "transform": "rotate(0deg)", "height": "42px", "width": "14px", "top": "1px", "border-radius": "50% 0 50% 50%" })
            $('.cat__head-dots_second').css({ "transform": "rotate(0deg)", "height": "42px", "width": "14px", "top": "1px", "border-radius": "0 50% 50% 50%" })
            break
        case 5:
            $('#decorationName').html('5: Long to right')
            $('.cat__head-dots').css({ "transform": "rotate(-20deg)", "height": "55px", "width": "14px", "top": "1px", "border-radius": "0 0 50% 50%" })
            $('.cat__head-dots_first').css({ "transform": "rotate(0deg)", "height": "42px", "width": "14px", "top": "1px", "border-radius": "50% 0 50% 50%" })
            $('.cat__head-dots_second').css({ "transform": "rotate(0deg)", "height": "42px", "width": "14px", "top": "1px", "border-radius": "0 50% 50% 50%" })
            break
        case 6:
            $('#decorationName').html('6: Long spread')
            $('.cat__head-dots').css({ "transform": "rotate(0deg)", "height": "55px", "width": "14px", "top": "1px", "border-radius": "0 0 50% 50%" })
            $('.cat__head-dots_first').css({ "transform": "rotate(28deg)", "height": "42px", "width": "14px", "top": "1px", "border-radius": "50% 0 50% 50%" })
            $('.cat__head-dots_second').css({ "transform": "rotate(-28deg)", "height": "42px", "width": "14px", "top": "1px", "border-radius": "0 50% 50% 50%" })
            break
        case 7:
            $('#decorationName').html('7: Longer spread')
            $('.cat__head-dots').css({ "transform": "rotate(0deg)", "height": "63px", "width": "14px", "top": "1px", "border-radius": "0 0 50% 50%" })
            $('.cat__head-dots_first').css({ "transform": "rotate(28deg)", "height": "50px", "width": "14px", "top": "1px", "border-radius": "50% 0 50% 50%" })
            $('.cat__head-dots_second').css({ "transform": "rotate(-28deg)", "height": "50px", "width": "14px", "top": "1px", "border-radius": "0 50% 50% 50%" })
            break
        }
}
1 Like

Hello, the dna (mouth, eyes, ears, eye shape) can’t be updated. I checked everything but It doesn’t work. Please Help!
Here is 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">
</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>
                        <span id="ok"></span>
                         <!-- Cattributes -->
                         <span id="dnashape"></span>
                         <span id="dnadecoration"></span>
                         <span id="dnadecorationMid"></span>
                         <span id="dnadecorationSides"></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 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 | Belly | 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>Eyes 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 | Paw</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 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>

                </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>

Here is catSettings.js


var colors = Object.values(allColors())

var defaultDNA = {
    "headcolor" : 10,
    "mouthColor" : 13,
    "eyesColor" : 96,
    "earsColor" : 10,
    "ok": 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);
  $('#ok').html(defaultDNA.ok);
    
  $('#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 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)
}

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)
  mouthAndBelly(colors[dna.mouthColor],dna.mouthColor)
  $('#mouthcolor').val(dna.mouthColor)
  eyeColor(colors[dna.eyesColor],dna.eyesColor)
  $('#eyecolor').val(dna.eyesColor)
  earsAndPaw(colors[dna.earsColor],dna.earsColor)
  $('#earcolor').val(dna.earsColor)
  
}

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

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

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

$('#eyesshape').change(()=>{
  var shape = parseInt($('#eyeshape').val())//c/o input between 1-7
  eyeVariation(shape)
})

Here is 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 mouthAndBelly(color,code) {
    $('.cat__mouth-contour, .cat__tail, .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) {
    $('.cat__eye').find('span').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 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 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
}


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

    $('#dnashape').html(num)
    switch (num) {
        case 1:
            normalEyes()
            $('#eyeName').html('Basic')//Set badge to basic
            break
        case 2:
            normalEyes()//reset
            $('#eyeName').html('Chill')//set the badge to chill
            eyesType1()//set border to change the shape of the eye
            break
        case 3:
            normalEyes()//reset
            $('#eyeName').html('up')//set the badge to up
            eyesType2()//set border to change the shape of the eye
            break
        default:
            console.log("not 1 or 2");
    }
}

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

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

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

}

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

}

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%" })
}

1 Like

hey @Mia1 where is you colors variable? Everthing looks good. Im wondering if the colors objects are ok.
Please you can also post github repo link so I can test by my side.

Here is the code, using Phillip’s cat. I had quite a few challenges with the original cat I created, for now focusing on learning.

Head Decoration Code
Index.html

<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>

CatSetting.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
}

$( 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)

});


//Radom cat DNA data
function randomCat(){
  var dna = randomDNA()
    //Rendering Cat
    renderCat(dna)
}

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 dna
}

function renderCat(dna){
    headColor(colors[dna.headColor],dna.headColor)
    $('#bodycolor').val(dna.headColor)
    mouthAndBelly(colors[dna.mouthColor],dna.mouthColor)
    $('#mouthcolor').val(dna.mouthColor)
    eyeColor(colors[dna.eyesColor],dna.eyesColor)
    $('#eyecolor').val(dna.eyesColor)
    earsAndPaw(colors[dna.earsColor],dna.earsColor)
    $('#earcolor').val(dna.earsColor)
    eyeVariation(dna.eyesShape)
    $('#shape').val(dna.eyesShape)
    decorationVariation(dna.decorationPattern)
    $('#decoration').val(dna.decorationPattern)
    midColor(colors[dna.decorationMidcolor],dna.decorationMidcolor)   
    $('#decorationmiddle').val(dna.decorationMidcolor)
    SidesColor(colors[dna.decorationSidescolor],dna.decorationSidescolor)
    $('#decorationsides').val(dna.decorationSidescolor)
    animationVariation(dna.animation)
    $('#animation').val(dna.animation)
    $('#dnaspecial').html(dna.lastNum)
}



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

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

})

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

})

$('#earcolor').change(()=>{
  var colorVal = $('#earcolor').val()
  earsAndPaw(colors[colorVal],colorVal)

})

// Changing cattributes

//Eye shape

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

})

// Decoration

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

// Decoration colors

// Middle color

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


// Sides color

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

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 mouthAndBelly(color,code) {
    $('.cat__mouth-contour, .cat__tail, .cat_chest_inner').css('background', '#' + color)  
    $('#muthcode').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 earsAndPaw(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) 
}

//Middle decoration color
function midColor(color,code) {
    $('.cat__head-dots').css('background', '#' + color)
    $('#midcode').html('code: '+code)
    $('#dnadecorationMid').html(code)
}

//Sides decoration color
function SidesColor(color,code) {
    $('.cat__head-dots_first').css('background', '#' + color)
    $('.cat__head-dots_second').css('background', '#' + color)
    $('#sidecode').html('code: '+code)
    $('#dnadecorationSides').html(code)
}



//Variation functions for range-bars

//8 eye types

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('Cute')
                eyesType2()
                break
        case 4:
                normalEyes()
                $('#eyeName').html('Watching')
                return eyesType3()            
                break
        case 5:
                normalEyes()
                $('#eyeName').html('Night eyes')
                return eyesType4()            
                break
        case 6:
                normalEyes()
                 $('#eyeName').html('Wonder down')
                return eyesType5()            
                break
        case 7:
                normalEyes()
                 $('#eyeName').html('Wonder up')
                return eyesType6()            
                break
        case 8:
                normalEyes()
                $('#eyeName').html('Circle')
                return eyesType7()            
                break
             }
        }
                
//8 decoration Types
function decorationVariations(number) {
$('#dnadecoration').html(num)
    switch (num) {
        case 1:
            $('#decorationName').html('Basic')
            normaldecoration()
            break
        case 2:
            $('#decorationName').html('Inverted')
            decorationType1()
            break
        case 3:
            $('#decorationName').html('Twisted')
            decorationType2()
            break
        case 4:
            $('#decorationName').html('Uniform')
            decorationType3()
            break
        case 5:
            $('#decorationName').html('Uniform twist')
            decorationType4()
            break
        case 6:
            $('#decorationName').html('Tribal')
            decorationType5()
            break
        case 7:
            $('#decorationName').html('Propeller')
            decorationType6()
            break
        case 8:
            $('#decorationName').html('Single')
            decorationType7()
            break
    }
}
2 Likes