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.

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

              
                
<html>

	<head>
		<meta charset="utf-8">
		<title>Dice throw by Rok Slana</title>	
	</head>

	<body>

		<div id="naslov"></div>

		<div id="kocke">
            <div id="kockeVsebina"></div>	
			<div id="kockeRazlaga"></div>	
		</div>	

		
		<div><button type="button" onclick="izrisi()">Throw dice</button></div>
		
            <script type="text/javascript">{
				var naslov = prompt("Type in your name please : ");
                    document.getElementById('naslov').innerHTML= "<h1>"+naslov+"</h1>";
                    izrisi();
                }   
                
                function izrisi(){
                    document.getElementById('kockeVsebina').innerHTML = metKock();
					document.getElementById('kockeRazlaga').innerHTML = razlaga();
                }
			</script>		
	</body>

</html>

              
            
!

CSS

              
                body {
  background: #98cdaa;
  width: 900px;
  height: 700px;
  border: 7px solid black;
  margin-left: 500px;
  border-radius: 10px;
}

#naslov {
  font-family: sans-serif;
  margin-left: 0px;
  margin-top: 50px;
  font-size: 48px;
  color: red;
  text-align: center;
}

#kocke {
  height: 200px;
  width: 700px;
  border-bottom: 21px solid #004d1a;
  border-right: 14px solid #00cc44;
  margin-left: 100px;
  font-family: sans-serif;
  background-color: #009933;
  border-radius: 10px;
}

button {
  margin: auto;
  margin-top: 50px;
  display: block;
  width: 160px;
  height: 50px;
  font-family: sans-serif;
  font-size: 20px;
}

#kocka {
  float: left;
  margin-top: 40px;
  margin-left: 43px;
  margin-bottom: 18px;
  width: 80px;
  height: 80px;
  border: 1px solid black;
  background-color: #1a1a1a;
  border-radius: 7px;
  border-bottom: 10px solid #333333;
  border-right: 7px solid #808080;
}

#cifra1 {
  position: relative;
  color: white;
  margin-left: 33px;
  margin-top: 33px;
  font-weight: bold;
}

#cifra2 {
  position: relative;
  color: white;
  margin-left: 23px;
  margin-top: 9px;
  font-weight: bold;
}

#cifra3 {
  position: relative;
  color: white;
  margin-left: 23px;
  margin-top: 9px;
  font-weight: bold;
}

#cifra4 {
  position: relative;
  color: white;
  margin-left: 23px;
  margin-top: 9px;
  font-weight: bold;
}

#cifra5 {
  position: relative;
  color: white;
  margin-left: 23px;
  margin-top: 9px;
  font-weight: bold;
}

#cifra6 {
  position: relative;
  color: white;
  margin-left: 23px;
  margin-top: 9px;
  font-weight: bold;
}

.presledek {
  color: #1a1a1a;
}

.razlaga {
  height: 180px;
  width: 100%;
  border-radius: 7px;
  color: #ffad33;
  font-weight: bold;
  font-family: sans-serif;
  letter-spacing: 3px;
  font-size: 24px;
  text-align: center;
  padding-top: 20px;
}

.class {
  text-align: center;
}
              
            
!

JS

              
                		var zf = [0, 0, 0, 0, 0];
		var stVrednosti = [0, 0, 0, 0, 0, 0];
		var maxV = 0;

		function metKock() {
		  for (var i = 0; i < 5; i++) {
		    zf[i] = Math.floor(Math.random() * 6 + 1);
		  }
		  return izrisKocke(zf[0]) + izrisKocke(zf[1]) + izrisKocke(zf[2]) + izrisKocke(zf[3]) + izrisKocke(zf[4]);
		}

		/*	Funkcija za izris kock na zaslonu */

		function izrisKocke(vrednost) {
		  if (vrednost == 1) {
		    return "<div id=\"kocka\">" + "<p id=\"cifra1\">O</p>" + "</div>";
		  } else if (vrednost == 2) {
		    return "<div id=\"kocka\">" + "<p id=\"cifra2\"><span class=\"presledek\">----</span>O<br><br>O</p>" + "</div>";
		  } else if (vrednost == 3) {
		    return "<div id=\"kocka\">" + "<p id=\"cifra3\"><span class=\"presledek\">----</span>O<br><span class=\"presledek\">--</span>O<br>O</p>" + "</div>";
		  } else if (vrednost == 4) {
		    return "<div id=\"kocka\">" + "<p id=\"cifra4\">O<span class=\"presledek\">--</span>O<br><br>O<span class=\"presledek\">--</span>O</p>" + "</div>";
		  } else if (vrednost == 5) {
		    return "<div id=\"kocka\">" + "<p id=\"cifra5\">O<span class=\"presledek\">--</span>O<br><span class=\"presledek\">--</span>O<br>O<span class=\"presledek\">--</span>O</p>" + "</div>";
		  } else if (vrednost == 6) {
		    return "<div id=\"kocka\">" + "<p id=\"cifra6\">O<span class=\"presledek\">--</span>O<br>O<span class=\"presledek\">--</span>O<br>O<span class=\"presledek\">--</span>O</p>" + "</div>";
		  }
		}

		function razlaga() {
		  for (var i = 0; i < 5; i++) {
		    if (zf[i] == 1) {
		      stVrednosti[0]++;
		    } else if (zf[i] == 2) {
		      stVrednosti[1]++;
		    } else if (zf[i] == 3) {
		      stVrednosti[2]++;
		    } else if (zf[i] == 4) {
		      stVrednosti[3]++;
		    } else if (zf[i] == 5) {
		      stVrednosti[4]++;
		    } else if (zf[i] == 6) {
		      stVrednosti[5]++;
		    }
		  }


		  for (var i = 0; i < 6; i++) {
		    if (stVrednosti[i] > maxV) {
		      maxV = stVrednosti[i];
		    }
		  }

		  if (maxV == 3) {
		    for (var i = 0; i < 6; i++) {
		      if (stVrednosti[i] == 2) {
		        maxV = 3.5;
		      }
		    }
		  }
		  /*	Zanki za iskanje male in velike kente*/
		  if (maxV == 1 && stVrednosti[5] != 1) {
		    maxV = 6;
		  }

		  if (maxV == 1 && stVrednosti[0] != 1) {
		    maxV = 7;
		  }

		  for (var i = 0; i < 5; i++) {
		    zf[i] = 0;
		  }
		  for (var i = 0; i < 6; i++) {
		    stVrednosti[i] = 0;
		  }


		  var vrednost = maxV;
		  maxV = 0;

		  switch(vrednost){
				case 2:
					return "<div class=\"razlaga\">PAIR</div>";
					break;
					
				case 3:
					return "<div class=\"razlaga\">THREE OF A KIND</div>";
					break;
					
				case 3.5:
					return "<div class=\"razlaga\">FULL HOUSE</div>";
					break;
					
				case 4:
					return "<div class=\"razlaga\">FOUR OF A KIND</div>";
					break;
					
				case 5:
					return "<div class=\"razlaga\">YAHTZEE</div>";
					break;
					
				case 6:
					return "<div class=\"razlaga\">SMALL STRAIGHT</div>";
					break;
					
				case 7:
					return "<div class=\"razlaga\">LARGE STRAIGTH</div>";
					break;	
					
				default:
					return "<div class=\"razlaga\">TRY AGAIN</div>";
					break;
			}

		}
              
            
!
999px

Console