Proyectos de Subversion Moodle

Rev

Autoría | Ultima modificación | Ver Log |

{"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\nlet timerReference = null;\nlet timerRunning = false;\nlet pollInterval = 0;\nlet pollIntervalFactor = 1;\nconst MAX_POLL_INTERVAL_FACTOR = 10;\n\nconst resetValues = () => {\n    timerRunning = false;\n    timerReference = null;\n    pollInterval = 0;\n    pollIntervalFactor = 1;\n};\n\n/**\n * Start the information poller.\n * @param {Number} interval interval in miliseconds between each poll action.\n */\nexport const start = (interval) => {\n    resetValues();\n    timerRunning = true;\n    pollInterval = interval;\n    poll();\n};\n\n/**\n * Stop the room updater.\n */\nexport const stop = () => {\n    if (timerReference) {\n        clearTimeout(timerReference);\n    }\n    resetValues();\n};\n\n/**\n * Start the information poller.\n */\nconst poll = () => {\n    if (!timerRunning || !pollInterval) {\n        // The poller has been stopped.\n        return;\n    }\n    updateRoom()\n        .then((updateOk) => {\n            if (!updateOk) {\n                pollIntervalFactor = (pollIntervalFactor < MAX_POLL_INTERVAL_FACTOR) ?\n                    pollIntervalFactor + 1 : MAX_POLL_INTERVAL_FACTOR;\n                // We make sure if there is an error that we do not try too often.\n            }\n            timerReference = setTimeout(() => poll(), pollInterval * pollIntervalFactor);\n            return true;\n        })\n        .catch();\n};\n\n/**\n * Update the room information.\n *\n * @param {boolean} [updatecache=false] should we update cache\n * @returns {Promise}\n */\nexport const updateRoom = (updatecache = false) => {\n    const bbbRoomViewElement = document.getElementById('bigbluebuttonbn-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 = !!(data.presentations && data.presentations.length);\n            return Templates.renderForPromise('mod_bigbluebuttonbn/room_view', data);\n        })\n        .then(({html, js}) => Templates.replaceNode(bbbRoomViewElement, html, js))\n        .then(() => pendingPromise.resolve())\n        .catch(displayException);\n};\n"],"names":["timerReference","timerRunning","pollInterval","pollIntervalFactor","resetValues","interval","poll","clearTimeout","updateRoom","then","updateOk","setTimeout","catch","updatecache","bbbRoomViewElement","document","getElementById","Promise","resolve","bbbId","dataset","groupId","pendingPromise","Pending","data","haspresentations","presentations","length","Templates","renderForPromise","_ref","html","js","replaceNode","displayException"],"mappings":";;;;;;;iNA4BIA,eAAiB,KACjBC,cAAe,EACfC,aAAe,EACfC,mBAAqB,QAGnBC,YAAc,KAChBH,cAAe,EACfD,eAAiB,KACjBE,aAAe,EACfC,mBAAqB,kBAOHE,WAClBD,cACAH,cAAe,EACfC,aAAeG,SACfC,sBAMgB,KACZN,gBACAO,aAAaP,gBAEjBI,qBAMEE,KAAO,KACJL,cAAiBC,cAItBM,aACKC,MAAMC,WACEA,WACDP,mBAAsBA,mBAzCL,GA0CbA,mBAAqB,EA1CR,IA6CrBH,eAAiBW,YAAW,IAAML,QAAQJ,aAAeC,qBAClD,KAEVS,SASIJ,WAAa,eAACK,0EACjBC,mBAAqBC,SAASC,eAAe,gCACxB,OAAvBF,0BACOG,QAAQC,SAAQ,SAGrBC,MAAQL,mBAAmBM,QAAQD,MACnCE,QAAUP,mBAAmBM,QAAQC,QAErCC,eAAiB,IAAIC,iBAAQ,qDAE5B,8BAAeJ,MAAOE,QAASR,aACjCJ,MAAKe,OAEFA,KAAKC,oBAAsBD,KAAKE,gBAAiBF,KAAKE,cAAcC,QAC7DC,mBAAUC,iBAAiB,gCAAiCL,SAEtEf,MAAKqB,WAACC,KAACA,KAADC,GAAOA,gBAAQJ,mBAAUK,YAAYnB,mBAAoBiB,KAAMC,OACrEvB,MAAK,IAAMa,eAAeJ,YAC1BN,MAAMsB"}