Skip to content

Instantly share code, notes, and snippets.

@sanderversluys
Created May 31, 2012 15:26
Show Gist options
  • Save sanderversluys/2844145 to your computer and use it in GitHub Desktop.
Save sanderversluys/2844145 to your computer and use it in GitHub Desktop.
Car crash calculator
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Car crash</title>
<link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.8.20/themes/base/jquery-ui.css"/>
<style type="text/css">
body {
margin:50px 0px;
padding:0px;
font-family: Verdana;
text-align: center;
}
div#sliders {
margin: 0px auto;
width: 300px;
}
div.slider {
//margin-bottom: 20px;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="http://code.jquery.com/ui/1.8.20/jquery-ui.min.js"></script>
<script>
function fcal(){fh=document.forms[0];def();fh.f.value=ff=0.5*fh.m.value*fh.v.value*fh.v.value/fh.d.value;fh.fc.value=ffc=ff/4.448;fh.ft.value=ffc/2000}
function wu(x){fh=document.forms[0];def();fh.w.value=x;fh.wc.value=x/4.448;fh.m.value=x/9.8;fh.mc.value=x*.3048/(4.448*9.8);fcal()}
function vu(x){fh=document.forms[0];def();fh.v.value=x;fh.vc.value=x*3600/(.3048*5280);fh.vk.value=x*3.6;fcal()}
function du(x){fh=document.forms[0];fh.d.value=x;fh.dc.value=x/.3048;fcal()}
function def(){fh=document.forms[0];if (fh.w.value==0)fh.w.value=711.68;if (fh.m.value==0)fh.m.value=72.62;if (fh.v.value==0)fh.v.value=13.411;if (fh.d.value==0)fh.d.value=.3048}
$(function() {
$('.slider').each(function() {
var value = parseInt($(this).text());
var min = parseInt($(this).data('min'));
var max = parseInt($(this).data('max'));
$(this).empty().slider({
value: value,
min: min,
max: max,
stop: function(event, ui) {
console.log('boe');
}
});
});
});
</script>
</head>
<body>
<div id="sliders">
<p>Leeftijd</p>
<div id="age" class="slider" data-min="0" data-max="100">40</div>
<p>Gewicht</p>
<div id="weight" class="slider" data-min="0" data-max="120">70</div>
<p>Remafstand</p>
<div id="distance" class="slider" data-min="10" data-max="200">100</div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment