<!DOCTYPE html>

{% extends "base.html" %}
{% block pagename %}offlinepage{% endblock %}
{% block title %} Редактирование стрельбы {{ job.n }}{% endblock %}

{% block body %}

<script nonce='{{ common.CSP_SCRIPT_NONCE }}'>
function testForEnter(event) 
{   
	if (event.ctrlKey && event.keyCode === 13) {
		$("#firestarter-submit").click()
	}
	else if (event.keyCode === 13)
		{        
        event.preventDefault();
    }
} 

</script>


<div class="container-fluid">
<h1>Редактирование стрельбы {{ job.n }}</h1>
<br>
<form method="POST" action="edit" style="white-space: nowrap;">
	{% csrf_token %}
	<input type="hidden" value="{{ job.n }}" name="job_update">
	<input type="hidden" value="" name="user">
    <div class="input-group firestarter-input">
		<span class="input-group-addon" style="min-width: 188px;">Задача&emsp;</span>
		<input maxlength="120" class="form-control firestarter-input" placeholder="Задача" value="{{ job.task }}" name="task_new" onkeydown="testForEnter(event);"/>
	</div>
	<div class="input-group firestarter-input">
		<span class="input-group-addon" style="min-width: 188px;">Имя&emsp;</span>
		<input maxlength="120" class="form-control firestarter-input" placeholder="Имя" value="{{ job.name }}" name="name_new" onkeydown="testForEnter(event);"/>
	</div>
	<div class="input-group firestarter-input">
		<span class="input-group-addon" style="min-width: 188px;">Описание&emsp;</span>
		<input class="form-control firestarter-input" placeholder="Описание" value="{{ job.dsc }}" name="dsc_new" onkeydown="testForEnter(event);"/>
	</div>
	<div class="input-group firestarter-input">
		<span class="input-group-addon" style="min-width: 188px;">Автор&emsp;</span>
		<input maxlength="64" class="form-control firestarter-input" placeholder="Автор стрельбы" value="{{ job.person }}" name="person_new" onkeydown="testForEnter(event);"/>
	</div>
	<div class="input-group firestarter-input">
		<span class="input-group-addon" style="min-width: 188px;">Версия&emsp;</span>
		<input maxlength="120" class="form-control firestarter-input" placeholder="Версия" value="{{ job.ver }}" name="ver_new" onkeydown="testForEnter(event);"/>
	</div>
	
	<div class="input-group firestarter-input">
		<span class="input-group-addon" style="min-width: 188px;" id="input-group-addon__task">Компонент&emsp;</span>
		<select class="form-control selectpicker" data-live-search="true" data-style="btn-secondary" id="component_select" size="1" name="component_new">
			<option value=""></option>
			{% for component in components %}
				{% if component.n == job.component %}
					<option selected value="{{ component.n }}">{{ component.name }}</option>
				{% else %}
					<option value="{{ component.n }}">{{ component.name }}</option>
				{% endif %}
			{% endfor %}
		</select>
	</div>
			
	<div class="input-group firestarter-input">
		<span class="input-group-addon" style="min-width: 188px;" id="input-group-addon__task">Мишень&emsp;</span>
		<select class="form-control selectpicker" data-live-search="true" data-style="btn-secondary" id="target_select" size="1" name="srv_new">
			{% for target in targets %}
				{% if target == job.srv %}
					<option selected value="{{ target.n }}">{{ target.host }}</option>
				{% else %}
					<option value="{{ target.n }}">{{ target.host }}</option>
				{% endif %}
			{% endfor %}
		</select>
	</div>
	<div class="input-group firestarter-input">
		<span class="input-group-addon" style="min-width: 188px;">Порт&emsp;</span>
		<input maxlength="8" value="{{ job.srv_port }}" size="8" name="port_new" class="form-control firestarter-input" onkeydown="testForEnter(event);"/>
	</div>
    <div class="input-group firestarter-input">
		<span class="input-group-addon" style="min-width: 188px;">Мобильные данные&emsp;</span>
		<input value="{{ job.mobile_data_key }}" size="8" name="mobile_data_key_new" class="form-control firestarter-input" onkeydown="testForEnter(event);"/>
	</div>
	<br>
	<input type="submit" value="Сохранить" class="btn btn-brand">
</form>
</div>


<script nonce='{{ common.CSP_SCRIPT_NONCE }}' type="text/javascript">

$(document).ready(function(){

    var $componentSelect = $('#component_select'),
	    $targetSelect = $('#target_select');
	
	$componentSelect.selectpicker();
	$targetSelect.selectpicker();

	$componentSelect.css('margin-left', '0px');
	$targetSelect.css('margin-left', '0px');
	 
});
</script>
<link href="/media/css/firestarter.css" type="text/css" rel="stylesheet" />

{% endblock %}