moodle_local_treestudyplan/amd/build/studyplan-processor.min.js.map
2024-06-03 23:24:16 +02:00

1 line
6.4 KiB
Plaintext

{"version":3,"file":"studyplan-processor.min.js","sources":["../src/studyplan-processor.js"],"sourcesContent":["/* eslint no-console: \"off\"*/\n/* eslint max-depth: [\"error\", 6]*/\n/**\n * Copy fields from one object to another\n * @param {Object} target The target to copy to\n * @param {Object} source The source to copy from\n * @param {Array} fields The field names to copy\n * @returns {Object} Reference to target\n */\nexport function objCopy(target, source, fields) {\n if (fields === undefined || fields === null) {\n fields = Object.getOwnPropertyNames(source);\n }\n for (const ix in fields) {\n const field = fields[ix];\n target[field] = source[field];\n }\n return target;\n}\n\n/**\n * Transport items from one object to another\n * @param {Object} target The target to move to\n * @param {Object} source The source to move from\n * @param {*} identifier The value used to match the item\n * @param {string} param The field name to match on (default: 'value')\n */\nexport function transportItem(target, source, identifier, param) {\n if (!param) {\n param = 'value';\n }\n // Find item\n let item;\n let itemindex;\n for (const ix in source) {\n if (source[ix][param] == identifier) {\n item = source[ix];\n itemindex = ix;\n break;\n }\n }\n if (item) {\n target.push(item);\n source.splice(itemindex, 1);\n }\n}\n\n/**\n * Do initial conversion on multiple studyplans\n * @param {Array} studyplans The list of studyplans to load\n * @returns {Array} List of updated studyplans\n */\nexport function processStudyplans(studyplans) {\n // Unify object references to connections between items, so there are no duplicates\n for (const isx in studyplans) {\n const studyplan = studyplans[isx];\n processStudyplan(studyplan);\n }\n return studyplans;\n}\n\n/**\n * Perform initial processing on a downloaded studyplan\n * Mainly used to create the proper references between items\n * @param {Object} studyplan The studyplan to process\n * @returns {object} Processed studyplan\n */\nexport function processStudyplan(studyplan) {\n for (const ip in studyplan.pages) {\n const page = studyplan.pages[ip];\n processStudyplanPage(page);\n }\n return studyplan;\n}\n\n/**\n * Perform initial processing on a downloaded studyplan'page\n * Mainly used to create the proper references between items\n * @param {Object} page The studyplan page to process\n * @returns {object} Processed studyplan\n */\nexport function processStudyplanPage(page) {\n let connections = {};\n for (const il in page.studylines) {\n const line = page.studylines[il];\n\n for (const is in line.slots) {\n const slot = line.slots[is];\n\n if (slot.courses !== undefined) {\n for (const ic in slot.courses) {\n const itm = slot.courses[ic];\n\n for (const idx in itm.connections.in) {\n const conn = itm.connections.in[idx];\n\n if (conn.id in connections) {\n itm.connections[idx] = connections[conn.id];\n } else {\n connections[conn.id] = conn;\n }\n }\n for (const idx in itm.connections.out) {\n const conn = itm.connections.out[idx];\n\n if (conn.id in connections) {\n itm.connections[idx] = connections[conn.id];\n } else {\n connections[conn.id] = conn;\n }\n }\n }\n }\n\n if (slot.filters !== undefined) {\n for (const ix in slot.filters) {\n const itm = slot.filters[ix];\n\n for (const idx in itm.connections.in) {\n const conn = itm.connections.in[idx];\n\n if (conn.id in connections) {\n itm.connections[idx] = connections[conn.id];\n } else {\n connections[conn.id] = conn;\n }\n }\n for (const idx in itm.connections.out) {\n const conn = itm.connections.out[idx];\n\n if (conn.id in connections) {\n itm.connections[idx] = connections[conn.id];\n } else {\n connections[conn.id] = conn;\n }\n }\n }\n }\n }\n }\n return page;\n}\n"],"names":["processStudyplan","studyplan","ip","pages","processStudyplanPage","page","connections","il","studylines","line","is","slots","slot","undefined","courses","ic","itm","idx","in","conn","id","out","filters","ix","target","source","fields","Object","getOwnPropertyNames","field","studyplans","isx","identifier","param","item","itemindex","push","splice"],"mappings":"0FAmEgBA,iBAAiBC,eACxB,MAAMC,MAAMD,UAAUE,MAAO,CAE9BC,qBADaH,UAAUE,MAAMD,YAG1BD,mBASKG,qBAAqBC,UAC7BC,YAAc,OACb,MAAMC,MAAMF,KAAKG,WAAY,OACxBC,KAAOJ,KAAKG,WAAWD,QAExB,MAAMG,MAAMD,KAAKE,MAAO,OACnBC,KAAOH,KAAKE,MAAMD,YAEHG,IAAjBD,KAAKE,YACA,MAAMC,MAAMH,KAAKE,QAAS,OACrBE,IAAMJ,KAAKE,QAAQC,QAEpB,MAAME,OAAOD,IAAIV,YAAYY,GAAI,OAC5BC,KAAOH,IAAIV,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