css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              #clone-box
  // Octocat clones will be attached here
.container
  #header.section
    .section.header-logo
      img(src="https://octodex.github.com/images/original.png")
    .section.header-text
      h2 Octocat Tribute
      h3.subheader A Mystical & Legendary Creature
  .content
    .section.randocat.card
      // Random Octocat Generator Section
      h2 Randocat!
      hr
      img#randocat-img(src="https://octodex.github.com/images/original.png")
      #randocat-info
        span#randocat-name Original
        span  made by 
        a#randocat-artist(href="#") unknown
        br
        a#randocat-link(href="https://octodex.github.com/original") View on Octodex
      #randocat-generator.custom-button.custom-hover Generate Randocat!
    .section.card
      // Random Factoid Generator Section
      #octofactoid-generator.custom-button.custom-hover Retrieve Octofactoid!
      #factoid-container
        span#octofactoid The Octocat is the logo for GitHub.
    .section.card
      // Octocat cloning machine
      .section
        h2#cloning-header Introducing the Octocat Cloning Machine!
        hr
        #cloning-warning May cause lag
      .section.cell
        img#cloning-scientist(src="https://octodex.github.com/images/labtocat.png")
      .section.cell
        #cloning-machine.custom-button.custom-hover Start Cloning!
  #footer.section
    p David Castner's Tribute Page for freeCodeCamp
    p The Octocat is a trademark of 
      a(href="https://github.com/") GitHub
            
          
!
            
              @import url(https://fonts.googleapis.com/css?family=Raleway:400,500,600,700);
//globals
$spacer: 8px;
$link-color: #651FFF;
$button-color: #651FFF;
$factoid-color: #9575CD;
* {
  box-sizing: border-box;
  font-family: 'Raleway', sans-serif;
  margin: 0;
}

body {
  background-color: #e0e0e0
}

@mixin custom-shadow {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
  transition: all 0.3s cubic-bezier(.25, .8, .25, 1);
}

@mixin custom-shadow-hover {
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
}

.card {
  border-radius: 2px;
  background-color: #ffffff;
  @include custom-shadow;
  margin: 16px;
  padding: 32px;
}

a {
  text-decoration: none;
  color: initial;
  font-weight: 600;
  color: initial;
}

a:hover {
  color: $link-color;
}

.section {
  padding: $spacer;
}

.center-text {
  text-align: center;
}

.center-div {
  width: auto;
  margin: 0 auto;
}

#header {
  background: #6441A5;
  /* fallback for old browsers */
  background: -webkit-linear-gradient(to left, #6441A5, #2a0845);
  /* Chrome 10-25, Safari 5.1-6 */
  background: linear-gradient(to left, #6441A5, #2a0845);
  /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
  color: white;
  .header-logo img {
    height: 51px;
  }
  .header-logo, .header-text {
    display: inline-block;
  }
  @include custom-shadow;
}

#randocat-info {
  max-width: 300px;
  margin: 0 auto;
}

#randocat-link {
  //font-size: 0.8em;
  width: auto;
  //margin: 0 auto;
  text-align: center;
}

#footer {
  background: #FF4E50;
  /* fallback for old browsers */
  background: -webkit-linear-gradient(to left, #FF4E50, #F9D423);
  /* Chrome 10-25, Safari 5.1-6 */
  background: linear-gradient(to left, #FF4E50, #F9D423);
  /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
  color: white;
  font-weight: 600;
  font-size: 0.9em;
  a {
    color: white;
    &:hover {
      color: $link-color;
    }
  }
}

#factoid-container {
  max-width: 600px;
  text-align: center;
  margin: 16px auto;
  padding: 16px;
  font-weight: 500;
  border-radius: 2px;
  background: #6a3093;
  /* fallback for old browsers */
  background: -webkit-linear-gradient(to left, #6a3093, #a044ff);
  /* Chrome 10-25, Safari 5.1-6 */
  background: linear-gradient(to left, #6a3093, #a044ff);
  /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
  color: #ffffff;
  min-height: 38px + 32px;
}

#cloning-header {}

hr {
  opacity: 0.38;
  margin: 4px 0;
}

#cloning-warning {
  opacity: 0.38;
  padding: 4px 0;
  font-size: 0.75em;
  font-weight: 500;
}

#cloning-scientist {
  width: 100%;
  max-width: 300px;
  margin: 0 auto;
  display: block;
}

