Assignment - Cattributes

Index.html

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

        <script type="text/javascript" src="assets/js/jquery-3.4.1.js"></script>
        <link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
        <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/dogs.css">
        <link rel="stylesheet" href="assets/css/colors.css">
        <link rel="stylesheet" href="assets/css/factory.css">
        <link rel="stylesheet" href="assets/css/frontend.css">
    </head>
    <body>
        <div class="container p-5">
            <div align="center">
                <h1 class="c-white">Crypto Doggies Factory</h1>
                <p class="c-white">Create your custom Doggy</p>
            </div>
        </div>
        <div class="row">
            <div class="col-12 col-lg-6 catBox light-b-shadow">
                <div class="container doggy-container">
                    <div class="bubble">
                        <div class="ear-left">
                            <div class="ear"></div>
                        </div>
                        <div class="ear-right">
                            <div class="ear"></div>
                        </div>
                        <div class="head">
                            <div id="mid" class="head-dots">
                                <div id="leftDot" class="head-dots_first"></div>
                                <div id="rightDot" class="head-dots_second"></div>
                            </div>
                        </div>
                        <div class="dog"></div>
                        <div class="eyes"></div>
                        <div class="nose"></div>
                        <div class="left mouth"></div>
                        <div class="right mouth"></div>
                        <div class="tongue"></div>
                    </div>
                </div>
                <br>
                <div class="dnaDiv" id="dogDNA">
                    <b>
                            DNA:
                            <!-- Colors -->
                            <span id="dnabody"></span>
                            <span id="dnaeyes"></span>
                            <span id="dnaears"></span>
                            <span id="dnamouth"></span>
                            <span id="dnasky"></span>
                            <span id="dnabubble"></span>
                            
                            <!-- Cattributes -->
                            <span id="dnashape"></span>
                            <span id="dnadecoration"></span>
                            <span id="dnadecorationMid"></span>
                            <span id="dnadecorationSides"></span>
                            <span id="dnadanimation"></span>
                            <span id="dnaspecial"></span>
                        </b>
                </div>
            </div>
            <div class="col-12 col-lg-6 cattributes light-b-shadow" >
                <!-- Cat colors -->
                <div id="catColors">
                    <div class="form-group">
                        <label for="formControlRange"><b>Head Color</b><span class="badge badge-dark ml-2" id="headcode"></span></label>
                        <input type="range" min="10" max="98" class="form-control-range" id="bodycolor">
                        <br>
                    </div>   
                    <div class="form-group">
                        <label for="formControlRange"><b>Eye Color</b><span class="badge badge-dark ml-2" id="eyecode"></span></label>
                        <input type="range" min="10" max="98" class="form-control-range" id="eyesColor">
                        <br>
                    </div>     
                    <div class="form-group">
                        <label for="formControlRange"><b>Ear Color</b><span class="badge badge-dark ml-2" id="earscode"></span></label>
                        <input type="range" min="10" max="98" class="form-control-range" id="earsColor">
                        <br>
                    </div>    
                    <div class="form-group">
                        <label for="formControlRange"><b>Mustache Color</b><span class="badge badge-dark ml-2" id="mouthcode"></span></label>
                        <input type="range" min="10" max="98" class="form-control-range" id="mouthColor">
                        <br>
                    </div>    
                    <div class="form-group">
                        <label for="formControlRange"><b>Sky Color</b><span class="badge badge-dark ml-2" id="skycode"></span></label>
                        <input type="range" min="10" max="98" class="form-control-range" id="skyColor">
                        <br>
                    </div>    
                    <div class="form-group">
                        <label for="formControlRange"><b>Bubble Color</b><span class="badge badge-dark ml-2" id="bubblecode"></span></label>
                        <input type="range" min="10" max="98" class="form-control-range" id="bubbleColor">
                        <br>
                    </div>
                    <div class="form-group">
                        <label for="formControlRange"><b>Eye Shape</b><span class="badge badge-dark ml-2" id="eyeName"></span></label>
                        <input type="range" min="1" max="7" class="form-control-range" id="eyeshape">
                        <br>
                    </div>
                    <div class="form-group">
                        <label for="formControlRange"><b>Patch Decoration</b><span class="badge badge-dark ml-2" id="decorationName"></span></label>
                        <input type="range" min="1" max="5" class="form-control-range" id="decorationstyle">
                        <br>
                    </div>
                    <div class="form-group">
                        <label for="formControlRange"><b>Patch Middle Color</b><span class="badge badge-dark ml-2" id="decorationMidCode"></span></label>
                        <input type="range" min="10" max="98" class="form-control-range" id="decMidColor">
                        <br>
                    </div>
                    <div class="form-group">
                        <label for="formControlRange"><b>Patch Side Colors</b><span class="badge badge-dark ml-2" id="decorationSidesCode"></span></label>
                        <input type="range" min="10" max="98" class="form-control-range" id="decSideColor">
                        <br>
                    </div>
                    <div class="form-group">
                        <label for="formControlRange"><b>Animations</b><span class="badge badge-dark ml-2" id="animationName"></span></label>
                        <input type="range" min="1" max="7" class="form-control-range" id="animation">
                        <br>
                    </div>
                </div>
                </div>
            </div>
        </div>
        <br> 
        <footer align="left">
            <p>Victor Valdez GoodGains Exchange 2022</p>
        </footer>
    </body>
        <script src="assets/js/colors.js"></script>
        <script src="assets/js/dogSettings.js"></script>
        <script src="assets/js/dogFactory.js"></script>
</html>

dogs.css

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

.doggy-container{
    position: relative;
    margin: auto;
    background-color: #fda47bd9;
    height: 375px;
    width: 375px;
}
.bubble{
    width: 360px;
    height: 360px;
    background: #0084ffa8;
    border-radius: 50%;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: auto;
}
.dog{
    width: 220px;
    height: 90px;
    background: #fcefcd;
    border-radius: 60px;
    position: absolute;
    left: 0;
    right: 0;
    bottom: 90px;
    margin: auto;
    z-index: 1;
    overflow: hidden;
}
.head{
    width: 170px;
    height: 120px;
    background: #fcefcd;
    border-radius: 70px 70px 0 0;
    position: absolute;
    left: 0;
    right: 0;
    top: 70px;
    margin: auto;
    overflow: hidden;
}

.head-dots {
    position: absolute;
    height: 30px;
    width: 10px;
    background: #0084ffa8;
    left: 78px;
    top: 20px;
    border-radius: 50% 50% 50% 50%;
    transform: rotate(360deg);
}

.head-dots_first {
    position: absolute;
    height: 30px;
    width: 10px;
    background: #0084ffa8;
    right: 20px;
    bottom: 5px;
    border-radius: 50% 50% 50% 50%;
    transform: rotate(360deg);
}

.head-dots_second {
    position: absolute;
    height: 30px;
    width: 10px;
    background: #0084ffa8;
    left: 20px;
    bottom: 5px;
    border-radius: 50% 50% 50% 50%;
    transform: rotate(360deg);
}

