2017-01-20 14:28:59 +01:00
|
|
|
{% extends "base.html" %}
|
|
|
|
|
|
|
|
{% load crispy_forms_tags %}
|
|
|
|
|
|
|
|
{% block content %}
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-sm-12">
|
|
|
|
<div class="panel panel-default">
|
|
|
|
<div class="panel-heading">Log a QSO!</div>
|
|
|
|
<div class="panel-body">
|
|
|
|
<style scoped>
|
2017-01-20 23:36:55 +01:00
|
|
|
#id_call {
|
|
|
|
text-transform: uppercase;
|
|
|
|
}
|
2017-01-20 14:28:59 +01:00
|
|
|
#id_reportRX, #id_reportTX {
|
2017-01-20 23:36:55 +01:00
|
|
|
width: 50px;
|
2017-01-20 14:28:59 +01:00
|
|
|
}
|
|
|
|
#id_ownNo, #id_otherNo {
|
2017-01-20 23:36:55 +01:00
|
|
|
width: 75px;
|
2017-01-20 14:28:59 +01:00
|
|
|
}
|
|
|
|
#id_refStr {
|
|
|
|
width: 100px;
|
2017-01-22 19:43:47 +01:00
|
|
|
text-transform: uppercase;
|
2017-01-20 14:28:59 +01:00
|
|
|
}
|
|
|
|
#id_call {
|
|
|
|
width: 100px;
|
|
|
|
}
|
2017-01-21 04:51:35 +01:00
|
|
|
|
2017-01-24 12:23:28 +01:00
|
|
|
#qso-log-form .form-group:last-child {
|
|
|
|
vertical-align: bottom;
|
|
|
|
}
|
|
|
|
|
2017-01-20 14:28:59 +01:00
|
|
|
</style>
|
2017-01-20 21:03:54 +01:00
|
|
|
|
2017-01-23 00:00:57 +01:00
|
|
|
<form method="post" id="qso-log-form" class="form-inline" action="{% url "contest:log" %}">
|
|
|
|
<div class="form-group">
|
|
|
|
<label class="control-label">Time</label>
|
|
|
|
<div class="controls">
|
2017-01-23 01:55:39 +01:00
|
|
|
<p id="id_curr_time" class="form-control-static">{% now "H:i:s" %}</p>
|
2017-01-23 00:00:57 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{% crispy form %}
|
|
|
|
</form>
|
2017-01-20 14:28:59 +01:00
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-sm-12">
|
|
|
|
<div class="panel panel-default">
|
|
|
|
<div class="panel-heading">Your QSO log</div>
|
|
|
|
<div class="panel-body">
|
|
|
|
<table class="table">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
2017-01-20 23:36:55 +01:00
|
|
|
<th>Nr-S</th>
|
2017-01-20 14:28:59 +01:00
|
|
|
<th>Band</th>
|
2017-01-20 23:36:55 +01:00
|
|
|
<th>UTC</th>
|
|
|
|
<th>Call</th>
|
2017-01-23 02:00:42 +01:00
|
|
|
<th class="hidden-xs">RS-S</th>
|
|
|
|
<th class="hidden-xs">RS-R</th>
|
2017-01-21 04:51:35 +01:00
|
|
|
<th class="hidden-xs">Nr-R</th>
|
2017-01-20 23:36:55 +01:00
|
|
|
<th>EXC</th>
|
2017-01-21 04:51:35 +01:00
|
|
|
<th class="hidden-xs">Remarks</th>
|
2017-01-20 14:28:59 +01:00
|
|
|
<th></th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{% for qso in qsos %}
|
2017-01-21 01:27:27 +01:00
|
|
|
<tr id="qso-row-{{ forloop.counter0 }}">
|
2017-01-20 14:28:59 +01:00
|
|
|
<td>{{ qso.ownNo }}</td>
|
|
|
|
<td>{{ qso.band }}</td>
|
2017-01-20 23:36:55 +01:00
|
|
|
<td>{{ qso.time|date:"H:i" }}</td>
|
|
|
|
<td>{{ qso.call }}</td>
|
2017-01-21 04:51:35 +01:00
|
|
|
<td class="hidden-xs">{{ qso.reportTX }}</td>
|
|
|
|
<td class="hidden-xs">{{ qso.reportRX }}</td>
|
|
|
|
<td class="hidden-xs">{{ qso.otherNo }}</td>
|
2017-01-20 14:28:59 +01:00
|
|
|
<td>{{ qso.refStr }}</td>
|
2017-01-21 04:51:35 +01:00
|
|
|
<td class="hidden-xs">{{ qso.remarks }}</td>
|
|
|
|
<td><a href="{% url "contest:logEdit" qso.id %}"><span class="glyphicon glyphicon-pencil"></span></a> <a href="{% url "contest:logDelete" qso.id %}"><span class="glyphicon glyphicon-trash"></span></a></td>
|
2017-01-20 14:28:59 +01:00
|
|
|
</tr>
|
|
|
|
{% endfor %}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2017-01-20 23:36:55 +01:00
|
|
|
<script type="text/javascript">
|
|
|
|
$(document).ready(function() {
|
|
|
|
// set focus to fucking call field
|
|
|
|
// ...i hate javascript so much.
|
|
|
|
$('#id_call').focus();
|
2017-01-21 00:53:00 +01:00
|
|
|
|
|
|
|
var log = [{% for qso in qsos %}{call: "{{ qso.call }}", band: "{{ qso.band }}"}{% if not forloop.last %}, {% endif %}{% endfor %}];
|
|
|
|
|
|
|
|
function checkForDupes(e) {
|
2017-01-21 05:06:58 +01:00
|
|
|
var call = $("#id_call").val().toUpperCase();
|
2017-01-21 00:53:00 +01:00
|
|
|
var band = $("#id_band :selected").text();
|
|
|
|
|
|
|
|
var dupe = false;
|
|
|
|
for(var i=0; i<log.length; i++) {
|
2017-01-21 05:06:58 +01:00
|
|
|
// hide non-matching QSOs
|
|
|
|
if(log[i].call.substr(0, call.length) != call) {
|
|
|
|
$("#qso-row-" + i).hide();
|
|
|
|
} else {
|
|
|
|
$("#qso-row-" + i).show();
|
|
|
|
}
|
|
|
|
|
|
|
|
// check if dupe
|
2017-01-21 00:53:00 +01:00
|
|
|
if(call == log[i].call && band == log[i].band) {
|
|
|
|
dupe = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(dupe) {
|
|
|
|
console.log("DUPE");
|
|
|
|
$("#id_call").css('background-color', 'red');
|
|
|
|
$("#id_band").css('background-color', 'red');
|
|
|
|
} else {
|
|
|
|
$("#id_call").css('background-color', 'white');
|
|
|
|
$("#id_band").css('background-color', 'white');
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$("#id_call").on("input", checkForDupes);
|
|
|
|
$("#id_band").change(checkForDupes);
|
2017-01-22 22:06:28 +01:00
|
|
|
|
|
|
|
// use space to get to the next field for certain fields
|
|
|
|
function mvFocusOnSpace(e, newFocusId) {
|
|
|
|
if(e.keyCode == 32) {
|
|
|
|
$(newFocusId).focus()
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$("#id_call").on("keydown", function(e) { return mvFocusOnSpace(e, "#id_otherNo"); });
|
|
|
|
$("#id_otherNo").on("keydown", function(e) { return mvFocusOnSpace(e, "#id_refStr"); });
|
2017-01-23 01:12:10 +01:00
|
|
|
$("#id_refStr").on("keydown", function(e) { return mvFocusOnSpace(e, "#id_call"); });
|
2017-01-22 22:06:28 +01:00
|
|
|
|
2017-01-23 00:00:57 +01:00
|
|
|
// display current time in log form
|
|
|
|
function zeropad(n) {
|
|
|
|
// srsly, how can javascript not have a printf/zeropad function?
|
|
|
|
if(n < 10)
|
|
|
|
return "0" + n;
|
|
|
|
else
|
|
|
|
return "" + n;
|
|
|
|
}
|
|
|
|
|
|
|
|
function displayTimeInForm() {
|
|
|
|
var d = new Date();
|
2017-01-23 01:55:39 +01:00
|
|
|
dstr = zeropad(d.getUTCHours()) + ":" + zeropad(d.getUTCMinutes()) + ":" + zeropad(d.getUTCSeconds());
|
2017-01-23 00:00:57 +01:00
|
|
|
$("#id_curr_time").text(dstr);
|
|
|
|
}
|
|
|
|
window.setInterval(displayTimeInForm, 200);
|
2017-01-20 23:36:55 +01:00
|
|
|
});
|
2017-01-21 00:53:00 +01:00
|
|
|
|
2017-01-20 23:36:55 +01:00
|
|
|
</script>
|
|
|
|
|
2017-01-20 14:28:59 +01:00
|
|
|
{% endblock %}
|
|
|
|
|