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.

createWindow.js 1.3KB

1234567891011121314151617181920212223242526272829303132333435
  1. "use strict";
  2. var __importDefault = (this && this.__importDefault) || function (mod) {
  3. return (mod && mod.__esModule) ? mod : { "default": mod };
  4. };
  5. Object.defineProperty(exports, "__esModule", { value: true });
  6. const uuid_1 = require("uuid");
  7. const createWindow_1 = __importDefault(require("../scripts/createWindow"));
  8. const WINDOW_FEATURES = 'menubar=1,toolbar=1,location=1,resizable=1,scrollbars=1';
  9. const NEW_PAGE_URL = 'about:blank';
  10. const DEFAULT_WINDOW_TYPE = 'tab';
  11. async function createWindow({ type }) {
  12. type = type || DEFAULT_WINDOW_TYPE;
  13. let newPage;
  14. if (type === 'window') {
  15. const page = this.getPageHandle();
  16. await page.evaluate(createWindow_1.default, NEW_PAGE_URL, WINDOW_FEATURES);
  17. const newWindowTarget = await this.browser.waitForTarget((target) => target.url() === NEW_PAGE_URL);
  18. newPage = await newWindowTarget.page();
  19. if (!newPage) {
  20. throw new Error('Couldn\'t find page to switch to');
  21. }
  22. }
  23. else {
  24. newPage = await this.browser.newPage();
  25. }
  26. const handle = uuid_1.v4();
  27. await newPage.bringToFront();
  28. this.currentWindowHandle = handle;
  29. this.windows.set(handle, newPage);
  30. return {
  31. handle: this.currentWindowHandle,
  32. type
  33. };
  34. }
  35. exports.default = createWindow;