Skip to content
Snippets Groups Projects
Commit 840e59f8 authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms
Browse files

fix url handling in resources.js, fixes #998

Closes #998

Merge request studip/studip!576
parent 4a97009b
No related branches found
No related tags found
No related merge requests found
......@@ -633,25 +633,18 @@ STUDIP.ready(function () {
}
function updateViewURL(defaultView) {
var sURLVariables = window.location.href.split(/[?&]/);
var changed = false;
for (var i = 0; i < sURLVariables.length; i++) {
var sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] == "defaultView") {
sParameterName[1] = defaultView;
sURLVariables[i] = sParameterName.join('=');
changed = true;
}
}
if (!changed) {
sURLVariables.push('defaultView=' + defaultView);
}
const url = new URL(window.location.href);
url.searchParams.set('defaultView', defaultView);
// Push current view url to history
history.pushState({}, null, url.toString());
let newurl = `${sURLVariables[0]}?${sURLVariables.slice(1).join('&')}`;
history.pushState({}, null, newurl);
var std_day = newurl.replace(/&?allday=\d+/, '');
$('.booking-plan-std_view').attr('href', std_day);
$('.booking-plan-allday_view').attr('href', std_day + '&allday=1');
// Set links accordingly
url.searchParams.delete('allday');
$('.booking-plan-std_view').attr('href', url.toString());
url.searchParams.set('allday', 1);
$('.booking-plan-allday_view').attr('href', url.toString());
}
function submitDatePicker() {
......@@ -705,27 +698,25 @@ STUDIP.ready(function () {
jQuery(export_action).attr('href', export_url);
}
//Now change the URL of the window.
// Now change the URL of the window.
var changeddate = STUDIP.Fullcalendar.toRFC3339String(changedmoment).split('T')[0];
var sURLVariables = window.location.href.split(/[?&]/);
var changed = false;
for (var i = 0; i < sURLVariables.length; i++) {
var sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] == "defaultDate") {
sParameterName[1] = changeddate;
sURLVariables[i] = sParameterName.join('=');
changed = true;
}
}
if (!changed) {
sURLVariables.push('defaultDate=' + changeddate);
}
let newurl = `${sURLVariables[0]}?${sURLVariables.slice(1).join('&')}`;
history.pushState({}, null, newurl);
var std_day = newurl.replace(/&?allday=\d+/, '');
$('.booking-plan-std_view').attr('href', std_day);
$('.booking-plan-allday_view').attr('href', std_day + '&allday=1');
const url = new URL(window.location.href);
url.searchParams.set('defaultDate', changeddate);
// Update url in history
history.pushState({}, null, url.toString());
// Adjust links accordingly
url.searchParams.delete('allday');
$('.booking-plan-std_view').attr('href', url.toString());
url.searchParams.set('allday', 1);
$('.booking-plan-allday_view').attr('href', url.toString());
// Update sidebar value
$('#booking-plan-jmpdate').val(changedmoment.toLocaleDateString('de-DE'));
//Store the date in the sessionStorage:
sessionStorage.setItem('booking_plan_date', changeddate)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment