Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
redmine 'view customize plugin' script to show subprojects in table
// Path pattern: /projects/[a-z0-9\-_]+$
// Type : JavaScript
$(function() {
var box = document.getElementsByClassName('projects box')[0]
var leaf = $(box).children('a');
var rows = [];
for (var i=0; i<leaf.length; i++) {
rows.push(createRow(leaf.eq(i)));
}
var table = $('<table class="list"></table>');
for (var i=0; i<rows.length; i++) {
table.append(rows[i].addClass((i % 2 == 0) ? 'odd' : 'even'));
}
var dataNodes = Array.prototype.slice.call($(box)[0].childNodes);
for (var i=0; i<dataNodes.length; i++) {
if (dataNodes[i].nodeType == 3) {
dataNodes[i].parentNode.removeChild(dataNodes[i]);
}
}
$(box).append(table);
function createRow(target) {
var tr = $('<tr>');
tr.addClass('project').addClass('child').addClass('leaf');
tr.append($('<td>').append($('<span>').append(target)).addClass('name'));
return tr;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment