All files / public/admin admin-controls-domain.js

95% Statements 19/20
96.29% Branches 26/27
100% Functions 4/4
100% Lines 14/14

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 273x   10x 10x 4x   6x 4x 3x 2x 1x       3x 2x 6x   2x     3x          
(function (global) {
  function nextOptionIndex(current, key, count) {
    Iif (!Number.isInteger(count) || count <= 0) return -1;
    if (!Number.isInteger(current) || current < 0 || current >= count) {
      return key === "ArrowUp" || key === "End" ? count - 1 : 0;
    }
    if (key === "ArrowDown") return (current + 1) % count;
    if (key === "ArrowUp") return (current - 1 + count) % count;
    if (key === "Home") return 0;
    if (key === "End") return count - 1;
    return current;
  }
 
  function selectedOptionIndex(options, value) {
    if (!Array.isArray(options) || options.length === 0) return -1;
    var index = options.findIndex(function (option) {
      return String(option[0]) === String(value);
    });
    return index < 0 ? 0 : index;
  }
 
  global.DecapAdminControlsDomain = {
    nextOptionIndex: nextOptionIndex,
    selectedOptionIndex: selectedOptionIndex,
  };
})(window);