Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function parseUrnik() {
- const weekDays = ['MON', 'TUE', 'WED', 'THU', 'FRI'];
- const getSubjectName = (fullName) => {
- const nameCutStart = fullName.search(new RegExp('[^a-zA-Z0-9]'));
- return fullName.substring(0, nameCutStart);
- }
- const allocateds = document.querySelectorAll('.allocated');
- return [...allocateds].map(el => {
- // Name from the cell
- const fullName = el.querySelector('.activity').innerHTML;
- const subject = getSubjectName(fullName);
- // Additional info from cell
- const classroom = el.querySelector('.classroom').innerHTML;
- const teacher = el.querySelector('.teacher').innerHTML;
- const length = el.attributes.getNamedItem('rowSpan').value;
- const type = el.classList.contains('P') ? 'P' : 'LV';
- const day = [...el.classList].filter(className => weekDays.indexOf(className) != -1)[0];
- // Get hour by looking at parent
- const hour = el.parentElement.querySelector('.hour').innerHTML;
- return {
- 'fullName': fullName,
- 'subject': subject,
- 'classroom': classroom,
- 'teacher': teacher,
- 'length': length,
- 'type': type,
- 'day': day,
- 'hour': hour,
- };
- });
- }
Add Comment
Please, Sign In to add comment