<commit_before>{% extends "cgen/base.html" %}
{% block content %}
<h1>Edit Character</h1>

<ul class="nav nav-tabs">
	<li class="active"><a href="#detail" data-toggle="tab">Details</a></li>
	<li><a href="#todo" data-toggle="tab">Tracks</a></li>
	<li><a href="#todo" data-toggle="tab">Feats</a></li>
	<li><a href="#todo" data-toggle="tab">Items</a></li>
</ul>
{% if error_message %}<p class="alert alert-danger">{{ error_message }}</p>{% endif %}
		
<form class="form-horizontal" role="form" action="{% url 'cgen:save' char.id %}" method="post">
	{% csrf_token %}

	<div class="tab-content well">
		<div id="detail" class="tab-pane fade in active">
            <h2>Name</h2>
			<div class="form-group">
				<label for="cname">Character Name</label>
				<input type="text" class="form-control" id="cname" name="cname" value="{{char.cname}}">
			</div>
			<div class="form-group">
				<label for="pname">Player Name</label>
				<input type="text" class="form-control" id="pname" name="pname" value="{{char.pname}}">
			</div>

            <h2>Race</h2>
            <div class="form-group">
                <label for="race" class="sr-only">Race</label>
                <select class="form-control" name="race">
					{% for race in races%}
					<option value="{{race.id}}" {% if race.id == char.race.id %} selected {% endif %}>{{race}}</option>
					{% endfor %}
				</select>
            </div>

            <h2>Class</h2>
			<div class="form-group">
				<label for="class_chassis" class="sr-only">Class Chassis</label>
				<select class="form-control" name="class_chassis" id="class_chassis">
					{% for cc in classes %}
					<option value="{{cc.id}}" {% if cc.id == char.class_chassis.id %} selected {% endif %}>{{cc}}</option>
					{% endfor %}
				</select>
			</div>
            <div class="form-group">
                <label for="kdm" class="control-label">KDM:</label>
                <span class="form-control-static" id="kdm">{{char.class_chassis.kdm}}</span>
            </div>
            <div class="form-group">
                <label for="kom" class="control-label">KOM:</label>
                <span class="form-control-static" id="kom">{{char.class_chassis.kom}}</span>
            </div>

            <h2>Attributes</h2>
			{% for k, v in attribs.items %}
			<div class="form-group">
				<label for="{{k}}" class="col-sm-2 control-label">{{v.0}}</label>
				<div class="col-xs-2">
					<input type="number" class="form-control att-input" id="{{k}}" name="{{k}}" value="{{v.1}}">
				</div>
				<div class="col-xs-2">
					(<span id="{{k}}mod"></span>)
				</div>
			</div>
			{% endfor %}
		</div>

		<div id="todo" class="tab-pane fade">
			<p class="alert alert-danger">Todo</p>
		</div>
	</div>

	<button type="submit" class="btn btn-primary">Save</button>
	<a href="{% url 'cgen:index' %}" class="btn btn-default">Character List</a>
	<a href="{% url 'cgen:delete' char.id %}" class="btn btn-danger">Delete</a>
</form>
{% endblock %}

{% block script %}
<script>
	$(document).ready(function() {
		$('.att-input').each(function() {
			$('#' + $(this).attr('name') + 'mod').text(~~(($(this).val() - 10) / 2));
		});

		$('.att-input').change(function() {
			$('#' + $(this).attr('name') + 'mod').text(~~(($(this).val() - 10) / 2));
		});

		$('#class_chassis').change(function() {
            $.ajax({
                url: "{% url 'cgen:get_class' 999 %}".replace('999', $('#class_chassis option:selected').attr('value')),
                dataType: "json"
            }).done(function(msg) {
                $('#kdm').text(msg[0].fields.kdm);
                $('#kom').text(msg[0].fields.kom);
            })
		});
	});
</script>
{% endblock %}<commit_msg>Modifiers now show a + for modifiers >= 0.<commit_after>{% extends "cgen/base.html" %}
{% block content %}
<h1>Edit Character</h1>

<ul class="nav nav-tabs">
	<li class="active"><a href="#detail" data-toggle="tab">Details</a></li>
	<li><a href="#todo" data-toggle="tab">Tracks</a></li>
	<li><a href="#todo" data-toggle="tab">Feats</a></li>
	<li><a href="#todo" data-toggle="tab">Items</a></li>
</ul>
{% if error_message %}<p class="alert alert-danger">{{ error_message }}</p>{% endif %}
		
<form class="form-horizontal" role="form" action="{% url 'cgen:save' char.id %}" method="post">
	{% csrf_token %}

	<div class="tab-content well">
		<div id="detail" class="tab-pane fade in active">
            <h2>Name</h2>
			<div class="form-group">
				<label for="cname">Character Name</label>
				<input type="text" class="form-control" id="cname" name="cname" value="{{char.cname}}">
			</div>
			<div class="form-group">
				<label for="pname">Player Name</label>
				<input type="text" class="form-control" id="pname" name="pname" value="{{char.pname}}">
			</div>

            <h2>Race</h2>
            <div class="form-group">
                <label for="race" class="sr-only">Race</label>
                <select class="form-control" name="race">
					{% for race in races%}
					<option value="{{race.id}}" {% if race.id == char.race.id %} selected {% endif %}>{{race}}</option>
					{% endfor %}
				</select>
            </div>

            <h2>Class</h2>
			<div class="form-group">
				<label for="class_chassis" class="sr-only">Class Chassis</label>
				<select class="form-control" name="class_chassis" id="class_chassis">
					{% for cc in classes %}
					<option value="{{cc.id}}" {% if cc.id == char.class_chassis.id %} selected {% endif %}>{{cc}}</option>
					{% endfor %}
				</select>
			</div>
            <div class="form-group">
                <label for="kdm" class="control-label">KDM:</label>
                <span class="form-control-static" id="kdm">{{char.class_chassis.kdm}}</span>
            </div>
            <div class="form-group">
                <label for="kom" class="control-label">KOM:</label>
                <span class="form-control-static" id="kom">{{char.class_chassis.kom}}</span>
            </div>

            <h2>Attributes</h2>
			{% for k, v in attribs.items %}
			<div class="form-group">
				<label for="{{k}}" class="col-sm-2 control-label">{{v.0}}</label>
				<div class="col-xs-2">
					<input type="number" class="form-control att-input" id="{{k}}" name="{{k}}" value="{{v.1}}">
				</div>
				<div class="col-xs-2">
					(<span id="{{k}}mod"></span>)
				</div>
			</div>
			{% endfor %}
		</div>

		<div id="todo" class="tab-pane fade">
			<p class="alert alert-danger">Todo</p>
		</div>
	</div>

	<button type="submit" class="btn btn-primary">Save</button>
	<a href="{% url 'cgen:index' %}" class="btn btn-default">Character List</a>
	<a href="{% url 'cgen:delete' char.id %}" class="btn btn-danger">Delete</a>
</form>
{% endblock %}

{% block script %}
<script>
	$(document).ready(function() {
		update_attr_mod_func = function() {
			var modifier = ~~(($(this).val() - 10) / 2);
			$('#' + $(this).attr('name') + 'mod').text(((modifier >= 0) ? "+" : "") + modifier);
		};

		$('.att-input').each(update_attr_mod_func);
		$('.att-input').change(update_attr_mod_func);

		$('#class_chassis').change(function() {
            $.ajax({
                url: "{% url 'cgen:get_class' 999 %}".replace('999', $('#class_chassis option:selected').attr('value')),
                dataType: "json"
            }).done(function(msg) {
                $('#kdm').text(msg[0].fields.kdm);
                $('#kom').text(msg[0].fields.kom);
            })
		});
	});
</script>
{% endblock %}
{'fraction_non_alphanumeric': 0.24055075593952485, 'fraction_numerical': 0.007694384449244061, 'mean_word_length': 3.0200759631036354, 'pattern_counts': {'":': 0, '<': 197, '<?xml version=': 0, '>': 199, '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': '4416614', 'n_tokens_mistral': 2954, 'n_tokens_neox': 2566, 'n_words': 473}