Sindbad~EG File Manager
{"version":3,"file":"roomupdater.min.js","sources":["../src/roomupdater.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * JS room updater.\n *\n * @module mod_bigbluebuttonbn/roomupdater\n * @copyright 2021 Blindside Networks Inc\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Pending from 'core/pending';\nimport Templates from \"core/templates\";\nimport {exception as displayException} from 'core/notification';\nimport {getMeetingInfo} from './repository';\n\nconst timeout = 5000;\nconst maxFactor = 10;\n\nlet updateCount = 0;\nlet updateFactor = 1;\nlet timerReference = null;\nlet timerRunning = false;\n\nconst resetValues = () => {\n updateCount = 0;\n updateFactor = 1;\n};\n\n/**\n * Start the information poller.\n */\nexport const start = () => {\n timerRunning = true;\n timerReference = setTimeout(() => poll(), timeout);\n};\n\n/**\n * Stop the room updater.\n */\nexport const stop = () => {\n timerRunning = false;\n if (timerReference) {\n clearInterval(timerReference);\n timerReference = null;\n }\n\n resetValues();\n};\n\nconst poll = () => {\n if (!timerRunning) {\n // The poller has been stopped.\n return;\n }\n if ((updateCount % updateFactor) === 0) {\n updateRoom()\n .then(() => {\n if (updateFactor >= maxFactor) {\n updateFactor = 1;\n } else {\n updateFactor++;\n }\n\n return;\n\n })\n .catch()\n .then(() => {\n timerReference = setTimeout(() => poll(), timeout);\n return;\n })\n .catch();\n }\n};\n\n/**\n * Update the room information.\n *\n * @param {boolean} [updatecache=false]\n * @returns {Promise}\n */\nexport const updateRoom = (updatecache = false) => {\n const bbbRoomViewElement = document.getElementById('bbb-room-view');\n if (bbbRoomViewElement === null) {\n return Promise.resolve(false);\n }\n\n const bbbId = bbbRoomViewElement.dataset.bbbId;\n const groupId = bbbRoomViewElement.dataset.groupId;\n\n const pendingPromise = new Pending('mod_bigbluebuttonbn/roomupdater:updateRoom');\n\n return getMeetingInfo(bbbId, groupId, updatecache)\n .then(data => {\n // Just make sure we have the right information for the template.\n data.haspresentations = false;\n if (data.presentations && data.presentations.length) {\n data.haspresentations = true;\n }\n return Templates.renderForPromise('mod_bigbluebuttonbn/room_view', data);\n })\n .then(({html, js}) => Templates.replaceNodeContents(bbbRoomViewElement, html, js))\n .then(() => pendingPromise.resolve())\n .catch(displayException);\n};\n"],"names":["updateCount","updateFactor","timerReference","timerRunning","setTimeout","poll","clearInterval","updateRoom","then","catch","updatecache","bbbRoomViewElement","document","getElementById","Promise","resolve","bbbId","dataset","groupId","pendingPromise","Pending","data","haspresentations","presentations","length","Templates","renderForPromise","_ref","html","js","replaceNodeContents","displayException"],"mappings":";;;;;;;iNA+BIA,YAAc,EACdC,aAAe,EACfC,eAAiB,KACjBC,cAAe,iBAUE,KACjBA,cAAe,EACfD,eAAiBE,YAAW,IAAMC,QAlBtB,oBAwBI,KAChBF,cAAe,EACXD,iBACAI,cAAcJ,gBACdA,eAAiB,MAnBrBF,YAAc,EACdC,aAAe,SAwBbI,KAAO,KACJF,cAIAH,YAAcC,cAAkB,GACjCM,aACCC,MAAK,KACEP,cAzCE,GA0CFA,aAAe,EAEfA,kBAMPQ,QACAD,MAAK,KACFN,eAAiBE,YAAW,IAAMC,QArD9B,QAwDPI,SAUIF,WAAa,eAACG,0EACjBC,mBAAqBC,SAASC,eAAe,oBACxB,OAAvBF,0BACOG,QAAQC,SAAQ,SAGrBC,MAAQL,mBAAmBM,QAAQD,MACnCE,QAAUP,mBAAmBM,QAAQC,QAErCC,eAAiB,IAAIC,iBAAQ,qDAE5B,8BAAeJ,MAAOE,QAASR,aACjCF,MAAKa,OAEFA,KAAKC,kBAAmB,EACpBD,KAAKE,eAAiBF,KAAKE,cAAcC,SACzCH,KAAKC,kBAAmB,GAErBG,mBAAUC,iBAAiB,gCAAiCL,SAEtEb,MAAKmB,WAACC,KAACA,KAADC,GAAOA,gBAAQJ,mBAAUK,oBAAoBnB,mBAAoBiB,KAAMC,OAC7ErB,MAAK,IAAMW,eAAeJ,YAC1BN,MAAMsB"}
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists