(baseUrl, nodes, options)
| 394 | // current: function() Map[Number,Boolean] |
| 395 | // Overridable mechanism for fetching set of currently selected nodes. |
| 396 | function viewer(baseUrl, nodes, options) { |
| 397 | 'use strict'; |
| 398 | |
| 399 | // Elements |
| 400 | const search = document.getElementById('search'); |
| 401 | const graph0 = document.getElementById('graph0'); |
| 402 | const svg = (graph0 == null ? null : graph0.parentElement); |
| 403 | const toptable = document.getElementById('toptable'); |
| 404 | |
| 405 | let regexpActive = false; |
| 406 | let selected = new Map(); |
| 407 | let origFill = new Map(); |
| 408 | let searchAlarm = null; |
| 409 | let buttonsEnabled = true; |
| 410 | |
| 411 | // Return current selection. |
| 412 | function getSelection() { |
| 413 | if (selected.size > 0) { |
| 414 | return selected; |
| 415 | } else if (options && options.current) { |
| 416 | return options.current(); |
| 417 | } |
| 418 | return new Map(); |
| 419 | } |
| 420 | |
| 421 | function handleDetails(e) { |
| 422 | e.preventDefault(); |
| 423 | const detailsText = document.getElementById('detailsbox'); |
| 424 | if (detailsText != null) { |
| 425 | if (detailsText.style.display === 'block') { |
| 426 | detailsText.style.display = 'none'; |
| 427 | } else { |
| 428 | detailsText.style.display = 'block'; |
| 429 | } |
| 430 | } |
| 431 | } |
| 432 | |
| 433 | function handleKey(e) { |
| 434 | if (e.keyCode != 13) return; |
| 435 | setHrefParams(window.location, function (params) { |
| 436 | params.set('f', search.value); |
| 437 | }); |
| 438 | e.preventDefault(); |
| 439 | } |
| 440 | |
| 441 | function handleSearch() { |
| 442 | // Delay expensive processing so a flurry of key strokes is handled once. |
| 443 | if (searchAlarm != null) { |
| 444 | clearTimeout(searchAlarm); |
| 445 | } |
| 446 | searchAlarm = setTimeout(selectMatching, 300); |
| 447 | |
| 448 | regexpActive = true; |
| 449 | updateButtons(); |
| 450 | } |
| 451 | |
| 452 | function selectMatching() { |
| 453 | searchAlarm = null; |
no test coverage detected
searching dependent graphs…