<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Event Calendar</title>
<link rel="stylesheet" href="https://vkurko.github.io/calendar/global.css?20231021">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@event-calendar/build@3.7.0/event-calendar.min.css">
<script src="https://cdn.jsdelivr.net/npm/@event-calendar/build@3.7.0/event-calendar.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
</head>
<body>
<main class="row">
<div id="ec" class="col"></div>
</main>
<div class="modal" tabindex="-1" id="modal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="modal-title"></h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<form id="form">
<div class="mb-3">
<label for="title" class="col-form-label">Title:</label>
<input type="text" class="form-control" id="title">
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary" form="form" id="save"></button>
</div>
</div>
</div>
</div>
<script type="text/javascript">
const modal = new bootstrap.Modal('#modal', {});
const modalTitle = document.getElementById('modal-title');
const form = document.getElementById('form');
const title = document.getElementById('title');
const save = document.getElementById('save');
let action;
let event;
const ec = new EventCalendar(document.getElementById('ec'), {
view: 'timeGridWeek',
dateClick: function (info) {
action = 'create';
event = {start: info.date, end: endDate(info.date)};
modalTitle.innerText = 'Create appointment';
title.value = '';
save.innerText = 'Create';
modal.show();
},
eventClick: function (info) {
action = 'edit';
event = info.event;
modalTitle.innerText = 'Edit appointment';
title.value = info.event.title;
save.innerText = 'Save changes';
modal.show();
}
});
form.addEventListener('submit', function (e) {
e.preventDefault();
if (action == 'create') {
ec.addEvent({
event,
title: title.value
});
} else {
ec.updateEvent({
event,
title: title.value
});
}
modal.hide();
});
function endDate(start) {
const end = new Date(start);
end.setHours(end.getHours() + 2);
return end;
}
document.getElementById('modal').addEventListener('shown.bs.modal', function () {
title.focus();
});
</script>
</body>
</html>
Output
300px
You can jump to the latest bin by adding /latest
to your URL
Keyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |