Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1441 ariadna 1
{"version":3,"file":"loading.min.js","sources":["../src/loading.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 * Tiny AI loading screen handling.\n *\n * @module      tiny_aiplacement/loading\n * @copyright   2024 Matt Porritt <matt.porritt@moodle.com>\n * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport {getString} from 'core/str';\nimport {prefetchString} from 'core/prefetch';\n\nconst strings = [\n    {\n        key: 'loading_processing',\n        component: 'tiny_aiplacement',\n    },\n    {\n        key: 'loading_generating',\n        component: 'tiny_aiplacement',\n    },\n    {\n        key: 'loading_applying',\n        component: 'tiny_aiplacement',\n    },\n    {\n        key: 'loading_almostdone',\n        component: 'tiny_aiplacement',\n    }\n];\n\nstrings.forEach((string) => prefetchString(string.component, string.key));\n\n/**\n * Display a series of messages one by one with a specified delay between each message.\n *\n * Returns a promise that resolves when the final message is displayed.\n *\n * @param {HTMLElement} element The element to display the messages in.\n * @param {number} delay The delay between each message in milliseconds.\n * @returns {Promise<function(): void>} A function to stop the message cycling.\n */\nexport async function loadingMessages(element, delay = 6000) {\n    const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));\n\n    for (const {key, component} of strings) {\n        element.textContent = await getString(key, component);\n        await sleep(delay);\n    }\n\n    return;\n}\n"],"names":["element","delay","sleep","ms","Promise","resolve","setTimeout","key","component","strings","textContent","forEach","string"],"mappings":"4MAwDsCA,aAASC,6DAAQ,UAC7CC,MAASC,IAAO,IAAIC,SAASC,SAAYC,WAAWD,QAASF,UAE9D,MAAMI,IAACA,IAADC,UAAMA,aAAcC,QAC3BT,QAAQU,kBAAoB,kBAAUH,IAAKC,iBACrCN,MAAMD;;;;;;;;MAnCdQ,QAAU,CACZ,CACIF,IAAK,qBACLC,UAAW,oBAEf,CACID,IAAK,qBACLC,UAAW,oBAEf,CACID,IAAK,mBACLC,UAAW,oBAEf,CACID,IAAK,qBACLC,UAAW,qBAInBC,QAAQE,SAASC,SAAW,4BAAeA,OAAOJ,UAAWI,OAAOL"}