Files
codeocean/app/assets/javascripts/programming_groups.js
Sebastian Serth 06cde49901 Keep var for global ProgrammingGroups object
Otherwise, Turbolinks might cause some nasty redefinition errors.

Fixes CODEOCEAN-FRONTEND-3W
Fixes CODEOCEAN-FRONTEND-3X
2023-09-20 23:56:13 +02:00

39 lines
1.3 KiB
JavaScript

var ProgrammingGroups = {
session_id: null,
getStoredViewedPPInfo: function () {
return localStorage.getItem('viewed_pp_info')
},
setStoredViewedPPInfo: function () {
localStorage.setItem('viewed_pp_info', 'true')
},
initializeEventHandler: function () {
$('#dont_show_info_pp_modal_again').on('click', this.setStoredViewedPPInfo.bind(this));
},
is_other_user: function (user) {
return !_.isEqual(current_user, user);
},
is_other_session: function (other_session_id) {
return this.session_id !== other_session_id;
},
};
$(document).on('turbolinks:load', function () {
const modal = $('#modal-info-pair-programming');
if (modal.isPresent()) {
ProgrammingGroups.initializeEventHandler();
// We only show the modal if the user has not decided to hide it on the current device.
// Further, the modal is either shown on /implement for a programming group or on /programming_groups/new.
if (ProgrammingGroups.getStoredViewedPPInfo() !== 'true' &&
((window.location.pathname.includes('/implement') && !_.isEqual(current_user, current_contributor)) ||
window.location.pathname.includes('/programming_groups/new'))) {
new bootstrap.Modal(modal).show();
}
}
});