<commit_before>var dispatcher = {};
var THREAD = window.location.pathname.match(/\/(\d+)$/);
THREAD = THREAD ? parseInt(THREAD[1]) : 0;
var nameField = $('input[name=name]'), emailField = $('input[name=email]');
var ceiling = $('hr:first');
var reconnectTimer = null, resetTimer = null, reconnectDelay = 3000;
var options, outOfSync, postForm, preview, previewNum;

var socket = new io.Socket(window.location.domain, {
	port: PORT,
	transports: ['websocket', 'htmlfile', 'xhr-multipart', 'xhr-polling',
		'jsonp-polling']
});

function load_ident() {
	try {
		function load(key, f) {
			if (!f()) {
				var val = localStorage.getItem(key);
				if (val)
					f(val);
			}
		}
		load('name', $.proxy(nameField, 'val'));
		load('email', $.proxy(emailField, 'val'));
	}
	catch (e) {}
}
load_ident();

$('<a id="options">Options</a>').insertAfter('#sync');

function save_ident() {
	try {
		function save(key, val) {
			if (typeof val == 'string')
				localStorage.setItem(key, val);
		}
		save('name', nameField.val());
		if (emailField.val() != 'sage')
			save('email', emailField.val());
	}
	catch (e) {}
}

function send(msg) {
	socket.send(JSON.stringify(msg));
}

function make_reply_box() {
	var box = $('<aside>[<a>Reply</a>]</aside>');
	box.find('a').click(on_make_post);
	return box;
}

function insert_new_post_boxes() {
	if (outOfSync)
		return;
	make_reply_box().appendTo('section');
	if (!THREAD) {
		var box = $('<aside>[<a>New thread</a>]</aside>');
		box.find('a').click(on_make_post);
		ceiling.after(box);
	}
}

function on_make_post() {
	var link = $(this);
	postForm = new PostForm(link.parent(), link.parents('section'));
}

function make_link(num, op) {
	var p = {num: num, op: op};
	return safe('<a href="' + post_url(p, false) + '">&gt;&gt;'
			+ num + '</a>');
}

var oneeSama = new OneeSama(function (num) {
	if (this.links && num in this.links)
		this.callback(make_link(num, this.links[num]));
	else
		this.callback('>>' + num);
});
oneeSama.dirs = DIRS;
oneeSama.full = THREAD;
oneeSama.image_view = function (img, imgnm, op) { return img; };

function inject(frag) {
	var dest = this.buffer;
	for (var i = 0; i < this.state[1]; i++)
		dest = dest.children('del:last');
	if (this.state[0] == 1)
		dest = dest.children('em:last');
	var out = null;
	if (frag.safe) {
		var m = frag.safe.match(/^<(\w+)>$/);
		if (m)
			out = document.createElement(m[1]);
		else if (frag.safe.match(/^<\/\w+>$/))
			out = '';
	}
	if (out === null)
		out = escape_fragment(frag);
	if (out)
		dest.append(out);
}

function get_focus() {
	var focus = window.getSelection().focusNode;
	if (focus && focus.tagName && focus.tagName.match(/blockquote/i))
		return $(focus).find('textarea');
}

function shift_replies(section) {
	if (THREAD)
		return;
	var shown = section.children('article[id]:not(:has(form))');
	var rem = shown.length;
	if (rem < ABBREV)
		return;
	var stat = section.find('.omit');
	var omit = 0, img = 0;
	if (stat.length) {
		var m = stat.text().match(/(\d+)\D+(\d+)?/);
		omit = parseInt(m[1]);
		img = parseInt(m[2] || 0);
	}
	else {
		stat = $('<span class="omit"></span>');
		section.children('blockquote,form').last().after(stat);
	}
	for (var i = 0; i < shown.length; i++) {
		var cull = $(shown[i]);
		if (rem-- < ABBREV)
			break;
		if (cull.has('figure').length)
			img++;
		omit++;
		cull.remove();
	}
	stat.text(abbrev_msg(omit, img));
}

dispatcher[INSERT_POST] = function (msg) {
	msg = msg[0];
	var orig_focus = get_focus();
	oneeSama.links = msg.links;
	var section, hr, bump = true;
	if (msg.op) {
		section = $('#' + msg.op);
		if (!section.length)
			return true;<commit_msg>Inserted posts always have editing class<commit_after>var dispatcher = {};
var THREAD = window.location.pathname.match(/\/(\d+)$/);
THREAD = THREAD ? parseInt(THREAD[1]) : 0;
var nameField = $('input[name=name]'), emailField = $('input[name=email]');
var ceiling = $('hr:first');
var reconnectTimer = null, resetTimer = null, reconnectDelay = 3000;
var options, outOfSync, postForm, preview, previewNum;

var socket = new io.Socket(window.location.domain, {
	port: PORT,
	transports: ['websocket', 'htmlfile', 'xhr-multipart', 'xhr-polling',
		'jsonp-polling']
});

function load_ident() {
	try {
		function load(key, f) {
			if (!f()) {
				var val = localStorage.getItem(key);
				if (val)
					f(val);
			}
		}
		load('name', $.proxy(nameField, 'val'));
		load('email', $.proxy(emailField, 'val'));
	}
	catch (e) {}
}
load_ident();

$('<a id="options">Options</a>').insertAfter('#sync');

function save_ident() {
	try {
		function save(key, val) {
			if (typeof val == 'string')
				localStorage.setItem(key, val);
		}
		save('name', nameField.val());
		if (emailField.val() != 'sage')
			save('email', emailField.val());
	}
	catch (e) {}
}

function send(msg) {
	socket.send(JSON.stringify(msg));
}

function make_reply_box() {
	var box = $('<aside>[<a>Reply</a>]</aside>');
	box.find('a').click(on_make_post);
	return box;
}

function insert_new_post_boxes() {
	if (outOfSync)
		return;
	make_reply_box().appendTo('section');
	if (!THREAD) {
		var box = $('<aside>[<a>New thread</a>]</aside>');
		box.find('a').click(on_make_post);
		ceiling.after(box);
	}
}

function on_make_post() {
	var link = $(this);
	postForm = new PostForm(link.parent(), link.parents('section'));
}

function make_link(num, op) {
	var p = {num: num, op: op};
	return safe('<a href="' + post_url(p, false) + '">&gt;&gt;'
			+ num + '</a>');
}

var oneeSama = new OneeSama(function (num) {
	if (this.links && num in this.links)
		this.callback(make_link(num, this.links[num]));
	else
		this.callback('>>' + num);
});
oneeSama.dirs = DIRS;
oneeSama.full = THREAD;
oneeSama.image_view = function (img, imgnm, op) { return img; };

function inject(frag) {
	var dest = this.buffer;
	for (var i = 0; i < this.state[1]; i++)
		dest = dest.children('del:last');
	if (this.state[0] == 1)
		dest = dest.children('em:last');
	var out = null;
	if (frag.safe) {
		var m = frag.safe.match(/^<(\w+)>$/);
		if (m)
			out = document.createElement(m[1]);
		else if (frag.safe.match(/^<\/\w+>$/))
			out = '';
	}
	if (out === null)
		out = escape_fragment(frag);
	if (out)
		dest.append(out);
}

function get_focus() {
	var focus = window.getSelection().focusNode;
	if (focus && focus.tagName && focus.tagName.match(/blockquote/i))
		return $(focus).find('textarea');
}

function shift_replies(section) {
	if (THREAD)
		return;
	var shown = section.children('article[id]:not(:has(form))');
	var rem = shown.length;
	if (rem < ABBREV)
		return;
	var stat = section.find('.omit');
	var omit = 0, img = 0;
	if (stat.length) {
		var m = stat.text().match(/(\d+)\D+(\d+)?/);
		omit = parseInt(m[1]);
		img = parseInt(m[2] || 0);
	}
	else {
		stat = $('<span class="omit"></span>');
		section.children('blockquote,form').last().after(stat);
	}
	for (var i = 0; i < shown.length; i++) {
		var cull = $(shown[i]);
		if (rem-- < ABBREV)
			break;
		if (cull.has('figure').length)
			img++;
		omit++;
		cull.remove();
	}
	stat.text(abbrev_msg(omit, img));
}

dispatcher[INSERT_POST] = function (msg) {
	msg = msg[0];
	msg.editing = true;
	var orig_focus = get_focus();
	oneeSama.links = msg.links;
	var section, hr, bump = true;
	if (msg.op) {
		section = $('#' + msg.op);
		if (!section.length)
			return true;
{'fraction_non_alphanumeric': 0.21591533809785596, 'fraction_numerical': 0.004947773501924134, 'mean_word_length': 4.1066666666666665, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 39, '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': '1019712', 'n_tokens_mistral': 3014, 'n_tokens_neox': 2814, 'n_words': 608}