Skip to content

Commit

Permalink
eslint: autofix all stylistic issues
Browse files Browse the repository at this point in the history
  • Loading branch information
hashar committed Oct 23, 2024
1 parent 30587f3 commit c629a4f
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 109 deletions.
23 changes: 0 additions & 23 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,4 @@ export default [
semi: true,
braceStyle: "1tbs",
}),
{
rules: {
"@stylistic/arrow-parens": "off",
"@stylistic/brace-style": "off",
"@stylistic/comma-dangle": "off",
"@stylistic/indent": "off",
"@stylistic/key-spacing": "off",
"@stylistic/keyword-spacing": "off",
"@stylistic/no-mixed-spaces-and-tabs": "off",
"@stylistic/no-multiple-empty-lines": "off",
"@stylistic/no-multi-spaces": "off",
"@stylistic/no-tabs": "off",
"@stylistic/no-trailing-spaces": "off",
"@stylistic/padded-blocks": "off",
"@stylistic/semi": "off",
"@stylistic/space-before-blocks": "off",
"@stylistic/space-before-function-paren": "off",
"@stylistic/spaced-comment": "off",
"@stylistic/space-infix-ops": "off",
"@stylistic/space-in-parens": "off",
"@stylistic/space-unary-ops": "off",
},
},
];
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// The doToggle method is used by CollapsingSectionAnnotator.java
// eslint-disable-next-line no-unused-vars
function doToggle(o)
{
function doToggle(o) {
var section = o.parentNode.parentNode;
if (section.nextElementSibling) {
if (section.nextElementSibling.className === "collapsed") {
Expand All @@ -12,13 +11,13 @@ function doToggle(o)
o.innerHTML = "Show Details";
}
} else {
if (section.nextSibling.className === "collapsed") {
if (section.nextSibling.className === "collapsed") {
section.nextSibling.className = "expanded";
o.innerHTML = "Hide Details";
} else {
section.nextSibling.className = "collapsed";
o.innerHTML = "Show Details";
}
}
}
}

Expand All @@ -30,29 +29,29 @@ document.addEventListener("DOMContentLoaded", function () {
var queue = []; // console sections are queued up until we load outline.

function getoffsets(object, offsets) {
if (! offsets) {
offsets = new Object();
offsets.x = offsets.y = 0;
if (!offsets) {
offsets = new Object();
offsets.x = offsets.y = 0;
}
if (typeof object === "string")
object = document.getElementById(object);
object = document.getElementById(object);
offsets.x += object.offsetLeft;
offsets.y += object.offsetTop;
do {
object = object.offsetParent;
if (! object)
break;
offsets.x += object.offsetLeft;
offsets.y += object.offsetTop;
} while(object.tagName.toUpperCase() !== "BODY");
object = object.offsetParent;
if (!object)
break;
offsets.x += object.offsetLeft;
offsets.y += object.offsetTop;
} while (object.tagName.toUpperCase() !== "BODY");
return offsets;
}
}

function initFloatingSection() {
var d = document.getElementById("console-section-container");
if (d === null) return;

window.onscroll = function() {
window.onscroll = function () {
var offsets = getoffsets(d);
var floatSection = d.childNodes[0];

Expand All @@ -70,116 +69,113 @@ document.addEventListener("DOMContentLoaded", function () {
floatSection.className = "scrollAttached";
}
}
}
};
}

function loadOutline() {
if (outline !== null) return false; // already loaded
if (outline !== null) return false; // already loaded

if (!loading) {
loading = true;
fetch(
rootURL+"/descriptor/org.jvnet.hudson.plugins.collapsingconsolesections.CollapsingSectionNote/outline"
rootURL + "/descriptor/org.jvnet.hudson.plugins.collapsingconsolesections.CollapsingSectionNote/outline",
).then(
(resp) => {
resp.text().then( (responseText) => {
resp.text().then((responseText) => {
const sidePanel = document.getElementById("side-panel");
sidePanel.insertAdjacentHTML("beforeend", responseText);

outline = document.getElementById("console-section-body");
initFloatingSection();
loading = false;
queue.forEach(handle);
})
}
});
},
);
}
return true;
}

function generateOutlineSection(sectionElt){

var id = "console-section-"+(iota++);
// add target link in output log
function generateOutlineSection(sectionElt) {
var id = "console-section-" + (iota++);
// add target link in output log
var targetLink = document.createElement("a");
targetLink.name = id;
sectionElt.prepend(targetLink);

// create outline element
var collapseHeader = sectionElt.querySelector("DIV.collapseHeader")
var elt = document.createElement("li")
// create outline element
var collapseHeader = sectionElt.querySelector("DIV.collapseHeader");
var elt = document.createElement("li");
var link = document.createElement("a");
link.href = "#" + id;
link.textContent = justtext(collapseHeader);
elt.appendChild(link);

//check children sections
var level = -1;
var currentElement = sectionElt;
while (currentElement.closest("div.section")) {
currentElement = currentElement.closest("div.section").parentElement;
level++;
}
var childrenSections = sectionElt.querySelectorAll("div.section")
// check children sections
var level = -1;
var currentElement = sectionElt;
while (currentElement.closest("div.section")) {
currentElement = currentElement.closest("div.section").parentElement;
level++;
}
var childrenSections = sectionElt.querySelectorAll("div.section");
childrenSections = Array.from(childrenSections).filter(
function( section ) {
var parentLevel = -1;
var parentElement = section.closest("div.section").parentElement;
while (parentElement.closest("div.section")) {
parentElement = parentElement.closest("div.section").parentElement;
parentLevel++;
}
return parentLevel == level;
}
)
if(childrenSections.length){
var newParentUl = document.createElement("ul");
newParentUl.dataset.name = "UL :"+sectionElt.dataset.level
childrenSections.forEach(function(child) {
var childElt = generateOutlineSection(child)
newParentUl.appendChild(childElt)
});
elt.appendChild(newParentUl);
function (section) {
var parentLevel = -1;
var parentElement = section.closest("div.section").parentElement;
while (parentElement.closest("div.section")) {
parentElement = parentElement.closest("div.section").parentElement;
parentLevel++;
}
return parentLevel == level;
},
);
if (childrenSections.length) {
var newParentUl = document.createElement("ul");
newParentUl.dataset.name = "UL :" + sectionElt.dataset.level;
childrenSections.forEach(function (child) {
var childElt = generateOutlineSection(child);
newParentUl.appendChild(childElt);
});
elt.appendChild(newParentUl);
}
return elt
return elt;
}


function handle(e) {
var sectionElt = e;

function handle(e) {
var sectionElt = e;
if (loadOutline()) {
queue.push(e);
} else {
var newElt = generateOutlineSection(sectionElt)
outline.appendChild(newElt);
queue.push(e);
} else {
var newElt = generateOutlineSection(sectionElt);
outline.appendChild(newElt);
}
}

function justtext(elt) {

var clone = elt.cloneNode(true);
const childNodes = Array.from(clone.childNodes);
childNodes.forEach(node => {
if (node.nodeType === Node.ELEMENT_NODE) {
clone.removeChild(node);
}
});
return clone.textContent;
var clone = elt.cloneNode(true);
const childNodes = Array.from(clone.childNodes);
childNodes.forEach((node) => {
if (node.nodeType === Node.ELEMENT_NODE) {
clone.removeChild(node);
}
});
return clone.textContent;
};

Behaviour.register({
// insert <a name="..."> for each console section and put it into the outline
"div.section" : function(e) {
var level = -1;
var currentElement = e;
while (currentElement && currentElement.closest("div.section")) {
currentElement = currentElement.closest("div.section").parentElement;
level++;
}
//only treat top level section
if(level == 0){
handle(e);
}
}
"div.section": function (e) {
var level = -1;
var currentElement = e;
while (currentElement && currentElement.closest("div.section")) {
currentElement = currentElement.closest("div.section").parentElement;
level++;
}
// only treat top level section
if (level == 0) {
handle(e);
}
},
});
});

0 comments on commit c629a4f

Please sign in to comment.