added all files to project

This commit is contained in:
2022-03-10 10:36:59 +01:00
parent 09dd957b33
commit 46a936d7de
25351 changed files with 3883356 additions and 0 deletions
+7
View File
@@ -0,0 +1,7 @@
{
"printWidth": 120,
"tabWidth": 2,
"singleQuote": true,
"trailingComma": "es5",
"semi": true
}
+10
View File
@@ -0,0 +1,10 @@
# Change Log
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## 1.0.0 - 2021-09-14
### Initial release of MMM-WebView
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2021 Shunta Iketaki
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+49
View File
@@ -0,0 +1,49 @@
/* Magic Mirror
* Module: MMM-WebView
*
* By Shunta Iketaki https://twitter.com/Iketaki
* MIT Licensed.
*/
const WEBVIEW_ID = 'mmm-webview';
Module.register('MMM-WebView', {
defaults: {
url: 'https://www.google.com/',
height: '640px',
width: '480px',
autoRefresh: false,
autoRefreshInterval: 10 * 60 * 1000,
loadedJS: undefined,
},
start: function () {
if (this.config.autoRefresh) {
setInterval(() => {
//Electron.session.defaultSession.clearCache(() => {});
//this.updateDom();
const webview = document.getElementById(WEBVIEW_ID);
webview.reloadIgnoringCache();
}, this.config.autoRefreshInterval);
}
},
getDom: function () {
let wrapper = document.createElement('div');
wrapper.id = 'mmm-webview-wrapper';
wrapper.innerHTML = `<webview id="${WEBVIEW_ID}" style="width: ${this.config.width}; height: ${this.config.height};" src="${this.config.url}"></webview>`;
return wrapper;
},
notificationReceived: function (notification, payload, sender) {
if (notification == 'MODULE_DOM_CREATED') {
if (this.config.loadedJS && this.config.loadedJS.length > 0) {
const webview = document.getElementById(WEBVIEW_ID);
if (webview) {
webview.addEventListener('did-finish-load', () => {
webview.executeJavaScript(this.config.loadedJS);
});
} else {
// TODO: Show Error
}
}
}
},
});
+75
View File
@@ -0,0 +1,75 @@
# MMM-WebView: A WebView module for MagicMirror²
This is a module for the [MagicMirror²](https://github.com/MichMich/MagicMirror/).
MMM-WebView allows you to add a webview which can display any url.
This module uses the [Electron's \<webview\> tag](https://www.electronjs.org/docs/api/webview-tag) instead of `<iframe>` to embed pages.
It makes possible to display pages that cannot be displayed in a `<iframe>`.
## Installation
1. Clone this repository in your `modules` folder:
```bash
cd ~/MagicMirror/modules
git clone https://github.com/Iketaki/MMM-WebView.git
```
2. Add the following configuration block to the modules array in the `config/config.js` file:
```js
let config = {
modules: [
{
module: 'MMM-WebView',
position: 'top_center',
config: {
url: 'https://www.google.com/',
width: '640px',
height: '480px',
},
},
],
};
```
3. Finally, add the following configuration block to `config/config.js` file. This is required to run this module correctly.
```js
let config = {
electronOptions: {
webPreferences: {
webviewTag: true,
},
},
};
```
## Update
1. Get the latest version using the command `git pull`:
```bash
cd ~/MagicMirror/modules/MMM-WebView
git pull
```
## Configuration options
| Option | Description |
| --------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| `url`<br> | [Optional] the URL in the WebView<br>Default: `https://www.google.com/` |
| `width` | [Optional] the Width of the WebView (the value of CSS property `width`)<br>Default: `640px` |
| `height` | [Optional] the Height of the WebView (the value of CSS property `height`)<br>Default: `480px` |
| `autoRefresh` | [Optional] Set to true to allow an auto-refresh of the WebView<br>Default: `false` |
| `autoRefreshInterval` | [Optional] the interval of auto-refresh for the WebView, in milliseconds If autoRefresh: true<br>Default: `10 * 60 * 1000` |
| `loadedJS` | [Optional] the JavaScript code string to be executed after page load<br>Default: `undefined` |
## Motivation
When considering about embedding websites to MagicMirror, some websites cannot be embedded using iframe.
There are several reasons, one of that is HTTP response header `X-Frame-Options: DENY` by the websites makes iframe disable. This is needed for the internet security.
For MagicMirror usage, using WebView instead of iframe may resolve the problem.
+14
View File
@@ -0,0 +1,14 @@
{
"name": "MMM-iFrameSimple",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"prettier": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.4.0.tgz",
"integrity": "sha512-DsEPLY1dE5HF3BxCRBmD4uYZ+5DCbvatnolqTqcxEgKVZnL2kUfyu7b8pPQ5+hTBkdhU9SLUmK0/pHb07RE4WQ==",
"dev": true
}
}
}
+23
View File
@@ -0,0 +1,23 @@
{
"name": "MMM-WebView",
"version": "1.0.0",
"description": "The simple WebView module for MagicMirror²",
"repository": {
"type": "git",
"url": "git+https://github.com/Iketaki/MMM-WebView"
},
"keywords": [
"magic mirror",
"magicmirror",
"magicmirror2",
"smart mirror",
"webview"
],
"author": "Shunta Iketaki",
"license": "MIT",
"homepage": "https://github.com/Iketaki/MMM-WebView",
"dependencies": {},
"devDependencies": {
"prettier": "2.4.0"
}
}