<commit_before>$(window).on('hashchange', function() {
	var url = window.location.href;
	
	var index = url.indexOf("#browser");
	if (index != -1) {
		browserSetAddr(url.substring(index));
	}
});

function browserDataReceived(id, data, error) {
	if (error != null) {
		noty({text: error});
	}
	else {
		display("browser-container", document.browserDisplayTemplate, {data: data});
		updateLinks();
		resizeTabs("#browser");
	}
	pauseUpdates("browser");
}

function updateLinks() {
	$("#browser a").each(function() {
		var href = $(this).attr("href");
		if (href != null && href.indexOf("#browser") == 0) {
			$(this).click(function() {
				console.log("Navigating to " + href);
				browserSetAddr(href);
			});
		}
	});
}

function browserSetHome(addr) {
	var url = window.location.href;
	document.browserHome = addr;
	var index = url.indexOf("#browser");
	if (index != -1) {
		browserSetAddr(url.substring(index));
	}
	else {
		browserSetAddr(addr);
	}
}

function browserEnable() {
	browserSetAddr(document.browserAddr);
}

function browserDisable() {
	stopUpdatesByID("browser");
}

function browserSetAddr(addr) {
	console.log("browserSetAddr(" + addr + ")");
	document.browserAddr = addr;
	document.browserDisplayTemplate = "browser-template-" + getCGIParam(addr, "type", "apps");
	if (window.location.href != addr) {
		window.location.href = addr;
	}
	stopUpdatesByID("browser");
	console.log(new Error());
	registerUpdate("browser", "browser.state" + addr, browserDataReceived);
}

function browserGetAddr() {
	return document.browserAddr;
}


function getCGIParam(addr, name, defVal) {
	var index = addr.indexOf(name + "=");
	if (index == -1) {
		return defVal;<commit_msg>don't set browser address if equal to the current one<commit_after>$(window).on('hashchange', function() {
	var url = window.location.href;
	
	var index = url.indexOf("#browser");
	if (index != -1) {
		browserSetAddr(url.substring(index));
	}
});

function browserDataReceived(id, data, error) {
	if (error != null) {
		noty({text: error});
	}
	else {
		display("browser-container", document.browserDisplayTemplate, {data: data});
		updateLinks();
		resizeTabs("#browser");
	}
	pauseUpdates("browser");
}

function updateLinks() {
	$("#browser a").each(function() {
		var href = $(this).attr("href");
		if (href != null && href.indexOf("#browser") == 0) {
			$(this).click(function() {
				console.log("Navigating to " + href);
				browserSetAddr(href);
			});
		}
	});
}

function browserSetHome(addr) {
	var url = window.location.href;
	document.browserHome = addr;
	var index = url.indexOf("#browser");
	if (index != -1) {
		browserSetAddr(url.substring(index));
	}
	else {
		browserSetAddr(addr);
	}
}

function browserEnable() {
	browserSetAddr(document.browserAddr);
}

function browserDisable() {
	stopUpdatesByID("browser");
}

function browserSetAddr(addr) {
	if (document.browserAddr == addr) {
		console.log("browserSetAddr(" + addr + ") (already there)");
	}
	else {
		console.log("browserSetAddr(" + addr + ")");
		document.browserAddr = addr;
		document.browserDisplayTemplate = "browser-template-" + getCGIParam(addr, "type", "apps");
		if (window.location.href != addr) {
			window.location.href = addr;
		}
		stopUpdatesByID("browser");
		registerUpdate("browser", "browser.state" + addr, browserDataReceived);
	}
}

function browserGetAddr() {
	return document.browserAddr;
}


function getCGIParam(addr, name, defVal) {
	var index = addr.indexOf(name + "=");
	if (index == -1) {
		return defVal;
{'fraction_non_alphanumeric': 0.17864300028628685, 'fraction_numerical': 0.002290294875465216, 'mean_word_length': 4.78476821192053, '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': '5918892', 'n_tokens_mistral': 1219, 'n_tokens_neox': 1153, 'n_words': 228}