Current time display in qso log form
This commit is contained in:
parent
3dd9930d0f
commit
1fa184eb98
|
@ -40,6 +40,7 @@ def log(request):
|
||||||
|
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
form = QSOForm(user=request.user, data=request.POST)
|
form = QSOForm(user=request.user, data=request.POST)
|
||||||
|
form.helper.form_tag = False
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
l = form.instance
|
l = form.instance
|
||||||
if not l.time:
|
if not l.time:
|
||||||
|
@ -63,6 +64,7 @@ def log(request):
|
||||||
data["band"] = qsos[0].band
|
data["band"] = qsos[0].band
|
||||||
|
|
||||||
form = QSOForm(request.user, initial=data)
|
form = QSOForm(request.user, initial=data)
|
||||||
|
form.helper.form_tag = False
|
||||||
|
|
||||||
|
|
||||||
return render(request, 'contest/log.html', {'form': form, 'qsos': qsos})
|
return render(request, 'contest/log.html', {'form': form, 'qsos': qsos})
|
||||||
|
|
|
@ -28,7 +28,15 @@
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<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">
|
||||||
|
<p id="id_curr_time" class="form-control-static">noot</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{% crispy form %}
|
{% crispy form %}
|
||||||
|
</form>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -130,6 +138,21 @@ $(document).ready(function() {
|
||||||
$("#id_otherNo").on("keydown", function(e) { return mvFocusOnSpace(e, "#id_refStr"); });
|
$("#id_otherNo").on("keydown", function(e) { return mvFocusOnSpace(e, "#id_refStr"); });
|
||||||
$("#id_refStr").on("keydown", function(e) { return mvFocusOnSpace(e, "#submit-id-submit"); });
|
$("#id_refStr").on("keydown", function(e) { return mvFocusOnSpace(e, "#submit-id-submit"); });
|
||||||
|
|
||||||
|
// 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();
|
||||||
|
dstr = zeropad(d.getHours()) + ":" + zeropad(d.getMinutes()) + ":" + zeropad(d.getSeconds());
|
||||||
|
$("#id_curr_time").text(dstr);
|
||||||
|
}
|
||||||
|
window.setInterval(displayTimeInForm, 200);
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue