I’d like to launch the web using myframe, but there’s no response.
Please help me.This is the code I wrote.
~/MagicMirror/modules/default/MMM-iFrame/MMM-iFrame .js
/* global Module */
/* Magic Mirror
* Module: iFrame
*
* By Ben Williams http://desertblade.com
* MIT Licensed.
*/
Module.register("MMM-iFrame",{
// Default module config.
defaults: {
height:"100px",
width:"100%",
updateInterval: 0.5 * 60 * 1000,
url: "http://www.naver.com",
scrolling: "no"
},
start: function () {
self = this;
var count = 0;
if (this.config.url.length > 0 ) {
setInterval( function () {
self.updateDom(1000);
console.log('update' + count++)
}, this.config.updateInterval);
}
},
getRandomInt: function (min, max) {
return Math.floor(Math.random() * (max - min)) + min;
},
resume: function() {
console.log("Resuming");
return this.getDom();
},
// Override dom generator.
getDom: function() {
var iframe = document.createElement("IFRAME");
iframe.style = "border:0"
iframe.width = this.config.width;
iframe.height = this.config.height;
iframe.scrolling = this.config.scrolling;
var url_index = 0;
// console.log("currentURL:" + this.currentURL);
var repeat = true;
while(repeat) {
url_index = this.getRandomInt(0,this.config.url.length);
futureURL = this.config.url[url_index];
console.log("URL_length:" + this.config.url.length + " " + "URL_index:" + url_index + " " + "url:" + futureURL);
// if( futureURL == currentURL) {
iframe.src = futureURL;
// currentURL = futureURL;
repeat = false;
// }
}
return iframe;
}
});
~/MagicMirror/config/config.js
}
},
{
module: "newsfeed",
position: "bottom_bar",
config: {
feeds: [
{
title: "New York Times",
url: "http://www.nytimes.com/services/xml/rss/nyt/HomePage.xml"
}
],
showSourceTitle: true,
showPublishDate: true
}
},
{
module: "MMM-iFrame",
position: "middle_center", // This can be any of the regions.
config: {
// See 'Configuration options' for more information.
url: "http://www.naver.com", // as many URLs you want or you can just ["ENTER IN URL"] if single URL.
updateInterval: 0.5 * 60 * 1000, // rotate URLs every 30 seconds
width: "100%", // Optional. Default: 100%
height: "100px" //Optional. Default: 100px
}
},
]
};
/*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== "undefined") {module.exports = config;}