{"size": 2901, "ext": "js", "max_stars_repo_path": "app/static/js/calendarView.js", "max_stars_repo_name": "JackNeus/lampPost", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "app/static/js/calendarView.js", "max_issues_repo_name": "JackNeus/lampPost", "max_issues_repo_issues_event_min_datetime": "2021-12-13T19:50:13.000Z", "max_issues_repo_issues_event_max_datetime": "2021-12-13T19:50:13.000Z", "max_forks_repo_path": "app/static/js/calendarView.js", "max_forks_repo_name": "JackNeus/lampPost", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 1, "max_forks_count": null, "avg_line_length": 28.1650485437, "max_line_length": 73, "alphanum_fraction": 0.6587383661}
// handle clicks of calendar view/list view button
var handleCalendarView = function() {
	$("#calendarViewBtn").click(function() {
		// Add calendar parameter to URL.
		if (getUrlParameter('cal') === undefined) {
			updateUrl(addUrlParameter(document.location.search, 'cal'));
		}
		else {
			updateUrl(removeUrlParameter(document.location.search, 'cal'));
		}
		$(this).tooltip('hide');
		// update that view mode has changed
		change_view_mode = true;
		toggleCalendarView();
	})
};

// toggle view for calendar and display the correct week calendar results
var toggleCalendarView = function() {
	// toggle column size proportions
	$("#browserView").toggleClass('calendar-view');
	$("#searchSort").toggle();
	$(".select-style").toggle();
	$(".sort-direction").toggle();
	$(".sort-box").toggle();
	$(".calendarBtns").toggle();
	$("#browserMsg").toggle();

	// make sure to update event view and recheck event url paramater
	$("#event-view").hide();
	urlParamEventId = checkEventUrlParameter();

	// toggle calendar/list view button
	if ($("#calendarViewBtn").hasClass("calendarMode")) {
		var calendarBtn = `<i class="fas fa-calendar"></i>`;
		$("#calendarViewBtn").html(calendarBtn);
		$("#calendarViewBtn").attr('data-original-title', 'Calendar View');
		$("#calendarViewBtn").prop('title', 'Calendar View');
		$('#weekTitle').text('');
	}
	else {
		var listBtn = `<i class="fas fa-list"></i>`;
		$("#calendarViewBtn").html(listBtn);
		$("#calendarViewBtn").attr('data-original-title', 'List View');
		$("#calendarViewBtn").prop('title', 'List View');
		calWeek = 0; // reset week to 0 (current week)
	}

	$("#searches").html("");
	$("#calendarViewBtn").toggleClass("calendarMode");
	trigger_search();	// get new search results
	handleNextWeekClick();
	handlePreviousWeekClick();
};

// handle clicks of next week arrow
// TODO: make date update in datepicker
var handleNextWeekClick = function() {
	$(".nextWeekBtn").unbind("click");
	$(".nextWeekBtn").click(function() {
		calWeek++;
		showSearchResults();
		calendarViewResizeDates();
	})
};

// handle clicks of previous week arrow
var handlePreviousWeekClick = function() {
	$(".previousWeekBtn").unbind("click");
	$(".previousWeekBtn").click(function() {
		calWeek--;
		showSearchResults();
		calendarViewResizeDates();
	})
};

function calendarViewResizeDates() {
	var maxWidth = 0.0
	var days = document.getElementsByClassName("dayName");
	// Find max
	for (var i = 0; i < 7; i++) {
		if (days[i].clientWidth > maxWidth) {
			maxWidth = days[i].clientWidth;
		}
	}
	// Set max
	for (var i = 0; i < 7; i++) {
		days[i].style.width = maxWidth + "px";
	}
	maxWidth = 0.0
	var dates = document.getElementsByClassName("date");
	// Find max
	for (var i = 0; i < 7; i++) {
		if (dates[i].clientWidth > maxWidth) {
			maxWidth = dates[i].clientWidth;
		}
	}
	// Set max
	for (var i = 0; i < 7; i++) {
		dates[i].style.width = maxWidth + "px";
	}
}
