<commit_before>Element.prototype.toggleClass = function(name) {
	if (this.classList.contains(name)) {
		this.classList.remove(name);
	} else {
		this.classList.add(name);
	}
};

Element.prototype.removeClass = function(name) {
	if (this.classList.contains(name)) {
		this.classList.remove(name);
	}
};

Element.prototype.addClass = function(name) {
	if (this.classList.contains(name) === false) {
		this.classList.add(name);
	}
}

function scrollToElement(parentElement, childElement) {
	var x = 0;
    var y = 0;
	var element = childElement;
    while( element && element !== parentElement && !isNaN( element.offsetLeft ) && !isNaN( element.offsetTop ) ) {
        x += element.offsetLeft - element.scrollLeft;
        y += element.offsetTop - element.scrollTop;
        element = element.offsetParent;
    }

	parentElement.scrollTop = y;
	parentElement.scrollLeft = x;
}

function setBlocker(isEnable) {
	var blocker = document.querySelector('.blockerUI');
	if (isEnable == true || isEnable == undefined) {
		if (blocker !== null) {
			return;
		}
		blocker = document.createElement('div');
		blocker.addClass('blockerUI');
		blocker.style.background = "rgba(0, 0, 0, .4)";
		blocker.style.position = "fixed";
		blocker.style.top = "0";
		blocker.style.left = "0";
		blocker.style.width = "100%";
		blocker.style.height = "100%";
		blocker.style.zIndex = "10";

		blocker.style.animation = "fade-in .7s";
		document.body.appendChild(blocker);
	} else {
		if (blocker !== null) {
			blocker.parentElement.removeChild(blocker);
		}
	}
}

function getJSON(url, onSuccess, onFail) {
	var xhr = new XMLHttpRequest();
	xhr.open('get', url);
	xhr.onreadystatechange = function() {
		if (xhr.readyState !== 4) {
			return;
		}

		if (xhr.status === 200) {
			if (onSuccess instanceof Function) {
				var obj = JSON.parse(xhr.responseText);
				(onSuccess)(obj);
			}
		} else {
			if(onFail instanceof Function) {
				(onFail)(xhr);
			} else {
				try {
					var json = JSON.parse(xhr.responseText);
					var error = json.error;
					var message = json.message;
					alert(error + '\n' + message);
				}catch(err) {
					alert(xhr.statusText);
				}
			}
		}
		setBlocker(false);
	}
	setBlocker(true);
	xhr.send();
}

function deleteJSON(url, onSuccess, onFail) {
	var xhr = new XMLHttpRequest();
	xhr.open('post', url + '?_method=DELETE');
	xhr.onreadystatechange = function() {
		if (xhr.readyState !== 4) {
			return;
		}

		if (xhr.status === 200) {
			if (onSuccess instanceof Function) {
				var obj = JSON.parse(xhr.responseText);
				(onSuccess)(obj);
			}
		} else {
			if(onFail instanceof Function) {
				(onFail)(xhr);
			} else {
				try {
					var json = JSON.parse(xhr.responseText);
					var error = json.error;
					var message = json.message;
					alert(error + '\n' + message);
				}catch(err) {
					alert(xhr.statusText);
				}
			}
		}
		setBlocker(false);
	}
	setBlocker(true);
	xhr.send();
}

function post(url, parameter, onSuccess, onFail) {
	var xhr = new XMLHttpRequest();
	xhr.open('post', url);
	xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
	xhr.onreadystatechange = function() {
		if (xhr.readyState !== 4) {
			return;
		}

		if (xhr.status === 200) {
			if (onSuccess instanceof Function) {
				var obj = JSON.parse(xhr.responseText);
				(onSuccess)(obj);
			}
		} else {
			if(onFail instanceof Function) {
				(onFail)(xhr);
			}
		}
		setBlocker(false);
	}
	setBlocker(true);
	xhr.send(parameter);
}

