<commit_before>import { softNavigate } from './helpers/navigation';
import { updateQueryStringParameter } from './helpers/queryStringParameter';


function loadSearchResult(event){
	event.preventDefault();
	const newUrl = updateQueryStringParameter("q",document.querySelector(".search-field").value, true);
	softNavigate(newUrl, ".ajaxcontent", ".pagination");
}

window.addEventListener("DOMContentLoaded", function(){
    /* FEATHERS FILTER MODULE */
    const filterModule = document.getElementById("filter");
    if(filterModule){
        filterModule.addEventListener('newFilter', (e) => {
            const filter = e.detail;
			const newurl = `?q=${document.querySelector('.search-field').value}&filterQuery=${escape(JSON.stringify(filter[0]))}`;
            softNavigate(newurl, ".ajaxcontent", ".pagination");
        });
        document.querySelector(".filter").dispatchEvent(new CustomEvent("getFilter"));
	}

	/* SOFT NAVIGATE SEARCH */
	const searchField = document.querySelector(".search-field");
	if(document.querySelector('#filter') && searchField){
		searchField.closest("form").addEventListener("submit", loadSearchResult);
	}
});

$(document).ready(function () {
	var $modals = $('.modal');
	var $editModal = $('.edit-modal');
	var $externalLinkModal = $('.external-link-modal');

	var populateCourseSelection = function (modal, courses) {
		var $selection = modal.find('.course-selection');
		courses.forEach(function (course) {
			var option = document.createElement("option");
			option.text = course.name;
			option.value = course._id;
			$selection.append(option);
		});
		$selection.chosen().trigger("chosen:updated");
	};

	var populateLessonSelection = function (modal, lessons) {
		var $selection = modal.find('.lesson-selection');
		$selection
			.find('option')
			.remove()
			.end();

		lessons.forEach(function (lesson) {
			var option = document.createElement("option");
			option.text = lesson.name;
			option.value = lesson._id;
			$selection.append(option);
		});

		modal.find('.lessons').css("display", "block");
		$selection.chosen().trigger("chosen:updated");
	};

	$('.add-to-lesson').on('click', function (e) {
		e.preventDefault();
		var entry = $(this).attr('href');
		var query = $('.search-field');

		$.getJSON(entry, function (result) {
			var fields = result.content;
			fields.query = query.val();

			if(window.isInline) {
					window.opener.addResource({
						url: fields.url,
						title: fields.title,
						description: fields.description,
						client: fields.providerName
					});
					window.close();
					return;
			}

			populateModalForm($editModal, {
				title: 'Material zu Thema hinzufügen',
				closeLabel: 'Abbrechen',
				submitLabel: 'Senden',
				fields: fields
			});
			populateCourseSelection($editModal, result.courses.data);
			$editModal.appendTo('body').modal('show');
		});

	});
<commit_msg>SC-2123 hotfix from staging<commit_after>import { softNavigate } from './helpers/navigation';
import { updateQueryStringParameter } from './helpers/queryStringParameter';


function loadSearchResult(event){
	event.preventDefault();
	const newUrl = updateQueryStringParameter("q",document.querySelector(".search-field").value, true);
	softNavigate(newUrl, ".ajaxcontent", ".pagination");
}

window.addEventListener("DOMContentLoaded", function(){
    /* FEATHERS FILTER MODULE */
    const filterModule = document.getElementById("filter");
    if(filterModule){
        filterModule.addEventListener('newFilter', (e) => {
            const filter = e.detail;
			const newurl = `?q=${document.querySelector('.search-field').value}&filterQuery=${escape(JSON.stringify(filter[0]))}`;
            softNavigate(newurl, ".ajaxcontent", ".pagination");
        });
        document.querySelector(".filter").dispatchEvent(new CustomEvent("getFilter"));
	}

	/* SOFT NAVIGATE SEARCH */
	const searchField = document.querySelector(".search-field");
	if(document.querySelector('#filter') && searchField){
		searchField.closest("form").addEventListener("submit", loadSearchResult);
	}
});

$(document).ready(function () {
	var $modals = $('.modal');
	var $editModal = $('.edit-modal');
	var $externalLinkModal = $('.external-link-modal');

	var populateCourseSelection = function (modal, courses) {
		var $selection = modal.find('.course-selection');
		courses.forEach(function (course) {
			var option = document.createElement("option");
			option.text = course.name;
			option.value = course._id;
			$selection.append(option);
		});
		$selection.chosen().trigger("chosen:updated");
	};

	var populateLessonSelection = function (modal, lessons) {
		var $selection = modal.find('.lesson-selection');
		$selection
			.find('option')
			.remove()
			.end();

		lessons.forEach(function (lesson) {
			var option = document.createElement("option");
			option.text = lesson.name;
			option.value = lesson._id;
			$selection.append(option);
		});

		modal.find('.lessons').css("display", "block");
		$selection.chosen().trigger("chosen:updated");
	};

	$('.add-to-lesson').on('click', function (e) {
		e.preventDefault();
		var entry = $(this).attr('href');
		var query = $('.search-field');

		$.getJSON(entry, function (result) {
			var fields = result.content;
			fields.query = query.val();

			if(window.isInline) {
					window.opener.addResource({
						url: fields.url,
						title: fields.title,
						description: fields.description,
						client: fields.providerName
					});
					window.close();
					return;
			}

			populateModalForm($editModal, {
				title: 'Material zu Thema hinzufügen',
				closeLabel: 'Abbrechen',
				submitLabel: 'Senden',
				fields: fields
			});
			populateCourseSelection($editModal, result.courses);
			$editModal.appendTo('body').modal('show');
		});

	});

{'fraction_non_alphanumeric': 0.17138884060490178, 'fraction_numerical': 0.0010429341213280027, 'mean_word_length': 4.240437158469946, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6242792', 'n_tokens_mistral': 1915, 'n_tokens_neox': 1685, 'n_words': 301}