diff --git a/static/js/deposit.js b/static/js/deposit.js
index 882b60e..1f9205f 100644
--- a/static/js/deposit.js
+++ b/static/js/deposit.js
@@ -6,25 +6,32 @@ $(document).ready(function() {
});
}
function filter_customers(typed) {
- /* FIXME: Does not work well. */
setTimeout(function() {
$("li.customer").each(function(i) {
- if($(this).children("span.name").text().indexOf(typed) == -1) {
+ var pattern = new RegExp(typed,"i");
+ var name = $(this).children("span.name").text();
+ if(!pattern.test(name)) {
$(this).hide();
$(this).removeClass("marked");
} else {
$(this).show();
- }
- /* Full match */
- if($(this).children("span.name").text() == typed) {
- $(this).addClass("marked");
+ var full_match = name.toLowerCase() == typed.toLowerCase();
+ // FIXME: needs one more char.
+ //var single_match = $("li.customer:visible").length == 1;
+ //console.log(full_match, single_match);
+ //if(full_match || single_match) {
+ if(full_match) {
+ $(this).addClass("marked");
+ } elseĀ {
+ $(this).removeClass("marked");
+ }
}
});
}, 50);
}
/* Customer search */
- $('.typeahead').typeahead();
- $('#id_customer_name').keydown(function(event) {
+ //$('.typeahead').typeahead();
+ $('#id_customer_typeahead').keyup(function(event) {
filter_customers(event.srcElement.value);
});
/* Customer selection */
diff --git a/static/js/register.js b/static/js/register.js
index 21bb13b..e3be914 100644
--- a/static/js/register.js
+++ b/static/js/register.js
@@ -21,19 +21,25 @@ $(document).ready(function() {
});
}
function filter_customers(typed) {
- /* FIXME: Does not work. */
- console.log(typed);
setTimeout(function() {
$("li.customer").each(function(i) {
- if($(this).children("span.name").text().indexOf(typed) == -1) {
+ var pattern = new RegExp(typed,"i");
+ var name = $(this).children("span.name").text();
+ if(!pattern.test(name)) {
$(this).hide();
$(this).removeClass("marked");
} else {
$(this).show();
- }
- /* Full match */
- if($(this).children("span.name").text() == typed) {
- $(this).addClass("marked");
+ var full_match = name.toLowerCase() == typed.toLowerCase();
+ // FIXME: needs one more char.
+ //var single_match = $("li.customer:visible").length == 1;
+ //console.log(full_match, single_match);
+ //if(full_match || single_match) {
+ if(full_match) {
+ $(this).addClass("marked");
+ } elseĀ {
+ $(this).removeClass("marked");
+ }
}
});
}, 50);
diff --git a/templates/deposit.html b/templates/deposit.html
index f9f2dc4..7203942 100644
--- a/templates/deposit.html
+++ b/templates/deposit.html
@@ -52,7 +52,7 @@
{% endblock %}
{% block tailinc %}
-
+
{% endblock %}