mirror of
https://github.com/nikdoof/website-hugo.git
synced 2025-12-13 14:32:25 +00:00
Switch calendar library (fixes #4)
This commit is contained in:
@@ -1,3 +1,7 @@
|
|||||||
|
function titleCase(word) {
|
||||||
|
return word.charAt(0).toUpperCase() + word.substr(1).toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
$(".navbar-burger").click(function () {
|
$(".navbar-burger").click(function () {
|
||||||
$(".navbar-burger").toggleClass("is-active");
|
$(".navbar-burger").toggleClass("is-active");
|
||||||
@@ -19,10 +23,6 @@ $(document).ready(function () {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function titleCase(word) {
|
|
||||||
return word.charAt(0).toUpperCase() + word.substr(1).toLowerCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 'printers' shortcode
|
// 'printers' shortcode
|
||||||
if ($('div#printer-status').length) {
|
if ($('div#printer-status').length) {
|
||||||
$.getJSON("https://api.leighhack.org/space.json", function (data) {
|
$.getJSON("https://api.leighhack.org/space.json", function (data) {
|
||||||
@@ -41,42 +41,3 @@ $(document).ready(function () {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function render_calendar() {
|
|
||||||
const calendar = new tui.Calendar('#calendar', {
|
|
||||||
defaultView: 'month',
|
|
||||||
isReadOnly: true,
|
|
||||||
useDetailPopup: true,
|
|
||||||
usageStatistics: false,
|
|
||||||
month: {
|
|
||||||
startDayOfWeek: 1,
|
|
||||||
visibleWeeksCount: 4,
|
|
||||||
},
|
|
||||||
calendars: [
|
|
||||||
{
|
|
||||||
id: '1',
|
|
||||||
name: 'Hackspace Events',
|
|
||||||
backgroundColor: '#d41246',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
$.getJSON('https://api.leighhack.org/events', function (data) {
|
|
||||||
data.forEach(function (event) {
|
|
||||||
calendar.createEvents([{
|
|
||||||
id: event['uid'],
|
|
||||||
calendarId: '1',
|
|
||||||
title: event['summary'],
|
|
||||||
body: event['description'],
|
|
||||||
state: 'Free',
|
|
||||||
dueDateClass: '',
|
|
||||||
start: event['start']['dateTime'],
|
|
||||||
end: event['end']['dateTime'],
|
|
||||||
}])
|
|
||||||
});
|
|
||||||
});
|
|
||||||
calendar.render();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,18 +7,41 @@
|
|||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ define "extra_css" }}
|
{{ define "extra_css" }}
|
||||||
<link rel="stylesheet" href="https://uicdn.toast.com/calendar/latest/toastui-calendar.min.css" />
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@event-calendar/build@2.4.1/event-calendar.min.css">
|
||||||
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ define "extra_js" }}
|
{{ define "extra_js" }}
|
||||||
<script src="https://uicdn.toast.com/calendar/latest/toastui-calendar.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/@event-calendar/build@2.4.1/event-calendar.min.js" type="application/javascript"></script>
|
||||||
<script>
|
<script type="application/javascript">
|
||||||
|
var events = [];
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
render_calendar();
|
$.getJSON('https://api.leighhack.org/events', function (data) {
|
||||||
|
data.forEach(function (event) {
|
||||||
|
events.push({
|
||||||
|
id: event['uid'],
|
||||||
|
title: event['summary'],
|
||||||
|
body: event['description'],
|
||||||
|
state: 'Free',
|
||||||
|
dueDateClass: '',
|
||||||
|
start: event['start']['dateTime'],
|
||||||
|
end: event['end']['dateTime'],
|
||||||
|
})
|
||||||
|
});
|
||||||
|
let ec = new EventCalendar(document.getElementById('calendar'), {
|
||||||
|
view: 'listMonth',
|
||||||
|
events: events,
|
||||||
|
headerToolbar: {
|
||||||
|
start: 'prev,next today',
|
||||||
|
center: 'title',
|
||||||
|
end: 'dayGridMonth, listMonth'
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ define "content" }}
|
{{ define "content" }}
|
||||||
<div id="calendar" style="height: 600px"></div>
|
<div id="calendar"></div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
Reference in New Issue
Block a user