function serializeForm(form) {
	var elements = form.querySelectorAll('input, textarea, select');
	var serialized = [];

	for (var i=0; i<elements.length; i++) {
		if (elements[i].name) {
			var name = encodeURIComponent(elements[i].name);
			var value = encodeURIComponent(elements[i].value);
			serialized.push(name + '=' + value);
		}
	}

	return serialized.join('&');
}

function resizer(event) {
	var name = event.animationName;

	if (name === "big") {
		document.body.removeClass('menu-open');
	} else if (name === "small") {
		document.body.removeClass('menu-open');
		document.body.removeClass('side-open');
	}
}

function clickPersistentMenu(event) {
	var target = event.target;
	if (["input", "textarea"].indexOf(target.localName) >= 0) {
		return;
	}
	while (target.getAttribute('data-action') == null) {
		target = target.parentElement;
		if (target === null) {
			return;
		}
	}

	var action = target.getAttribute('data-action');
	closeMenu();

	if (action === 'all') {
		getAllEntries();
	}
}

function clickComplementaryMenu(event) {
	var target = event.target;
	if (["input", "textarea"].indexOf(target.localName) >= 0) {
		return;
	}

	while (target.getAttribute('data-action') == null) {
		target = target.parentElement;
		if (target === null) {
			return;
		}
	}

	var action = target.getAttribute('data-action');
	closeSide();

	if (action === 'remove-this') {
		removeCurrentSelected();
	}
}

function removeCurrentSelected() {
	var current = document.querySelector('[role=navigation] .current');

	var url = current.getAttribute('data-remove-feed-url') || current.getAttribute('data-remove-category-url');
	if (url) {
		var parentMenu = current;
		while (parentMenu.classList.contains('fold') == false) {
			parentMenu = parentMenu.parentElement;
			if (parentMenu == null) {
				break;
			}
		}

		deleteJSON(url, function(obj) {
			makeFeedList(obj, parentMenu);
		});
	}
}

function toggleMenu(event) {
	var target = event.target;
	while (target.classList.contains('off-canvas-menu') == false) {
		target = target.parentElement;
		if (target === null) {
			return;
		}
	}

	closeSide();
	document.body.toggleClass('menu-open');
}

function toggleSide(event) {
	var target = event.target;
	while (target.classList.contains('off-canvas-side') == false) {
		target = target.parentElement;
		if (target === null) {
			return;
		}
	}

	closeMenu();
	document.body.toggleClass('side-open');
}

function toggleFolding(event) {
	var target = event.target;
	while (target.classList.contains('header') == false) {
		target = target.parentElement;
		if (target === null) {
			return;
		}
	}

	target.toggleClass('closed');
}

function closeMenu() {
	document.body.removeClass('menu-open');
}

function closeSide() {
	document.body.removeClass('side-open');
}

function processForm(event) {
	var target = event.target;
	event.preventDefault();

	var data = serializeForm(target);
	var after = target.getAttribute('data-after');
	if (after === "makeFeedList") {
		var action = target.action;
		try {
			var current = document.querySelector('[role=navigation] .feedlist .current');
			if (target.getAttribute('data-action') === 'addFeed') {
				action = current.getAttribute('data-add-feed-url');
			} else if (target.getAttribute('data-action') === 'addCategory') {
				action = current.getAttribute('data-add-category-url');
			}
		} catch (err) {
		}
		post(action, data, function(res) {
			if (current == null) {
				makeFeedList(res);
			} else {
				var fold = current.nextElementSibling;
				fold.innerHTML = "";
				//makeCategory(fold, res);
				makeFeedList(res, fold);
			}
			target.reset();
		});
	} else {
		post(target.action, data, function(res) {
			alert(res);
			target.reset();
		});
	}
}


