<commit_before>$(function() {
	var client = $("head").data("client");
	var setup = function() {
		$.getJSON("/getToken/", {client: client}, function(token) {
			var chan = new goog.appengine.Channel(token);
			var sock = chan.open();
			sock.onmessage = function(m) {
				var res = $.parseJSON(m.data);
				var button = $("button[data-index="+res.Ind+"]");
				var mark;
				if (res.Read) {
					mark = "unread";
				} else {
					mark = "read";
				}
				button.text("mark " + mark);
				button.data("mark", mark);
			};
			//sock.onclose = setup;
		});
	};
	setup();

	$(".ajax_link").click(function() {
		var button = $(this);
		var url;
		var mark = button.data("mark")
		if (mark === "read") {
			url = "/markRead/";
		} else {
			url = "/markUnread/";
		}
		$.get(url, button.data());
	});
});<commit_msg>Reconnect channel on window focus.<commit_after>$(function() {
	var connected = false;
	var client = $("head").data("client");
	var setup = function() {
		$.getJSON("/getToken/", {client: client}, function(token) {
			console.log("connecting");
			var chan = new goog.appengine.Channel(token);
			var sock = chan.open();
			sock.onopen = function() { connected = true; };
			sock.onmessage = function(m) {
				var res = $.parseJSON(m.data);
				var button = $("button[data-index="+res.Ind+"]");
				var mark;
				if (res.Read) {
					mark = "unread";
				} else {
					mark = "read";
				}
				button.text("mark " + mark);
				button.data("mark", mark);
			};
			sock.onclose = function() { connected = false; };
		});
	};
	setup();
	window.onfocus = function() {
		if (!connected) {
			setup();
		}
	};

	$(".ajax_link").click(function() {
		var button = $(this);
		var url;
		var mark = button.data("mark")
		if (mark === "read") {
			url = "/markRead/";
		} else {
			url = "/markUnread/";
		}
		$.get(url, button.data());
	});
});
{'fraction_non_alphanumeric': 0.21951219512195122, 'fraction_numerical': 0.0, 'mean_word_length': 2.91932059447983, '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': '6018192', 'n_tokens_mistral': 777, 'n_tokens_neox': 654, 'n_words': 141}