Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion resources/views/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,26 @@
}
});

var rowsById = {};
$('.table tbody tr').each(function() {
var id = $(this).attr('id').toLowerCase();
rowsById[id] = $(this);
});

$('#search-field').keyup(function() {
var searchKey = $(this).val().toLowerCase();
Object.keys(rowsById).forEach(function(key) {
rowsById[key].toggle(!searchKey || key.includes(searchKey));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to replace key.includes(searchKey) with key.toUpperCase().includes(searchKey).
Otherwise very good. Good Job.

});
});

$("a.delete-key").click(function(event){
event.preventDefault();
var row = $(this).closest('tr');
var url = $(this).attr('href');
var id = row.attr('id');
$.post( url, {id: id}, function(){
delete rowsById[id.toLowerCase()];
row.remove();
} );
});
Expand Down Expand Up @@ -227,7 +241,10 @@
</div>
</form>
<hr>
<h4>Total: <?= $numTranslations ?>, changed: <?= $numChanged ?></h4>
<div class="row">
<h4 class="col-md-9">Total: <?= $numTranslations ?>, changed: <?= $numChanged ?></h4>
<p class="col-md-3"><input type="search" placeholder="Filter by key..." id="search-field" class="form-control" /></p>
</div>
<table class="table">
<thead>
<tr>
Expand Down