Pen Settings

HTML

CSS

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

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

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.

Editor Settings

Code Indentation

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

Visit your global Editor Settings.

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.

HTML

            
              <link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="http://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
    <div id="GameData">
        <div style="text-align:center">
            <h1 style="display:inline-block">Simon Game</h1><button style="display:inline-block" id="power"><i class="ion ion-power"></i></button>
            <br>
            <center><div id="turn_number" style="display:inline-block"> 1   </div><button id="strict_mode">Normal Mode</button><section id="display_light"></center>
        </div>
    </div>
    <center>
        <div id = "gameCircle">
            <div id = "upper">
                <div id="_0" class="u-l color-button yellow-off inline">&nbsp</div>
                <div id="_1" class="u-r color-button red-off inline">&nbsp</div>
            </div>
            <div id = "lower">
                <div id="_2" class="l-l color-button green-off inline">&nbsp</div>
                <div id="_3" class="l-r color-button blue-off inline">&nbsp</div>
            </div>
        </div>
    </center>
            
          
!

CSS

            
              body{
    background-image: url("https://s20.postimg.org/c0ksq08jh/simon_Gamebkg.jpg");
    background-repeat: no-repeat;
    background-size: cover;
}
h1{
    size:200%;  
    font-family:Lobster;
}
.u-l{
    border-top-left-radius: 100%;
}

.u-r{
    border-top-right-radius: 100%;
}
.l-l{
    border-bottom-left-radius: 100%;
}

.l-r{
    border-bottom-right-radius: 100%;
}
.yellow{
    background-color:#EBF910;
}
.yellow-hover-allowed{
    background-color:#EBF910;
}
.yellow-hover-allowed:hover{
    background-color:#EDF578;
    cursor:pointer;
    cursor:hand;
}
.yellow-off{
    background-color:#A5A517;
}
.red{
    background-color:#EE0C0C;
}
.red-hover-allowed{
    background-color:#EE0C0C;
}
.red-hover-allowed:hover{
    background-color: #F76868;
    cursor:pointer;
    cursor:hand;
}
.red-off{
    background-color:#933010;
}
.green{
    background-color:#27B510;
}
.green-hover-allowed{
    background-color:#27B510;
}
.green-hover-allowed:hover{
    background-color:#82EE71;
    cursor:hand;
    cursor:pointer;
}
.green-off{
    background-color:#4B7854;
}

.blue{
    background-color:#2C84EE;
}
.blue-hover-allowed{
    background-color:#2C84EE;
}
.blue-hover-allowed:hover{
    background-color:#73ACF1;
    cursor:hand;
    cursor:pointer;
}
.blue-off{
    background-color: #0F366C;
}

.inline{
    display: inline-block;  
    margin: 0 0 -4px 0;
    
}


.color-button{
    padding:0;  
    border: 5px solid black;
}
#_0,#_1,#_2,#_3{
    display:table-cell; 
    width:200px;
    height:200px;
    
}
#upper, #lower{
    display:table-row;

}

#power{
    cursor:pointer;
    cursor:hand;
    outline:none;
    background-color:#FF2A00;
    color:white;
    border:none;
    border-radius:100%;
    box-shadow: 0 6px #999;
}

#power:hover{background-color:#F36043;}

#power:active{
    background-color: #F36043;
    box-shadow:0 2px #666;
    transform: translateY(4px);
}

#turn_number{
    width:35px;
    height:35px;
    border-radius:100%;
    padding-top:12  px;
    color:white;
    background-color:blue;
}

#strict_mode{
    height:35px;
    cursor:pointer;
    cursor:hand;
    outline:none;
    background-color:#FF2A00;
    color:white;
    border:none;
    border-radius:15px;
    box-shadow: 0 6px #999;
}

#strict_mode:hover{background-color:#F36043;}

#strict_mode:active{
    background-color: #F36043;
    box-shadow:0 2px #666;
    transform: translateY(4px);
}


            
          