.eyes{
    width: 16px;
    height: 16px;
    background: #0084ffa8;
    border-radius: 50%;
    position: absolute;
    left: 140px;
    bottom: 180px;
    z-index: 1;
    box-shadow: 65px 0 inherit;
    animation: blink 3s infinite linear;
}
@keyframes blink{
    4%{
        transform: scaleY(.1);
    }
    15%{
        transform: scaleY(1);
    }
}
.nose{
    width: 44px;
    height: 24px;
    background: #89766c;
    border-radius: 20% 20% 50% 50% / 25% 25% 70% 70%;
    position: absolute;
    left: 0;
    right: 0;
    bottom: 153px;
    margin: auto;
    z-index: 3;
}
.nose:before{
    content: '';
    width: 24px;
    height: 10px;
    background: #a58f82;
    border-radius: inherit;
    position: absolute;
    left: 0;
    right: 0;
    top: 4px;
    margin: auto;
}
.mouth{
    width: 50px;
    height: 25px;
    background: #9a7b6a;
    border: 5px solid #9a7b6a;
    border-bottom-left-radius: 30px;
    border-bottom-right-radius: 30px;
    position: absolute;
    bottom: 134px;			
    z-index: 2;		
}
.mouth:before{
    content: '';
    width: 5px;
    height: 5px;
    background: inherit;
    border-radius: 50%;
    position: inherit;
    top: -2.5px;
}
.left.mouth{
    left: 132.5px;
}
.right.mouth{
    right: 132.5px;
}
.left.moutheft:before{
    left: -5px;
}
.right.mouth:before{
    right: -5px;
}
.tongue{
    width: 36px;
    height: 40px;
    background: #ffc7d0;
    border-radius: 0 0 50px 50px;
    position: absolute;
    left: 0;
    right: 0;
    bottom: 108px;
    margin: auto;
    z-index: 1;
}
.tongue:before{
    content: '';
    width: 5px;
    height: 36px;
    background: #fea4b0;
    border-radius: 10px;
    position: inherit;
    left: 0;
    right: 0;
    margin: auto;
}
.ear{
    position: absolute;
    background: #89766c;
    z-index: 1;
}
.ear:before,
.ear:after{
    content: '';
    position: inherit;
    background: inherit;
}
.ear,
.ear:before,
.ear:after{
    width: 50px;
    height: 50px;
    border-top-right-radius: 30%;
}
.ear{
    transform: rotate(-60deg) skewX(-30deg) scale(1, .866);
}
.ear:before{
    transform: rotate(-135deg) skewX(-45deg) scale(1.414, .707) translate(0, -50%);
}
.ear:after{
    transform: rotate(135deg) skewY(-45deg) scale(.707, 1.414) translate(50%);
}
.ear-left{
    position: absolute;
    left: 104px;
    top: 69px;
    transform: rotate(30deg);
    z-index: 1;
}
.ear-right{
    position: absolute;
    right: 150px;
    top: 90px;
    transform: rotate(-30deg);
    z-index: 1;
}

dogsSettings.js

var colors = Object.values(allColors())

var defaultDNA = {
    "headcolor" : 33,
    "mouthColor" : 20,
    "eyesColor" : 74,
    "earsColor" : 23,
    "skyColor": 88,
    "bubbleColor": 73,
    //Cattributes
    "eyesShape" : 1,
    "decorationPattern" : 1,
    "decorationMidcolor" : 13,
    "decorationSidescolor" : 13,
    "animation" :  1,
    "lastNum" :  1
    }

// when page load
$( document ).ready(function() {
  $('#dnabody').html(defaultDNA.headColor);
  $('#dnaeyes').html(defaultDNA.eyesColor);
  $('#dnaears').html(defaultDNA.earsColor);
  $('#dnamouth').html(defaultDNA.mouthColor);
  $('#dnasky').html(defaultDNA.skyColor);
  $('#dnabubble').html(defaultDNA.bubbleColor);
    
  $('#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 += $('#dnasky').html()
    dna += $('#dnabubble').html()
    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)
    eyesColor(colors[dna.eyesColor],dna.eyesColor)
    $('#eyesColor').val(dna.eyesColor)
    earsColor(colors[dna.earsColor],dna.earsColor)
    $('#earsColor').val(dna.earsColor)
    mouthColor(colors[dna.mouthColor],dna.mouthColor)
    $('#mouthColor').val(dna.mouthColor)
    skyColor(colors[dna.skyColor],dna.skyColor)
    $('#skyColor').val(dna.skyColor)
    bubbleColor(colors[dna.bubbleColor],dna.bubbleColor)
    $('#bubbleColor').val(dna.bubbleColor)
    eyeVariation(dna.eyesShape)
    $('eyeshape').val(dna.eyesShape)
    decorationVariation(dna.decorationPattern)
    $('#decorationstyle').val(dna.decorationPattern)
    decorationMidColorVar([dna.decorationMidcolor],dna.decorationMidcolor)
    $('#decMidColor').val(dna.decorationMidcolor)
    decorationSidesColorVar([dna.decorationSidescolor],dna.decorationSidescolor)
    $('#decSideColor').val(dna.decorationSidescolor)
} 

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

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

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

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

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

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

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

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

$('#decMidColor').change(()=>{
  var colorVal = $('#decMidColor').val()
  console.log(colorVal)
  decorationMidColorVar(colors[colorVal],colorVal)
})

$('#decSideColor').change(()=>{
  var colorVal = $('#decSideColor').val()
  console.log(colorVal)
  decorationSidesColorVar(colors[colorVal],colorVal)
})

dogFactory.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 the dog code.
function headColor(color,code) {
    $('.head, .dog').css('background', '#' + color)  //This changes the color of the dog
    $('#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
}

//This function is for the color of the eyes
function eyesColor(color,code) {
    $('.eyes').css('background', '#' + color)  //This changes the color of the eyes
    $('.eyes').css('box-shadow', '65px' + ' 0' + ' #' + color)
    $('#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
}

//This function is for the color of the ears
function earsColor(color,code) {
    $('.ear').css('background', '#' + color)  //This changes the color of the eyes
    $('#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
}

//This function is for the color of the patch and mustache
function mouthColor(color,code) {
    $('.mouth').css('background', '#' + color)  //This changes the color of the eyes
    $('.mouth').css('border', '5px ' + 'solid ' + '#' + color)
    $('#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
}
//This function is for the color of the sky
function skyColor(color,code) {
    $('.doggy-container').css('background', '#' + color)  //This changes the color of the eyes
    $('#skycode').html('code: ' + code) //This updates text of the badge next to the slider
    $('#dnasky').html(code) //This updates the body color part of the DNA that is displayed below the cat
}
//This function is for the color of the bubble
function bubbleColor(color,code) {
    $('.bubble').css('background', '#' + color)  //This changes the color of the eyes
    $('#bubblecode').html('code: ' + code) //This updates text of the badge next to the slider
    $('#dnabubble').html(code) //This updates the body color part of the DNA that is displayed below the cat
}

function decorationMidColorVar(color,code) {
    console.log(color + code)
    $('.head-dots').css('background', '#' + color)  //This changes the color of Mid head decoration
    $('#decorationMidCode').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 decorationSidesColorVar(color,code) {
    console.log(color + code)
    $('.head-dots_first, .head-dots_second').css('background', '#' + color)  //This changes the color of Sides head decoration
    $('#decorationSidesCode').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnadecorationSides').html(code) //This updates the body color part of the DNA that is displayed below the cat
}


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

    $('#dnashape').html(num)
    switch (num) {
        case 1:
            normalEyes()
            $('#eyeName').html('Basic')
            break
        case 2:
            normalEyes()
            $('#eyeName').html('Chill')
            return eyesType1()
            break
        case 3:
            normalEyes()
            $('#eyeName').html('Suprised')
            return eyesType2()
            break    
        case 4:
            normalEyes()
            $('#eyeName').html('Tiny')
            return eyesType3()
            break   
        case 5:
            normalEyes()
            $('#eyeName').html('Detective')
            return eyesType4()
            break
        case 6:
            normalEyes()
            $('#eyeName').html('Stoner')
            return eyesType5()
            break
        case 7:
            normalEyes()
            $('#eyeName').html('Cyclopes')
            return eyesType6()
            break                               
    }
}

function decorationVariation(num) {
    $('#dnadecoration').html(num)
    switch (num) {
        case 1:
            $('#decorationName').html('Basic')
            normaldecoration()
            break
            case 2:
                normaldecoration()
                $('#decorationName').html('Tribal')
                return decorationType1()
                break   
            case 3:
                normaldecoration()
                $('#decorationName').html('Big')
                return decorationType2()
                break 
            case 4:
                normaldecoration()
                $('#decorationName').html('Funny')
                return decorationType3()
                break   
            case 5:
                normaldecoration()
                $('#decorationName').html('Round')
                return decorationType4()
                break                
    }
}

function normalEyes() {
    $('.eyes').css('border', 'none')
    $('.eyes').css('height', '16px')
    $('.eyes').css('width', '16px')
    $('.eyes').css('border-radius', '50%')
    $('.eyes').css('left', '140px')
    $('.eyes').css('bottom', '180px')
    $('.eyes').css('box-shadow', '65px 0 inherit')

}
function eyesType1() {
    normalEyes()
    $('.eyes').css('width', '20px')
    $('.eyes').css('height', '10px')
}
function eyesType2() {
    normalEyes()
    $('.eyes').css('width', '20px')
    $('.eyes').css('height', '40px')
}
function eyesType3() {
    normalEyes()
    $('.eyes').css('width', '5px')
    $('.eyes').css('height', '5px')
}
function eyesType4() {
    normalEyes()
    $('.eyes').css('width', '50px')
    $('.eyes').css('height', '30px')
    $('.eyes').css('left', '121px')
    $('.eyes').css('bottom', '170px')
    $('.eyes').css('border-radius', '0 0 50% 50%')
}
function eyesType5() {
    normalEyes()
    $('.eyes').css('width', '50px')
    $('.eyes').css('height', '22px')
    $('.eyes').css('left', '124px')
    $('.eyes').css('bottom', '179px')
    $('.eyes').css('border-radius', '144% 138% 50% 50%')
}
function eyesType6() {
    normalEyes()
    $('.eyes').css('width', '69px')
    $('.eyes').css('height', '50px')
    $('.eyes').css('left', '144px')
    $('.eyes').css('bottom', '184px')
    $('.eyes').css('border-radius', '500%')
    $('.eyes').css('border', '10px solid #ffffff')
    $('.eyes').css('box-shadow', 'none')
}


function normaldecoration() {
    //Remove all style from other decorations
    //In this way we can also use normalDecoration() to reset the decoration style
    $('.head-dots').css({ "transform": "rotate(360deg)", "height": "30px", "width": "10px", "top": "20px", "left": "78px", "border-radius": "50% 50% 50% 50%" })
    $('.head-dots_first').css({ "transform": "rotate(360deg)", "height": "30px", "width": "10px", "bottom": "5px", "right": "20px", "border-radius": "50% 50% 50% 50%" })
    $('.head-dots_second').css({ "transform": "rotate(360deg)", "height": "30px", "width": "10px", "bottom": "5px", "left": "20px", "border-radius": "50% 50% 50% 50%" })
}

function decorationType1() {
    //Remove all style from other decorations
    //In this way we can also use normalDecoration() to reset the decoration style
    $('.head-dots').css({ "transform": "rotate(360deg)", "height": "40px", "width": "10px", "top": "20px", "left": "78px", "border-radius": "50% 50% 50% 50%" })
    $('.head-dots_first').css({ "transform": "rotate(323deg)", "height": "40px", "width": "10px", "bottom": "5px", "right": "20px", "border-radius": "50% 50% 50% 50%" })
    $('.head-dots_second').css({ "transform": "rotate(215deg)", "height": "40px", "width": "10px", "bottom": "5px", "left": "20px", "border-radius": "50% 50% 50% 50%" })
}

function decorationType2() {
    //Remove all style from other decorations
    //In this way we can also use normalDecoration() to reset the decoration style
    $('.head-dots').css({ "transform": "rotate(360deg)", "height": "40px", "width": "30px", "top": "20px", "left": "70px", "border-radius": "50% 50% 50% 50%" })
    $('.head-dots_first').css({ "transform": "rotate(270deg)", "height": "40px", "width": "30px", "bottom": "5px", "right": "20px", "border-radius": "50% 50% 50% 50%" })
    $('.head-dots_second').css({ "transform": "rotate(225deg)", "height": "40px", "width": "30px", "bottom": "5px", "left": "20px", "border-radius": "50% 50% 50% 50%" })
}

function decorationType3() {
    //Remove all style from other decorations
    //In this way we can also use normalDecoration() to reset the decoration style
    $('.head-dots').css({ "transform": "rotate(360deg)", "height": "40px", "width": "10px", "top": "20px", "left": "78px", "border-radius": "50% 50% 50% 50%" })
    $('.head-dots_first').css({ "transform": "rotate(323deg)", "height": "40px", "width": "10px", "bottom": "5px", "right": "20px", "border-radius": "50% 50% 50% 50%" })
    $('.head-dots_second').css({ "transform": "rotate(215deg)", "height": "40px", "width": "10px", "bottom": "5px", "left": "20px", "border-radius": "50% 50% 50% 50%" })
}

function decorationType4() {
    //Remove all style from other decorations
    //In this way we can also use normalDecoration() to reset the decoration style
    $('.head-dots').css({ "transform": "rotate(360deg)", "height": "40px", "width": "30px", "top": "20px", "left": "70px", "border-radius": "50% 50% 50% 50%" })
    $('.head-dots_first').css({ "transform": "rotate(270deg)", "height": "40px", "width": "30px", "bottom": "5px", "right": "20px", "border-radius": "50% 50% 50% 50%" })
    $('.head-dots_second').css({ "transform": "rotate(225deg)", "height": "40px", "width": "30px", "bottom": "5px", "left": "20px", "border-radius": "50% 50% 50% 50%" })
}
2 Likes

Hello everyone,

Been silent for a few months, but Iā€™m back in business.
My plan was that the inner decoration color is always inverted to the two outer decoration.
I did not make 2 sliders for the inner and outer decoration color, but just chose for 1, because the color will always be different than the outer circle

Further on, I was just messing around with the position of the decoration. As you can seeā€¦
Anyhow, hereā€™s my code.

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 mouthAndBellyColor(color,code) {
    $('.cat__mouth-contour, cat__tail, .cat__chest_inner').css('background', '#' + color)  //This changes the mouth color of the cat
    $('#mouthcode').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnamouth').html(code) //This updates the body color part of the DNA that is displayed below the cat
}
function eyeColor(color,code) {
    $('.pupil-left, .pupil-right').css('background', '#' + color)  //This changes the eye color of the cat
    $('#eyecode').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnaeyes').html(code) //This updates the body color part of the DNA that is displayed below the cat
}
function earsAndPaw(color,code) {
    $('.cat__ear--left, .cat__ear--right, .cat__paw--left, .cat__paw--right, .cat__paw-right_inner, .cat__paw-left_inner').css('background', '#' + color)  //This changes the ear color of the cat
    $('#earscode').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnaears').html(code) //This updates the body color part of the DNA that is displayed below the cat
}
function decorationColor(color, code) {
    $('#midDot, .cat__head-dots_first, .cat__head-dots_second').css('background','#' + color)
    $('#decorationColor').html('code: '+code)
    &('#dnadecorationcolor').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()//Reset the settings so no errors could occur
            $('#eyeName').html('Chill')//set the badge to "Chill"
            eyesType1() //Set border to change the shape of the eyes
            break
        case 3:
            normalEyes()//Reset the settings so no errors could occur
            $('#eyeName').html('Thinking')//set the badge to "Chill"
            eyesType2() //Set border to change the shape of the eyes
            break
            case 4:
                normalEyes()//Reset the settings so no errors could occur
                $('#eyeName').html('Professor')//set the badge to "Chill"
                eyesType3() //Set border to change the shape of the eyes
                break    
        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:
            $('#decorationName').html('Croscy')//set the badge to Biggie
            decorationType1()
            break
        case 3:
            $('#decorationName').html('Meowthy')
            decorationType2()
            break    
        case 4:
            $('#decorationName').html('Nothing')
            decorationType3()
            break
        case 5:
            $('#decorationName').html('Lefty')
            decorationType4()
            break
        case 6:
            $('#decorationName').html('Mirrory')
            decorationType5()
            break
        case 7:
            $('#decorationName').html('Browser')
            decorationType6()
            break
        case 8:
            $('#decorationName').html('Strange')
            decorationType7()
            break
        }
}

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

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

function eyesType2(){
    $('.cat__eye').find('span').css('border-bottom','15px solid')
}
function eyesType3(){
    $('.cat__eye').find('span').css('border-bottom','5px solid')
    $('.cat__eye--left').find('span').css('transform','scale(1.5)', 'border-top','7px solid')
    $('.cat__eye--right').find('span').css('transform','scale(1.2)')
}


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

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

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

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

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

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

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

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

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

catSettings.js


var colors = Object.values(allColors())

var defaultDNA = {
    "headcolor" : 10,
    "mouthColor" : 13,
    "eyesColor" : 96,
    "earsColor" : 10,
    //Cattributes
    "eyesShape" : 1,
    "decorationPattern" : 1,
    "decorationColor" : 96,
    "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)
    $('#dnadecorationcolor').html(defaultDNA.decorationMidcolor)
    $('#dnaanimation').html(defaultDNA.animation)
    $('#dnaspecial').html(defaultDNA.lastNum)

  renderCat(defaultDNA)
});

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

    return parseInt(dna)
}

function renderCat(dna){
    headColor(colors[dna.headcolor],dna.headcolor)
    $('#bodycolor').val(dna.headcolor)
    mouthAndBellyColor(colors[dna.mouthcolor],dna.mouthcolor)
    $('#mouthcolor').val(dna.mouthcolor)
    eyeColor(colors[dna.eyecolor],dna.eyecolor)
    $('#eyecolor').val(dna.eyecolor)
    earsAndPaw(colors[dna.earsColor],dna.earsColor)
    $('#earcolor').val(dna.earsColor)
}

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

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="dnadecorationcolor"></span>
                         <span id="dnadanimation"></span>
                         <span id="dnaspecial"></span>
                    </b>
                </div>
            </div>
            <div class="col-lg-7 cattributes m-2 light-b-shadow">

<!-- Cat colors -->
<div id="catColors">
                <div class="form-group">
                    <label for="formControlRange"><b>Head and body</b><span class="badge badge-dark ml-2" id="headcode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="bodycolor">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Mouth, Body & Tail</b><span class="badge badge-dark ml-2" id="mouthcode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="mouthcolor">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Eye Color</b><span class="badge badge-dark ml-2" id="eyecode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="eyecolor">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Ears & Paws</b><span class="badge badge-dark ml-2" id="earscode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="earcolor">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Eyes Shape</b><span class="badge badge-dark ml-2" id="eyeName"></span></label>
                    <input type="range" min="1" max="7" class="form-control-range" id="eyeshape">
                </div>   
                <div class="form-group">
                    <label for="formControlRange"><b>Decorative Pattern</b><span class="badge badge-dark ml-2" id="decorationName"></span></label>
                    <input type="range" min="1" max="7" class="form-control-range" id="decorationvariation">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Decorative Color</b><span class="badge badge-dark ml-2" id="decorationColor"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="decorationcolor">
                </div>             
            </div>

            </div>

            </div>
            <br>

        </div>



    </div>
    <footer align="left">
        <p>Moralis Academy Bootcamp July 2020</p>
    </footer>

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

</html>

Hey @Sil ! Can you please send a screen shot of your result ? And also a picture that describe what you want to do.

1 Like

The plan was that the outer two dots always have another color than the inner dot.
I found it prettier if the color was inverted in comparison to the other color.

Outer dots => White
Inner dot => Black

Outer dots => Blue
Inner dot => Orange

Outer dots => Red
Inner dot => Green

Hope this explains it better.

1 Like

Currently looking like:

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="ears">
                        <div class="ear left_ear">
                            <div class="inner-ear"></div>
                        </div>
                        <div class="ear right_ear">
                            <div class="inner-ear"></div>
                        </div>
                    </div>
                    <div id="head">
                        <div class="whisker_left whiskers one"></div>
                        <div class="whisker_left whiskers"></div>
                        <div class="whisker_left whiskers three"></div>
                        <div class="whisker_right whiskers R-one"></div>
                        <div class="whisker_right whiskers R-two"></div>
                        <div class="whisker_right whiskers R-three"></div>
                        <div class="eyes">
                            <div class="eye">
                                <div class="pupils">
                                    <div class="pupil_reflect"></div>
                                </div>
                            </div>
                            <div class="eye">
                                <div class="pupils">
                                    <div class="pupil_reflect"></div>
                                </div>
                            </div>
                        </div>
                        <div class="nose"></div>
                        <div class="cat__mouth-left"></div>
                        <div class="cat__mouth-right"></div>
                        <div class="head_mark"></div>
                        <div class="head_mark_2"></div>
                        <div class="head_mark_3"></div>
                    </div>
                    <div class="body">
                        <div class="leg leg-one"></div>
                        <div class="leg leg-two"></div>
                        <div class="leg leg-three"></div>
                        <div class="leg leg-four"></div>
                        <div class="belly"></div>
                    </div>
                    <div class="tail"></div>
                </div>
                <br>
                <div class="dnaDiv" id="catDNA">
                    <b>
                        DNA:
                        <!-- Colors -->
                         <span id="dnahead"></span>
                         <span id="dnaearsandbody"></span>
                         <span id="dnapaws"></span>
                         <span id="dnaeyes"></span>
                        
                         <!-- Cattributes -->
                         <span id="dnashape"></span>
                         <span id="dnadecoration"></span>
                         <span id="dnadecorationMid"></span>
                         <span id="dnadecorationSides"></span>
                         <span id="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 Tail</b><span class="badge badge-dark ml-2" id="headcode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="bodycolor">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Outer Ears and Body</b><span class="badge badge-dark ml-2" id="ear_bodycode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="ear_body">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Paws</b><span class="badge badge-dark ml-2" id="pawscode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="pawscolor">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Eyes</b><span class="badge badge-dark ml-2" id="eyecode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="eyecolor">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Eyes shape</b><span class="badge badge-dark ml-2" id="eyeName"></span></label>
                    <input type="range" min="1" max="7" class="form-control-range" id="eyeshape">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Marking Style</b><span class="badge badge-dark ml-2" id="markingName"></span></label>
                    <input type="range" min="1" max="4" class="form-control-range" id="marking">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Big Marking</b><span class="badge badge-dark ml-2" id="bigMarkingCode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="bigmarking">
                </div>
                <div class="form-group">
                    <label for="formControlRange"><b>Little Markings</b><span class="badge badge-dark ml-2" id="littleMarkingCode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="littlemarking">
                </div>
            </div>

            </div>

            </div>
            <br>

        </div>



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

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

</html>

catSettings.js

var colors = Object.values(allColors())

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

// when page load
$( document ).ready(function() {
  $('#dnahead').html(defaultDNA.headColor);
  $('#dnaearsbody').html(defaultDNA.mouthColor);
  $('#dnapaws').html(defaultDNA.pawsColor);
  $('#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 += $('#dnahead').html()
    dna += $('#dnaearsandbody').html()
    dna += $('#dnapaws').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)
    earBodyColor(colors[dna.earsBodyColor],dna.earsBodyColor) 
    $('#ear_body').val(dna.earsBodyColor)
    pawsColor(colors[dna.pawsColor],dna.pawsColor)
    $('#pawscolor').val(dna.pawsColor)
    eyesColor(colors[dna.eyesColor],dna.eyesColor)
    $('#eyecolor').val(dna.eyesColor)
}

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

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

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

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

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

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

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

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

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) {
    $('#head, .tail').css('background', '#' + color)  //This changes the color of the cat
    $('#headcode').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnahead').html(code) //This updates the body color part of the DNA that is displayed below the cat
}

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

function pawsColor(color,code) {
    $('.leg').css('background', '#' + color)
    $('#pawscode').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnapaws').html(code) //This updates the body color part of the DNA that is displayed below the cat
}

function eyesColor(color,code) {
    $('.pupils').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 bigMarkingColor(color,code) {
    $('.head_mark').css('background', '#' + color)  //This changes the color of the cat
    $('#bigMarkingCode').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 littleMarkingColor(color,code) {
    $('.head_mark_2 , .head_mark_3').css('background', '#' + color)  //This changes the color of the cat
    $('#littleMarkingCode').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnadecorationSides').html(code) //This updates the body color part of the DNA that is displayed below the cat
}


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

    $('#dnashape').html(num)
    switch (num) {
        case 1:
            normalEyes()
            $('#eyeName').html('Basic')
            break
        case 2:
            normalEyes() //reset
            $('#eyeName').html('Shy')
            eyesType2()
            break
        case 3:
            normalEyes() //reset
            $('#eyeName').html('Chill')
            eyesType3()
            break
        case 4:
            normalEyes() //reset
            $('#eyeName').html('Hypnotized')
            eyesType4()
            break
        case 5:
            normalEyes() //reset
            $('#eyeName').html('Right Gaze')
            eyesType5()
            break
        case 6:
            normalEyes() //reset
            $('#eyeName').html('Left Gaze')
            eyesType6()
            break
        case 7:
            normalEyes() //reset
            $('#eyeName').html('Happy')
            eyesType7()
            break
    }
}

function markingVariation(num) {
    $('#dnadecoration').html(num)
    switch (num) {
        case 1:
            $('#markingName').html('Basic')
            normalmarking()
            break
        case 2:
            normalmarking()
            $('#markingName').html('Slanted')
            markingType2()
            break
        case 3:
            normalmarking()
            $('#markingName').html('Slanted two')
            markingType3()
            break
        case 4:
            normalmarking()
            $('#markingName').html('Strange')
            markingType4()
            break
    }
}
//following functions are different eye shapes
async function normalEyes() {
    await $('.pupils').css('border', 'none')
    $('.pupil_reflect').css('background', 'white')
    $('.pupil_reflect').css('left', '22px')
    $('.pupil_reflect').css('top', '22px')
}

async function eyesType2(){
    await $('.pupils').css('border-top', '8px solid')
}

async function eyesType3(){
    await $('.pupils').css('border-bottom', '15px solid')
}

async function eyesType4(){
    await $('.pupils').css('border', '10px solid')
    $('.pupil_reflect').css('background', 'transparent')
}

async function eyesType5(){
    await $('.pupils').css('border-left', '7px solid')
    $('.pupil_reflect').css('left', '18px')
}

async function eyesType6(){
    await $('.pupils').css('border-right', '7px solid')
    $('.pupil_reflect').css('left', '12px')
}
async function eyesType7(){
    await $('.pupils').css('border-bottom', '17px solid')
    $('.pupil_reflect').css('top', '10px')
}



//following functions are different marking combinations
async function normalmarking() {
    //Remove all style from other decorations
    //In this way we can also use normalDecoration() to reset the decoration style
    $('.head_mark').css({ "transform": "rotate(0deg)", "height": "40px", "width": "14px", "top": "-150px", "left": "98px", "border-radius": "30%" })
    $('.head_mark_2').css({ "transform": "rotate(0deg)", "height": "20px", "width": "10px", "top": "-180px", "left": "80px", "border-radius": "30%" })
    $('.head_mark_3').css({ "transform": "rotate(0deg)", "height": "20px", "width": "10px", "top": "-200px", "left": "120px", "border-radius": "30%" })
}

async function markingType2(){
    $('.head_mark_2').css({ "transform": "rotate(10deg)"})
    $('.head_mark_3').css({ "transform": "rotate(-10deg)"})
}

async function markingType3(){
    $('.head_mark_2').css({ "transform": "rotate(-10deg)"})
    $('.head_mark_3').css({ "transform": "rotate(10deg)"})
}

async function markingType4(){
    $('.head_mark_2 , .head_mark_3').css({ "transform": "rotate(30deg)"})
    $('.head_mark').css({ "transform": "rotate(30deg)"})
}
1 Like

Index.html

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


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

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

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

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

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

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

        <div class="form-group">
            <label for="formControlRange"><b>Inner Dot Color</b><span class="badge badge-dark ml-2" id="dotName3"></span></label>
            <input type="range" min="1" max="98" class="form-control-range" id="dotcolor2">
        </div>
</id>
        
            </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)
$('#eyeshape').change(()=>{
  var shape = parseInt($('#eyeshape').val())
  eyeVariation(shape)
})

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

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

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

catFactory.js

function innerDotColor(color,code) {
    $('.cat__head-dots_first, .cat__head-dots_second').css('background', '#' + color)  //This changes the color of the cat
    $('#dotName2').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 outerDotColor(color,code) {
    $('.cat__head-dots').css('background', '#' + color)  //This changes the color of the cat
    $('#dotName3').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnadecorationSides').html(code) //This updates the body color part of the DNA that is displayed below the cat
}


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

    $('#dnashape').html(num)
    switch (num) {
        case 1:
            normalEyes()
            $('#eyeName').html('Basic')
            break
        case 2:
            normalEyes()
            $('#eyeName').html('Chill')
            eyesType1();
            break
        case 3:
            normalEyes()
            $('#eyeName').html('Cheerful')
            eyesType2();
            break
        case 4:
            normalEyes()
            $('#eyeName').html('squinty')
            eyesType3();
            break
        case 5:
            normalEyes()
            $('#eyeName').html('sleepy')
            eyesType4();
            break
        case 6:
            normalEyes()
            $('#eyeName').html('Cheezin')
            eyesType5();
            break
        case 7:
            normalEyes()
            $('#eyeName').html('breezin')
            eyesType6();
            break
    }
}


async function normalEyes() {
    await $('.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-top', '28px solid');
}

function eyesType4() {
    $('.cat__eye').find('span').css('border-top', '32px solid');
}

function eyesType5() {
    $('.cat__eye').find('span').css('border-top', '10px solid');
}

function eyesType6() {
    $('.cat__eye').find('span').css('border-bottom', '8px solid');
}

function decorationVariation(num) {
    $('#dnadecoration').html(num)
    switch (num) {
        case 1:
            normaldecoration()
            $('#dotName').html('Basic')
            break
        case 2:
            $('#dotName').html('Slightly Tilted')
            decoration2()
            break
        case 3:
            $('#dotName').html('Tilted')
            decoration3()
            break
        case 4:
            $('#dotName').html('Very Tilted')
            decoration4()
            break
        case 5:
            $('#dotName').html('Extremely Tilted')
            decoration5()
            break
    }
}


function decoration2() {
    $('.cat__head-dots_first').css("transform", "rotate(7deg)");
    $('.cat__head-dots_second').css("transform", "rotate(-7deg)");
}

function decoration3() {
    $('.cat__head-dots_first').css("transform", "rotate(15deg)");
    $('.cat__head-dots_second').css("transform", "rotate(-15deg)");
}

function decoration4() {
    $('.cat__head-dots_first').css("transform", "rotate(21deg)");
    $('.cat__head-dots_second').css("transform", "rotate(-21deg)");
}

function decoration5() {
    $('.cat__head-dots_first').css("transform", "rotate(27deg)");
    $('.cat__head-dots_second').css("transform", "rotate(-27deg)");
}

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

Current state of the bear marketplace


index.html

<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Academy Bears </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">Bear-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="hat">
                        <div class="hat-top"></div>
                        <div class="hat-brim"></div>
                    </div>
                    <div class="ears">
                        <div class="ear leftEar">
                            <div class="innerEar"></div>
                        </div>
                        <div class="ear rightEar">
                            <div class="innerEar"></div>
                        </div>
                    </div>
                    <div class="head">
                        <div class="eyes">
                            <div class="eye">
                                <span class="pupils"></span>
                            </div>
                            <div class="eye">
                                <span class="pupils"></span>
                            </div>
                        </div>
                        <div class="nose"></div>
                        <div class="mouth"></div>
                    </div>
                    <div class="body">
                        <div class="frontPaws">
                            <div class="frontPaw leftFrontPaw"></div>
                            <div class="frontPaw rightFrontPaw"></div>
                        </div>
                        <div class="belly"></div>
                        <div class="backPaws">
                            <div class="backPaw leftBackPaw"></div>
                            <div class="backPaw rightBackPaw"></div>
                        </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>
                        
                         <!-- 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 bearAttributes m-2 light-b-shadow">
                <!-- Bear colors -->
                <div id="bearColors">
                <!-- Bear Head and Body -->
                <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>
                <!-- Bear Mouth, Belly and Nose -->
                <div class="form-group">
                    <label for="formControlRange"><b>Mouth, Belly & Nose</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>
                <!-- Bear Pupil Color -->
                <div class="form-group">
                    <label for="formControlRange"><b>Eye Color</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>
                <!-- Bear Inner Ear and Paw Color -->
                <div class="form-group">
                    <label for="formControlRange"><b>Ear & Paw Color</b><span class="badge badge-dark ml-2" id="earscode"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="earscolor">
                </div>

                <!-- Eye Shape -->
                <div class="form-group">
                    <label for="formControlRange"><b>Eye Shape</b><span class="badge badge-dark ml-2" id="eyeName"></span></label>
                    <input type="range" min="1" max="7" class="form-control-range" id="eyesshape">
                </div>
                <!-- Hat Variation -->
                <div class="form-group">
                    <label for="formControlRange"><b>Hat</b><span class="badge badge-dark ml-2" id="decorationName"></span></label>
                    <input type="range" min="1" max="7" class="form-control-range" id="hatshape">
                </div>
                <!-- Pattern Color 1 -->
                <div class="form-group">
                    <label for="formControlRange"><b>Hat Top Color</b><span class="badge badge-dark ml-2" id="decorationColor1"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="hattopcolor">
                </div>
                <!-- Pattern Color 2 -->
                <div class="form-group">
                    <label for="formControlRange"><b>Hat Brim Color</b><span class="badge badge-dark ml-2" id="decorationColor2"></span></label>
                    <input type="range" min="10" max="98" class="form-control-range" id="hatbrimcolor">
                </div>
            </div>

            </div>

            </div>
            <br>

        </div>

    </div>
    <footer align="left">
        <p>Project for NFT Marketplace Course @ Moralis Academy, August 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>

bearFactory.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;
};

//Color Variations
function headColor(color,code) {
    $('.ear, .head, .body').css('background', '#' + color)  //This changes the color of the bear
    $('#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 bear
};

function mouthColor(color,code) {
    $('.mouth, .nose, .belly').css('background', '#' + color) 
    $('#mouthcode').html('code: '+ code) 
    $('#dnamouth').html(code) 
};

function eyesColor(color,code) {
    $('.pupils').css('background', '#' + color)  
    $('#eyescode').html('code: '+ code) 
    $('#dnaeyes').html(code) 
};

function earsColor(color,code) {
    $('.innerEar, .frontPaw, .backPaw').css('background', '#' + color)  
    $('#earscode').html('code: '+ code) 
    $('#dnaears').html(code) 
};

function decorationColor1(color,code) {
    $('.hat-top').css('background', '#' + color)  
    $('#decorationColor1').html('code: '+ code) 
    $('#dnadecorationMid').html(code) 
};

function decorationColor2(color,code) {
    $('.hat-brim').css('background', '#' + color)  
    $('#decorationColor2').html('code: '+ code) 
    $('#dnadecorationSides').html(code) 
};

//Eye Variation
function eyeVariation(num) {
    $('#dnashape').html(num)
    switch (num) {
        case 1:
            normalEyes()
            $('#eyeName').html('Basic')
            break;
        case 2:
            normalEyes()
            $('#eyeName').html('Eyelid down')
            eyesType2()
            break;
        case 3:
            normalEyes()
            $('#eyeName').html('Eyelid up')
            eyesType3()
            break;
        case 4:
            normalEyes()
            $('#eyeName').html('Schock')
            eyesType4()
            break;
        case 5:
            normalEyes()
            $('#eyeName').html('Unset')
            eyesType5()
            break;
        case 6:
            normalEyes()
            $('#eyeName').html('Square')
            eyesType6()
            break;
        case 7:
            normalEyes()
            $('#eyeName').html('Up')
            eyesType7()
            break;
        default:
            $('#eyeName').html('INVALID')
            break;
    }
};
//Hat Variations
function decorationVariation(num) {
    $('#dnadecoration').html(num)
    switch (num) {
        case 1:
            $('#decorationName').html('Basic')
            normaldecoration()
            break
        case 2:
            normaldecoration()
            $('#decorationName').html('Tophat')
            decorationPattern2()
            break
        case 3:
            normaldecoration()
            $('#decorationName').html('Hat with No Brim')
            decorationPattern3()
            break
        case 4:
            normaldecoration()
            $('#decorationName').html('Big Hat')
            decorationPattern4()
            break
        case 5:
            normaldecoration()
            $('#decorationName').html('Small Hat')
            decorationPattern5()
            break
        case 6:
            normaldecoration()
            $('#decorationName').html('Cap')
            decorationPattern6()
            break
        case 7:
            normaldecoration()
            $('#decorationName').html('No Hat')
            decorationPattern7()
            break
        }
};

//Eye types
function normalEyes() {
    //all variantions are reset to default
    $('.eye').find('span').css('border', 'none')
    $('.eye').find('span').css('width', '35px')
    $('.eye').find('span').css('position', 'absolute')
    $('.eye').find('span').css('border-radius', '50%')
    $('.eye').find('span').css('top', '10px')
};

function eyesType2() {
    $('.eye').find('span').css('border-top', '15px solid ')
};

function eyesType3() {
    $('.eye').find('span').css('border-bottom', '15px solid')
};

function eyesType4() {
    $('.eye').find('span').css('width', '25px')
};

function eyesType5() {
    $('.eye').find('span').css('position', 'unset')
};

function eyesType6() {
    $('.eye').find('span').css('border-radius', '0 0 0 0')
};

function eyesType7() {
    $('.eye').find('span').css('top', '1px')
};

//Hat Types
async function normaldecoration() {
    //Remove all style from other decorations
    $('.hat-top').css({"height": "50px", "width": "90px", "left": "93px", "border-radius": "85% 85% 25% 25%", "top": "0px", "visibility": "visible"})
    $('.hat-brim').css({"height": "7px", "width": "120px", "top": "45px", "left": "78px", "border-radius": "0 0 0 0", "visibility": "visible"})
};

function decorationPattern2() {
    $('.hat-top').css({"height": "70px", "width": "90px", "left": "93px", "border-radius": "0 0 0 0", "top": "-18px", "visibility": "visible"})
    $('.hat-brim').css({"height": "7px", "width": "120px", "top": "45px", "left": "78px", "border-radius": "0 0 0 0", "visibility": "visible"})
};

function decorationPattern3() {
    $('.hat-top').css({"height": "50px", "width": "90px", "left": "93px", "border-radius": "85% 85% 25% 25%", "visibility": "visible" })
    $('.hat-brim').css({"height": "7px", "width": "90px", "top": "45px", "left": "93px", "border-radius": "0 0 0 0", "visibility": "visible"})
};

function decorationPattern4() {
    $('.hat-top').css({"height": "50px", "width": "120px", "left": "78px", "border-radius": "85% 85% 25% 25%", "visibility": "visible" })
    $('.hat-brim').css({"height": "7px", "width": "200px", "top": "45px", "left": "39px", "border-radius": "0 0 0 0", "visibility": "visible"})
};

function decorationPattern5() {
    $('.hat-top').css({"height": "38px", "width": "47px", "left": "113px","top": "6px", "border-radius": "85% 85% 25% 25%", "visibility": "visible" })
    $('.hat-brim').css({"height": "7px", "width": "85px", "top": "38px", "left": "95px", "border-radius": "0 0 0 0", "visibility": "visible"})
};

function decorationPattern6() {
    $('.hat-top').css({"height": "50px", "width": "90px", "left": "93px", "border-radius": "85% 85% 25% 25%", "visibility": "visible" })
    $('.hat-brim').css({"height": "7px", "width": "120px", "top": "45px", "left": "63px", "border-radius": "0 0 0 0", "visibility": "visible"})
};

function decorationPattern7() {
    $('.hat-top').css({"height": "50px", "width": "90px", "left": "93px", "border-radius": "85% 85% 25% 25%", "visibility": "hidden" })
    $('.hat-brim').css({"height": "7px", "width": "120px", "top": "45px", "left": "78px", "border-radius": "0 0 0 0", "visibility": "hidden" })
};

bearSettings.js


var colors = Object.values(allColors())

var defaultDNA = {
  "headColor" : 10,
  "mouthColor" : 19,
  "eyesColor" : 29,
  "earsColor" : 21,
  //Attributes
  "eyesShape" : 1,
  "decorationPattern" : 1,
  "decorationMidcolor" : 16,
  "decorationSidescolor" : 16,
  "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)

  renderBear(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 renderBear(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)
  $('#eyesshape').val(dna.eyesShape)

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

  decorationColor1(colors[dna.decorationMidcolor], dna.decorationMidcolor)
  $('#hattopcolor').val(dna.decorationMidcolor)

  decorationColor2(colors[dna.decorationSidescolor], dna.decorationSidescolor)
  $('#hatbrimcolor').val(dna.decorationSidescolor) 
}

// Changing bear DNA attributes
$('#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)
});

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

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

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

$('#hatbrimcolor').change(()=>{
  var colorVal = ($('#hatbrimcolor').val())
  decorationColor2(colors[colorVal],colorVal)
});
1 Like

Itā€™s starting to look pretty good. I did a lot of updates since the last postings.
Some of the feature adjustments are pretty funny lol

You can test out my latest updates on my github page:
https://ciphergrind.github.io/TrippySquirrelsNFTMaker/

The code is listed in the repos:
https://github.com/CipherGrind/TrippySquirrelsNFTMaker/tree/main

2 Likes

amazinggg brooo. mad trippy lol. keep up the great work

1 Like

you should try deploy it on netlify when your done for ppl to try

1 Like

wooooow, crypto beaver looks insaaaane!!

Amazing job man! :muscle:

Carlos Z!

1 Like

Thanks Evan!
I havenā€™t used Netlify before. I just signed up for their free account.
What are some of the benefits of using Netlify?

Thanks Carlos!
I just fixed up the slider for changing the cryptocurrency coin feature. When I uploaded my latest repo updates to Github Pages, it wasnā€™t displaying the png files of the crypto logos. I couldnā€™t figure it out until about an hour ago. Had to go in to the assets folder of where the image files are and right click copy image address and then use that in the code for the img src. So that feature slider is working properly now.
I am having a fun time with this course, I think itā€™s my favorite one so far. Thanks for a great course team!

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>
            <!-- Mouth colors -->
            <div id="mouthColors">
                <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>
            <!-- Eyes colors -->
            <div id="eyesColors">
                <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>
            <!-- Ears colors -->
            <div id="earsColors">
                <div class="form-group">
                    <label for="formControlRange"><b>Ears | Paw</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>
            <!-- Ears shape -->
            <div id="eyesShape">
                <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>
            <!-- Decoration Pattern -->
            <div id="decorations">
                <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>
            <!-- Decoration Middle Colors -->
            <div id="decorationsMidColors">
                <div class="form-group">
                    <label for="formControlRange"><b>Decoration Colors - Middle</b><span class="badge badge-dark ml-2" id="decorationMidName"></span></label>
                    <input type="range" min="1" max="98" class="form-control-range" id="decorationMid">
                </div>
            </div>
            <!-- Decoration Side Colors -->
            <div id="decorationsSideColors">
                <div class="form-group">
                    <label for="formControlRange"><b>Decoration Colors - Side</b><span class="badge badge-dark ml-2" id="decorationSideName"></span></label>
                    <input type="range" min="1" max="98" class="form-control-range" id="decorationSide">
                </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>

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, .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 body color part of the DNA that is displayed below the cat
}
function eyesColor(color,code) {
    $('.cat__eye .pupil-left, .cat__eye .pupil-right').css('background', '#' + color)  
    $('#eyescode').html('code: '+code)
    $('#dnaeyes').html(code) 
}
function earsColor(color,code) {
    $('.cat__ear .cat__ear--left, .cat__ear .cat__ear--right, .cat__paw-left, .cat__paw-right').css('background', '#' + color)  
    $('#earscode').html('code: '+code) 
    $('#dnaears').html(code) 
}
function decorationMidColor(color,code) {
    $('#midDot').css('background', '#' + color) 
    $('#decorationMidName').html('code: '+code) 
    $('#dnadecorationMid').html(code) 
}
function decorationSideColor(color,code) {
    $('#midDot #leftDot, #midDot #rightDot').css('background', '#' + color)  
    $('#decorationSideName').html('code: '+code) 
    $('#dnadecorationSides').html(code) 
}


//###################################################
//Functions below will be used later on in the project
//###################################################
function eyeVariation(num) {
    $('#eyeshape').val(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('Up')
            eyesType2()
            break
    }
}

function decorationVariation(num) {
    $('#dnadecoration').html(num)
    console.log(num)
    $('#decoration').val(num)
    switch (num) {
        case 1:
            $('#decorationName').html('Basic')
            normaldecoration()
            break
        case 2:
            $('#decorationName').html('Cool')
            normaldecoration()
            cooldecoration()
            break
        case 3:
            $('#decorationName').html('Relax')
            normaldecoration()
            relaxdecoration()
            break
        case 4:
            $('#decorationName').html('Thin')
            normaldecoration()
            thindecoration()
            break
        case 5:
            $('#decorationName').html('Bold')
            normaldecoration()
            bolddecoration()
            break  
        case 6:
            $('#decorationName').html('Spring Break')
            normaldecoration()
            springBreakecoration()
            break    
    }
}


async function normalEyes() {
    await $('.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')
}

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%", "left": "-20px" })
    $('.cat__head-dots_second').css({ "transform": "rotate(0deg)", "height": "35px", "width": "14px", "top": "1px", "border-radius": "0 50% 50% 50%", "left": "20px" })
}
function cooldecoration() {
    //Remove all style from other decorations
    //In this way we can also use normalDecoration() to reset the decoration style
    $('.cat__head-dots_first').css( "transform", "rotate(15deg)")
    $('.cat__head-dots_second').css("transform", "rotate(-15deg)")
}
function relaxdecoration() {
    //Remove all style from other decorations
    //In this way we can also use normalDecoration() to reset the decoration style
    $('.cat__head-dots_first').css({ "transform": "rotate(40deg)", "height": "45px", "width": "14px", "top": "1px", "border-radius": "50% 0 50% 50%", "left": "-35px" })
    $('.cat__head-dots_second').css({ "transform": "rotate(-40deg)", "height": "45px", "width": "14px", "top": "1px", "border-radius": "0 50% 50% 50%", "left": "35px" })
}
function thindecoration() {
    //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": "75px", "width": "8px", "top": "1px", "border-radius": "0 0 50% 50%" })
    $('.cat__head-dots_first').css({ "transform": "rotate(40deg)", "height": "75px", "width": "8px", "top": "1px", "border-radius": "100% 0 100% 0%", "left": "-44px" })
    $('.cat__head-dots_second').css({ "transform": "rotate(-40deg)", "height": "75px", "width": "8px", "top": "1px", "border-radius": "0 100% 0% 100%", "left": "44px" })
}
function bolddecoration() {
    //Remove all style from other decorations
    //In this way we can also use normalDecoration() to reset the decoration style
    $('.cat__head-dots').css({ "height": "41px", "width": "31px", "top": "1px", "border-radius": "50% 0 50% 0%" })
    $('.cat__head-dots_first').css( {"transform": "rotate(15deg)", "width": "33px", "left": "-39px" })
    $('.cat__head-dots_second').css({"transform": "rotate(-15deg)", "width": "33px", "left": "39px", "top": "8px" })
}
function springBreakecoration() {
    //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": "49px", "width": "47px", "top": "1px", "border-radius": "50% 0 50% 0%" })
    $('.cat__head-dots_first').css( {"transform": "rotate(13deg)", "width": "38px", "height": "53px", "top": "3px", "left": "-39px", "border-radius": "50% 0 50% 0%" })
    $('.cat__head-dots_second').css({"transform": "rotate(10deg)", "width": "43px", "height": "42px", "top": "17px", "left": "45px", "border-radius": "0px 100% 50%" })
}