var makeCategory = function(parentObj, obj) {
	var header = document.createElement('li');
	var list = document.createElement('li');

	header.addClass('header');
	header.addClass('feed');
	header.setAttribute('role', 'link');
	header.setAttribute('data-entries', obj.entries_url);
	if (obj.add_category_url) {
		header.setAttribute('data-add-category-url', obj.add_category_url);
	}
	if (obj.add_feed_url) {
		header.setAttribute('data-add-feed-url', obj.add_feed_url);
	}
	if (obj.remove_feed_url) {
		header.setAttribute('data-remove-feed-url', obj.remove_feed_url);
	}
	if (obj.remove_category_url) {
		header.setAttribute('data-remove-category-url', obj.remove_category_url);
	}

	header.textContent = obj.title;

	var toggle = document.createElement('span');
	toggle.addClass('toggle');
	header.insertBefore(toggle, header.firstChild);

	list.addClass('fold');

	var ul = document.createElement('ul');
	getJSON(obj.feeds_url, function(obj) {
		for (var i=0; i<obj.categories.length; i++) {
			makeCategory(ul, obj.categories[i]);
		}
		for (var i=0; i<obj.feeds.length; i++) {
			makeFeed(ul, obj.feeds[i]);
		}
	});

	list.appendChild(ul);

	parentObj.appendChild(header);
	parentObj.appendChild(list);
};

var makeFeed = function(parentObj, obj) {
	var elem = document.createElement('li');
	elem.addClass('feed');
	elem.setAttribute('data-entries', obj.entries_url);
	elem.setAttribute('data-remove-feed-url', obj.remove_feed_url);
	elem.setAttribute('role', 'link');
	elem.textContent = obj.title;

	parentObj.appendChild(elem);
};

function makeFeedList(obj, target) {
	var feedList;
	if (target) {
		feedList = target;
	} else {
		feedList = document.querySelector('.feedlist');
	}
	feedList.innerHTML = "";

	for (var i=0; i<obj.categories.length; i++) {
		makeCategory(feedList, obj.categories[i]);
	}
	for (var i=0; i<obj.feeds.length; i++) {
		makeFeed(feedList, obj.feeds[i]);
	}
}

function refreshFeedList() {
	getJSON(URLS.feeds, makeFeedList);
}

function getAllEntries() {
	var all_feed = document.querySelector('[role=navigation] [data-action=all]');
	var list = document.querySelectorAll('[role=navigation] .current');
	for (var i=0; i<list.length; i++) {
		list[i].removeClass('current');
	}
	all_feed.addClass('current');
	getEntries(URLS.entries);
}

function appendEntry(entry) {
	var main = document.querySelector('[role=main]');
	
	var article = document.createElement('article');
	var header = document.createElement('div');
	var time = document.createElement('time');
	var title = document.createElement('span');

	article.addClass('entry');
	article.setAttribute('data-entries', entry.entry_url);

	header.addClass('entry-title');
	header.setAttribute('role', 'button');

	if (entry.feed) {
		var category = document.createElement('span');
		category.addClass('feed');
		category.textContent = entry.feed.title;
		header.appendChild(category);
	}

	time.textContent = entry.updated;
	header.appendChild(time);

	title.textContent = entry.title;
	title.addClass('title');
	header.appendChild(title);

	article.appendChild(header);
	main.appendChild(article);
}

function getEntries(feed_url) {
	var main = document.querySelector('[role=main]');

	getJSON(feed_url, function(obj) {
		main.innerHTML = "";

		var feed_title = obj.title;
		var entries = obj.entries;

		var header = document.createElement('header');
		var h2 = document.createElement('h2');
		header.appendChild(h2);
		h2.textContent = feed_title;

		main.appendChild(header);

		for (var i=0; i<entries.length; i++) {
			appendEntry(entries[i]);
		}

		if (obj.next_url) {
			var nextLoader = main.querySelector('.nextPage');
			if (nextLoader == null) {
				nextLoader = document.createElement('div');
				nextLoader.addClass('nextPage');
				nextLoader.textContent = "Load next page";
			}
			nextLoader.setAttribute('data-next-url', obj.next_url);
			main.appendChild(nextLoader);
		}
	});
}
<commit_msg>click listener for 'load next page'<commit_after>Element.prototype.toggleClass = function(name) {
	if (this.classList.contains(name)) {
		this.classList.remove(name);
	} else {
		this.classList.add(name);
	}
};

