Allow first column to not have an image. Fixes #2

This commit is contained in:
Glen Cheney
2016-09-15 20:36:44 -07:00
parent a354f71159
commit 1fc22ee586

View File

@@ -27,12 +27,25 @@ void(function() {
// Remove the first column and put the image in the next. // Remove the first column and put the image in the next.
var rows = toArray(table.querySelectorAll('tr')); var rows = toArray(table.querySelectorAll('tr'));
rows.forEach(function(row) { rows.forEach(function(row) {
var iconColumn = row.children[0];
var fileColumn = row.children[1];
// Remove icon column.
row.removeChild(iconColumn);
var image = iconColumn.firstElementChild;
if (!image) {
return;
}
// Wrap icon in a div.img-wrap.
var div = document.createElement('div'); var div = document.createElement('div');
div.className = 'img-wrap'; div.className = 'img-wrap';
var first = row.removeChild(row.firstElementChild).firstElementChild; div.appendChild(image);
div.appendChild(first);
var filename = row.firstElementChild; // Insert icon before filename.
filename.insertBefore(div, filename.firstElementChild); fileColumn.insertBefore(div, fileColumn.firstElementChild);
}); });
// Swap special images. // Swap special images.