Skip to content

Instantly share code, notes, and snippets.

@bcls
Created November 21, 2017 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bcls/587b612cd8f38feabca6d36ac69e91e4 to your computer and use it in GitHub Desktop.
Save bcls/587b612cd8f38feabca6d36ac69e91e4 to your computer and use it in GitHub Desktop.
CMS API search (javascript part) #html #javascript
// JavaScript part
var BCLS = ( function (window, document, rome) {
var dateRangeType = document.getElementById('dateRangeType'),
fromDate = document.getElementById('fromDate'),
toDate = document.getElementById('toDate'),
dateTypeValue,
fromDateValue,
toDateValue,
searchString;
// date pickers
rome(fromDate);
rome(toDate);
// inside event handler for submit
dateTypeValue = getSelectedValue(dateRangeType);
fromDateValue = rome(fromDate).getDate();
if (isDefined(fromDateValue)) {
fromDateValue = fromDateValue.toISOString();
}
toDateValue = rome(toDate).getDate();
if (isDefined(toDateValue)) {
toDateValue = toDateValue.toISOString();
}
searchString += dateTypeValue + ':' + fromDateValue + '..' + toDateValue;
})(window, document, rome);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment