<commit_before><div id="content">

<h1>Settings</h1>

<h2>Categories</h2>

			<ul id="category-list" class="nav nav-pills nav-stacked">
				<?php
					foreach ($categories as $category)
					{
						echo '<li class="ui-state-default" data-id="'.$category->getId().'"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>'.$category->getName().'</li>';
					}
				?>
			</ul>

			<h3>New category</h3>

			<form method="post" class="settings-form">
				<label for="category-name">Category name</label>
				<input type="text" name="category-text" id="category-text" required />
				<input type="hidden" name="action" value="new-category" />
				<button type="submit" class="btn">Create category</button>
			</form>

<h2>Update user</h2>

<form method="post" class="settings-form" novalidate>
	<label for="login">Login</label>
	<input type="email" name="login" id="login" required />
	<label for="password">Password</label>
	<input type="password" name="password" id="password" required />
	<input type="hidden" name="action" value="update-user" />
	<button type="submit" class="btn">Update</button>
</form>

</div>

<script type="text/javascript">
$(function() {
	$( "#category-list" ).sortable({
		update: function(event, ui)
		{
			var catId = ui.item.data('id');
			var order = ui.item.prevAll("li").size();
			setNewCatOrder(catId, order);
		}
	});
});
function setNewCatOrder(catId, order)
{
	var request = $.ajax({
		url: "category/order/" + catId + "/" + order,
		type: "GET",
		dataType: "html"
	});
	request.done(function(msg) {
	});
	request.fail(function(jqXHR, textStatus) {
	});
}
$("#category-list").on("click", "a", function(e) {
	e.preventDefault();
});
</script><commit_msg>Added create category action on the settings screen.<commit_after><div id="content">

<h1>Settings</h1>

<h2>Categories</h2>

<ul id="category-list" class="nav nav-pills nav-stacked">
<?php
	foreach ($categories as $category)
	{
		echo '<li class="ui-state-default" data-id="'.$category->getId().'">'.$category->getName().'</li>';
	}
?>
</ul>

<h3>New category</h3>

<form method="post" id="form-create-category" class="settings-form">
	<label for="category-name">Category name</label>
	<input type="text" name="category-name" id="category-name" required />
	<input type="hidden" name="action" value="new-category" />
	<a href="#" class="btn btn-primary create-category">Create category</a>
</form>

<h2>Update user</h2>

<form method="post" class="settings-form" novalidate>
	<label for="login">Login</label>
	<input type="email" name="login" id="login" required />
	<label for="password">Password</label>
	<input type="password" name="password" id="password" required />
	<input type="hidden" name="action" value="update-user" />
	<button type="submit" class="btn">Update</button>
</form>

</div>

<script type="text/javascript">
$(function() {
	$( "#category-list" ).sortable({
		update: function(event, ui)
		{
			var catId = ui.item.data('id');
			var order = ui.item.prevAll("li").size();
			setNewCatOrder(catId, order);
		}
	});
});
function setNewCatOrder(catId, order)
{
	var request = $.ajax({
		url: "category/order/" + catId + "/" + order,
		type: "GET",
		dataType: "html"
	});
	request.done(function(msg) {
	});
	request.fail(function(jqXHR, textStatus) {
	});
}
$("#category-list").on("click", "a", function(e) {
	e.preventDefault();
});

$("form#form-create-category").on("click", "a.create-category", function(e) {
	e.preventDefault();
	var name = $("form#form-create-category").find("input#category-name").val();
	var request = $.ajax({
		url: "category/create",
		type: "POST",
		dataType: "json",
		data: { categoryName: name }
	});
	request.done(function(data) {
		var template = $('<li class="ui-state-default" data-id=""></li>');
		template.attr('data-id', data.id);
		template.html(data.name);
		$('ul#category-list').append(template);
	});
	request.fail(function(jqXHR, textStatus) {
	});
});

</script>
{'fraction_non_alphanumeric': 0.22327124266394488, 'fraction_numerical': 0.004337841286042358, 'mean_word_length': 4.894736842105263, 'pattern_counts': {'":': 0, '<': 79, '<?xml version=': 0, '>': 83, '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': '7301664', 'n_tokens_mistral': 1464, 'n_tokens_neox': 1382, 'n_words': 258}