MCPcopy Create free account
hub / github.com/idank/explainshell / reorder

Function reorder

explainshell/web/static/js/es.js:278–304  ·  view source on GitHub ↗
(lefteslinks)

Source from the content-addressed store, hash-verified

276
277// reorder the help <pre>'s of all links that go left
278function reorder(lefteslinks) {
279 const help = lefteslinks.map((l) => l.help),
280 visiblehelp = Array.from(
281 document.querySelectorAll('#help .help-box'),
282 ).filter((el) => el.offsetParent !== null);
283
284 // check the indices of the first and last help boxes. if the first is
285 // greater than the last, then it appears later in the DOM which means
286 // we've already reordered this set of boxes and they're in the correct
287 // order
288 if (
289 visiblehelp.indexOf(help[0]) >=
290 visiblehelp.indexOf(help[help.length - 1])
291 )
292 return;
293
294 for (
295 let i = 0, j = help.length - 1;
296 i < Math.floor(help.length / 2) && i !== j;
297 i++, j = help.length - 1 - i
298 ) {
299 const h = help[i],
300 hh = help[j];
301
302 swapNodes(h, hh);
303 }
304}
305
306// return the matching <pre> in .help for each item in commandselector
307function helpselector(commandselector) {

Callers

nothing calls this directly

Calls 1

swapNodesFunction · 0.85

Tested by

no test coverage detected