MCPcopy Create free account
hub / github.com/Threadfin/Threadfin / enableGroupSelection

Function enableGroupSelection

ts/base_ts.ts:456–477  ·  view source on GitHub ↗
(selector)

Source from the content-addressed store, hash-verified

454}
455
456function enableGroupSelection(selector) {
457 var lastcheck = null // no checkboxes clicked yet
458
459 // get desired checkboxes
460 var checkboxes = document.querySelectorAll(selector)
461 // loop over checkboxes to add event listener
462 Array.prototype.forEach.call(checkboxes, function (cbx, idx) {
463 cbx.addEventListener('click', function (evt) {
464 // test for shift key, not first checkbox, and not same checkbox
465 if (evt.shiftKey && null !== lastcheck && idx !== lastcheck) {
466 // get range of checks between last-checkbox and shift-checkbox
467 // Math.min/max does our sorting for us
468 Array.prototype.slice.call(checkboxes, Math.min(lastcheck, idx), Math.max(lastcheck, idx))
469 // and loop over each
470 .forEach(function (ccbx) {
471 ccbx.checked = true
472 })
473 }
474 lastcheck = idx // set this checkbox as last-checked for later
475 })
476 })
477}
478
479function searchInMapping() {
480

Callers 1

openThisMenuFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected