From 54cdc2e8c16f70e93719b6ce6dae7e93969c0562 Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Sun, 12 Jul 2026 18:10:39 +0200 Subject: [PATCH] add js onload media functions --- teleforma/static/teleforma/js/application.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/teleforma/static/teleforma/js/application.js b/teleforma/static/teleforma/js/application.js index 1f897b75..16b718a6 100644 --- a/teleforma/static/teleforma/js/application.js +++ b/teleforma/static/teleforma/js/application.js @@ -377,3 +377,19 @@ tarteaucitron.init({ "partnersList": false /* Show the number of partners on the popup/middle banner */ }); + +function onLoadMedia(mediaId, username) { + // send a request when user load a seminar + json([mediaId, username], 'teleforma.media_load', function () { return null; }); +} + +function onUnloadMedia(mediaId, username) { + try { + var params = JSON.stringify({ "id": "jsonrpc", "params": [mediaId, username], "method": "teleforma.media_unload", "jsonrpc": "1.0" }) + navigator.sendBeacon("/json/", params); + } + catch { + // compatibility with old navigators + json_sync([mediaId, username], 'teleforma.media_unload', function () { return null; }); + } +} \ No newline at end of file -- 2.47.3