{% extends "../base.html" %}
{% block content %}
{% macro buttonView(name,position,color,syscall,gcode,confirmText,cond) %}
<tr>
	<td>
		<input name="Name" value="{{name}}" class="form-control name">
		<select name="Color" class="form-control">
			<option value="btn btn-success" {% if color=="btn btn-success" %}selected{% endif %} translate>Green</option>
			<option value="btn btn-info" {% if color=="btn btn-info" %}selected{% endif %} translate>Blue</option>
			<option value="btn btn-warning" {% if color=="btn btn-warning" %}selected{% endif %} translate>Orange</option>
			<option value="btn btn-danger" {% if color=="btn btn-danger" %}selected{% endif %} translate>Red</option>
		</select>
	</td>
	<td>
		<select name="Position" class="form-control">
			<option value="/" {% if position=="/" %}selected{% endif %} translate>Dashboard</option>
			<option value="/z-calibration" {% if position=="/z-calibration" %}selected{% endif %} translate>Z-Axis Calibration</option>
			<option value="/projector-calibration" {% if position=="/projector-calibration" %}selected{% endif %} translate>Projector Calibration</option>
		</select>
		<select name="Condition" class="form-control">
			<option value="" {% if cond=="" %}selected{% endif %} translate>Anytime</option>
			<option value="idle-obj" {% if cond=="idle-obj" %}selected{% endif %} translate>Idle</option>
			<option value="printing-obj" {% if cond=="printing-obj" %}selected{% endif %} translate>Printing</option>
		</select>
	</td>
	<td><input name="Syscall" value="{{syscall}}" placeholder="Program Path" class="form-control"></td>
	<td><textarea name="Gcode" class="form-control">{{gcode}}</textarea></td>
	<td><input name="ConfirmText" value="{{confirmText}}" placeholder="Optional confirmation dialog text" class="form-control"></td>
	<td class="action"><a href="#" class="up">&#x2B06;</a><br><a href="#" class="down">&#x2B07;</a><br><a href="#" class="remove">&#x2716;</a></td>
</tr>
{% endmacro %}
<form action="" method="post" id="buttons" class="edit-page edit-table">
	<div class="row">
		<div class="col-md-12">
			<table class="table-striped">
				<tr class="thead">
					<th translate>Name / Color</th>
					<th translate>Position / Condition</th>
					<th translate>Syscall</th>
					<th translate>Gcode</th>
					<th translate>Confirmation Text</th>
					<th translate>Action</th>
				</tr>
				{% if buttons %}
					{% for button in buttons %}
						{{ buttonView(button.Name,button.Position,button.Color,button.Syscall,button.Gcode,button.ConfirmText,button.Condition) }}
					{% endfor %}
				{% endif %}
				{{ buttonView("",0,0,"","","","") }}
			</table>
			<br>
			<button type="submit" class="btn btn-success">Submit</button>
		</div>
	</div>
</form>
<div class="row">
	<div class="col-md-6">
		<br>
		<div class="note">
		<translate>It is possible to call a program or a script from shell and use the result as Gcode.</translate>
		<br>
		<translate>eg.</translate> python execute.py<br><br>

		<translate>Usable Keywords:</translate>
			<ul>
				<li>[[LayerNumber]]</li>
				<li>[[LayerThickness]]</li>
				<li>[[ZLiftDistance]]</li>
				<li>[[ZSpeed]]</li>
				<li>[[TotalSolidArea]]</li>
				<li>[[LargestArea]]</li>
				<li>[[Delay Seconds]] eg. [[Delay 1.23]]</li>
				<li>[[Pause]]</li>
				<li>[[GPIOWaitForLow]] and [[WaitForDoneMessage]]</li>
			</ul>
		</div>
	</div>
	<div class="col-md-6">
		<br>
		<div class="note">
		<translate>Supported Math operations:</translate>
			<ul>
				<li>+ - * / ** () &lt; ></li>
				<li translate>eg. {[[LayerThickness]]-[[ZLiftDistance]]}</li>
			</ul>
			<translate>Binary support:</translate>
			<ul>
				<li translate>It is possible to send binary codes using base 16 format.</li>
				<li translate>eg. \x00\xff</li>
			</ul>
		</div>
	</div>
</div>
{% endblock %}
