const update = () => {
	let request = new XMLHttpRequest();
	if (selected_cal_type == "daily") {
		request.open('GET', "/calendar/events/day/" + selected_date.format('YYYY-MM-DD'), true);
		request.onload = () => { day_onload(request) };
	}
	else if (selected_cal_type == "monthly") {
		request.open('GET', "/calendar/events/month/" + selected_date.format('YYYY-MM'), true);
		request.onload = () => { month_onload(request) };
	}
	request.send();
	update_timeout = setTimeout(update, 60000);
}

init_times(selected_date);
init_event_listeners();
init_user_listeners();
update();
//listen();

//Secret!
if ( window.addEventListener ) {
	let kkeys = [], konami = "38,38,40,40,37,39,37,39,66,65";
	window.addEventListener("keydown", (e) => {
		kkeys.push( e.keyCode );
		if ( kkeys.toString().indexOf( konami ) >= 0 ) {
			alert("nice")
			kkeys = [];
		}
	}, true);
}