CatSetting.js


var colors = Object.values(allColors())

var defaultDNA = {
    "headcolor" : 10,
    "mouthColor" : 13,
    "eyesColor" : 96,
    "earsColor" : 10,
    //Cattributes
    "eyesShape" : 2,
    "decorationPattern" : 1,
    "decorationMidcolor" : 42,
    "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){
    console.log({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(defaultDNA.eyesShape)
    decorationVariation(dna.decorationPattern)
    decorationMidColor(colors[dna.decorationMidcolor], dna.decorationMidcolor)
    decorationSideColor(colors[dna.decorationSidescolor], dna.decorationSidescolor)

}

// Changing cat colors
$('#bodycolor').change(()=>{
    var colorVal = $('#bodycolor').val()
    headColor(colors[colorVal],colorVal)
})
// Changing mouth colors
$('#mouthcolor').change(()=>{
    var colorVal = $('#mouthcolor').val()
    mouthColor(colors[colorVal],colorVal)
})
// Changing eyes colors
$('#eyescolor').change(()=>{
    var colorVal = $('#eyescolor').val()
    eyesColor(colors[colorVal],colorVal)
})
// Changing ears colors
$('#earscolor').change(()=>{
    var colorVal = $('#earscolor').val()
    earsColor(colors[colorVal],colorVal)
})
// Changing eyes shape
$('#eyeshape').change(()=>{
    var shape = parseInt($('#eyeshape').val())
    eyeVariation(shape)
})
// Changing decoration pattern
$('#decoration').change(()=>{
    var deco = parseInt($('#decoration').val())
    decorationVariation(deco)
})
// Changing decoration middle
$('#decorationMid').change(()=>{
    var deco = parseInt($('#decorationMid').val())
    decorationMidColor(colors[deco], deco)
})
// Changing decoration side
$('#decorationSide').change(()=>{
    var deco = parseInt($('#decorationSide').val())
    decorationSideColor(colors[deco], deco)
})

Hi guys,
Iā€™m having trouble rotating the decorations, and hope somebody can point out to me where Iā€™ve done it wrong. I just wanted to a basic transform rotation to start and add more stuff to it later, but it didnā€™t even rotate. hereā€™s my code:

index.html

<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Kitties Factory</title>
  <script type="text/javascript" src="assets/js/jquery-3.4.1.js"></script>
  <link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
  <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:
                        <!-- Colours -->
                         <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 colours -->
<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>
                    <!--Slider for body and head colour, set min to 10 because 
                        DNA strands needs 2 digits to represents colour, 
                        but if its 01 its just equals to 1, and made it invalide input-->
                    <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>
                    <!--Slider for mouth, belly and tail colour, set min to 10 because 
                        DNA strands needs 2 digits to represents colour, 
                        but if its 01 its just equals to 1, and made it invalide input-->
                    <input type="range" min="10" max="98" class="form-control-range" id="mouthcolor"> 
                </div>

                <div class="form-group">
                    <label for="formControlRange"><b>Eyes colour</b><span class="badge badge-dark ml-2" id="eyecode"></span></label>
                    <!--Slider for eyes colour, set min to 10 because 
                        DNA strands needs 2 digits to represents colour, 
                        but if its 01 its just equals to 1, and made it invalide input-->
                    <input type="range" min="10" max="98" class="form-control-range" id="eyecolor"> 
                </div>

                <div class="form-group">
                    <label for="formControlRange"><b>Ears | Paws</b><span class="badge badge-dark ml-2" id="earscode"></span></label>
                    <!--Slider for ears and paws colour, set min to 10 because 
                        DNA strands needs 2 digits to represents colour, 
                        but if its 01 its just equals to 1, and made it invalide input-->
                    <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>
                    <!--Slider for eye shape, range between 1~8, 8 in total-->
                    <input type="range" min="1" max="8" class="form-control-range" id="eyeshape"> 
                </div>

                <div class="form-group">
                    <label for="formControlRange"><b>Stripe shape</b><span class="badge badge-dark ml-2" id="decorationName"></span></label>
                    <!--Slider for stripe shape, range between 1~7, 7 in total-->
                    <input type="range" min="1" max="7" class="form-control-range" id="decorationShape"> 
                </div>

                <div class="form-group">
                    <label for="formControlRange"><b>Middle stripe colour</b><span class="badge badge-dark ml-2" id="midStripeColorCode"></span></label>
                    <!--Slider for outer stripe colour, range between 1~98, 99 in total-->
                    <input type="range" min="1" max="98" class="form-control-range" id="midStripeColor"> 
                </div>

                <div class="form-group">
                    <label for="formControlRange"><b>Outter stripe colour</b><span class="badge badge-dark ml-2" id="outerStripeColorCode"></span></label>
                    <!--Slider for outer stripe colour, range between 1~98, 99 in total-->
                    <input type="range" min="1" max="98" class="form-control-range" id="outerStripeColor"> 
                </div>                
            </div>

            </div>

            </div>
            <br>

        </div>



    </div>
    <footer align="left">
        <p>cryptokitties-clone NFT marketplace by Philip, Feb 2023</p>
    </footer>

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

</html>

catFactory.js


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

function 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 eyesColor(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-left_inner, .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 body color part of the DNA that is displayed below the cat
}

function midColor(color,code) {
    $('.cat__head-dots').css('background', '#' + color)  //This changes the color of the cat
    $('#midStripeColorCode').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 sideColor(color,code) {
    $('.cat__head-dots_first, .cat__head-dots_second').css('background', '#' + color)  //This changes the color of the cat
    $('#outerStripeColorCode').html('code: '+code) //This updates text of the badge next to the slider
    $('#dnadecorationSides').html(code) //This updates the body color part of the DNA that is displayed below the cat
}

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

    $('#dnashape').html(num)
    switch (num) {
        case 1:
            normalEyes()
            $('#eyeName').html('Basic') //set the badge in slider to "Basic"
            break
        case 2:
            normalEyes() //reset eyes to normal setting first
            $('#eyeName').html('Look Down') //set the badge in slider to "Look Down"
            eyesType1() //applies new eye settings
            break
        case 3:
            normalEyes() //reset eyes to normal setting first
            $('#eyeName').html('Look Up') //set the badge in slider to "Roll"
            eyesType2() //applies new eye settings
            break
        case 4:
            normalEyes() //reset eyes to normal setting first
            $('#eyeName').html('Look Left') //set the badge in slider to "Look Left"
            eyesType3() //applies new eye settings
            break
        case 5:
            normalEyes() //reset eyes to normal setting first
            $('#eyeName').html('Look Right') //set the badge in slider to "Look Right"
            eyesType4() //applies new eye settings
            break
        case 6:
            normalEyes() //reset eyes to normal setting first
            $('#eyeName').html('Crossed') //set the badge in slider to "Crossed"
            eyesType5() //applies new eye settings
            break
        case 7:
            normalEyes() //reset eyes to normal setting first
            $('#eyeName').html('Crazy') //set the badge in slider to "Crazy"
            eyesType6() //applies new eye settings
            break
        case 8:
            normalEyes() //reset eyes to normal setting first
            $('#eyeName').html('Split') //set the badge in slider to "Split"
            eyesType7() //applies new eye settings
            break            
    }
}

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

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

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

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

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

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

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

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

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

        case 2:
            $('#decorationName').html('type1')
            decoration1()
            break
            
        case 3:
            $('#decorationName').html('type2')
            decoration2()
            break
            
        case 4:
            $('#decorationName').html('type3')
            decoration3()
            break     
            
        case 5:
            $('#decorationName').html('type4')
            decoration4()
            break
            
        case 6:
            $('#decorationName').html('type5')
            decoration5()
            break  
            
        case 7:
            $('#decorationName').html('type6')
            decoration6()
            break    
    }
}

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