Element.prototype.removeClass = function(name) {
	if (this.classList.contains(name)) {
		this.classList.remove(name);
	}
};

Element.prototype.addClass = function(name) {
	if (this.classList.contains(name) === false) {
		this.classList.add(name);
	}
}

function scrollToElement(parentElement, childElement) {
	var x = 0;
    var y = 0;
	var element = childElement;
    while( element && element !== parentElement && !isNaN( element.offsetLeft ) && !isNaN( element.offsetTop ) ) {
        x += element.offsetLeft - element.scrollLeft;
        y += element.offsetTop - element.scrollTop;
        element = element.offsetParent;
    }

	parentElement.scrollTop = y;
	parentElement.scrollLeft = x;
}

function setBlocker(isEnable) {
	var blocker = document.querySelector('.blockerUI');
	if (isEnable == true || isEnable == undefined) {
		if (blocker !== null) {
			return;
		}
		blocker = document.createElement('div');
		blocker.addClass('blockerUI');
		blocker.style.background = "rgba(0, 0, 0, .4)";
		blocker.style.position = "fixed";
		blocker.style.top = "0";
		blocker.style.left = "0";
		blocker.style.width = "100%";
		blocker.style.height = "100%";
		blocker.style.zIndex = "10";

		blocker.style.animation = "fade-in .7s";
		document.body.appendChild(blocker);
	} else {
		if (blocker !== null) {
			blocker.parentElement.removeChild(blocker);
		}
	}
}

function getJSON(url, onSuccess, onFail) {
	var xhr = new XMLHttpRequest();
	xhr.open('get', url);
	xhr.onreadystatechange = function() {
		if (xhr.readyState !== 4) {
			return;
		}

		if (xhr.status === 200) {
			if (onSuccess instanceof Function) {
				var obj = JSON.parse(xhr.responseText);
				(onSuccess)(obj);
			}
		} else {
			if(onFail instanceof Function) {
				(onFail)(xhr);
			} else {
				try {
					var json = JSON.parse(xhr.responseText);
					var error = json.error;
					var message = json.message;
					alert(error + '\n' + message);
				}catch(err) {
					alert(xhr.statusText);
				}
			}
		}
		setBlocker(false);
	}
	setBlocker(true);
	xhr.send();
}

function deleteJSON(url, onSuccess, onFail) {
	var xhr = new XMLHttpRequest();
	xhr.open('post', url + '?_method=DELETE');
	xhr.onreadystatechange = function() {
		if (xhr.readyState !== 4) {
			return;
		}

		if (xhr.status === 200) {
			if (onSuccess instanceof Function) {
				var obj = JSON.parse(xhr.responseText);
				(onSuccess)(obj);
			}
		} else {
			if(onFail instanceof Function) {
				(onFail)(xhr);
			} else {
				try {
					var json = JSON.parse(xhr.responseText);
					var error = json.error;
					var message = json.message;
					alert(error + '\n' + message);
				}catch(err) {
					alert(xhr.statusText);
				}
			}
		}
		setBlocker(false);
	}
	setBlocker(true);
	xhr.send();
}

function post(url, parameter, onSuccess, onFail) {
	var xhr = new XMLHttpRequest();
	xhr.open('post', url);
	xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
	xhr.onreadystatechange = function() {
		if (xhr.readyState !== 4) {
			return;
		}

		if (xhr.status === 200) {
			if (onSuccess instanceof Function) {
				var obj = JSON.parse(xhr.responseText);
				(onSuccess)(obj);
			}
		} else {
			if(onFail instanceof Function) {
				(onFail)(xhr);
			}
		}
		setBlocker(false);
	}
	setBlocker(true);
	xhr.send(parameter);
}

function serializeForm(form) {
	var elements = form.querySelectorAll('input, textarea, select');
	var serialized = [];

	for (var i=0; i<elements.length; i++) {
		if (elements[i].name) {
			var name = encodeURIComponent(elements[i].name);
			var value = encodeURIComponent(elements[i].value);
			serialized.push(name + '=' + value);
		}
	}

	return serialized.join('&');
}

function resizer(event) {
	var name = event.animationName;

	if (name === "big") {
		document.body.removeClass('menu-open');
	} else if (name === "small") {
		document.body.removeClass('menu-open');
		document.body.removeClass('side-open');
	}
}

function clickPersistentMenu(event) {
	var target = event.target;
	if (["input", "textarea"].indexOf(target.localName) >= 0) {
		return;
	}
	while (target.getAttribute('data-action') == null) {
		target = target.parentElement;
		if (target === null) {
			return;
		}
	}

	var action = target.getAttribute('data-action');
	closeMenu();

	if (action === 'all') {
		getAllEntries();
	}
}

function clickComplementaryMenu(event) {
	var target = event.target;
	if (["input", "textarea"].indexOf(target.localName) >= 0) {
		return;
	}

	while (target.getAttribute('data-action') == null) {
		target = target.parentElement;
		if (target === null) {
			return;
		}
	}

	var action = target.getAttribute('data-action');
	closeSide();

	if (action === 'remove-this') {
		removeCurrentSelected();
	}
}

function removeCurrentSelected() {
	var current = document.querySelector('[role=navigation] .current');

	var url = current.getAttribute('data-remove-feed-url') || current.getAttribute('data-remove-category-url');
	if (url) {
		var parentMenu = current;
		while (parentMenu.classList.contains('fold') == false) {
			parentMenu = parentMenu.parentElement;
			if (parentMenu == null) {
				break;
			}
		}

		deleteJSON(url, function(obj) {
			makeFeedList(obj, parentMenu);
		});
	}
}

function toggleMenu(event) {
	var target = event.target;
	while (target.classList.contains('off-canvas-menu') == false) {
		target = target.parentElement;
		if (target === null) {
			return;
		}
	}

	closeSide();
	document.body.toggleClass('menu-open');
}

function toggleSide(event) {
	var target = event.target;
	while (target.classList.contains('off-canvas-side') == false) {
		target = target.parentElement;
		if (target === null) {
			return;
		}
	}

	closeMenu();
	document.body.toggleClass('side-open');
}

function toggleFolding(event) {
	var target = event.target;
	while (target.classList.contains('header') == false) {
		target = target.parentElement;
		if (target === null) {
			return;
		}
	}

	target.toggleClass('closed');
}

function closeMenu() {
	document.body.removeClass('menu-open');
}

function closeSide() {
	document.body.removeClass('side-open');
}

function processForm(event) {
	var target = event.target;
	event.preventDefault();

	var data = serializeForm(target);
	var after = target.getAttribute('data-after');
	if (after === "makeFeedList") {
		var action = target.action;
		try {
			var current = document.querySelector('[role=navigation] .feedlist .current');
			if (target.getAttribute('data-action') === 'addFeed') {
				action = current.getAttribute('data-add-feed-url');
			} else if (target.getAttribute('data-action') === 'addCategory') {
				action = current.getAttribute('data-add-category-url');
			}
		} catch (err) {
		}
		post(action, data, function(res) {
			if (current == null) {
				makeFeedList(res);
			} else {
				var fold = current.nextElementSibling;
				fold.innerHTML = "";
				//makeCategory(fold, res);
				makeFeedList(res, fold);
			}
			target.reset();
		});
	} else {
		post(target.action, data, function(res) {
			alert(res);
			target.reset();
		});
	}
}


