Files
i2p.i2p/apps/i2ptunnel/jsp/js/tableSlider.js

78 lines
2.9 KiB
JavaScript
Raw Normal View History

function initTables() {
var hideableTables = document.querySelectorAll("table.tunnelConfig th");
hideableTables.forEach(function(configTable) {
function lookupTableRow() {
for (var i = 0, row; (row = configTable.offsetParent.rows[i]); i++) {
if (configTable.parentNode == row) {
return i;
}
}
return -1;
}
2020-04-27 03:17:12 +00:00
function hideRow(row) {
if (Object.keys(row.querySelectorAll(".buttons")).length < 1 ) {
if (Object.keys(row.querySelectorAll("th")).length < 1 ) {
row.style.visibility = "collapse";
}
} else if (Object.keys(row.querySelectorAll("th")).length < 1 ) {
if (Object.keys(row.querySelectorAll(".buttons")).length < 1 ) {
row.style.visibility = "collapse";
}
} else {
configTable.style.visibility = "visible"
}
}
function showAllControls() {
for (var i = 0, row; (row = configTable.offsetParent.rows[i]); i++) {
hideRow(row)
}
}
configTable.onclick = function() {
2020-04-27 03:17:12 +00:00
var minRow = lookupTableRow();
for (var i = 0, row; (row = configTable.offsetParent.rows[i]); i++) {
2020-04-27 03:17:12 +00:00
if (i >= minRow) {
2020-04-26 11:31:14 +00:00
if (row.classList.contains("tunnelConfigExpanded")) {
2020-04-27 03:17:12 +00:00
hideRow(row)
row.querySelectorAll("th").forEach(function(configRow) {
configRow.classList.remove('tunnelConfigExpanded');
});
configTable.classList.remove('tunnelConfigExpanded');
2020-04-26 11:31:14 +00:00
row.classList.remove('tunnelConfigExpanded');
} else {
row.style.visibility = "visible";
row.querySelectorAll("th").forEach(function(configRow) {
configRow.classList.add('tunnelConfigExpanded');
});
configTable.classList.add('tunnelConfigExpanded');
2020-04-26 11:31:14 +00:00
row.classList.add('tunnelConfigExpanded')
row.classList.add('excludeBackgroundImage')
}
}
}
configTable.parentNode.style.visibility = "visible";
var iiframe = document.getElementById("i2ptunnelframe");
if (iiframe != null) {
var adjustHeight = 0;
for (var child = frame.firstChild; child !== null; child.nextSibling){
adjustHeight += child.offsetHeight;
}
iiframe.height = adjustHeight;
}
};
2020-04-27 03:17:12 +00:00
showAllControls()
for (var i = 0, row; (row = hideableTables[0].offsetParent.rows[i]); i++) {
row.style.visibility = "visible";
row.querySelectorAll("th").forEach(function(configRow) {
configRow.classList.add('tunnelConfigExpanded');
});
}
});
}
document.addEventListener("DOMContentLoaded", function() {
initTables();
}, true);