Add politicians question type
This commit is contained in:
parent
4fe218166f
commit
2893f2bc53
16 changed files with 101 additions and 33 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue