Skip to content

Commit

Permalink
Reformatted the slider display
Browse files Browse the repository at this point in the history
I changed the slider display so that it shows the date, as well as the time (in military time) which updates at any movement in the slider.
  • Loading branch information
joh13010 committed Jan 13, 2017
1 parent 0c8bbbd commit ef4a1ae
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions Slider.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,42 @@
function addSlider(fileData) {
var minDate = new Date(parseInt(fileData.data[0].senseStartTimeMillis));
var maxDate = new Date(parseInt(fileData.data[data.data.length - 1].senseStartTimeMillis));
minDateMillis = parseInt(fileData.data[0].senseStartTimeMillis);
maxDateMillis = parseInt(fileData.data[data.data.length - 1].senseStartTimeMillis);
var minDate = new Date(minDateMillis);
var maxDate = new Date(maxDateMillis);

$("#slider").dateRangeSlider({

arrows: false,

bounds: {
min: minDate,
max: maxDate
},

defaultValues: {
min: minDate,
max: maxDate
}
},
formatter:function(val){
var days = val.getDate();
var month = val.getMonth() + 1;
var year = val.getFullYear();
var hours = val.getHours();
var minutes = val.getMinutes();
var time = val.getTime();
return month + "/" + days + "/" + year + " " + addZero(hours) + ":" + addZero(minutes);
}
});

function addZero(val) {
if (val < 10) {
return "0" + val;
}
else {
return val;
}
}

document.getElementById("sliderHeading").innerHTML = "Specify a Date Range:";

// Will call an updateMarkers() function that adds/removes points depending on their date
$("#slider").bind("valuesChanged", function(e, data) {
updateMarkers(data.values.min, data.values.max);
//console.log("Values just changed. min: " + data.values.min + " max: " + data.values.max);
});
}

0 comments on commit ef4a1ae

Please sign in to comment.