Made call log filtering case insensitive + optimizing

This commit is contained in:
Sebastian Lohff 2017-01-21 05:06:58 +01:00
parent eca75e19b2
commit 8227a16c0a
1 changed files with 9 additions and 17 deletions

View File

@ -85,14 +85,21 @@ $(document).ready(function() {
var log = [{% for qso in qsos %}{call: "{{ qso.call }}", band: "{{ qso.band }}"}{% if not forloop.last %}, {% endif %}{% endfor %}]; var log = [{% for qso in qsos %}{call: "{{ qso.call }}", band: "{{ qso.band }}"}{% if not forloop.last %}, {% endif %}{% endfor %}];
function checkForDupes(e) { function checkForDupes(e) {
var call = $("#id_call").val(); var call = $("#id_call").val().toUpperCase();
var band = $("#id_band :selected").text(); var band = $("#id_band :selected").text();
var dupe = false; var dupe = false;
for(var i=0; i<log.length; i++) { for(var i=0; i<log.length; i++) {
// 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
if(call == log[i].call && band == log[i].band) { if(call == log[i].call && band == log[i].band) {
dupe = true; dupe = true;
break;
} }
} }
@ -107,22 +114,7 @@ $(document).ready(function() {
} }
} }
function filterTableCalls(e) {
var call = $("#id_call").val();
//var band = $("#id_band :selected").text();
for(var i=0; i<log.length; i++) {
console.log(log[i].call.substr(0, call.length));
if(log[i].call.substr(0, call.length) != call) {
$("#qso-row-" + i).hide();
} else {
$("#qso-row-" + i).show();
}
}
}
$("#id_call").on("input", checkForDupes); $("#id_call").on("input", checkForDupes);
$("#id_call").on("input", filterTableCalls);
$("#id_band").change(checkForDupes); $("#id_band").change(checkForDupes);
}); });