diff --git a/Netdisco/share/public/javascripts/netdisco.js b/Netdisco/share/public/javascripts/netdisco.js
index 42be2719..7ac3f787 100644
--- a/Netdisco/share/public/javascripts/netdisco.js
+++ b/Netdisco/share/public/javascripts/netdisco.js
@@ -39,7 +39,7 @@ function do_search (event, tab) {
);
return;
}
- if (response === "") {
+ if (response == "") {
$(target).html(
'
No matching records.
'
);
@@ -111,32 +111,41 @@ if (window.History && window.History.enabled) {
// if any field in Search Options has content, highlight in green
function device_form_state(e) {
- if (e.prop('value') != "") {
- e.parent(".clearfix").addClass('success');
+ var with_val = $.grep(form_inputs,
+ function(n,i) {return($(n).prop('value') != "")}).length;
+ var with_text = $.grep(form_inputs.not('select'),
+ function(n,i) {return($(n).val() != "")}).length;
- if (e.parents('#device_form').length) {
- $('#nq').css('text-decoration', 'line-through');
-
- if (e.attr('type') == 'text') {
- $('.nd_field-copy-icon').hide();
- }
- }
-
- var id = '#' + e.attr('name') + '_clear_btn';
- $(id).show();
- }
- else {
+ if (e.prop('value') == "") {
e.parent(".clearfix").removeClass('success');
var id = '#' + e.attr('name') + '_clear_btn';
$(id).hide();
- var num_empty = $.grep(form_inputs,
- function(n,i) {return($(n).val() != "")}).length;
- if (num_empty === 3) {
+ // if form has no field val, clear strikethough
+ if (with_val == 0) {
$('#nq').css('text-decoration', 'none');
+ }
+
+ // for text inputs only, extra formatting
+ if (with_text == 0) {
$('.nd_field-copy-icon').show();
}
}
+ else {
+ e.parent(".clearfix").addClass('success');
+ var id = '#' + e.attr('name') + '_clear_btn';
+ $(id).show();
+
+ // if form still has any field val, set strikethough
+ if (e.parents('form[action="/search"]').length > 0 && with_val != 0) {
+ $('#nq').css('text-decoration', 'line-through');
+ }
+
+ // if we're text, hide copy icon when we get a val
+ if (e.attr('type') == 'text') {
+ $('.nd_field-copy-icon').hide();
+ }
+ }
}
$(document).ready(function() {