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.

MMM-WebView.js 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* Magic Mirror
  2. * Module: MMM-WebView
  3. *
  4. * By Shunta Iketaki https://twitter.com/Iketaki
  5. * MIT Licensed.
  6. */
  7. const WEBVIEW_ID = 'mmm-webview';
  8. Module.register('MMM-WebView', {
  9. defaults: {
  10. url: 'https://www.google.com/',
  11. height: '640px',
  12. width: '480px',
  13. autoRefresh: false,
  14. autoRefreshInterval: 10 * 60 * 1000,
  15. loadedJS: undefined,
  16. },
  17. start: function () {
  18. if (this.config.autoRefresh) {
  19. setInterval(() => {
  20. //Electron.session.defaultSession.clearCache(() => {});
  21. //this.updateDom();
  22. const webview = document.getElementById(WEBVIEW_ID);
  23. webview.reloadIgnoringCache();
  24. }, this.config.autoRefreshInterval);
  25. }
  26. },
  27. getDom: function () {
  28. let wrapper = document.createElement('div');
  29. wrapper.id = 'mmm-webview-wrapper';
  30. wrapper.innerHTML = `<webview id="${WEBVIEW_ID}" style="width: ${this.config.width}; height: ${this.config.height};" src="${this.config.url}"></webview>`;
  31. return wrapper;
  32. },
  33. notificationReceived: function (notification, payload, sender) {
  34. if (notification == 'MODULE_DOM_CREATED') {
  35. if (this.config.loadedJS && this.config.loadedJS.length > 0) {
  36. const webview = document.getElementById(WEBVIEW_ID);
  37. if (webview) {
  38. webview.addEventListener('did-finish-load', () => {
  39. webview.executeJavaScript(this.config.loadedJS);
  40. });
  41. } else {
  42. // TODO: Show Error
  43. }
  44. }
  45. }
  46. },
  47. });