(main): Add module

This commit is contained in:
2026-06-22 09:45:20 +02:00
parent e8b381b132
commit 763745ee1b
17 changed files with 620 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
(function () {
'use strict';
function savePaperChoice(choice) {
var ajaxUrl = window.wsGiftDropdownAjaxUrl || '';
if (!ajaxUrl || !choice) {
return;
}
var xhr = new XMLHttpRequest();
xhr.open('POST', ajaxUrl, true);
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.send('gift_paper=' + encodeURIComponent(choice) + '&ajax=1');
}
function init() {
var checked = document.querySelector('input[name="gift_paper"]:checked');
if (checked) {
savePaperChoice(checked.value);
}
document.addEventListener('change', function (e) {
if (e.target && e.target.name === 'gift_paper') {
savePaperChoice(e.target.value);
}
});
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', init);
} else {
init();
}
}());