From: Guillaume Pellerin Date: Sun, 12 Jul 2026 16:10:39 +0000 (+0200) Subject: add js onload media functions X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=54cdc2e8c16f70e93719b6ce6dae7e93969c0562;p=teleforma.git add js onload media functions --- 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