mirror of
https://github.com/Vestride/fancy-index.git
synced 2025-11-08 11:45:40 +01:00
Allow first column to not have an image. Fixes #2
This commit is contained in:
21
script.js
21
script.js
@@ -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.
|
||||||
|
|||||||
Reference in New Issue
Block a user