<commit_before>﻿<!--
Copyright © 2017 <NAME>, <NAME>. All rights reserved.
This software is released under the MIT license.
See LICENSE for more information.
-->
<html>
<head>
<script type="text/x-mathjax-config">
    MathJax.Hub.Config({ messageStyle: "none"});
</script>
<style>
    math {display:none}
</style>
<script type="text/x-mathjax-config">
    MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
</script>
<script type="text/javascript" async
  src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS_CHTML">
</script>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<title>REU CDS Demo</title>
<script src="res/jquery.min.js"></script>
<script src="res/bonsai.min.js"></script>
<script src="showmatrix.js"></script>
<script>
var p = [];
function runDemo() {
	document.getElementById("stage").innerHTML = "";
	document.getElementById("fixedchoose").hidden = true;
    var x;
    if (document.getElementById("sorttype2").checked)
        x = "sortable";
    else if (document.getElementById("sorttype3").checked)
        x = "unsortable";
	else if (document.getElementById("sorttype4").checked) {
		x = "game_init";
		document.getElementById("fixedchoose").hidden = false;
		var spSize = Math.floor(Math.random()*(NODE_COUNT-5)+3);
		do {
			p = getPermutation(NODE_COUNT-1);
		} while (SP(p).length != spSize);
		document.getElementById("fixedchoose").innerHTML = 'Number of fixed points for Red (pick number from 0 to '+spSize.toString()+'):<br>	<input type="text" id="p1points" name="sorttype"><br><input type="button" onclick="selectFixedPoints()" value="Select">';
	}
    else
        x = "random";
    var game = bonsai.run($('#stage')[0], {url: 'demo.js', sorttype: x, permutation: p});
    game.on('message:change', function(arg) {
        showObjects(arg);
    });
}

function selectFixedPoints() {
	document.getElementById("stage").innerHTML = "";
	document.getElementById("fixedchoose").hidden = true;
    var numFixed = Number(document.getElementById("p1points").value);
	var game = bonsai.run($('#stage')[0], {url: 'demo.js', sorttype: "game", permutation: p, nfixed: numFixed});
    game.on('message:change', function(arg) {
        showObjects(arg);
    });
}
</script>
</head>
<body>
    <h1 id="permutation"></h1>
	<form id="fixedchoose" action="javascript:selectFixedPoints()" hidden>
	Number of fixed points for red:<br>
	<input type="text" id="p1points" name="sorttype"><br>
	<input type="button" onclick="selectFixedPoints()" value="Select">
	</form>
	<h1 id="pile" hidden></h1>
    <div id="stage"></div>
    <h3 id="matrix"></h3> 
	<div class="container">
    <form>
	<div class="form-group">
	<div class="radio"><input type="radio" id="sorttype1" name="sorttype" value="random" checked>Random<br></div>
    <div class="radio"><input type="radio" id="sorttype2" name="sorttype" value="sortable">Sortable<br></div>
    <div class="radio"><input type="radio" id="sorttype3" name="sorttype" value="unsortable">Unsortable<br></div>
    <div class="radio"><input type="radio" id="sorttype4" name="sorttype" value="game">Game<br></div>
	</div>
	<input type="button" onclick="runDemo()" value="Get Permutation">
	</div>
    </form>
	</div>
    <script type="text/javascript">
        var game = bonsai.run($('#stage')[0], 'demo.js');
        game.on('message:change', function(arg) {
            showObjects(arg);
        });
    </script>
</body>
</html>
<commit_msg>add error checking<commit_after>﻿<!--
Copyright © 2017 <NAME>, <NAME>. All rights reserved.
This software is released under the MIT license.
See LICENSE for more information.
-->
<html>
<head>
<script type="text/x-mathjax-config">
    MathJax.Hub.Config({ messageStyle: "none"});
</script>
<style>
    math {display:none}
</style>
<script type="text/x-mathjax-config">
    MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
</script>
<script type="text/javascript" async
  src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS_CHTML">
</script>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<title>REU CDS Demo</title>
<script src="res/jquery.min.js"></script>
<script src="res/bonsai.min.js"></script>
<script src="showmatrix.js"></script>
<script>
var p = [];
function runDemo() {
	document.getElementById("stage").innerHTML = "";
	document.getElementById("fixedchoose").hidden = true;
    var x;
    if (document.getElementById("sorttype2").checked)
        x = "sortable";
    else if (document.getElementById("sorttype3").checked)
        x = "unsortable";
	else if (document.getElementById("sorttype4").checked) {
		x = "game_init";
		document.getElementById("fixedchoose").hidden = false;
		var spSize = Math.floor(Math.random()*(NODE_COUNT-5)+3);
		do {
			p = getPermutation(NODE_COUNT-1);
		} while (SP(p).length != spSize);
		document.getElementById("fixedchoose").innerHTML = 'Number of fixed points for Red (pick number from 0 to '+spSize.toString()+'):<br>	<input type="text" id="p1points" name="sorttype"><br><input type="button" onclick="selectFixedPoints()" value="Select">';
	}
    else
        x = "random";
    var game = bonsai.run($('#stage')[0], {url: 'demo.js', sorttype: x, permutation: p});
    game.on('message:change', function(arg) {
        showObjects(arg);
    });
}

function selectFixedPoints() {
	var numFixed = Number(document.getElementById("p1points").value);
	if (numFixed < 0 || numFixed > SP(p).length) {
		document.getElementById("p1points").value = "invalid fixed point count";
		return;
	}
	document.getElementById("stage").innerHTML = "";
	document.getElementById("fixedchoose").hidden = true;
    var game = bonsai.run($('#stage')[0], {url: 'demo.js', sorttype: "game", permutation: p, nfixed: numFixed});
    game.on('message:change', function(arg) {
        showObjects(arg);
    });
}
</script>
</head>
<body>
    <h1 id="permutation"></h1>
	<form id="fixedchoose" action="javascript:selectFixedPoints()" hidden>
	Number of fixed points for red:<br>
	<input type="text" id="p1points" name="sorttype"><br>
	<input type="button" onclick="selectFixedPoints()" value="Select">
	</form>
	<h1 id="pile" hidden></h1>
    <div id="stage"></div>
    <h3 id="matrix"></h3> 
	<div class="container">
    <form>
	<div class="form-group">
	<div class="radio"><input type="radio" id="sorttype1" name="sorttype" value="random" checked>Random<br></div>
    <div class="radio"><input type="radio" id="sorttype2" name="sorttype" value="sortable">Sortable<br></div>
    <div class="radio"><input type="radio" id="sorttype3" name="sorttype" value="unsortable">Unsortable<br></div>
    <div class="radio"><input type="radio" id="sorttype4" name="sorttype" value="game">Game<br></div>
	</div>
	<input type="button" onclick="runDemo()" value="Get Permutation">
	</div>
    </form>
	</div>
    <script type="text/javascript">
        var game = bonsai.run($('#stage')[0], 'demo.js');
        game.on('message:change', function(arg) {
            showObjects(arg);
        });
    </script>
</body>
</html>

{'fraction_non_alphanumeric': 0.20490814000268204, 'fraction_numerical': 0.01045997049751911, 'mean_word_length': 4.933174224343675, 'pattern_counts': {'":': 0, '<': 154, '<?xml version=': 0, '>': 154, 'https://': 6, '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': '4836739', 'n_tokens_mistral': 2570, 'n_tokens_neox': 2478, 'n_words': 485}