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.

executeAsyncScript.js 1.2KB

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