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.

executeScript.js 827B

1234567891011121314151617181920
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.default = (_, script, dataProperty, dataFlag, ...args) => {
  4. window.arguments = args;
  5. const result = eval(script);
  6. let tmpResult = result instanceof NodeList ? Array.from(result) : result;
  7. const isResultArray = Array.isArray(tmpResult);
  8. tmpResult = isResultArray ? tmpResult : [tmpResult];
  9. if (tmpResult.find((r) => r instanceof HTMLElement)) {
  10. tmpResult = tmpResult.map((r, i) => {
  11. if (r instanceof HTMLElement) {
  12. const dataPropertyValue = `${dataFlag}_${i}`;
  13. r.setAttribute(dataProperty, dataPropertyValue);
  14. return dataPropertyValue;
  15. }
  16. return result;
  17. });
  18. }
  19. return isResultArray ? tmpResult : tmpResult[0];
  20. };