<commit_before>var unescape = require("lodash/unescape");

/**
 * Contains the logic for the ontology listing and conversion.
 *
 * @returns {{}}
 */
module.exports = function (graph) {

	var ontologyMenu = {},
		DEFAULT_JSON_NAME = "foaf", // This file is loaded by default
		loadingError = d3.select("#loading-error"),
		loadingProgress = d3.select("#loading-progress"),
		ontologyMenuTimeout,
		emptyGraph=false,
		fileToLoad,
		cachedConversions = {},
		loadOntologyFromText;


	String.prototype.beginsWith = function (string) {
		return(this.indexOf(string) === 0);
	};

	ontologyMenu.setup = function (_loadOntologyFromText) {
		loadOntologyFromText = _loadOntologyFromText;

		var menuEntry= d3.select("#select");
		menuEntry.on("mouseover",function(){
			var searchMenu=graph.options().searchMenu();
			searchMenu.hideSearchEntries();
		});

		setupConverterButtons();
		setupUploadButton();

		var descriptionButton = d3.select("#error-description-button").datum({open: false});
		descriptionButton.on("click", function (data) {
			var errorContainer = d3.select("#error-description-container");
			var errorDetailsButton = d3.select(this);

			// toggle the state
			data.open = !data.open;
			var descriptionVisible = data.open;
			if (descriptionVisible) {
				errorDetailsButton.text("Hide error details");
			} else {
				errorDetailsButton.text("Show error details");
			}
			errorContainer.classed("hidden", !descriptionVisible);
		});

		setupUriListener();
	};


	function setupUriListener() {
		// parse the url initially
		parseUrlAndLoadOntology();

		// reload ontology when hash parameter gets changed manually
		d3.select(window).on("hashchange", function () {
			var oldURL = d3.event.oldURL, newURL = d3.event.newURL;

			if (oldURL !== newURL) {
				// don't reload when just the hash parameter gets appended
				if (newURL === oldURL + "#") {
					return;
				}

				updateNavigationHrefs();
				parseUrlAndLoadOntology();
			}
		});

		updateNavigationHrefs();
	}

	/**<commit_msg>Remove parameter in URL when the model is changed <commit_after>var unescape = require("lodash/unescape");

/**
 * Contains the logic for the ontology listing and conversion.
 *
 * @returns {{}}
 */
module.exports = function (graph) {

	var ontologyMenu = {},
		DEFAULT_JSON_NAME = "foaf", // This file is loaded by default
		loadingError = d3.select("#loading-error"),
		loadingProgress = d3.select("#loading-progress"),
		ontologyMenuTimeout,
		emptyGraph=false,
		fileToLoad,
		cachedConversions = {},
		loadOntologyFromText;


	String.prototype.beginsWith = function (string) {
		return(this.indexOf(string) === 0);
	};

	ontologyMenu.setup = function (_loadOntologyFromText) {
		loadOntologyFromText = _loadOntologyFromText;

		var menuEntry= d3.select("#select");
		menuEntry.on("mouseover",function(){
			var searchMenu=graph.options().searchMenu();
			searchMenu.hideSearchEntries();
		});

		setupConverterButtons();
		setupUploadButton();

		var descriptionButton = d3.select("#error-description-button").datum({open: false});
		descriptionButton.on("click", function (data) {
			var errorContainer = d3.select("#error-description-container");
			var errorDetailsButton = d3.select(this);

			// toggle the state
			data.open = !data.open;
			var descriptionVisible = data.open;
			if (descriptionVisible) {
				errorDetailsButton.text("Hide error details");
			} else {
				errorDetailsButton.text("Show error details");
			}
			errorContainer.classed("hidden", !descriptionVisible);
		});

		setupUriListener();
	};


	function setupUriListener() {
		// parse the url initially
		parseUrlAndLoadOntology();

		// reload ontology when hash parameter gets changed manually
		d3.select(window).on("hashchange", function () {
			var oldURL = d3.event.oldURL, newURL = d3.event.newURL;

			if (oldURL !== newURL) {
				// don't reload when just the hash parameter gets appended
				if (newURL === oldURL + "#") {
					return;
				}

				updateNavigationHrefs();
				parseUrlAndLoadOntology();
				// remove param if exists
				webvowl.updateParam('IRIcenter');
			}
		});

		updateNavigationHrefs();
	}

	/**
{'fraction_non_alphanumeric': 0.13624242424242425, 'fraction_numerical': 0.0048484848484848485, 'mean_word_length': 4.138231631382316, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4099640', 'n_tokens_mistral': 1436, 'n_tokens_neox': 1220, 'n_words': 270}