// Custom Button
.custom-button {
  border-width: 3px;
  border-color: $button-color;
  border-style: solid;
  border-radius: 2px;
  width: 100%;
  max-width: 300px;
  margin: 8px auto;
  padding: 8px;
  text-align: center;
  color: $button-color;
  @include custom-shadow;
  user-select: none;
}

.custom-hover:hover {
  background-color: $button-color;
  color: #ffffff;
  cursor: pointer;
  @include custom-shadow-hover;
}

// SCSS necessary for the jquery interactions
#clone-box {
  position: fixed;
}

.clone {
  position: absolute;
  width: 64px;
  z-index: 20;
  cursor: pointer;
}

#randocat-img {
  width: 100%;
  max-width: 300px;
  display: block;
  margin: 0 auto;
}
            
          
!
            
              var GitHubURL = "https://github.com/";
var OctodexURL = "https://octodex.github.com";
var CloneImage = "https://assets-cdn.github.com/images/modules/logos_page/Octocat.png";

// list of octocats pulled via https://gist.github.com/cbednarski/6546719
// ran the code in console for https://octodex.github.com/
// followed by the command `JSON.stringify(items, null, 4)` for output
var Octocats = [{
  "name": "Hanukkat",
  "url": "/images/hanukkat.png",
  "artist": "tonyjaramillo"
}, {
  "name": "Welcometocat",
  "url": "/images/welcometocat.png",
  "artist": "jglovier"
}, {
  "name": "Filmtocat",
  "url": "/images/filmtocat.png",
  "artist": "jeejkang"
}, {
  "name": "Private Investocat",
  "url": "/images/privateinvestocat.jpg",
  "artist": "jeejkang"
}, {
  "name": "Gracehoppertocat",
  "url": "/images/gracehoppertocat.jpg",
  "artist": "jeejkang"
}, {
  "name": "Gobble-o-tron",
  "url": "/images/gobbleotron.gif",
  "artist": "JohnCreek"
}, {
  "name": "Jetpacktocat",
  "url": "/images/jetpacktocat.png",
  "artist": "tonyjaramillo"
}, {
  "name": "Minertocat",
  "url": "/images/minertocat.png",
  "artist": "jeejkang"
}, {
  "name": "Mountietocat",
  "url": "/images/mountietocat.png",
  "artist": "jeejkang"
}, {
  "name": "Saketocat",
  "url": "/images/saketocat.png",
  "artist": "jeejkang"
}, {
  "name": "Luchadortocat",
  "url": "/images/luchadortocat.png",
  "artist": "jeejkang"
}, {
  "name": "Saritocat",
  "url": "/images/saritocat.png",
  "artist": "JohnCreek"
}, {
  "name": "Topguntocat",
  "url": "/images/topguntocat.png",
  "artist": "leereilly"
}, {
  "name": "Carlostocat",
  "url": "/images/carlostocat.gif",
  "artist": "jeejkang"
}, {
  "name": "Grinchtocat",
  "url": "/images/grinchtocat.gif",
  "artist": "tonyjaramillo"
}, {
  "name": "Maxtocat",
  "url": "/images/maxtocat.gif",
  "artist": "jeejkang"
}, {
  "name": "Yaktocat",
  "url": "/images/yaktocat.png",
  "artist": "jeejkang"
}, {
  "name": "Steroidtocat",
  "url": "/images/steroidtocat.png",
  "artist": "jeejkang"
}, {
  "name": "Mummytocat",
  "url": "/images/mummytocat.gif",
  "artist": "tonyjaramillo"
}, {
  "name": "Labtocat",
  "url": "/images/labtocat.png",
  "artist": "JohnCreek"
}, {
  "name": "Dunetocat",
  "url": "/images/dunetocat.png",
  "artist": "JohnCreek"
}, {
  "name": "OctoLiberty",
  "url": "/images/octoliberty.png",
  "artist": "tonyjaramillo"
}, {
  "name": "Femalecodertocat",
  "url": "/images/femalecodertocat.png",
  "artist": "jeejkang"
}, {
  "name": "Daftpunktocat-Thomas",
  "url": "/images/daftpunktocat-thomas.gif",
  "artist": "jeejkang"
}, {
  "name": "Daftpunktocat-Guy",
  "url": "/images/daftpunktocat-guy.gif",
  "artist": "jeejkang"
}, {
  "name": "Founding Father v2",
  "url": "/images/foundingfather_v2.png",
  "artist": "jeejkang"
}, {
  "name": "Poptocat v2",
  "url": "/images/poptocat_v2.png",
  "artist": "jeejkang"
}, {
  "name": "Mardigrastocat",
  "url": "/images/Mardigrastocat.png",
  "artist": "jeejkang"
}, {
  "name": "Kimonotocat",
  "url": "/images/kimonotocat.png",
  "artist": "jeejkang"
}, {
  "name": "professortocat_v2",
  "url": "/images/Professortocat_v2.png",
  "artist": "jeejkang"
}, {
  "name": "goretocat",
  "url": "/images/goretocat.png",
  "artist": "jeejkang"
}, {
  "name": "Robotocat",
  "url": "/images/Robotocat.png",
  "artist": "jeejkang"
}, {
  "name": "Motherhubbertocat",
  "url": "/images/motherhubbertocat.png",
  "artist": "jeejkang"
}, {
  "name": "Skitchtocat",
  "url": "/images/skitchtocat.png",
  "artist": "jonrohan"
}, {
  "name": "Gangnamtocat",
  "url": "/images/gangnamtocat.png",
  "artist": "jeejkang"
}, {
  "name": "Dr.Octocat",
  "url": "/images/droctocat.png",
  "artist": "jeejkang"
}, {
  "name": "Spidertocat",
  "url": "/images/spidertocat.png",
  "artist": "jeejkang"
}, {
  "name": "Megacat v2",
  "url": "/images/megacat-2.png",
  "artist": "jeejkang"
}, {
  "name": "Dodgetocat v2",
  "url": "/images/dodgetocat_v2.png",
  "artist": "tonyjaramillo"
}, {
  "name": "Stormtroopocat",
  "url": "/images/stormtroopocat.png",
  "artist": "jeejkang"
}, {
  "name": "Pusheencat",
  "url": "/images/pusheencat.png",
  "artist": "billyroh"
}, {
  "name": "Deckfailcat",
  "url": "/images/deckfailcat.png",
  "artist": "mattgraham"
}, {
  "name": "Murakamicat",
  "url": "/images/murakamicat.png",
  "artist": "billyroh"
}, {
  "name": "Homercat",
  "url": "/images/homercat.png",
  "artist": "nickh"
}, {
  "name": "Minion",
  "url": "/images/minion.png",
  "artist": "nickh"
}, {
  "name": "Droidtocat",
  "url": "/images/droidtocat.png",
  "artist": "tonyjaramillo"
}, {
  "name": "Octofez",
  "url": "/images/octofez.png",
  "artist": "nickh"
}, {
  "name": "Heisencat",
  "url": "/images/heisencat.png",
  "artist": "jonrohan"
}, {
  "name": "Red Polo",
  "url": "/images/red-polo.png",
  "artist": "cameronmcefee"
}, {
  "name": "20% Cooler Octocat",
  "url": "/images/twenty-percent-cooler-octocat.png",
  "artist": "cameronmcefee"
}, {
  "name": "Momtocat",
  "url": "/images/momtocat.png",
  "artist": "tonyjaramillo"
}, {
  "name": "Front-End Conftocat",
  "url": "/images/front-end-conftocat.png",
  "artist": "tonyjaramillo"
}, {
  "name": "Snow Octocat",
  "url": "/images/snowoctocat.png",
  "artist": "cameronmcefee"
}, {
  "name": "Electrocat",
  "url": "/images/electrocat.png",
  "artist": "cameronmcefee"
}, {
  "name": "Codercat",
  "url": "/images/codercat.jpg",
  "artist": "cameronmcefee"
}, {
  "name": "Strongbadtocat",
  "url": "/images/strongbadtocat.png",
  "artist": "cameronmcefee"
}, {
  "name": "Adventure Cat",
  "url": "/images/adventure-cat.png",
  "artist": "jonrohan"
}, {
  "name": "Doctocat Brown",
  "url": "/images/doctocat-brown.jpg",
  "artist": "jonrohan"
}, {
  "name": "Dojocat",
  "url": "/images/dojocat.jpg",
  "artist": "cameronmcefee"
}, {
  "name": "Defunktocat",
  "url": "/images/defunktocat.png",
  "artist": "jasoncostello"
}, {
  "name": "Nemesis",
  "url": "/images/herme-t-crabb.png",
  "artist": "cameronmcefee"
}, {
  "name": "Saint Nicktocat",
  "url": "/images/saint-nicktocat.jpg",
  "artist": "cameronmcefee"
}, {
  "name": "Ordered Listocat",
  "url": "/images/orderedlistocat.png",
  "artist": "cameronmcefee"
}, {
  "name": "Thanktocat",
  "url": "/images/thanktocat.png",
  "artist": "cameronmcefee"
}, {
  "name": "Megacat",
  "url": "/images/megacat.jpg",
  "artist": "jasoncostello"
}, {
  "name": "Linktocat",
  "url": "/images/linktocat.jpg",
  "artist": "cameronmcefee"
}, {
  "name": "Plumber",
  "url": "/images/plumber.jpg",
  "artist": "cameronmcefee"
}, {
  "name": "Octotron",
  "url": "/images/octotron.jpg",
  "artist": "broccolini"
}, {
  "name": "Baracktocat",
  "url": "/images/baracktocat.jpg",
  "artist": "cameronmcefee"
}, {
  "name": "Octocat De Los Muertos",
  "url": "/images/octocat-de-los-muertos.jpg",
  "artist": "cameronmcefee"
}, {
  "name": "Grim Repo",
  "url": "/images/grim-repo.jpg",
  "artist": "cameronmcefee"
}, {
  "name": "Father Timeout",
  "url": "/images/father_timeout.jpg",
  "artist": "jasoncostello"
}, {
  "name": "Where's Waldocat",
  "url": "/images/waldocat.png",
  "artist": "jasoncostello"
}, {
  "name": "Hipster Partycat",
  "url": "/images/hipster-partycat.jpg",
  "artist": "jina"
}, {
  "name": "Riddlocat",
  "url": "/images/riddlocat.png",
  "artist": "cameronmcefee"
}, {
  "name": "Visionary",
  "url": "/images/visionary.jpg",
  "artist": "cameronmcefee"
}, {
  "name": "Oktobercat",
  "url": "/images/oktobercat.png",
  "artist": "cameronmcefee"
}, {
  "name": "Shoptocat",
  "url": "/images/shoptocat.png",
  "artist": "cameronmcefee"
}, {
  "name": "Nyantocat",
  "url": "/images/nyantocat.gif",
  "artist": "cameronmcefee"
}, {
  "name": "Octdrey Catburn",
  "url": "/images/octdrey-catburn.jpg",
  "artist": "cameronmcefee"
}, {
  "name": "Spectrocat",
  "url": "/images/spectrocat.png",
  "artist": "cameronmcefee"
}, {
  "name": "Bear Cavalry",
  "url": "/images/bear-cavalry.png",
  "artist": "cameronmcefee"
}, {
  "name": "Andycat",
  "url": "/images/andycat.jpg",
  "artist": "jasoncostello"
}, {
  "name": "Not Octocat",
  "url": "/images/notocat.jpg",
  "artist": "cameronmcefee"
}, {
  "name": "Dodge, Duck, Dip, Dive, Dodgetocat",
  "url": "/images/dodgetocat.jpg",
  "artist": "cameronmcefee"
}, {
  "name": "Cloud",
  "url": "/images/cloud.jpg",
  "artist": "cameronmcefee"
}, {
  "name": "Scarletteocat",
  "url": "/images/scarletteocat.jpg",
  "artist": "jordanmccullough"
}, {
  "name": "Poptocat",
  "url": "/images/poptocat.png",
  "artist": "cameronmcefee"
}, {
  "name": "Jenktocat",
  "url": "/images/jenktocat.jpg",
  "artist": "cameronmcefee"
}, {
  "name": "X-tocat",
  "url": "/images/xtocat.jpg",
  "artist": "cameronmcefee"
}, {
  "name": "Chellocat",
  "url": "/images/chellocat.jpg",
  "artist": "cameronmcefee"
}, {
  "name": "Cherryontop-o-cat",
  "url": "/images/cherryontop-o-cat.png",
  "artist": "jasoncostello"
}, {
  "name": "Supportcat",
  "url": "/images/supportcat.png",
  "artist": "jasoncostello"
}, {
  "name": "Collabocats",
  "url": "/images/collabocats.jpg",
  "artist": "jasoncostello"
}, {
  "name": "Constructocat",
  "url": "/images/constructocat2.jpg",
  "artist": "jasoncostello"
}, {
  "name": "Total Eclipse of the Octocat",
  "url": "/images/total-eclipse-of-the-octocat.jpg",
  "artist": "cameronmcefee"
}, {
  "name": "Blinktocat, Pinktocat, Inktocat, and Clyde",
  "url": "/images/pacman-ghosts.jpg",
  "artist": "cameronmcefee"
}, {
  "name": "Okal-Eltocat",
  "url": "/images/okal-eltocat.jpg",
  "artist": "cameronmcefee"
}, {
  "name": "Octoclark Kentocat",
  "url": "/images/octoclark-kentocat.jpg",
  "artist": "cameronmcefee"
}, {
  "name": "Agendacat",
  "url": "/images/agendacat.png",
  "artist": "jasoncostello"
}, {
  "name": "IronCat",
  "url": "/images/ironcat.jpg",
  "artist": "cameronmcefee"
}, {
  "name": "Inspectocat",
  "url": "/images/inspectocat.jpg",
  "artist": "jasoncostello"
}, {
  "name": "Jean-Luc Picat",
  "url": "/images/jean-luc-picat.jpg",
  "artist": "cameronmcefee"
}, {
  "name": "Spocktocat",
  "url": "/images/spocktocat.png",
  "artist": "cameronmcefee"
}, {
  "name": "Wilson",
  "url": "/images/wilson.jpg",
  "artist": "cameronmcefee"
}, {
  "name": "Swagtocat",
  "url": "/images/swagtocat.png",
  "artist": "cameronmcefee"
}, {
  "name": "Drunktocat",
  "url": "/images/drunktocat.jpg",
  "artist": "cameronmcefee"
}, {
  "name": "Hubot",
  "url": "/images/hubot.jpg",
  "artist": "cameronmcefee"
}, {
  "name": "Monroe",
  "url": "/images/monroe.jpg",
  "artist": "cameronmcefee"
}, {
  "name": "Trekkie",
  "url": "/images/trekkie.png",
  "artist": "cameronmcefee"
}, {
  "name": "Octonaut",
  "url": "/images/octonaut.jpg",
  "artist": "cameronmcefee"
}, {
  "name": "Bouncer",
  "url": "/images/bouncercat.png",
  "artist": "cameronmcefee"
}, {
  "name": "Founding Father",
  "url": "/images/founding-father.jpg",
  "artist": "cameronmcefee"
}, {
  "name": "Pythocat",
  "url": "/images/pythocat.png",
  "artist": "cameronmcefee"
}, {
  "name": "Drupalcat",
  "url": "/images/drupalcat.jpg",
  "artist": "cameronmcefee"
}, {
  "name": "Socialite",
  "url": "/images/socialite.jpg",
  "artist": "cameronmcefee"
}, {
  "name": "Setuptocat",
  "url": "/images/setuptocat.jpg",
  "artist": "cameronmcefee"
}, {
  "name": "Repo",
  "url": "/images/repo.png",
  "artist": "cameronmcefee"
}, {
  "name": "Forktocat",
  "url": "/images/forktocat.jpg",
  "artist": "cameronmcefee"
}, {
  "name": "Benevocats",
  "url": "/images/benevocats.png",
  "artist": "cameronmcefee"
}, {
  "name": "Scottocat",
  "url": "/images/scottocat.jpg",
  "artist": "cameronmcefee"
}, {
  "name": "Puppeteer",
  "url": "/images/puppeteer.png",
  "artist": "cameronmcefee"
}, {
  "name": "Octobi Wan Catnobi",
  "url": "/images/octobiwan.jpg",
  "artist": "cameronmcefee"
}, {
  "name": "Class Act",
  "url": "/images/class-act.png",
  "artist": "cameronmcefee"
}, {
  "name": "Original",
  "url": "/images/original.png",
  "artist": "unknown"
}];

