clean up A, An, and The before sorting

This commit is contained in:
David 2017-05-17 14:47:35 -04:00
parent 4b84ce0feb
commit 0b8c7d4260
1 changed files with 9 additions and 1 deletions

View File

@ -34,6 +34,7 @@
$.each(data, function(key, value) {
value.rowNumber = key; // re-key for new sort
value.sortTitle = titleCleaner(value.title);
});
var template = $('#Table').html();
@ -53,6 +54,13 @@
$('#current').html(rendered);
}
function titleCleaner(title) {
return title
.replace('"', '')
.replace(':', '')
.replace(/^(An?|The)\s/i, '');
}
window.addEventListener('DOMContentLoaded', init);
</script>
</head>
@ -71,7 +79,7 @@
<script id="Table" type="text/html">
<table class="bookTable">
<tr>
<th data-sort-by="title" class="tHeader title">Title</th>
<th data-sort-by="sortTitle" class="tHeader title">Title</th>
<th data-sort-by="authorLast" class="tHeader author">Author</th>
<th data-sort-by="publisher" class="tHeader publisher">Publisher</th>
<th data-sort-by="year" class="tHeader year">Year</th>