!

JS

            
              var inputAllowed = false;
var running_state = false;
var randomNumbers = [1,2,3,1,2,3,0,1,2,3,0,1,2,3,0];
var userInput = [];
var timeOutElements = [];
var timeOutElements_b = [];
var timesPowerPressed = 0;
var tmp_boolean_array = [true];
function simple_assign(a){
    $('#_0').addClass(a);
    $('#_1').addClass(a);
    $('#_2').addClass(a);
    $('#_3').addClass(a);
}

function simple_remove(a){
    $('#_0').removeClass(a);
    $('#_1').removeClass(a);
    $('#_2').removeClass(a);
    $('#_3').removeClass(a);
}

function assign_to_all(a){
    $('#_0').addClass('yellow'+a);
    $('#_1').addClass('red'+a);
    $('#_2').addClass('green'+a);
    $('#_3').addClass('blue'+a);
}

function remove_from_all(a){
    $('#_0').removeClass('yellow'+a);
    $('#_1').removeClass('red'+a);
    $('#_2').removeClass('green'+a);
    $('#_3').removeClass('blue'+a);
}

function addById(a,b){
    switch(a){
        case 0: $('#_0').addClass('yellow'+b);break;
        case 1: $('#_1').addClass('red'+b);break;
        case 2: $('#_2').addClass('green'+b);break;
        case 3: $('#_3').addClass('blue'+b);break;
    }
}

function removeById(a,b){
    switch(a){
        case 0: $('#_0').removeClass('yellow'+b);break;
        case 1: $('#_1').removeClass('red'+b);break;
        case 2: $('#_2').removeClass('green'+b);break;
        case 3: $('#_3').removeClass('blue'+b);break;
    }
}

$(document).ready(function(){
var tmp;
var run_blinks = function(){
    blink();
    userInput = [];
}
    $('#power').on('click',function(){
        running_state = !running_state;
        if(running_state){
            remove_from_all('-off');
            assign_to_all('');
            tmp = setTimeout(run_blinks,5000);
        }else{
            assign_to_all('-off');
            remove_from_all('');
            tmp_boolean_array[timesPowerPressed] = false;
            timesPowerPressed++;
            tmp_boolean_array.push(true);
        }
    });
});

function blink(){
    var t_tmp = timesPowerPressed;
    var i = 0;
    function change_color(a){
            if(running_state && !inputAllowed && a[3]){
                removeById(a[0],a[2]);
                addById(a[0],a[1]);
                if(i==(randomNumbers.length-1) && (a[2]=='-hovering-state')){
                    inputAllowed = true;
                   // setTimeout()
                }
            }
    }
    function run(b){
        change_color([b,'-hovering-state','',tmp_boolean_array[t_tmp]]);
        timeOutElements_b.push(setTimeout(change_color.bind(null,[b,'','-hovering-state',tmp_boolean_array[t_tmp]]),1000));
    }
    for(i = 0; i < randomNumbers.length; ++i){
        timeOutElements[i] = setTimeout(run.bind(null,randomNumbers[i]),(i*1100));
    }
}   

//Code below this section is in development phase
function getRandomNumber(){
    return (((Math.floor(Math.random()*1000))%783)%4);
}


function userInputCheck(){
    var counta = [0,0,0,0];
    var countb = [0,0,0,0];
    for(i=0;i<randomNumbers.length;++i){
        counta[randomNumbers[i]]++;
    }
    for(i=0;i<userInput.length;++i){
        counta[userInput[i]]++;
    }
    if((counta[0]<countb[0])||(counta[3]<countb[3])||(counta[2]<countb[2])||(counta[1]<countb[1]))return -10;
    if((counta[0]==countb[0])&&(counta[3]==countb[3])&&(counta[2]==countb[2])&&(counta[1]==countb[1]))return 10; 
return 0;
}
            
          
!
999px

Console