RaPla-Middleware-LinkGen/scripts.js
Patrick Müller 800ab0d9b7
All checks were successful
Jenkins Production Deployment
V1 complete
2021-10-07 10:04:32 +02:00

53 lines
1.7 KiB
JavaScript

"use strict";
$(document).ready(function () {
$('#submitBtn').click(function () {
generateLink();
});
});
function generateLink() {
let selectedCourseFromPicker = $('#coursename').val().toString();
let raplaUser = '';
let raplaFile = '';
if (selectedCourseFromPicker === '-1') {
let providedRaPlaLink = $('#raplalink').val().toString();
const url = new URL(providedRaPlaLink);
raplaUser = url.searchParams.get('user');
raplaFile = url.searchParams.get('file');
} else {
let courseInfo = courseLinks[selectedCourseFromPicker];
raplaUser = courseInfo.user;
raplaFile = courseInfo.file;
}
let showBlockers = $('#hideBlockers').is(':checked') ? 0 : 1;
let selectedElectiveModule = $('#wahlmodul').val().toString();
let selectedProfileModule = $('#profilmodul').val().toString();
let base_url = 'https://api.plutodev.de/rapla-middleware'
base_url += '?user=' + raplaUser;
base_url += '&file=' + raplaFile;
base_url += '&blockers=' + showBlockers;
base_url += '&wahl=' + selectedElectiveModule;
base_url += '&pflicht=' + selectedProfileModule;
$('#full-link').text(base_url);
}
let courseLinks = {
'TINF19B1': {user: 'freudenmann', file: 'TINF19B1'},
'TINF19B2': {user: 'braun', file: 'TINF19B2'},
'TINF19B3': {user: 'vollmer', file: 'tinf19b3'},
'TINF19B4': {user: 'eisenbiegler', file: 'TINF19B4'},
'TINF19B5': {user: 'strand', file: 'TINF19B5'},
'TINF20B1': {user: 'freudenmann', file: 'TINF20B1'},
'TINF20B2': {user: 'braun', file: 'TINF20B2'},
'TINF20B3': {user: 'vollmer', file: 'tinf20b3'},
'TINF20B4': {user: 'eisenbiegler', file: 'TINF20B4'},
'TINF20B5': {user: 'strand', file: 'TINF20B5'}
}