<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.0/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<div class="container">
<div class="price-box">
<div class="row">
<div class="col-sm-6">
<form class="form-horizontal form-pricing" role="form">
<div class="price-slider">
<h4 class="great">Príkon vo Watoch</h4>
<span>Príkon vo Watoch starej žiarovky</span>
<div class="col-sm-12">
<div id="slider_amirol"></div>
</div>
</div>
<div class="price-slider">
<h4 class="great">Doba svietenia</h4>
<span>Doba svietenia počas dňa v hodinách</span>
<div class="col-sm-12">
<div id="slider_doba_svietenia"></div>
</div>
</div>
<div class="price-slider">
<h4 class="great">Čas šetrenia</h4>
<span>Koľko ušetríte za obdobie</span>
<div class="btn-group btn-group-justified">
<div class="btn-group btn-group-lg">
<button type="button"
class="btn btn-primary btn-lg btn-block month active-month selected-month"
id='one_year'>1 rok
</button>
</div>
<div class="btn-group btn-group-lg">
<button type="button"
class="btn btn-primary btn-lg btn-block month" id='six_months'>
6 Mesiacov
</button>
</div>
<div class="btn-group btn-group-lg">
<button type="button"
class="btn btn-primary btn-lg btn-block month" id='one_months'>1 Mesiac
</button>
</div>
</div>
<div class="price-slider">
<h4 class="great">Cena za kWh</h4>
<span>Priemerná cena za kWh na Slovensku [EUR/kWh]</span>
<input name="sliderVal" type="hidden" id="sliderVal" value='0'
readonly="readonly"/>
<input name="sliderDsVal" type="hidden" id="sliderDsVal" value='0'
readonly="readonly"/>
<input name="month" type="hidden" id="month" value='24'
readonly="readonly"/>
<input name="term" type="hidden" id="term" value='quarterly'
readonly="readonly"/>
<div class="btn-group btn-group-justified">
<div class="btn-group btn-group-lg">
<button type="button"
class="btn btn-primary btn-lg btn-block term active-term selected-term"
id='quarterly'>0.0505 [EUR/kWh]
</button>
</div>
<div class="btn-group btn-group-lg">
<button type="button"
class="btn btn-primary btn-lg btn-block term"
id='monthly'>
0.0622 [EUR/kWh]
</button>
</div>
<div class="btn-group btn-group-lg">
<button type="button"
class="btn btn-primary btn-lg btn-block term"
id='weekly'>
0.0379 [EUR/kWh]
</button>
</div>
</div>
</div>
</div>
</div>
<div class="col-sm-6">
<div class="price-form">
<div class="form-group">
<div class="row">
<div class="col-sm-6">
<label for="amount_amirol" class="control-label">Obýčajná
žiarovka
(EUR): </label>
<span class="help-text">Cena starého osvetlenia</span>
</div>
<div class="col-sm-6">
<input type="hidden" id="amount_amirol"
class="form-control">
<!-- <p class="price lead" id="total"></p> -->
<input class="price lead" name="totalprice" type="text"
id="total"
disabled="disabled" style=""/>
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-sm-6">
<label for="amount_amirol" class="control-label">LED
Žiarovka (EUR): </label>
<span class="help-text">Cena LED osvetlenia</span>
</div>
<div class="col-sm-6">
<input type="hidden" id="amount_amirol"
class="form-control">
<!-- <p class="price lead" id="total12"></p> -->
<input class="price lead" name="totalprice12" type="text"
id="total12"
disabled="disabled" style=""/>
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-sm-6">
<label for="amount_amirol" class="control-label">Úspora
(EUR): </label>
<span class="help-text">Suma ktorú ušetríte pri použiti LED osvetlenia</span>
</div>
<div class="col-sm-6">
<input type="hidden" id="amount_amirol"
class="form-control">
<!-- <p class="price lead" id="total52"></p> -->
<input class="price lead" name="totalprice52" type="text"
id="total52"
disabled="disabled" style=""/>
</div>
</div>
</div>
<div style="margin-top:30px"></div>
<hr class="style">
<div class="form-group">
<div class="col-sm-12">
<button type="submit"
class="btn btn-primary btn-lg btn-block">
Pokračovať <span
class="glyphicon glyphicon-chevron-right"></span></button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/ui/1.10.4/jquery-ui.min.js"></script>
body {
padding-top: 60px;
}
.price-box {
margin: 0 auto;
background: #E9E9E9;
border-radius: 10px;
padding: 40px 15px;
/*width: 500px;*/
}
.ui-widget-content {
border: 1px solid #bdc3c7;
background: #e1e1e1;
color: #222222;
margin-top: 4px;
}
.ui-slider .ui-slider-handle {
position: absolute;
z-index: 2;
width: 7.2em;
height: 2.7em;
cursor: default;
margin: 0 -40px auto !important;
text-align: center;
line-height: 30px;
color: #FFFFFF;
font-size: 12px;
}
.ui-slider .ui-slider-handle .glyphicon {
color: #FFFFFF;
margin: 0 1px;
font-size: 11px;
opacity: 0.7;
}
.ui-corner-all {
border-radius: 20px;
}
.ui-slider-horizontal .ui-slider-handle {
top: -.9em;
}
.ui-state-default,
.ui-widget-content .ui-state-default {
border: 1px solid #f9f9f9;
background: #3498db;
}
.ui-slider-horizontal .ui-slider-handle {
margin-left: -0.5em;
}
.ui-slider .ui-slider-handle {
cursor: pointer;
}
.ui-slider a,
.ui-slider a:focus {
cursor: pointer;
outline: none;
}
.price, .lead p {
font-weight: 600;
font-size: 32px;
display: inline-block;
line-height: 60px;
border:0;
width: 245px;
}
h4.great {
background: #00ac98;
margin: 0 0 25px -60px;
padding: 7px 15px;
color: #ffffff;
font-size: 18px;
font-weight: 600;
border-radius: 5px;
display: inline-block;
-moz-box-shadow: 2px 4px 5px 0 #ccc;
-webkit-box-shadow: 2px 4px 5px 0 #ccc;
box-shadow: 2px 4px 5px 0 #ccc;
}
.total {
border-bottom: 1px solid #7f8c8d;
/*display: inline;
padding: 10px 5px;*/
position: relative;
padding-bottom: 20px;
}
.total:before {
content: "";
display: inline;
position: absolute;
left: 0;
bottom: 5px;
width: 100%;
height: 3px;
background: #7f8c8d;
opacity: 0.5;
}
.price-slider {
margin-bottom: 70px;
}
.price-slider span {
font-weight: 200;
display: inline-block;
color: #7f8c8d;
font-size: 13px;
}
.form-pricing {
background: #ffffff;
padding: 20px;
border-radius: 4px;
}
.price-form {
background: #ffffff;
margin-bottom: 10px;
padding: 20px;
border: 1px solid #eeeeee;
min-height: 520px;
border-radius: 4px;
/*-moz-box-shadow: 0 5px 5px 0 #ccc;
-webkit-box-shadow: 0 5px 5px 0 #ccc;
box-shadow: 0 5px 5px 0 #ccc;*/
}
.form-group {
margin-bottom: 0;
}
.form-group span.price {
font-weight: 200;
display: inline-block;
color: #7f8c8d;
font-size: 14px;
}
.help-text {
display: block;
margin-top: -10px;
margin-bottom: 10px;
color: #737373;
/*position: absolute;*/
/*margin-left: 20px;*/
font-weight: 200;
/*text-align: right;*/
width: 188px;
}
.price-form label {
font-weight: 200;
font-size: 21px;
}
img.payment {
display: block;
margin-left: auto;
margin-right: auto
}
.ui-slider-range-min {
background: #2980b9;
}
.active-month,
.active-term {
background: #3276b1;
}
/* HR */
hr.style {
margin-top: 0;
border: 0;
border-bottom: 1px dashed #ccc;
background: #999;
}
// JavaScript Document
var p = {
0: "15W",
1: "20W",
2: "25W",
3: "30W",
4: "35W",
5: "40W",
6: "45W",
7: "50W",
8: "55W",
9: "60W",
10: "65W",
11: "70W",
12: "75W",
13: "80W",
14: "85W",
15: "90W",
16: "95W",
17: "100W",
};
var t = {
0: "15",
1: "20",
2: "25",
3: "30",
4: "35",
5: "40",
6: "45",
7: "50",
8: "55",
9: "60",
10: "65",
11: "70",
12: "75",
13: "80",
14: "85",
15: "90",
16: "95",
17: "100",
}
var ds = {
0: "1",
1: "2",
2: "3",
3: "4",
4: "5",
5: "6",
6: "7",
7: "8",
8: "9",
9: "10",
10: "11",
11: "12",
12: "13",
13: "14",
14: "15",
15: "16",
16: "17",
17: "18",
18: "19",
19: "20",
20: "21",
21: "22",
22: "23",
23: "24",
}
var obj = {
'24' : {
'quarterly' : '0.0505',
'monthly' : '0.0622',
'weekly' : '0.0379'
},
'12' : {
'quarterly' : '0.0505',
'monthly' : '0.0622',
'weekly' : '0.0379'
},
'8' : {
'quarterly' : '0.0505',
'monthly' : '0.0622',
'weekly' : '0.0379'
}
};
$(document).ready(function() {
$("#total").val("10000");
$("#slider_amirol").slider({
range: "min",
animate: true,
min: 0,
max: 17,
step: 1,
slide:
function(event, ui)
{
update(1,ui.value); //changed
calcualtePrice(ui.value);
}
});
$('#slider_doba_svietenia').slider({
range: "min",
animate: true,
min: 0,
max: 23,
step: 1,
slide:
function(event, ui)
{
updateHours('#slider_doba_svietenia',ui.value);
calcualtePrice(ui.value);
}
});
$('.term').on('click',function(event) {
var id = $(this).attr('id');
$('.term').removeClass('selected-term');
$(this).addClass('selected-term');
$(".term").removeClass("active-term");
$(this).addClass("active-term");
$('#term').val(id);
calcualtePrice()
});
updateHours();
update();
calcualtePrice();
});
function updateHours(slider,val) {
if(undefined === val) val = 0;
var hours = ds[val];
$('#sliderDsVal').val(val);
$('#slider_doba_svietenia a').html('<label><span class="glyphicon glyphicon-chevron-left"></span> '+hours
+' <span class="glyphicon glyphicon-chevron-right"></span></label>');
}
function update(slider,val) {
if(undefined === val) val = 0;
var amount = p[val];
$('#sliderVal').val(val);
$('#slider_amirol a').html('<label><span class="glyphicon glyphicon-chevron-left"></span> '+amount
+' <span class="glyphicon glyphicon-chevron-right"></span></label>');
}
function calcualtePrice(val){
if(undefined === val)
val = $('#sliderVal').val();
var ds_hours = $('#sliderDsVal').val();
var month = $('#month').val();
var term = obj[month][$('#term').val()];
var poc_dni_rok = 365;
// var totalPrice = t[val]*term;
var totalPrice = t[val]/1000*ds_hours*term;
var ledWat = t[val]/12;
totalPrice *= poc_dni_rok;
var totalPriceLed = ledWat/1000*ds_hours*term;
totalPriceLed *=poc_dni_rok;
var totalUspora = totalPrice - totalPriceLed;
$("#total").val(totalPrice.toFixed(2));
$("#total12").val(totalPriceLed.toFixed(2));
$("#total52").val(totalUspora.toFixed(2));
}