()
| 335 | // selectors: one selects which spans in .command and the other selects their |
| 336 | // matching help text in .help |
| 337 | function initialize() { |
| 338 | let head = { name: 'all' }, |
| 339 | prev = head, |
| 340 | groupcount = 0, |
| 341 | s = $('#command span[class^=shell]'), |
| 342 | curr; |
| 343 | |
| 344 | if (s.length) { |
| 345 | const shell = { name: 'shell', commandselector: s, prev: head }; |
| 346 | head.next = shell; |
| 347 | prev = shell; |
| 348 | groupcount += 1; |
| 349 | } |
| 350 | |
| 351 | // construct a doubly linked list of previous/next groups. this is used |
| 352 | // by the navigation buttons to move between groups |
| 353 | let i = 0, |
| 354 | g = `command${i}`; |
| 355 | |
| 356 | s = $(`#command span[class^=${g}]`); |
| 357 | |
| 358 | let unknownsselector = $(); |
| 359 | |
| 360 | while (s.length > 0) { |
| 361 | curr = { name: g, commandselector: s }; |
| 362 | |
| 363 | // add this group to the linked list only if it's not full of unknowns |
| 364 | if (s.filter(':not(.unknown)').length > 0) { |
| 365 | curr.prev = prev; |
| 366 | prev.next = curr; |
| 367 | prev = curr; |
| 368 | groupcount += 1; |
| 369 | } else { |
| 370 | unknownsselector = unknownsselector.add(s); |
| 371 | } |
| 372 | |
| 373 | i++; |
| 374 | g = `command${i}`; |
| 375 | s = $(`#command span[class^=${g}]`); |
| 376 | } |
| 377 | |
| 378 | if (groupcount === 1) { |
| 379 | // if we have a single group, get rid of 'all' and remove the prev/next |
| 380 | // links |
| 381 | head = head.next; |
| 382 | |
| 383 | delete head.next; |
| 384 | delete head.prev; |
| 385 | |
| 386 | // if we have 1 group and it's the shell, all other commands in there |
| 387 | // are unknowns, add them to the selector so they show up as unknowns |
| 388 | // in the UI |
| 389 | if (head.name === 'shell') { |
| 390 | head.commandselector = head.commandselector.add(unknownsselector); |
| 391 | } |
| 392 | } else { |
| 393 | // add a group for all spans at the start |
| 394 | // select spans that start with command or shell to filter out |
nothing calls this directly
no test coverage detected