2021-10-06 18:05:01 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
$(document).ready(function () {
|
|
|
|
$('#submitBtn').click(function () {
|
|
|
|
generateLink();
|
|
|
|
});
|
2021-10-08 04:57:05 +00:00
|
|
|
|
|
|
|
$('#full-link').click(function () {
|
|
|
|
let element = $('#full-link');
|
|
|
|
let text = element.text()
|
|
|
|
copyToClipboard(text);
|
|
|
|
element.text('Copied!');
|
|
|
|
setTimeout(function () {
|
|
|
|
element.text(text);
|
|
|
|
}, 2000);
|
|
|
|
});
|
2021-10-06 18:05:01 +00:00
|
|
|
});
|
|
|
|
|
2021-10-08 04:57:05 +00:00
|
|
|
function copyToClipboard(text) {
|
|
|
|
var $temp = $("<input>");
|
2021-10-11 10:43:29 +00:00
|
|
|
$("#linkModal").append($temp);
|
2021-10-08 04:57:05 +00:00
|
|
|
$temp.val(text).select();
|
|
|
|
document.execCommand("copy");
|
|
|
|
$temp.remove();
|
|
|
|
}
|
|
|
|
|
2021-10-06 18:05:01 +00:00
|
|
|
function generateLink() {
|
2021-10-11 09:58:32 +00:00
|
|
|
// Clear paragraph
|
|
|
|
$('#full-link').text('');
|
|
|
|
|
|
|
|
|
2021-10-07 08:04:32 +00:00
|
|
|
let selectedCourseFromPicker = $('#coursename').val().toString();
|
2021-10-06 18:05:01 +00:00
|
|
|
|
2021-10-07 08:04:32 +00:00
|
|
|
let raplaUser = '';
|
|
|
|
let raplaFile = '';
|
2021-10-06 18:05:01 +00:00
|
|
|
|
2021-10-07 08:04:32 +00:00
|
|
|
if (selectedCourseFromPicker === '-1') {
|
|
|
|
let providedRaPlaLink = $('#raplalink').val().toString();
|
2021-10-09 13:29:18 +00:00
|
|
|
if(providedRaPlaLink !== '') {
|
|
|
|
const url = new URL(providedRaPlaLink);
|
|
|
|
raplaUser = url.searchParams.get('user');
|
|
|
|
raplaFile = url.searchParams.get('file');
|
|
|
|
} else {
|
2021-10-11 07:01:09 +00:00
|
|
|
$('#linkModalTitle').text('Oh No!');
|
|
|
|
$('#raplalinkcontainer--link').text('Please provide either a course or a RaPla Link!');
|
|
|
|
$('#raplalinkcontainer--closeButton').text('Gonna Do that!');
|
2021-10-09 13:29:18 +00:00
|
|
|
return;
|
|
|
|
}
|
2021-10-07 08:04:32 +00:00
|
|
|
} else {
|
|
|
|
let courseInfo = courseLinks[selectedCourseFromPicker];
|
|
|
|
raplaUser = courseInfo.user;
|
|
|
|
raplaFile = courseInfo.file;
|
|
|
|
}
|
2021-10-06 18:05:01 +00:00
|
|
|
|
2021-10-07 08:04:32 +00:00
|
|
|
let showBlockers = $('#hideBlockers').is(':checked') ? 0 : 1;
|
|
|
|
let selectedElectiveModule = $('#wahlmodul').val().toString();
|
|
|
|
let selectedProfileModule = $('#profilmodul').val().toString();
|
2021-10-06 18:05:01 +00:00
|
|
|
|
2021-10-07 08:04:32 +00:00
|
|
|
let base_url = 'https://api.plutodev.de/rapla-middleware'
|
2021-10-06 18:05:01 +00:00
|
|
|
|
2021-10-07 08:04:32 +00:00
|
|
|
base_url += '?user=' + raplaUser;
|
|
|
|
base_url += '&file=' + raplaFile;
|
|
|
|
base_url += '&blockers=' + showBlockers;
|
|
|
|
base_url += '&wahl=' + selectedElectiveModule;
|
|
|
|
base_url += '&pflicht=' + selectedProfileModule;
|
|
|
|
|
2021-10-11 07:01:09 +00:00
|
|
|
$('#linkModalTitle').text('Your RaPla Link 🥳 ');
|
|
|
|
$('#raplalinkcontainer--link').text('Here is the link that you can use for importing RaPla into your iCloud etc. calendar (click to copy)');
|
2021-10-07 08:04:32 +00:00
|
|
|
$('#full-link').text(base_url);
|
2021-10-11 07:01:09 +00:00
|
|
|
$('#raplalinkcontainer--closeButton').text('Thank you for using');
|
2021-10-07 08:04:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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'}
|
2021-10-06 18:05:01 +00:00
|
|
|
}
|
2021-10-09 12:42:19 +00:00
|
|
|
|
|
|
|
/* Toggle Dark-Mode */
|
|
|
|
|
|
|
|
const toggleDarkMode = () => {
|
|
|
|
let element = document.body;
|
|
|
|
let navElement = document.getElementById('raplalinkcontainer--nav');
|
|
|
|
let colorModeToggleIcon = document.getElementById('colorModeToggleIcon');
|
|
|
|
let submitButton = document.getElementById('submitBtn');
|
|
|
|
|
|
|
|
element.classList.toggle("body--dark-mode");
|
|
|
|
navElement.classList.toggle("nav--dark-mode");
|
|
|
|
submitButton.classList.toggle("submitButton--dark-mode");
|
|
|
|
|
2021-10-13 12:01:52 +00:00
|
|
|
/* Dialog */
|
|
|
|
let modalContents = document.getElementsByClassName('modal-toggle')
|
|
|
|
|
|
|
|
for (content of modalContents) {
|
|
|
|
content.classList.toggle("modal--dark-mode")
|
|
|
|
}
|
|
|
|
|
2021-10-09 12:42:19 +00:00
|
|
|
if (colorModeToggleIcon.classList.contains("fa-moon")) {
|
|
|
|
colorModeToggleIcon.classList.remove("fa-moon");
|
|
|
|
colorModeToggleIcon.classList.add("fa-sun");
|
|
|
|
} else {
|
|
|
|
colorModeToggleIcon.classList.remove("fa-sun");
|
|
|
|
colorModeToggleIcon.classList.add("fa-moon");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|