async function decoration1() {
    normaldecoration()//Reset the settings so no errors could occur
    await $('.cat__head-dots').css({ "transform": "rotate(20deg)"})
    await $('.cat__head-dots_first').css({ "transform": "rotate(20deg)"})
    await $('.cat__head-dots_second').css({ "transform": "rotate(20deg)"})

}

async function decoration2() {
    normaldecoration()//Reset the settings so no errors could occur
    await $('.cat__head-dots').css({ "transform": "rotate(45deg)"})
    await $('.cat__head-dots_first').css({ "transform": "rotate(45deg)"})
    await $('.cat__head-dots_second').css({ "transform": "rotate(45deg)"})
}

async function decoration3()  {
    normaldecoration()//Reset the settings so no errors could occur
    await $('.cat__head-dots').css({ "transform": "rotate(90deg)"})
    await $('.cat__head-dots_first').css({ "transform": "rotate(490deg)"})
    await $('.cat__head-dots_second').css({ "transform": "rotate(90deg)"})
}

async function decoration4() {
    normaldecoration()//Reset the settings so no errors could occur
    await $('.cat__head-dots').css({ "transform": "rotate(122deg)"})
    await $('.cat__head-dots_first').css({ "transform": "rotate(125deg)"})
    await $('.cat__head-dots_second').css({ "transform": "rotate(125deg)"})
}

async function decoration5() { //Mirrory
    normaldecoration()//Reset the settings so no errors could occur
    await $('.cat__head-dots').css({ "transform": "rotate(180deg)"})
    await $('.cat__head-dots_first').css({ "transform": "rotate(180deg)"})
    await $('.cat__head-dots_second').css({ "transform": "rotate(180deg)"})
}

async function decoration6() { //Browser
    normaldecoration()//Reset the settings so no errors could occur
    await $('.cat__head-dots').css({ "transform": "rotate(200deg)"})
    await $('.cat__head-dots_first').css({ "transform": "rotate(200deg)"})
    await $('.cat__head-dots_second').css({ "transform": "rotate(200deg)"})
}

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

//run this function whenever page restart or refresh
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)
    $('#eyeshape').val(dna.eyesShape)

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

    midColor(colors[dna.decorationMidcolor],dna.decorationMidcolor)
    $('#midStripeColor').val(dna.decorationMidcolor)

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

}

// 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()
  eyesColor(colors[colorVal],colorVal)
})

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

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

$('#decorationName').change(()=>{
  var decorationVal = parseInt($('#decorationShape').val()) //between 1 and 7
  decorationVal(decorationVal)
})

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

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