Skip to content

Instantly share code, notes, and snippets.

@onliniak
Created November 30, 2019 20:09
Show Gist options
  • Save onliniak/f09df9049266d0f1a89dbe28c4d1555b to your computer and use it in GitHub Desktop.
Save onliniak/f09df9049266d0f1a89dbe28c4d1555b to your computer and use it in GitHub Desktop.
Flatpickr sample
<!DOCTYPE html>
<html lang="pl" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="https://npmcdn.com/[email protected]/dist/flatpickr.min.css">
<link rel="stylesheet" type="text/css" href="https://npmcdn.com/[email protected]/dist/themes/confetti.css">
<script src="https://npmcdn.com/[email protected]/dist/flatpickr.min.js" charset="utf-8"></script>
<script src="https://npmcdn.com/[email protected]/dist/l10n/pl.js"></script>
</head>
<body>
<input type="text" id="demo">
<span id="news"></span>
<script type="text/javascript">
//fetch("/wp-content/plugins/test_kalendarz/check.php")
//.then((res) => {
// return res.text();
// })
//.then((data) => {
//});
document.getElementById("demo").flatpickr({
enableTime: true,
dateFormat: "F, d Y H:i",
minDate: "today",
//maxDate: new Date().fp_incr(14), // 14 days from now
"locale": "pl",
onDayCreate: function(dObj, dStr, fp, dayElem){
let thisday = dayElem.dateObj
if (thisday.getDate() == 30) {
dayElem.innerHTML += "<span class='event'></span>";
}
},
onChange: [
function(selectedDates, dateStr, instance){
if (selectedDates[0].getDate() == 30) {
document.getElementById("news").innerHTML += "hjhjshjshjsjhshj";
}
},
],
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment