From a20e9a7c6eaa98c96a75eaf0d90127a529cceac5 Mon Sep 17 00:00:00 2001 From: Henri Bergius Date: Wed, 29 Nov 2017 18:14:37 +0100 Subject: [PATCH] Remove load listener after ready --- infodisplay/infodisplay.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/infodisplay/infodisplay.js b/infodisplay/infodisplay.js index 5ff416d..024b481 100644 --- a/infodisplay/infodisplay.js +++ b/infodisplay/infodisplay.js @@ -50,6 +50,7 @@ function DisplayParticipant(broker, role, defaultUrls, timer) { // Update URL listing urls = indata; callback('urls', null, urls); + return; } if (next.getAttribute('src') === indata) { // Already open! @@ -86,7 +87,8 @@ function DisplayParticipant(broker, role, defaultUrls, timer) { return participant; } -window.addEventListener('load', () => { +function onPageReady() { + window.removeEventListener('load', onPageReady, false); const params = msgflo.options({ broker: 'mqtt://c-beam.cbrp3.c-base.org:1882', role: 'infodisplay', @@ -103,4 +105,5 @@ window.addEventListener('load', () => { } p.send('open', getRotationUrl(params.urls)); }); -}, false); +} +window.addEventListener('load', onPageReady, false);