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.

info.js 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. "use strict";
  2. function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } it = o[Symbol.iterator](); return it.next.bind(it); }
  3. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  4. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  5. var browserslist = require('browserslist');
  6. function capitalize(str) {
  7. return str.slice(0, 1).toUpperCase() + str.slice(1);
  8. }
  9. var NAMES = {
  10. ie: 'IE',
  11. ie_mob: 'IE Mobile',
  12. ios_saf: 'iOS',
  13. op_mini: 'Opera Mini',
  14. op_mob: 'Opera Mobile',
  15. and_chr: 'Chrome for Android',
  16. and_ff: 'Firefox for Android',
  17. and_uc: 'UC for Android'
  18. };
  19. function prefix(name, prefixes, note) {
  20. var out = " " + name;
  21. if (note) out += ' *';
  22. out += ': ';
  23. out += prefixes.map(function (i) {
  24. return i.replace(/^-(.*)-$/g, '$1');
  25. }).join(', ');
  26. out += '\n';
  27. return out;
  28. }
  29. module.exports = function (prefixes) {
  30. if (prefixes.browsers.selected.length === 0) {
  31. return 'No browsers selected';
  32. }
  33. var versions = {};
  34. for (var _iterator = _createForOfIteratorHelperLoose(prefixes.browsers.selected), _step; !(_step = _iterator()).done;) {
  35. var _browser = _step.value;
  36. var parts = _browser.split(' ');
  37. var _name2 = parts[0];
  38. var version = parts[1];
  39. _name2 = NAMES[_name2] || capitalize(_name2);
  40. if (versions[_name2]) {
  41. versions[_name2].push(version);
  42. } else {
  43. versions[_name2] = [version];
  44. }
  45. }
  46. var out = 'Browsers:\n';
  47. for (var browser in versions) {
  48. var list = versions[browser];
  49. list = list.sort(function (a, b) {
  50. return parseFloat(b) - parseFloat(a);
  51. });
  52. out += " " + browser + ": " + list.join(', ') + "\n";
  53. }
  54. var coverage = browserslist.coverage(prefixes.browsers.selected);
  55. var round = Math.round(coverage * 100) / 100.0;
  56. out += "\nThese browsers account for " + round + "% of all users globally\n";
  57. var atrules = [];
  58. for (var name in prefixes.add) {
  59. var data = prefixes.add[name];
  60. if (name[0] === '@' && data.prefixes) {
  61. atrules.push(prefix(name, data.prefixes));
  62. }
  63. }
  64. if (atrules.length > 0) {
  65. out += "\nAt-Rules:\n" + atrules.sort().join('');
  66. }
  67. var selectors = [];
  68. for (var _iterator2 = _createForOfIteratorHelperLoose(prefixes.add.selectors), _step2; !(_step2 = _iterator2()).done;) {
  69. var selector = _step2.value;
  70. if (selector.prefixes) {
  71. selectors.push(prefix(selector.name, selector.prefixes));
  72. }
  73. }
  74. if (selectors.length > 0) {
  75. out += "\nSelectors:\n" + selectors.sort().join('');
  76. }
  77. var values = [];
  78. var props = [];
  79. var hadGrid = false;
  80. for (var _name in prefixes.add) {
  81. var _data = prefixes.add[_name];
  82. if (_name[0] !== '@' && _data.prefixes) {
  83. var grid = _name.indexOf('grid-') === 0;
  84. if (grid) hadGrid = true;
  85. props.push(prefix(_name, _data.prefixes, grid));
  86. }
  87. if (!Array.isArray(_data.values)) {
  88. continue;
  89. }
  90. for (var _iterator3 = _createForOfIteratorHelperLoose(_data.values), _step3; !(_step3 = _iterator3()).done;) {
  91. var value = _step3.value;
  92. var _grid = value.name.includes('grid');
  93. if (_grid) hadGrid = true;
  94. var string = prefix(value.name, value.prefixes, _grid);
  95. if (!values.includes(string)) {
  96. values.push(string);
  97. }
  98. }
  99. }
  100. if (props.length > 0) {
  101. out += "\nProperties:\n" + props.sort().join('');
  102. }
  103. if (values.length > 0) {
  104. out += "\nValues:\n" + values.sort().join('');
  105. }
  106. if (hadGrid) {
  107. out += '\n* - Prefixes will be added only on grid: true option.\n';
  108. }
  109. if (!atrules.length && !selectors.length && !props.length && !values.length) {
  110. out += '\nAwesome! Your browsers don\'t require any vendor prefixes.' + '\nNow you can remove Autoprefixer from build steps.';
  111. }
  112. return out;
  113. };