From c34a33a2136d4a39a06c4549807b92f88502fbf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A4r=20Thernstr=C3=B6m?= Date: Fri, 17 May 2024 08:26:56 +0200 Subject: [PATCH] Observe ad --- resources/views/components/events-map.blade.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/resources/views/components/events-map.blade.php b/resources/views/components/events-map.blade.php index 9c2345c7..bc3fc168 100644 --- a/resources/views/components/events-map.blade.php +++ b/resources/views/components/events-map.blade.php @@ -324,7 +324,6 @@ class EventsMap { return; } - // Options for the observer (which mutations to observe) const config = { attributes: false, @@ -346,6 +345,20 @@ class EventsMap { // Check status of ad. console.log('dataset: ', node.dataset); console.log('dataset stringified: ', JSON.stringify(node.dataset)); + + // Keep track of attribute changes on this ad. + const adObserver = new MutationObserver((adMutationsList, adObserver) => { + for (const mutation of mutationsList) { + if (mutation.type === "attributes") { + console.log("An attribute was modified on the ad: ", mutation); + console.log("Ad status: ", node.dataset); + } + } + }); + adObserver.observe(node, { + attributes: true, + //attributeFilter: ['data-ad-status'], + }); } } }