Add politicians question type

This commit is contained in:
Charlotte Van Petegem 2025-05-17 11:58:07 +02:00
parent 4fe218166f
commit 2893f2bc53
Signed by: chvp
SSH key fingerprint: SHA256:s9rb8jBVfdahqWHuBAcHCBP1wmj4eYQXZfqgz4H3E9E
16 changed files with 101 additions and 33 deletions

View file

@ -1,4 +1,4 @@
const csrfToken = document.querySelector("[name='csrf-token']").content
import { submitValue } from './submit_value.js'
export default function initImageQuestions() {
document.querySelectorAll('[data-behaviour="question_image_input"]').forEach((input) => {
@ -8,17 +8,10 @@ export default function initImageQuestions() {
const file = input.files[0];
const fileReader = new FileReader();
fileReader.onload = (ev) => {
fetch(submitUrl, {
method: 'PUT',
headers: {
"x-csrf-token": csrfToken,
"content-type": "application/json",
},
body: JSON.stringify({
filename: file.name,
mimetype: file.type,
data: ev.target.result.replace(/^data:[a-zA-Z0-9!#$%^&\\*_\-+{}|'.`~]+\/[a-zA-Z0-9!#$%^&\\*_\-+{}|'.`~]+;base64,/, ""),
})
submitValue(submitUrl, {
filename: file.name,
mimetype: file.type,
data: ev.target.result.replace(/^data:[a-zA-Z0-9!#$%^&\\*_\-+{}|'.`~]+\/[a-zA-Z0-9!#$%^&\\*_\-+{}|'.`~]+;base64,/, ""),
})
}
fileReader.readAsDataURL(file);