var Octofactoids = [
  "The octocat is the logo for GitHub.",
  "Octocats are notoriously shy, so seeing one in the wild is extremely rare.",
  "Although the octocat is part of the feline family, it exhibits many characteristics of octopusses.",
  "Although the octocat is part of the octopus family, it exhibits many characteristics of cats.",
  "When migrating south for the winter, most octocats go to Australia.",
  "The first octocat fossil discovered was found in digital form.",
  "When threatened, the octocat lets out a \"meow\" and a jet of ink.",
  "Why did the octocat cross the road? It didn't have a choice, everyone was pushing and pulling it across.",
  "The first words of any octocat are \"Hello World!\".",
  "Octocats often snack on abandoned repos. The repos typically do nothing except for print 'hello world' and fill octocat bellies.",
  "Octocats are multilingual.",
  "An octocat’s favorite utensil is a fork.",
  "Octocats reproduce by cloning.",
  "Octocats make a purr-fect pet since they can play fetch very well.",
];

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

// OCTOCAT FUNCTIONS
var currentOctocat = Octocats.length - 1;
var getRandomOctocat = function() {
  var newOctocat = getRandomInt(0, (Octocats.length - 1));
  if (newOctocat >= currentOctocat) {
    newOctocat++;
  } // avoids repeating octocats
  currentOctocat = newOctocat;
  return Octocats[newOctocat];
};
var generateRandocat = function() {
  var octocat = getRandomOctocat();
  var imgURL = OctodexURL + octocat.url;
  var dexURL = OctodexURL + octocat.url.slice(7, -4); //strips image resource from url
  var artistURL = GitHubURL + octocat.artist;
  $("#randocat-name").text(octocat.name);
  $("#randocat-artist").text(octocat.artist);
  $("#randocat-artist").attr("href", artistURL);
  $("#randocat-img").attr("src", imgURL);
  $("#randocat-link").attr("href", dexURL);
};

