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="wrapper">
<div class="container">
<div class="icons" id="btn-start-stop">
<span class="stop-watch">
<span class="sw-parts">
<span class="sw-parts2" id="icn-clock-line"></span>
</span>
</span>
<span class="label" id="label-start-stop">START</span>
</div>
<div class="clock">
<p><span id="hr">00</span>:<span id="min">00</span>:<span id="sec">00</span></p>
</div>
<ul class="clockline" id="clockline">
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
<div class="btn btn-reset" id="btn-reset">
<span class="bl-parts"></span>
<span class="bl-parts"></span>
<span class="btn-label">RESET</span>
</div>
</div><!-- /.container -->
</div><!--/.wrapper -->
@import "compass/css3";
$boxWidth: 50;
html,body{
width:100%;
height:100%;
background: radial-gradient(50% 16%, circle, #219eb0 32%, #3f679d 88%);
}
.wrapper{
position:relative;
width:100%;
height:100%;
}
.container{
width:320px;
height:320px;
margin:auto;
position:absolute;
top:0;
bottom:0;
left:0;
right:0;
background: linear-gradient(to bottom, #0c3d69 16%, #116c97 95%);
box-shadow:0 4px 36px 0 rgba(0,0,0,0.5);
border-radius:8px;
overflow:hidden;
}
.icons{
position:absolute;
width:48px;
height:48px;
text-align:center;
cursor:pointer;
top:4px;
left:8px;
.stop-watch{
display:block;
width:24px;
height:24px;
position:absolute;
left:0;
right:0;
top:50%;
margin:-10px auto 0;
border: 2px solid #f8f8f8;
border-radius:24px;
//margin:4px auto;
&::before{
content:"";
display:block;
width:10px;
height:2px;
background:#f8f8f8;
position:absolute;
top:-6px;
right:0;
left:0;
margin:0 auto;
transform:top 0.2s;
}
&::after{
content:"";
display:block;
width:2px;
height:4px;
background:#f8f8f8;
position:absolute;
top:-3px;
right:-3px;
transform:rotate(45deg);
}
&.sw-click::before{
top:-3px;
}
.sw-parts{
display:block;
position:absolute;
top:0;
bottom:0;
left:0;
right:0;
margin:auto;
width:4px;
height:4px;
border-radius:4px;
background:#F8f8f8;
.sw-parts2{
display:block;
width:2px;
height:9px;
background:#f8f8f8;
position:absolute;
top:2px;
left:1px;
}
#icn-clock-line{
transform-origin:50% 0;
transform:rotate(180deg);
transition:transform 0.5s ;
}
}
}
.label{
color:#FFF;
text-align:center;
position:absolute;
bottom:-1rem;
left:0;
right:0;
margin:auto;
font-size:0.75rem;
font-family: 'Share Tech Mono',sans-serif;
}
}
.clock{
p{
position:absolute;
color:#FFF;
text-align:center;
top:144px;
left:0;
right:0;
margin:0 auto;
font-family: 'Share Tech Mono',sans-serif;
font-size:2rem;
font-weight:300;
}
}
.clockline li{
width:1px;
height:20px;
border-radius:2px;
background:#f8f8f8;
position:absolute;
left: 160px;
top: 160px;
//Half size of a circle
$r: 112;//224px cirlcle
@for $i from 1 through 100{
//What I want to repeat
&:nth-child(#{$i}){
$angle:450 + (360 / 100) * $i;
$radian: (360 / 100) * (pi()/180) * $i;
$x: $r * cos($radian) + px;
$y: $r * sin($radian) + px;
transform-origin:100% 0%;
transform: translate($x,$y) rotate( $angle + deg) ;
@if ($i % 5) == 0 {
height:32px;
}
}
}
}
.btn{
cursor:pointer;
}
.btn-reset{
//shape
width:48px;
height:48px;
//border:1px solid #f8f8f8;
//border-radius:48px;
position:absolute;
top:4px;
right:8px;
box-sizing:border-box;
//padding:10px;
opacity:0.5;
transition:opacity 0.2s;
.bl-parts{
display:block;
position:absolute;
width:24px;
height:24px;
border-top:2px solid #f8f8f8;
border-right:2px solid transparent;
border-left:2px solid transparent;
border-radius:50%;
transform:rotate(45deg);
top:10px;
left:10px;
transition:transform 0s;
&::after{
content:"";
display:block;
width:0;
height:0;
border-top:8px solid transparent;
border-right:8px solid #f8f8f8;
border-left:8px solid transparent;
position:absolute;
top:2px;
// transform:rotate(-1deg);
left:8px;
top:-2px;
}
}
.bl-parts:nth-child(2){
transform:rotate(225deg);
}
&.br-click{
.bl-parts{
transform:rotate(405deg);
}
.bl-parts:nth-child(2){
transform:rotate(585deg);
}
}
}
.btn-label{
width:100%;
color:#FFF;
text-align:center;
position:absolute;
bottom:-1rem;
font-size:0.75rem;
font-family: 'Share Tech Mono',sans-serif;
}
(function($,doc,win){
//Variables
var hour = $('#hr');
var min = $('#min');
var sec = $('#sec');
var liNum = 75;
var flip = false;
var intervalCounter = 0;
//Buttons
var btnStartStop = $('#btn-start-stop');
var labelStartStop = $('#label-start-stop');
var btnReset = $('#btn-reset');
//Elements for Animations
var icnClockLine = $('#icn-clock-line');
var icnClockLineDeg = 180;
var clockLines = $('.clockline').find('li');
var clockLines_arr = [];
for (var i = 0; i < clockLines.length; i++) {
clockLines_arr.push(clockLines[i]);
}
//Time
var currentTime = 0;
//States
var stop = true;
//Method
var sWatchMethod ={
timer: function(){
var interval = 10;
time = setInterval(function() {
intervalCounter +=interval;
if (!stop) {
if((intervalCounter%1000)==0){
currentTime += 1000;
var appendHour = currentTime / (1000 * 60 * 60) | 0;
var appendMinute = currentTime % (1000 * 60 * 60) / (1000 * 60) | 0;
var appendSecond = currentTime % (1000 * 60) / 1000 | 0;
appendHour = appendHour < 10 ? "0" + appendHour : appendHour;
appendMinute = appendMinute < 10 ? "0" + appendMinute : appendMinute;
appendSecond = appendSecond < 10 ? "0" + appendSecond : appendSecond;
hour.html(appendHour);
min.html(appendMinute);
sec.html(appendSecond);
}
//------
var target = $('#clockline li').eq(liNum);
if(!flip){
target.css('background','#339dac');
}else{
target.css('background','#fff');
}
liNum += 1;
if(liNum>100){
liNum=0;
}
if(liNum ==75){
flip =!flip;
}
}
}, 10);
},
startAndStop: function(){
$('#btn-start-stop .stop-watch').addClass('sw-click');
setTimeout(function(){
$('#btn-start-stop .stop-watch').removeClass('sw-click');
},200);
stop = !stop;
if(!stop){
labelStartStop.html('STOP');
if(!intervalCounter){
sWatchMethod.timer();
}
}else{
labelStartStop.html('START');
//clearInterval(time);
//clearInterval(time2);
}
btnReset.css('opacity',1);
$('.btn-reset .bl-parts').css('transition','transform 0s');
btnReset.removeClass('br-click');
setTimeout(function(){
$('.btn-reset .bl-parts').css('transition','transform 0.5s');
},200);
},
reset: function(){
if(!stop){
stop = !stop;
labelStartStop.html('START');
}
clearInterval(time);
if(intervalCounter){
currentTime = 0;
intervalCounter = 0;
hour.html("00");
min.html("00");
sec.html("00");
liNum = 75;
flip = false;
for (var i = 0; i < clockLines.length; i++) {
$('#clockline li').eq(i).css('background','#fff');
}
$(this).css('opacity',0.5);
$(this).addClass('br-click');
}
},
init: function(){
btnStartStop.on('click',sWatchMethod.startAndStop);
btnReset.on('click',sWatchMethod.reset);
}
}
$(document).ready(sWatchMethod.init);
}(jQuery,document,window));
Also see: Tab Triggers