Commit 1ebddf7a authored by khawkins98's avatar khawkins98
Browse files

Update date picker function location

parent 93c63345
......@@ -18,27 +18,7 @@ function numberWithCommas(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
// allow the user to change the query
function enableUserDatePicking() {
// set a default date
document.getElementById("originDate").value = moment().format('YYYY-MM-DD');
// update the report on date change
function userChangedDate() {
console.log('Change requested, refreshing...');
render_queue_time = 1; // reset the processing throttle
$('tbody.top-stories').html(''); // empty the results
var requestDate = moment(document.getElementById("originDate").value, 'YYYY-MM-DD');
bootstrapCustomEBIAnalytics(requestDate);
}
// delay the invokation of the date change to not hammer the GAPI
var userChangedDateTimeoutID;
$('#originDate').change( function () {
window.clearTimeout(userChangedDateTimeoutID); // delete any pending change that occured before the timeout cleared
userChangedDateTimeoutID = window.setTimeout(userChangedDate, 750);
});
}
// check if the request has expired (that is: the user changed the params)
function requestIsExpired(requestDate) {
......
......@@ -21,6 +21,29 @@ shared['dayRange'] = 8; // the number of days you wish to get results for. Make
shared['viewID'] = ['ga:91186979']; //The GA property we want to view: www.ebi.ac.uk
shared['clientid'] = '1025857412047-p3jieogi7mgkhb0dre41rm2ge3r8jn0s.apps.googleusercontent.com'; // get at https://console.developers.google.com/apis/credentials
// Allow the user to change the query (date)
// --------
function enableUserDatePicking() {
// set a default date
document.getElementById("originDate").value = moment().format('YYYY-MM-DD');
// update the report on date change
function userChangedDate() {
console.log('Change requested, refreshing...');
render_queue_time = 1; // reset the processing throttle
$('tbody.top-stories').html(''); // empty the results
var requestDate = moment(document.getElementById("originDate").value, 'YYYY-MM-DD');
bootstrapCustomEBIAnalytics(requestDate);
}
// delay the invokation of the date change to not hammer the GAPI
var userChangedDateTimeoutID;
$('#originDate').change( function () {
window.clearTimeout(userChangedDateTimeoutID); // delete any pending change that occured before the timeout cleared
userChangedDateTimeoutID = window.setTimeout(userChangedDate, 750);
});
}
// Bootstrap
// --------
$(document).ready(function() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment