JavaScript preprocessors can help make authoring JavaScript easier and more convenient. For instance, CoffeeScript can help prevent easy-to-make mistakes and offer a cleaner syntax and Babel can bring ECMAScript 6 features to browsers that only support ECMAScript 5.
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.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
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.
<div class="main-wrapper">
<div class="content">
<div class="blockHolder hourP1"></div>
<div class="blockHolder hourP0"></div>
<div class="blockHolder colon"></div>
<div class="blockHolder minP1"></div>
<div class="blockHolder minP0"></div>
<div class="blockHolder colon"></div>
<div class="blockHolder secP1"></div>
<div class="blockHolder secP0"></div>
<div class="blockHolder spacer"></div>
<div class="blockHolder letterAP"></div>
</div>
<div class="toggle">
<input name="toggle" id="toggle" type="checkbox" />
<label for="toggle">Toggle 24hr</label>
</div>
</div>
$bg : #111;
$dark : #161616;
$active : #f80;
html, body {
margin: 0;
padding: 0;
height: 100%;
width: 100%;
background:$bg;
color:$active;
}
.main-wrapper {
height: 100%;
position: relative;
margin: 0 10%;
.content::after {
clear:left;
content:"";
display:block;
}
}
.blockHolder {
transition: .2s all;
display:inline-block;
border-radius:1%;
overflow:hidden;
width:11.5%;
margin:50px 0.5%;
float:left;
>div {
width:18%;
padding-top:18%;
margin:1%;
display:inline-block;
float:left;
background:$dark;
transition:.6s background;
border-radius:20%;
}
}
.active {
animation: flip .4s 1 cubic-bezier(0, 0.78, 1, 0.13);
-webkit-animation: flip .4s 1 cubic-bezier(0, 0.78, 1, 0.13);
background:$active;
}
.num0 .cell0,
.num1 .cell1,
.num2 .cell2,
.num3 .cell3,
.num4 .cell4,
.num5 .cell5,
.num6 .cell6,
.num7 .cell7,
.num8 .cell8,
.num9 .cell9,
.colon.on .cellcolon,
.letterAP.AM .cellA,
.letterAP.PM .cellP {
@extend .active;
}
.toggle {
font-size:.8em;
width: 100%;
position:absolute;
left:0;
bottom:1em;
text-align:center;
font-family:Verdana,Arial,Sans;
input {
display:none;
}
label {
transition: .5s all;
opacity:.1;
cursor:pointer;
background:$active;
color:$dark;
padding:5px;
border-radius:5px;
font-weight:bold;
&::before {
content:"\2610";
margin-right:.5em;
}
&:hover {
opacity:1;
}
}
input:checked+label::before{
content:"\2611";
}
}
.hourP1.num0 .cell0 {
background:$dark;
animation:none;
}
.twelvehour {
.blockHolder {
width: 9%;
}
}
.letterAP, .spacer {
width:0;
margin-left:0;
margin-right:0%;
opacity:0;
.twelvehour & {
width: 9%;
margin-left:.5%;
margin-right:.5%;
opacity:1;
}
}
.colon>div {
transition:1s all;
}
@-webkit-keyframes flip {
0% {background:$dark; width:18%; margin:1%;}
49% {background:$dark;}
50% {background:$active; width:0%; margin:1% 10%;}
100% {background:$active; width:18%; margin:1%;}
}
@keyframes flip {
0% {background:$dark; width:18%; margin:1%;}
49% {background:$dark;}
50% {background:$active; width:0%; margin:1% 10%;}
100% {background:$active; width:18%; margin:1%;}
}
/* Append required divs to the dom */
window.xnum = 5; //width
window.ynum = 8; //height
$('.content').children().each(function() {
var str = '';
for(i=0;i<window.xnum*window.ynum;i++) {
str+= '<div/>';
}
$(this).append(str);
});
/* Matrix of digits for LCD display */
var numberGroup = {
0:[1,2,3,5,9,10,14,15,19,20,24,25,29,30,34,36,37,38],
1:[2,6,7,12,17,22,27,32,36,37,38],
2:[1,2,3,5,9,14,18,22,26,30,35,36,37,38,39],
3:[1,2,3,5,9,14,17,18,24,29,30,34,36,37,38],
4:[3,7,8,11,13,15,18,20,21,22,23,24,28,33,38],
5:[0,1,2,3,4,5,10,15,16,17,18,24,29,30,34,36,37,38],
6:[2,3,6,10,15,16,17,18,20,24,25,29,30,34,36,37,38],
7:[0,1,2,3,4,9,13,18,22,27,31,36],
8:[1,2,3,5,9,10,14,16,17,18,20,24,25,29,30,34,36,37,38],
9:[1,2,3,5,9,10,14,15,19,21,22,23,24,29,33,36,37],
"colon":[12,27],
"A":[1,2,3,5,9,10,14,15,16,17,18,19,20,24,25,29,30,34,35,39],
"P":[0,1,2,3,5,9,10,14,15,16,17,18,20,25,30,35,40]
};
/* Apply classes */
for (var key in numberGroup) {
for (var i=0; i<numberGroup[key].length; i++) {
$('.blockHolder,.blockSeparator').find('>div:eq('+(numberGroup[key][i])+')').addClass('cell'+key);
}
}
/* function to run once a second */
window.setTime = function() {
var d = new Date(),
time = {
'hour': $('#toggle').is(':checked') ? d.getHours() : ((d.getHours()-1)%12)+1, //The minus before hand, then plus afterward is so that "12" in the hour shows up as "12" and not "0"
'min':d.getMinutes(),
'sec':d.getSeconds()
},
PM = Math.floor(d.getHours()/12);
if ($('#toggle').is(':checked')) {
$('.content').removeClass('twelvehour');
} else {
$('.content').addClass('twelvehour');
$('.letterAP').removeClass(PM?'AM':'PM').addClass(PM?'PM':'AM');
}
if (time['sec'] % 6) {
$('.colon').addClass("on");
} else {
$('.colon').removeClass("on");
}
for (var key in time) {
var p1 = 'num'+Math.floor(time[key]/10);
var p0 = 'num'+(time[key]%10);
var str = 'num0 num1 num2 num3 num4 num5 num6 num7 num8 num9';
$('.'+key+'P1').removeClass(str.replace(p1,'')).addClass(p1).attr('data-num',p1);
$('.'+key+'P0').removeClass(str.replace(p0,'')).addClass(p0).attr('data-num',p0);
}
}
window.setTime();
$('label').click(function() {
window.setTime();
});
setInterval(function(){
window.setTime();
},1000);
Also see: Tab Triggers