Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX for refresh issue #2

Open
kevsfastz opened this issue Jan 31, 2017 · 2 comments
Open

FIX for refresh issue #2

kevsfastz opened this issue Jan 31, 2017 · 2 comments

Comments

@kevsfastz
Copy link

kevsfastz commented Jan 31, 2017

EDIT: After some testing with below it appears some URLs will not load after adding numbers such as the date and time suggested below. Adding a ? at the end of the URL appears to be a simple workaround.

It appears this happens to URL's that do not change when refreshed. I corrected the refresh issue by adding + new Date().getTime(); after the URL in the .js file:

`Module.register("MMM-iFrameReload",{
// Default module config.
defaults: {
url: "",
height:"800px",
width:"400%",
refreshInterval: 3600,
animationSpeed: 1000
},

// Define start sequence.
start: function() {
	Log.info("Starting module: " + this.name);
	this.scheduleUpdate(this.config.refreshInterval);
},
// 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.src =  this.config.url + new Date().getTime();
	return iframe;
},
scheduleUpdate: function(delay) {
	var nextLoad = this.config.refreshInterval;
	if (typeof delay !== "undefined" && delay >= 0) {
		nextLoad = delay * 1000; // Convert seconds to millis
	}
	var self = this;
	setTimeout(function() {
		self.updateFrame();
	}, 30000);
	},
updateFrame: function() {
	if (this.config.url === "") {
		Log.error("Tried to refresh, iFrameReload URL not set!");
		return;
	}
	// Change url to force refresh?
	this.src = this.config.url;
	Log.info("attempting to update dom for iFrameReload");
	Log.info('/"this/" module is: ' + this);
	this.updateDom(this.config.animationSpeed);
	this.scheduleUpdate(this.config.refreshInterval);
}

});`

@Cyan-Kali
Copy link

Hi,

I tried the fixes you suggested but nothing seems to work. I don´t think the module reloads at all. I set the update interval to 60 and the animation speed to 4000, but I never saw an animation. I now nothing about coding, I just go by trial and error. So here is what I did already:

First I tried:
adding
iframe.src = this.config.url + new Date().getTime();
in the section
// Override dom generator.

as you did in the example.
After that, the stream does not load at all (I see only a rectangle).

Then I tried:
Adding "+ new Date().getTime();" to the other url in the js file:
// Change url to force refresh?
this.src = this.config.url + new Date().getTime();
Now I see the stream again, but it does not seem to reload.

Then I tried:
the solution with adding the "?" to the url:
First try:
iframe.src = this.config.url?;
in the section
// Override dom generator.
Again, this broke the stream (I see only a rectangle).

Then I tried:
// Change url to force refresh?
this.src = this.config.url?;
Now I see nothing at all, not even the rectangle.

I´m sure I´m doing something wrong, can you tell me, what it is?
I am trying to embed a foscam camera stream into my mirror by the way.

@fewieden
Copy link

fewieden commented Apr 2, 2017

put iframe.setAttribute("timestamp", new Date().getTime()); between line 32 and 33

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants