Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

entriesToDisplay.js 721B

123456789101112131415161718192021
  1. 'use strict';
  2. /**
  3. * Determine what entries should be displayed on the screen, based on the
  4. * currently selected index and the maximum visible. Used in list-based
  5. * prompts like `select` and `multiselect`.
  6. *
  7. * @param {number} cursor the currently selected entry
  8. * @param {number} total the total entries available to display
  9. * @param {number} [maxVisible] the number of entries that can be displayed
  10. */
  11. module.exports = (cursor, total, maxVisible) => {
  12. maxVisible = maxVisible || total;
  13. let startIndex = Math.min(total- maxVisible, cursor - Math.floor(maxVisible / 2));
  14. if (startIndex < 0) startIndex = 0;
  15. let endIndex = Math.min(startIndex + maxVisible, total);
  16. return { startIndex, endIndex };
  17. };