Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class='losetag'>Oops, try again.</div>
<div class='wintag'>Congratulations. <br>You win!</div>
<div class='container'>
  <div class='wrapper'>
    <div class='box'>
      <div class='title'>
        <h1>simon</h1>
      </div>
      
      
      <div class="sm">
        <div class="svg-icon">
          <div class="svg-container">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
	 viewBox="0 0 960 560" style="enable-background:new 0 0 960 560;" xml:space="preserve">
 
  <g class="game">
<path id="id1" class="st0" d="M386,280c0-45.1,36.4-81.7,81.5-82c0-56,0-112,0-168C329.7,30.3,218,142.1,218,280
	c0,0.2,0,0.3,0,0.5h168C386,280.3,386,280.2,386,280z"/>
<path id="id2" class="st1" d="M386,280.5H218c0.3,137.7,111.8,249.2,249.5,249.5c0-56,0-112,0-168
	C422.6,361.7,386.3,325.4,386,280.5z"/>
<path id="id3" class="st2" d="M468,30c-0.2,0-0.3,0-0.5,0c0,56,0,112,0,168c0.2,0,0.3,0,0.5,0c45.3,0,82,36.7,82,82
	c0,0.2,0,0.3,0,0.5h168c0-0.2,0-0.3,0-0.5C718,141.9,606.1,30,468,30z"/>
<path id="id4" class="st3" d="M468,362c-0.2,0-0.3,0-0.5,0c0,56,0,112,0,168c0.2,0,0.3,0,0.5,0c137.9,0,249.7-111.7,250-249.5
	H550C549.7,325.6,513.1,362,468,362z"/>
  </g>
</svg>

          </div>
        </div>
      </div>
      
       
      <a class='play btn active'>Start</a>
    </div>
    <div class='debug'>
      Playerplays:
      <span class='playerplays'></span>
      Correct:
      <span class='correct'></span>
    </div>
    Steps:
    <span class='correctsteps'>0</span>
    Strict:
    <span class='strictmode btn'>Disabled</span>
  </div>
</div>
              
            
!

CSS

              
                @import "compass";
@import "compass"; 
$color1: rgba(181, 76, 104, 1);
$color2: rgba(241, 157, 45, 1);
$color3: rgba(147, 183, 190, 1);
$color4: rgba(126, 107, 143, 1);
$color5: rgba(255, 253, 152, 1);
.debug { display:none;}
* {font-family: 'Righteous', cursive; text-transform:uppercase;}
.box { position:relative; text-align:center; width:100%;  }
.container{ max-width:800px;}
body {      
background:
radial-gradient(darken($color5,30) 15%, transparent 16%) 0 0,
radial-gradient(darken($color5,33) 15%, transparent 16%) 8px 8px,
radial-gradient(rgba(255, 253, 152,.1) 15%, transparent 20%) 0 1px,
radial-gradient(rgba(255, 253, 152,.1) 15%, transparent 20%) 8px 9px;
background-color:$color5;
background-size:16px 16px;

}
.game {    
}
.strictmode, a.play { border: 1px solid #ccc; padding: 4px 8px; display:inline-block; cursor:pointer; margin-top:20px;}
a.play.active { background:#003f7f; color:#fff;}
.playerplays, .correct, .correctsteps { display:inline; 
  &:after { clear:both;content:''; display:block;}
}
.losetag, .wintag { position:absolute;top:0;left:0; z-index:333; font-size:2rem; width:100%; background:rgba(0,0,0,.7); margin-top:10px;padding:10%; text-align:center; color:#fff;}
.strictmode.active { color:#f00;}
.wintag { height:100%;margin:0;padding-top:35%; overflow:hidden;background:rgba(222,222,222,.7); color:#003f7f; font-size:4rem;}

.btn { background:#efefef;}
.svg-icon { width:100%;margin:0 auto;} 
.svg-link { padding: 10px;}
.svg-container {
  margin: 0 auto;
    padding:0; 
    display: inline-block;
    position: relative;
    width: 100%;  
    /* depends on svg ratio, for my zebra height/width = 1.2 so padding-bottom = 50% * 1.2 = 60% */
    vertical-align: middle;
    text-align:center; 
    height: 0; 
    padding-bottom: 50%;
    /* top | middle | bottom ... do what you want */
}
.svg-container svg {
    position: absolute;
    height: 100%;
    width: 100%;
    left: 0;
    top: 0;
}
.svg-container path, .svg-container polygon {
    display: table-cell
}
.svg-container:hover path.bg-red, .svg-container:hover polygon.bg-red {
    fill: #B40026;
    width:100%;
    cursor:pointer;
    -o-transition:.5s;
    -ms-transition:.5s;
    -moz-transition:.5s;
    -webkit-transition:.5s;
    /* ...and now for the proper property */
    transition:.5s;
}
.sm {
    display: table-cell;
  padding:0;
    width:100%;
    margin: 0 auto;
    position:relative;
    float:left; 
}
.sm p { clear:both; background:#f00; text-align:center;}
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
    img[src*=".svg"] {
        width: 100%;
    }
}
@supports (-ms-accelerator:true) {
    img[src*=".svg"] {
        width: 100%
    }
}
.st0,.st1,.st2,.st3 {stroke:#fff;stroke-miterlimit:10;cursor:pointer;}
	.st0{fill:$color1;}
  .st0.active, .st0:hover { fill: darken($color1,10);}
	.st1{fill:$color2;}
  .st1.active, .st1:hover  { fill:darken($color2,10);}
	.st2{fill:$color3;}
  .st2.active, .st2:hover  { fill: darken($color3,10);}
	.st3{fill:$color4;}
  .st3.active, .st3:hover  { fill:darken($color4,10);}
              
            
!

JS

              
                var sndlinkroot = "//s3.amazonaws.com/freecodecamp/simonSound";
var snd1 = new Audio(sndlinkroot + "1.mp3"),
  snd2 = new Audio(sndlinkroot + "2.mp3"),
  snd3 = new Audio(sndlinkroot + "3.mp3"),
  snd4 = new Audio(sndlinkroot + "4.mp3");
var strict = false;
var correct = [],
  playerplays = [];
var delay = 900;
$(function() {
  $('.losetag').hide();
  $('.wintag').hide();
});

/* Check if current plays are correct */
function checkCorrect() {
  if (playerplays.toString() === correct.toString()) {
    // good full string, next
    // Speed up 
    if (correct.length === 5) {
      delay = 800;
    } else if (correct.length === 9) {
      delay = 700;
    } else if (correct.length === 20) {
      // 20 good plays, win!
      $('.wintag').show().fadeOut(4000);
      $('.play').addClass("active");
      setTimeout(function() {
        playAll();
      }, (delay + 1000));
      exit;
    }
    $('.playerplays').html("");
    playerplays = [];
    setTimeout(function() {
      playAll();
      addPlay();
    }, (delay + 1000));
    // Loss
  } else if ((playerplays.length === correct.length) ||
    (correct[(playerplays.length - 1)]) !== (playerplays[(playerplays.length - 1)])) {
    $('.losetag').show().fadeOut(2000);
    setTimeout(function() {
      playerplays = [];
      $('.playerplays').html(" ");
      playAll();
    }, (1700));
    if (strict)
      $('.play').addClass("active");
  }
}

// On game button press
function clickPlay(id) {
  $('.playerplays').append(" " + id);
  makePlay(id);
  playerplays.push(id);
}

// Responsive button push 
function makePlay(id) {
  window[("snd" + id)].play();
  $("#id" + id).addClass('active');
  setTimeout(function() {
    $("#id" + id).removeClass('active');
  }, 200);
}

// Replay current correct plays
function playAll() {
  $('.correct').html(" ");
  for (var i = 0; i < correct.length; i++) {
    (function(i) {
      setTimeout(function() {
        $('.correct').append(" " + correct[i]);
        makePlay(correct[i]);
      }, delay * i);
    })([i]);
  }
}

// Add additional play
function addPlay() {
  var random = Math.floor((Math.random() * 4) + 1);
  setTimeout(function() {
    makePlay(random);
    $('.correct').append(" " + random);
    correct.push(random);
    $('.correctsteps').html(correct.length);
  }, (delay * correct.length));
}

$(".game path").click(function() {
  if (!($('.play').hasClass('active'))) {
    clickPlay($(this).index(".game path") + 1);
    checkCorrect();
  }
});

function setup() {
  $('.correctsteps').html("0");
  playerplays = [];
  correct = [];
  addPlay();
  playAll();
}

// Start/restart button press
$(".play").click(function() {
  setTimeout(function() {
    $(".play").removeClass('active');
    $(".play").text('Restart');
    setup();
  }, 400);

});

// Toggles on/off Strict mode
$(".strictmode").click(function() {
  $(this).toggleClass('active');
  if ($(this).text() === 'Disabled') {
    $('.losetag').html('You lost.');
    $(this).html('Enabled');
    strict = true;
  } else {
    $('.losetag').html('Oops, try again.');
    $(this).html('Disabled');
    strict = false;
  }
});
              
            
!
999px

Console