MediaWiki:Common.js: Difference between revisions

From Vintage Story Wiki
no edit summary
No edit summary
No edit summary
Line 17: Line 17:
var $el = $(el);
var $el = $(el);
var id = $el.data('tt-id');
var id = $el.data('tt-id');
var level = 1;
var parent = $el.data('tt-parent');
var parent = $el.data('tt-parent');
if(parent === '') {
if(parent === '') {
parent = undefined;
parent = undefined;
level = 0;
}
}


var item = {
var item = {
id: id,
id: id,
level: level,
parent: parent,
parent: parent,
children: [],
children: [],
Line 39: Line 42:
if (item.parent !== undefined) {
if (item.parent !== undefined) {
item.parent = index[item.parent];
item.parent = index[item.parent];
item = parent.level+1;
item.parent.children.push(item);
item.parent.children.push(item);
}
}
Line 65: Line 69:
// add parent classes
// add parent classes
items.forEach(function (item) {
items.forEach(function (item) {
item.el.closest("tr").addClass("level" + item.level);
if (item.children.length > 0) {
if (item.children.length > 0) {
item.el.addClass("tt-parent");
item.el.addClass("tt-parent");
Confirmedusers, editor, Administrators
886

edits