<commit_before>"use strict";
var snackbarContainer = document.querySelector("#ex-snackbar");
let ws = new WebSocket('ws://' + window.location.host + '/example');

ws.onmessage = function(message) {
	data = JSON.parse(message.data);
	for (key in data) {
		$("#" + data[key].label_safe).css(
			'width', data[key].value + "%");
		$("#content-" + data[key].label_safe).html(
			data[key].value + "%");
		if ($("#ex-has-fail").css("display") == "block") {
			$("#ex-has-fail").css("display", "none");
		}
	}
}

function fail() {
	$("#ex-has-fail").css("display", "block");
	snackbarContainer.MaterialSnackbar.showSnackbar({
		message: "Unable to connect for module: example",
		timeout: 5000,
		actionHandler: (()=> window.location.reload()),
		actionText: "Reload"
	});
}

ws.onerror = fail;
ws.onclose = fail;<commit_msg>static/example.js: add resumable connections<commit_after>"use strict";
var snackbarContainer = document.querySelector("#ex-snackbar");
function fail() {
	$("#ex-has-fail").css("display", "block");
	snackbarContainer.MaterialSnackbar.showSnackbar({
		message: "Unable to connect for module: example",
		timeout: 5000,
		actionHandler: (()=> window.location.reload()),
		actionText: "Reload"
	});
}

let ws; // linger

function ex_refresh() {
	ws = new WebSocket('ws://' + window.location.host + '/example');

	ws.onmessage = function(message) {
		var data = typeof message.data == 'object' && message.data || JSON.parse(message.data)
		for (var key in data) {
			$("#" + data[key].label_safe).css(
				'width', data[key].value + "%");
			$("#content-" + data[key].label_safe).html(
				data[key].value + "%");
			if ($("#ex-has-fail").css("display") == "block") {
				$("#ex-has-fail").css("display", "none");
			}
		}
	}

	ws.onerror = fail;
	ws.onclose = fail;
}

ex_refresh()
{'fraction_non_alphanumeric': 0.21981079577072898, 'fraction_numerical': 0.004451864218141347, 'mean_word_length': 4.448484848484848, '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': '1828577', 'n_tokens_mistral': 669, 'n_tokens_neox': 622, 'n_words': 117}