diff --git a/mbclist.html b/mbclist.html
index 3e48612..0c78917 100644
--- a/mbclist.html
+++ b/mbclist.html
@@ -63,6 +63,15 @@
.narrow {
max-width: 5em;
}
+ .row-busy {
+ opacity: 40%;
+ }
+ .row-expiring {
+ background-color: DarkOrange !important;
+ }
+ .row-expired {
+ background-color: Red !important;
+ }
@@ -127,28 +136,36 @@
function ChildData ( d ) {
// `d` is the original data object for the row
- return '
'+
- ''+
- 'Address: | '+
- ''+d.address+', '+d.city+', '+d.state+' '+d.zip+' | '+
- '
'+
- ''+
- 'Phone: | '+
- ''+d.phone.map(item => item.type + " " + item.number).join(" ")+' | '+
- '
'+
- ''+
- 'Email: | '+
- ''+d.email+' | '+
- '
'+
- ''+
- 'BSA ID: | '+
- ''+d.bsaid+' | '+
- '
'+
- ''+
- 'Works with: | '+
- ''+d.workwith+' | '+
- '
'+
- '
';
+ return `
+
+ Address: |
+ ${d.address}, ${d.city}, ${d.state} ${d.zip} |
+
+
+ Phone: |
+ ${d.phone.map(item => item.type + " " + item.number).join(" ")} |
+
+
+ Email: |
+ ${d.email} |
+
+
+ BSA ID: |
+ ${d.bsaid} |
+
+
+ Works with: |
+ ${d.workwith} |
+
+
+ Availability: |
+ ${d.availability} |
+
+
+ YPT expires: |
+ ${d.yptexpiry} |
+
+
`;
}
$(document).ready( function () {
@@ -162,14 +179,26 @@
$('#mbcs thead tr:eq(1) th:gt(1)').each( function (i) {
var title = $(this).text();
- $(this).html( '' );
+ $(this).html( `` );
$( 'input', this ).on( 'keyup change', function () {
- if ( table.column(i+2).search() !== this.value ) {
- table
- .column(i+2)
- .search( this.value )
- .draw();
+ if ( table.column(i+2).search() !== this.value )
+ {
+ // if it looks like a regex, do a regex search
+ if ($.fn.dataTable.util.escapeRegex(this.value) != this.value)
+ {
+ table
+ .column(i+2)
+ .search( this.value, true, false )
+ .draw();
+ }
+ else
+ {
+ table
+ .column(i+2)
+ .search( this.value )
+ .draw();
+ }
}
} );
} );
@@ -230,14 +259,28 @@
return retval;
}
},
- { data: 'workwith', visible: false }
+ { data: 'workwith', visible: false },
+ { data: 'availability', visible: false },
+ { data: 'yptexpiry', visible: false },
],
order: [[2, 'asc']],
dom: '<"top"lif<"clear">>rt<"bottom"lip<"clear">>',
orderCellsTop: true,
fixedHeader: true,
pageLength: 10,
- } );
+ createdRow: function( row, data, dataIndex ) {
+ if ( data.availability == "Busy" )
+ {
+ $(row).addClass('row-busy');
+ }
+ var diffDays = (Date.parse(data.yptexpiry) - Date.now()) / (1000 * 60 * 60 * 24);
+ if ( diffDays <= 45 )
+ {
+ console.log(data.yptexpiry, diffDays, row);
+ $(row).addClass(diffDays <= 0 ? 'row-expired' : 'row-expiring');
+ }
+ } // createdRow
+ } ); // DataTable
// Event listener to the two distance filtering inputs to redraw on input
$('#targetZipcode, #radius').keyup( function(e) {