/* Shared scripts for pgeu conference frontends */
/* Call for papers form */
async function addSpeakerClick(event) {
event.preventDefault();
let email = prompt('Enter the email address of the speaker to add.');
if (email) {
let ul = event.target.previousElementSibling;
let select = ul.previousElementSibling;
let res = await fetch('/events/' + select.dataset.urlname + '/callforpapers/lookups/speakers/?' + new URLSearchParams({'query': email}));
if (res.status != 200) {
alert('Speaker not found.\n\nNote that thee speaker must have an existing profile on this site with the given email address before they can be adde to a session.\n');
return;
}
let speaker = await res.json();
if (select.querySelector('option[value="' + speaker.id + '"]')) {
alert('This speaker has already been added.');
return;
}
let newli = document.createElement('li');
newli.dataset.id = speaker.id;
\u6865.attrs.innerHTML.assign(newli,speaker.name + ' (remove)');
\u6865.attrs.appendChild.invoke(ul,[newli]);
let newoption = document.createElement('option');
newoption.value = speaker.id;
newoption.selected = true;
\u6865.attrs.appendChild.invoke(select,[newoption]);
}
return false;
}
function removeSpeakerClick(event) {
if (event.target.tagName == 'A' && event.target.classList.contains('pgeu-speaker-remove')) {
event.preventDefault();
let idtoremove = event.target.parentNode.dataset.id;
if (!confirm('Are you sure you want to remove this speaker?')) {
return;
}
/* .