Read the statement by Michael Teeuw here.
Timer on Module
-
@dsmtweaker
I’ve added in prior post. Sorry I’m typing on my phone. So I cannot write long… -
job: function() { setInterval(()=>{ this.updateDom() // this will execute your getDom() }, yourInterval) }, notificationReceived: function (noti, payload, sender) { if (noti == “DOM_OBJECT_CREATED”) this.job() }, getDom: function () { //making your video DOM here. }
-
@sean Sorry for being so new at this. And thank you for all of the help. I tried using your code.
get: function() {
setInterval(()=>{this.updateDom()}, 60000)
notificationRecieved: function (noti, payload, sender) {
if (noti = “DOM_OBJECT_CREATED”) this.job()}, getDom: function () var video = document.createElement("video"); video.src = this.config.videoSRC; video.autoplay = true; video.loop = this.config.loop; },
});
But I get “Uncaught SyntaxError: Unexpected token (” from notificationRecieved: function (noti, payload, sender) {
-
@dsmtweaker you missed some of the job function
this.updateDom()}, yourInterval)
-
@sdetweil It is there in the get:function
get: function() {setInterval(()=>{this.updateDom()}, 60000) notificationRecieved: function (noti, payload, sender) { if (noti = "DOM_OBJECT_CREATED") this.job() }, getDom: fuction () var video = document.createElement("video"); video.src = this.config.videoSRC; video.autoplay = true; video.loop = this.config.loop;
},});
-
@dsmtweaker i hate code posting on this forum…
note that
getDom: fuction () is spelled wrong
and also missing the open brace -
there are 3 routines (functions)… in seans post
// worker function job: function() { // start a recurring timer that will tell MM to get the module updated dom content // this uses an inline function, be careful of braces and parens matching setInterval(()=>{ this.updateDom() // this will execute your getDom(), after 'yourInterval' time }, yourInterval) }, // the function called when notifications are received from the system notificationReceived: function (noti, payload, sender) { // if the notification is "dom is created", then call our worker function if (noti == “DOM_OBJECT_CREATED”) this.job() }, // the function called for the module to provide its dom content getDom: function () { //making your video DOM here. }
-
@sdetweil I made all the corrections noted.
but on if (noti == “DOM_OBJECT_CREATED”) this.job() I am still getting the error SyntaxError: Invalid or unexpected token
-
@dsmtweaker said in Timer on Module:
but on if (noti == “DOM_OBJECT_CREATED”) this.job() I am still getting the error SyntaxError: Invalid or unexpected token
Excuse me for jumping in but the curly quotes containing DOM_OBJECT_CREATED will cause that error. Try:
if (noti == "DOM_OBJECT_CREATED") this.job()
The difference is slight, but enough.
-
@dsmtweaker its the darned cut/paste of the double quotes… in the web posting it shows the MS word document style quotes which cause an error with the javascript parser…
overtype those double quotes with the text editor…