<commit_before><html>
<head>
<link rel="stylesheet" href="style.css"/>
<script>
function Get(yourUrl){
    var Httpreq = new XMLHttpRequest(); // a new request
    Httpreq.open("GET",yourUrl,false);
    Httpreq.send(null);
    return Httpreq.responseText;          
}

function stringFromObject(obj) {
	var ret = "";
	for(var property in obj) {
		if(obj.hasOwnProperty(property) && property[0] === property[0].toUpperCase()) {
			ret += "<td valign='top'>" + obj[property] + "</td>";
		}
	}
	if(obj.IslandTime == null) {
		ret += "<td valign='top'></td>";
	}
	return ret;
}

function* iter(o) {
    var keys = Object.keys(o);
    for (var i=0; i<keys.length; i++) {
		yield {key: keys[i], value: o[keys[i]]};
    }
}

function filterItem(obj,params,month,hour) {
	if(params['show'] == 'all') {
		return true;
	}

	var passedDateValidation = false;
	if(obj.datetime != null) {
		if(obj.datetime == '*') {
			passedDateValidation = true;
		}
		else {
			obj.datetime[Symbol.iterator] = iter.bind(null, obj.datetime);

			for(var dateTimeEntry of obj.datetime) {
				var buffer = dateTimeEntry.key.split('-');
				var firstMonth = parseInt(buffer[0]);
				var lastMonth = parseInt(buffer[1]);
				var currentMonth = month;
				if(lastMonth < firstMonth) {
					lastMonth += 12;
					if(currentMonth < firstMonth) {
						currentMonth += 12;
					}
				}
			
				if(currentMonth >= firstMonth && currentMonth <= lastMonth) {
					timeList = dateTimeEntry.value;
					for(var i = 0; i < timeList.length; ++i) {
						buffer = timeList[i].split('-');
						var firstHour = parseInt(buffer[0]);
						var lastHour = parseInt(buffer[1]);
						var currentHour = hour;
						
						if(lastHour < firstHour) {
							lastHour += 24;
							if(currentHour < firstHour) {
								currentHour += 24;
							}
						}

						if(currentHour >= firstHour && currentHour < lastHour) {
							passedDateValidation = true;
						}
					}
				}
			}
		}
	}
	
	var passedIslandTimeValidation = false;
	if(obj.islandhours != null) {
		for(var hourEntry of obj.islandhours) {
			var buffer = hourEntry.split('-');
			var firstHour = parseInt(buffer[0]);
			var lastHour = parseInt(buffer[1]);
			var currentHour = hour;
			
			if(lastHour < firstHour) {
				lastHour += 24;
				if(currentHour < firstHour) {
					currentHour += 24;
				}
			}

			if(currentHour >= firstHour && currentHour < lastHour) {
				passedIslandTimeValidation = true;
			}
		}
	}
		
	var showIsland = params['island'];
	if(showIsland == 'only') {
		if(obj.IslandTime == null || !passedIslandTimeValidation) {
			return false;
		}
	} else if (showIsland == 'false') {
		if(!passedDateValidation) {
			return false;
		}
	}
	return passedIslandTimeValidation || passedDateValidation;
}

function compareItems(x, y, sortField, sortOrder) {
	var comparisonResult = x[sortField] < y[sortField] ? -1 : (x[sortField] > y[sortField] ? 1 : 0);
	if (comparisonResult == 0) {
		comparisonResult = x.Name < y.Name ? -1 : 1;
	}

	if(sortOrder == 'desc') {
		comparisonResult *= -1;
	}

	return comparisonResult;
}

function sortItems(obj,params) {
	var sortField = params['sf'];
	var sortOrder = params['so'];
	if(sortField == null) {
		sortField = 'Value';
	}
	if(sortOrder == null) {
		if(sortField == 'Value') {
			sortOrder = 'desc';
		} else {
			sortOrder = 'asc';
		}
	}
	obj.sort((x, y) => compareItems(x, y, sortField, sortOrder));
	return obj;
}

var json_obj;
var searchParams;

function process() {
	json_obj = sortItems(json_obj,searchParams);

	var resultHTML = "";
	resultHTML += "<table><tbody>";
	resultHTML += "<tr><td class='header'>Name</td><td class='header'>Value</td><td class='header'>Rarity</td><td class='header'>Location</td><td class='header'>Date,Time (" + new Date(new Date().getTime()).toLocaleTimeString() + ")</td><td class='header'>Island Time</td>";
	var month = new Date().getMonth() + 1;
	var hour = new Date().getHours();
	for(var i = 0; i < json_obj.length; i++) {
		var dataObj = json_obj[i];
		if(filterItem(dataObj,searchParams,month,hour)) {
			resultHTML += "<tr>" 
				+ stringFromObject(dataObj)
				+"</tr>";
		}
	}
	resultHTML += "</tbody></table>";
	document.getElementById('results').innerHTML = resultHTML;
	var interval = (5 - new Date().getSeconds() % 5) * 1000 + new Date().getMilliseconds();
	if(interval > 5000) {
		interval = 5000;
	}
	setTimeout(process, interval);
}

function load() {
	json_obj = JSON.parse(Get("bugs.json"));
	var urlParams = new URLSearchParams(location.search.slice(1));
	searchParams = {};
	for(var searchKey of urlParams) {
		searchParams[searchKey[0]] = searchKey[1];
	}
	process();
}
</script>
</head>
<body onload="load()">
<div id="results" />
</body>
</html><commit_msg>Added search options to bugs.htm<commit_after><html>
<head>
<link rel="stylesheet" href="style.css"/>
<script>
function Get(yourUrl){
    var Httpreq = new XMLHttpRequest(); // a new request
    Httpreq.open("GET",yourUrl,false);
    Httpreq.send(null);
    return Httpreq.responseText;          
}

function capitalizeFirstLetter(string) {
    return string.charAt(0).toUpperCase() + string.slice(1);
}

function stringFromObject(obj) {
	var ret = "";
	for(var property in obj) {
		if(obj.hasOwnProperty(property) && property[0] === property[0].toUpperCase()) {
			ret += "<td valign='top'>" + obj[property] + "</td>";
		}
	}
	if(obj.IslandTime == null) {
		ret += "<td valign='top'></td>";
	}
	return ret;
}

function* iter(o) {
    var keys = Object.keys(o);
    for (var i=0; i<keys.length; i++) {
		yield {key: keys[i], value: o[keys[i]]};
    }
}

function filterItem(obj,params,month,hour) {
	if(params['show'] == 'all') {
		return true;
	}

	var passedDateValidation = false;
	if(obj.datetime != null) {
		if(obj.datetime == '*') {
			passedDateValidation = true;
		}
		else {
			obj.datetime[Symbol.iterator] = iter.bind(null, obj.datetime);

			for(var dateTimeEntry of obj.datetime) {
				var buffer = dateTimeEntry.key.split('-');
				var firstMonth = parseInt(buffer[0]);
				var lastMonth = parseInt(buffer[1]);
				var currentMonth = month;
				if(lastMonth < firstMonth) {
					lastMonth += 12;
					if(currentMonth < firstMonth) {
						currentMonth += 12;
					}
				}
			
				if(currentMonth >= firstMonth && currentMonth <= lastMonth) {
					timeList = dateTimeEntry.value;
					for(var i = 0; i < timeList.length; ++i) {
						buffer = timeList[i].split('-');
						var firstHour = parseInt(buffer[0]);
						var lastHour = parseInt(buffer[1]);
						var currentHour = hour;
						
						if(lastHour < firstHour) {
							lastHour += 24;
							if(currentHour < firstHour) {
								currentHour += 24;
							}
						}

						if(currentHour >= firstHour && currentHour < lastHour) {
							passedDateValidation = true;
						}
					}
				}
			}
		}
	}
	
	var passedIslandTimeValidation = false;
	if(obj.islandhours != null) {
		for(var hourEntry of obj.islandhours) {
			var buffer = hourEntry.split('-');
			var firstHour = parseInt(buffer[0]);
			var lastHour = parseInt(buffer[1]);
			var currentHour = hour;
			
			if(lastHour < firstHour) {
				lastHour += 24;
				if(currentHour < firstHour) {
					currentHour += 24;
				}
			}

			if(currentHour >= firstHour && currentHour < lastHour) {
				passedIslandTimeValidation = true;
			}
		}
	}
		
	var showIsland = params['island'];
	if(showIsland == 'only') {
		if(obj.IslandTime == null || !passedIslandTimeValidation) {
			return false;
		}
	} else if (showIsland == 'false') {
		if(!passedDateValidation) {
			return false;
		}
	}
	return passedIslandTimeValidation || passedDateValidation;
}

function compareItems(x, y, sortField, sortOrder) {
	var comparisonResult = x[sortField] < y[sortField] ? -1 : (x[sortField] > y[sortField] ? 1 : 0);
	if (comparisonResult == 0) {
		comparisonResult = x.Name < y.Name ? -1 : 1;
	}

	if(sortOrder == 'desc') {
		comparisonResult *= -1;
	}

	return comparisonResult;
}

function sortItems(obj,params) {
	var sortField = params['sf'];
	var sortOrder = params['so'];
	if(sortField == null) {
		sortField = 'Value';
	}
	if(sortOrder == null) {
		if(sortField == 'Value') {
			sortOrder = 'desc';
		} else {
			sortOrder = 'asc';
		}
	}
	obj.sort((x, y) => compareItems(x, y, sortField, sortOrder));
	return obj;
}

function navigateToParameterizedPage(){
	var s = window.location.href.split("?")[0];
	window.location.href = s + '?sf=' + searchParams['sf'] + '&so=' + searchParams['so'] + '&island=' + searchParams['island'];
}

function readParamsFromUi() {
	var radios = document.getElementsByName('sortOrder');
	for(var i = 0; i < radios.length; ++i) {
		if(radios[i].checked) {
			searchParams['so'] = radios[i].value;
			break;
		}
	}
	
	radios = document.getElementsByName('sortField');
	for(var i = 0; i < radios.length; ++i) {
		if(radios[i].checked) {
			searchParams['sf'] = radios[i].value;
			break;
		}
	}
	
	radios = document.getElementsByName('island');
	for(var i = 0; i < radios.length; ++i) {
		if(radios[i].checked) {
			searchParams['island'] = radios[i].value;
			break;
		}
	}
}

function populateUiWithParams() {
	var radios = document.getElementsByName('sortOrder');
	for(var i = 0; i < radios.length; ++i) {
		radios[i].checked = false;
	}
	document.getElementById('sortOrder' + capitalizeFirstLetter(searchParams['so'])).checked = true;
	
	radios = document.getElementsByName('sortField');
	for(var i = 0; i < radios.length; ++i) {
		radios[i].checked = false;
	}
	document.getElementById('sortField' + capitalizeFirstLetter(searchParams['sf'])).checked = true;
	
	radios = document.getElementsByName('island');
	for(var i = 0; i < radios.length; ++i) {
		radios[i].checked = false;
	}
	document.getElementById('island' + capitalizeFirstLetter(searchParams['island'])).checked = true;
}


function buildOptions(resultHTML) {
	resultHTML += "<div class='optionPanel'><button class='borderless' onclick='toggleOptionsPanel()'>&#9776;</button></div>";
	resultHTML += "<div class='optionPanel closed'><table><tbody>"
	resultHTML += "<tr><td>Sort By</td>";
	resultHTML += "<td><input type='radio' name='sortField' value='Value' id='sortFieldValue' onclick='process()'/><label for='sortFieldValue'>Value</label></td>";
	resultHTML += "<td><input type='radio' name='sortField' value='Name' id='sortFieldName' onclick='process()'/><label for='sortFieldName'>Name</label></td></tr>";
	resultHTML += "<tr><td>Order</td>";
	resultHTML += "<td><input type='radio' name='sortOrder' value='asc' id='sortOrderAsc' onclick='process()'/><label for='sortOrderAsc'>Asc</label></td>";
	resultHTML += "<td><input type='radio' name='sortOrder' value='desc' id='sortOrderDesc' onclick='process()'/><label for='sortOrderDesc'>Desc</label></td></tr>";
	resultHTML += "<tr><td>Island Bugs?</td>";
	resultHTML += "<td><input type='radio' name='island' value='true' id='islandTrue' onclick='process()'/><label for='islandTrue'>True</label></td>";
	resultHTML += "<td><input type='radio' name='island' value='only' id='islandOnly' onclick='process()'/><label for='islandOnly'>Only</label></td>";
	resultHTML += "<td><input type='radio' name='island' value='false' id='islandFalse' onclick='process()'/><label for='islandFalse'>False</label></td></tr>";
	resultHTML += "<tr><td><button class='borderless' onclick='toggleOptionsPanel()'>&#9776;</button></td><td/><td/><td><button class='borderless right' onclick='navigateToParameterizedPage()'>&#9741;</button></td></tr></tbody></table></div>";
	return resultHTML;
}

function buildTable(resultHTML) {
	resultHTML += "<table><tbody>";
	var month = new Date().getMonth() + 1;
	var hour = new Date().getHours();
	resultHTML += "<tr><td class='header'>Name</td><td class='header'>Value</td><td class='header'>Rarity</td><td class='header'>Location</td><td class='header'>Date,Time (" + new Date(new Date().getTime()).toLocaleTimeString() + ")</td><td class='header'>Island Time</td>";
	for(var i = 0; i < json_obj.length; i++) {
		if(filterItem(json_obj[i],searchParams,month,hour)) {
			resultHTML += "<tr>" 
				+ stringFromObject(json_obj[i])
				+"</tr>";
		}
	}
	resultHTML += "</tbody></table>";
	return resultHTML;
}

var json_obj;
var searchParams;

function reloadProcess() {
	var interval = (5 - new Date().getSeconds() % 5) * 1000 + new Date().getMilliseconds();
	if(interval > 5000) {
		interval = 5000;
	}
	setTimeout(process, interval);
}

function process() {
	readParamsFromUi();
	json_obj = sortItems(json_obj,searchParams);
	document.getElementById('results').innerHTML = buildTable('');
	reloadProcess();
}


function loadSearchParams() {
	var urlParams = new URLSearchParams(location.search.slice(1));
	searchParams = {};
	var anyIncluded = false;
	for(var searchKey of urlParams) {
		anyIncluded = true;
		searchParams[searchKey[0]] = searchKey[1];
	}

	if(!anyIncluded) {
		toggleOptionsPanel();
	}

	if(searchParams['sf'] == null) {
		searchParams['sf'] = 'Value';
	}
	if(searchParams['so'] == null) {
		if(searchParams['sf'] == 'Value') {
			searchParams['so'] = 'desc';
		}
		else {
			searchParams['so'] = 'asc';
		}
	}
	if(searchParams['island'] == null) {
		searchParams['island'] = 'true';
	}
}


function load() {
	json_obj = JSON.parse(Get("bugs.json"));
	document.getElementById('options').innerHTML = buildOptions('');
	loadSearchParams();
	populateUiWithParams();
	process();
}

function toggleOptionsPanel() {
	var elements = document.getElementsByClassName('optionPanel');
	for(var i = 0; i < elements.length; ++i) {
		elements[i].classList.toggle('closed');
	}
}
</script>
</head>
<body onload="load()">
<div id="options"></div>
<div id="results"></div>
</body>
</html>
{'fraction_non_alphanumeric': 0.1846006342650638, 'fraction_numerical': 0.00870270668928387, 'mean_word_length': 4.193412485637687, 'pattern_counts': {'":': 0, '<': 176, '<?xml version=': 0, '>': 153, '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': '2846738', 'n_tokens_mistral': 5283, 'n_tokens_neox': 4658, 'n_words': 911}