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.

sort.js 897B

12345678910111213141516171819202122232425262728293031323334353637
  1. 'use strict';
  2. const hint = '(Use <shift>+<up/down> to sort)';
  3. const Prompt = require('./select');
  4. class Sort extends Prompt {
  5. constructor(options) {
  6. super({ ...options, reorder: false, sort: true, multiple: true });
  7. this.state.hint = [this.options.hint, hint].find(this.isValue.bind(this));
  8. }
  9. indicator() {
  10. return '';
  11. }
  12. async renderChoice(choice, i) {
  13. let str = await super.renderChoice(choice, i);
  14. let sym = this.symbols.identicalTo + ' ';
  15. let pre = (this.index === i && this.sorting) ? this.styles.muted(sym) : ' ';
  16. if (this.options.drag === false) pre = '';
  17. if (this.options.numbered === true) {
  18. return pre + `${i + 1} - ` + str;
  19. }
  20. return pre + str;
  21. }
  22. get selected() {
  23. return this.choices;
  24. }
  25. submit() {
  26. this.value = this.choices.map(choice => choice.value);
  27. return super.submit();
  28. }
  29. }
  30. module.exports = Sort;