first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-09-30 18:11:26 -04:00
commit e592ca6823
27270 changed files with 5002257 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
define("tool_monitor/dropdown",["exports"],(function(_exports){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=void 0;_exports.init=()=>{const componentSelector=document.querySelector('[data-field="component"]'),eventSelector=document.querySelector('[data-field="eventname"]'),matchesComponent=(component,event)=>event.startsWith("\\".concat(component,"\\")),getEventOptionsForComponent=component=>(component=>Object.entries(JSON.parse(eventSelector.dataset.eventlist)).filter(((_ref,index)=>{let[eventName]=_ref;return 0===index||matchesComponent(component,eventName)})))(component).map((_ref2=>{let[name,description]=_ref2;const option=document.createElement("option");return option.value=name,option.text=description,option}));componentSelector.addEventListener("change",(()=>{eventSelector.innerHTML="",getEventOptionsForComponent(componentSelector.value).forEach((option=>{eventSelector.options.add(option)})),eventSelector.options.value=""}));const initialCount=eventSelector.options.length;[...eventSelector.options].reverse().forEach(((option,index)=>{""!==option.value&&(matchesComponent(componentSelector.value,option.value)||eventSelector.options.remove(initialCount-index-1))}))}}));
//# sourceMappingURL=dropdown.min.js.map
@@ -0,0 +1 @@
{"version":3,"file":"dropdown.min.js","sources":["../src/dropdown.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 * Dropdown handler for the Event monitor tool.\n *\n * @module tool_monitor/dropdown\n * @copyright 2023 Andrew Lyons <andrew@nicols.co.uk>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nexport const init = () => {\n const componentSelector = document.querySelector('[data-field=\"component\"]');\n const eventSelector = document.querySelector('[data-field=\"eventname\"]');\n\n const matchesComponent = (component, event) => event.startsWith(`\\\\${component}\\\\`);\n\n // Helper to fetch events for a component.\n const getEventsForComponent = (component) => {\n const events = Object.entries(JSON.parse(eventSelector.dataset.eventlist));\n return events.filter(([eventName], index) => {\n // Always return the Choose... option.\n if (index === 0) {\n return true;\n }\n return matchesComponent(component, eventName);\n });\n };\n\n // Helper to fetch the <option> elements for a compoment.\n const getEventOptionsForComponent = (component) => {\n return getEventsForComponent(component).map(([name, description]) => {\n const option = document.createElement('option');\n option.value = name;\n option.text = description;\n return option;\n });\n };\n\n // Change handler for the component selector.\n componentSelector.addEventListener('change', () => {\n eventSelector.innerHTML = '';\n getEventOptionsForComponent(componentSelector.value).forEach((option) => {\n eventSelector.options.add(option);\n });\n eventSelector.options.value = '';\n });\n\n // Set the initial value.\n // Rather than emptying the list and re-adding as the change handler does, remove any options that don't match.\n // This means that the current selection (when editing) is maintained.\n const initialCount = eventSelector.options.length;\n [...eventSelector.options].reverse().forEach((option, index) => {\n if (option.value === '') {\n // The first value is the \"Choose...\" pseudo-option.\n return;\n }\n if (!matchesComponent(componentSelector.value, option.value)) {\n eventSelector.options.remove(initialCount - index - 1);\n }\n });\n};\n"],"names":["componentSelector","document","querySelector","eventSelector","matchesComponent","component","event","startsWith","getEventOptionsForComponent","Object","entries","JSON","parse","dataset","eventlist","filter","index","eventName","getEventsForComponent","map","_ref2","name","description","option","createElement","value","text","addEventListener","innerHTML","forEach","options","add","initialCount","length","reverse","remove"],"mappings":"0JAuBoB,WACVA,kBAAoBC,SAASC,cAAc,4BAC3CC,cAAgBF,SAASC,cAAc,4BAEvCE,iBAAmB,CAACC,UAAWC,QAAUA,MAAMC,uBAAgBF,iBAe/DG,4BAA+BH,WAZNA,CAAAA,WACZI,OAAOC,QAAQC,KAAKC,MAAMT,cAAcU,QAAQC,YACjDC,QAAO,MAAcC,aAAZC,uBAEL,IAAVD,OAGGZ,iBAAiBC,UAAWY,cAMhCC,CAAsBb,WAAWc,KAAIC,YAAEC,KAAMC,yBAC1CC,OAAStB,SAASuB,cAAc,iBACtCD,OAAOE,MAAQJ,KACfE,OAAOG,KAAOJ,YACPC,UAKfvB,kBAAkB2B,iBAAiB,UAAU,KACzCxB,cAAcyB,UAAY,GAC1BpB,4BAA4BR,kBAAkByB,OAAOI,SAASN,SAC1DpB,cAAc2B,QAAQC,IAAIR,WAE9BpB,cAAc2B,QAAQL,MAAQ,YAM5BO,aAAe7B,cAAc2B,QAAQG,WACvC9B,cAAc2B,SAASI,UAAUL,SAAQ,CAACN,OAAQP,SAC7B,KAAjBO,OAAOE,QAINrB,iBAAiBJ,kBAAkByB,MAAOF,OAAOE,QAClDtB,cAAc2B,QAAQK,OAAOH,aAAehB,MAAQ"}
+74
View File
@@ -0,0 +1,74 @@
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Dropdown handler for the Event monitor tool.
*
* @module tool_monitor/dropdown
* @copyright 2023 Andrew Lyons <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
export const init = () => {
const componentSelector = document.querySelector('[data-field="component"]');
const eventSelector = document.querySelector('[data-field="eventname"]');
const matchesComponent = (component, event) => event.startsWith(`\\${component}\\`);
// Helper to fetch events for a component.
const getEventsForComponent = (component) => {
const events = Object.entries(JSON.parse(eventSelector.dataset.eventlist));
return events.filter(([eventName], index) => {
// Always return the Choose... option.
if (index === 0) {
return true;
}
return matchesComponent(component, eventName);
});
};
// Helper to fetch the <option> elements for a compoment.
const getEventOptionsForComponent = (component) => {
return getEventsForComponent(component).map(([name, description]) => {
const option = document.createElement('option');
option.value = name;
option.text = description;
return option;
});
};
// Change handler for the component selector.
componentSelector.addEventListener('change', () => {
eventSelector.innerHTML = '';
getEventOptionsForComponent(componentSelector.value).forEach((option) => {
eventSelector.options.add(option);
});
eventSelector.options.value = '';
});
// Set the initial value.
// Rather than emptying the list and re-adding as the change handler does, remove any options that don't match.
// This means that the current selection (when editing) is maintained.
const initialCount = eventSelector.options.length;
[...eventSelector.options].reverse().forEach((option, index) => {
if (option.value === '') {
// The first value is the "Choose..." pseudo-option.
return;
}
if (!matchesComponent(componentSelector.value, option.value)) {
eventSelector.options.remove(initialCount - index - 1);
}
});
};