var makeCategory = function(parentObj, obj) {
	var header = document.createElement('li');
	var list = document.createElement('li');

	header.addClass('header');
	header.addClass('feed');
	header.setAttribute('role', 'link');
	header.setAttribute('data-entries', obj.entries_url);
	if (obj.add_category_url) {
		header.setAttribute('data-add-category-url', obj.add_category_url);
	}
	if (obj.add_feed_url) {
		header.setAttribute('data-add-feed-url', obj.add_feed_url);
	}
	if (obj.remove_feed_url) {
		header.setAttribute('data-remove-feed-url', obj.remove_feed_url);
	}
	if (obj.remove_category_url) {
		header.setAttribute('data-remove-category-url', obj.remove_category_url);
	}

	header.textContent = obj.title;

	var toggle = document.createElement('span');
	toggle.addClass('toggle');
	header.insertBefore(toggle, header.firstChild);

	list.addClass('fold');

	var ul = document.createElement('ul');
	getJSON(obj.feeds_url, function(obj) {
		for (var i=0; i<obj.categories.length; i++) {
			makeCategory(ul, obj.categories[i]);
		}
		for (var i=0; i<obj.feeds.length; i++) {
			makeFeed(ul, obj.feeds[i]);
		}
	});

	list.appendChild(ul);

	parentObj.appendChild(header);
	parentObj.appendChild(list);
};

var makeFeed = function(parentObj, obj) {
	var elem = document.createElement('li');
	elem.addClass('feed');
	elem.setAttribute('data-entries', obj.entries_url);
	elem.setAttribute('data-remove-feed-url', obj.remove_feed_url);
	elem.setAttribute('role', 'link');
	elem.textContent = obj.title;

	parentObj.appendChild(elem);
};

function makeFeedList(obj, target) {
	var feedList;
	if (target) {
		feedList = target;
	} else {
		feedList = document.querySelector('.feedlist');
	}
	feedList.innerHTML = "";

	for (var i=0; i<obj.categories.length; i++) {
		makeCategory(feedList, obj.categories[i]);
	}
	for (var i=0; i<obj.feeds.length; i++) {
		makeFeed(feedList, obj.feeds[i]);
	}
}

function refreshFeedList() {
	getJSON(URLS.feeds, makeFeedList);
}

function getAllEntries() {
	var all_feed = document.querySelector('[role=navigation] [data-action=all]');
	var list = document.querySelectorAll('[role=navigation] .current');
	for (var i=0; i<list.length; i++) {
		list[i].removeClass('current');
	}
	all_feed.addClass('current');
	getEntries(URLS.entries);
}

function appendEntry(entry) {
	var main = document.querySelector('[role=main]');
	
	var article = document.createElement('article');
	var header = document.createElement('div');
	var time = document.createElement('time');
	var title = document.createElement('span');

	article.addClass('entry');
	article.setAttribute('data-entries', entry.entry_url);

	header.addClass('entry-title');
	header.setAttribute('role', 'button');

	if (entry.feed) {
		var category = document.createElement('span');
		category.addClass('feed');
		category.textContent = entry.feed.title;
		header.appendChild(category);
	}

	time.textContent = entry.updated;
	header.appendChild(time);

	title.textContent = entry.title;
	title.addClass('title');
	header.appendChild(title);

	article.appendChild(header);
	main.appendChild(article);
}

function getEntries(feed_url) {
	var main = document.querySelector('[role=main]');

	getJSON(feed_url, function(obj) {
		main.innerHTML = "";

		var feed_title = obj.title;
		var entries = obj.entries;

		var header = document.createElement('header');
		var h2 = document.createElement('h2');
		header.appendChild(h2);
		h2.textContent = feed_title;

		main.appendChild(header);

		for (var i=0; i<entries.length; i++) {
			appendEntry(entries[i]);
		}

		if (obj.next_url) {
			var nextLoader = main.querySelector('.nextPage');
			if (nextLoader == null) {
				nextLoader = document.createElement('div');
				nextLoader.addClass('nextPage');
				nextLoader.textContent = "Load next page";
				nextLoader.onclick = loadNextPage();
			}
			nextLoader.setAttribute('data-next-url', obj.next_url);
			main.appendChild(nextLoader);
		}
	});
}

{'fraction_non_alphanumeric': 0.16727387217199657, 'fraction_numerical': 0.003778167588719471, 'mean_word_length': 4.13962089690245, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5755671', 'n_tokens_mistral': 8233, 'n_tokens_neox': 7559, 'n_words': 1381}