// FACTOID FUNCTIONS
var currentOctofactoid = 0;
var getRandomOctofactoid = function() {
  var newOctofactoid = getRandomInt(0, (Octofactoids.length - 1));
  if (newOctofactoid >= currentOctofactoid) {
    newOctofactoid++;
  } // avoids repeating factoids
  currentOctofactoid = newOctofactoid;
  return Octofactoids[newOctofactoid];
};
var generateOctofactoid = function() {
  var octofactoid = getRandomOctofactoid();
  $("#octofactoid").text(octofactoid);
};

// CLONING FUNCTIONS
var cloneIndex = 0;
var cloneCount = 0;
var cloneLimit = 64;
var cloneSize = 64;

var spawnNewClone = function() {
  var windowWidth = $(window).width();
  var windowHeight = $(window).height();
  if (windowWidth <= cloneSize || windowHeight <= cloneSize) {
    console.log("window too small for clones");
  } else {
    var xPoint = getRandomInt(0, windowWidth - cloneSize);
    var yPoint = getRandomInt(0, windowHeight - cloneSize);
    //console.log(xPoint, yPoint);
    var clone = $("<img src=\"" + CloneImage + "\">").addClass("clone");
    clone.css("left", xPoint);
    clone.css("top", yPoint);
    var id = "clone" + cloneIndex.toString();
    clone.attr("id", id);
    clone.addClass("animated zoomIn");
    var timer = getRandomInt(1000, 3000);
    setTimeout(wobble, timer, id);
    //clone.click(cloneHandler);
    $("#clone-box").append(clone);
    cloneIndex++;
    cloneCount++;
  }
};

var wobble = function(cloneId) {
  var timer = getRandomInt(1000, 3000);
  var octoclone = $("#" + cloneId);
  octoclone.removeClass("zoomIn");
  octoclone.removeClass("bounce");
  octoclone.addClass("wobble");
  setTimeout(bounce, timer, cloneId);
};

var bounce = function(cloneId) {
  var timer = getRandomInt(1000, 3000);
  var octoclone = $("#" + cloneId);
  octoclone.removeClass("zoomIn");
  octoclone.removeClass("wobble");
  octoclone.addClass("bounce");
  setTimeout(wobble, timer, cloneId);
};

var cloneHandler = function() {
  //console.log(cloneCount, cloneLimit);
  $(this).remove();
  cloneCount--;
  if (cloneCount < cloneLimit) {
    spawnNewClone();
    spawnNewClone();
    $(".clone").click(cloneHandler);
  } else {
    runawayOctocats();
  }
};

var runawayOctocats = function() {
  $(".clone").removeClass("zoomIn");
  $(".clone").removeClass("wobble");
  $(".clone").removeClass("bounce");
  $(".clone").addClass("bounceOutDown");
  $("#cloning-machine").text("Aw they got nervous and ran away");
  setTimeout(function() {
    $(".clone").remove();
    $("#cloning-machine").text("Starting up a new cloning machine");
    setTimeout(startCloningMachine, 4000);
  }, 8000);
};

var startCloning = function() {
  if (cloneIndex === 0) {
    spawnNewClone();
    $(".clone").click(cloneHandler);
    $("#cloning-machine").text("Click on a clone!");
    $("#cloning-machine").removeClass("custom-hover");
  }
}

var startCloningMachine = function() {
  cloneIndex = 0;
  cloneCount = 0;
  $("#cloning-machine").text("Start Cloning!");
  $("#cloning-machine").addClass("custom-hover");
  $("#cloning-machine").click(startCloning);
}

$(document).ready(function() {
  // INITIALIZE
  generateRandocat();
  generateOctofactoid();
  $("#randocat-generator").click(generateRandocat);
  $("#octofactoid-generator").click(generateOctofactoid);
  startCloningMachine();
});
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console